mirror of
https://github.com/aljazceru/claude-code-viewer.git
synced 2025-12-21 15:24:20 +01:00
refactor sse
This commit is contained in:
@@ -25,8 +25,13 @@ export const SSEEventListeners: FC<PropsWithChildren> = ({ children }) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
useServerEventListener("taskChanged", async (event) => {
|
useServerEventListener("taskChanged", async ({ aliveTasks, changed }) => {
|
||||||
setAliveTasks(event.aliveTasks);
|
setAliveTasks(aliveTasks);
|
||||||
|
|
||||||
|
await queryClient.invalidateQueries({
|
||||||
|
queryKey: sessionDetailQuery(changed.projectId, changed.sessionId)
|
||||||
|
.queryKey,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { QueryClient } from "@tanstack/react-query";
|
import { QueryClient } from "@tanstack/react-query";
|
||||||
import type { Metadata } from "next";
|
|
||||||
import { Geist, Geist_Mono } from "next/font/google";
|
import { Geist, Geist_Mono } from "next/font/google";
|
||||||
|
|
||||||
import { Toaster } from "../components/ui/sonner";
|
import { Toaster } from "../components/ui/sonner";
|
||||||
@@ -24,7 +23,7 @@ const geistMono = Geist_Mono({
|
|||||||
subsets: ["latin"],
|
subsets: ["latin"],
|
||||||
});
|
});
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata = {
|
||||||
title: "Claude Code Viewer",
|
title: "Claude Code Viewer",
|
||||||
description: "Web Viewer for Claude Code history",
|
description: "Web Viewer for Claude Code history",
|
||||||
};
|
};
|
||||||
@@ -42,7 +41,7 @@ export default async function RootLayout({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<html lang="ja">
|
<html lang="en">
|
||||||
<body
|
<body
|
||||||
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ export const SessionPageContent: FC<{
|
|||||||
{/* Fixed Diff Button */}
|
{/* Fixed Diff Button */}
|
||||||
<Button
|
<Button
|
||||||
onClick={() => setIsDiffModalOpen(true)}
|
onClick={() => setIsDiffModalOpen(true)}
|
||||||
className="fixed bottom-6 right-6 w-14 h-14 rounded-full shadow-lg hover:shadow-xl transition-all duration-200 z-50"
|
className="fixed bottom-15 right-6 w-14 h-14 rounded-full shadow-lg hover:shadow-xl transition-all duration-200 z-50"
|
||||||
size="lg"
|
size="lg"
|
||||||
>
|
>
|
||||||
<GitCompareIcon className="w-6 h-6" />
|
<GitCompareIcon className="w-6 h-6" />
|
||||||
|
|||||||
@@ -444,6 +444,7 @@ export const routes = (app: HonoAppType) => {
|
|||||||
) => {
|
) => {
|
||||||
stream.writeSSE("taskChanged", {
|
stream.writeSSE("taskChanged", {
|
||||||
aliveTasks: event.aliveTasks,
|
aliveTasks: event.aliveTasks,
|
||||||
|
changed: event.changed,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -451,6 +452,7 @@ export const routes = (app: HonoAppType) => {
|
|||||||
eventBus.on("sessionChanged", onSessionChanged);
|
eventBus.on("sessionChanged", onSessionChanged);
|
||||||
eventBus.on("taskChanged", onTaskChanged);
|
eventBus.on("taskChanged", onTaskChanged);
|
||||||
const { connectionPromise } = adaptInternalEventToSSE(rawStream, {
|
const { connectionPromise } = adaptInternalEventToSSE(rawStream, {
|
||||||
|
timeout: 5 /* min */ * 60 /* sec */ * 1000,
|
||||||
cleanUp: () => {
|
cleanUp: () => {
|
||||||
eventBus.off("sessionListChanged", onSessionListChanged);
|
eventBus.off("sessionListChanged", onSessionListChanged);
|
||||||
eventBus.off("sessionChanged", onSessionChanged);
|
eventBus.off("sessionChanged", onSessionChanged);
|
||||||
|
|||||||
@@ -368,8 +368,11 @@ export class ClaudeCodeTaskController {
|
|||||||
|
|
||||||
Object.assign(target, task);
|
Object.assign(target, task);
|
||||||
|
|
||||||
|
if (task.status === "paused" || task.status === "running") {
|
||||||
this.eventBus.emit("taskChanged", {
|
this.eventBus.emit("taskChanged", {
|
||||||
aliveTasks: this.aliveTasks,
|
aliveTasks: this.aliveTasks,
|
||||||
|
changed: task,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export type InternalEventDeclaration = {
|
|||||||
|
|
||||||
taskChanged: {
|
taskChanged: {
|
||||||
aliveTasks: AliveClaudeCodeTask[];
|
aliveTasks: AliveClaudeCodeTask[];
|
||||||
|
changed: AliveClaudeCodeTask;
|
||||||
};
|
};
|
||||||
|
|
||||||
permissionRequested: {
|
permissionRequested: {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ export type SSEEventDeclaration = {
|
|||||||
|
|
||||||
taskChanged: {
|
taskChanged: {
|
||||||
aliveTasks: AliveClaudeCodeTask[];
|
aliveTasks: AliveClaudeCodeTask[];
|
||||||
|
changed: AliveClaudeCodeTask;
|
||||||
};
|
};
|
||||||
|
|
||||||
permission_requested: {
|
permission_requested: {
|
||||||
|
|||||||
Reference in New Issue
Block a user