fix(web): take the Session's elapsed time from Trace timestamps, so a reload stops restarting it (#124)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Yaowei Zheng
2026-07-29 23:30:13 +08:00
committed by GitHub
parent ed1ea509d3
commit b9de3da879
7 changed files with 289 additions and 78 deletions
+11 -2
View File
@@ -71,7 +71,7 @@ import type {
VersionResponse,
WorkspaceFilesResponse,
} from "@prismshadow/penguin-server/api";
import { apiFetch } from "./client";
import { apiFetch, apiFetchWithMeta } from "./client";
// Auth & user -----------------------------------------------------------------
@@ -246,8 +246,17 @@ export const patchSession = (sessionId: string, body: SessionPatchRequest) =>
export const deleteSession = (sessionId: string) =>
apiFetch<void>(`/api/sessions/${encodeURIComponent(sessionId)}`, { method: "DELETE" });
/**
* History rebuild. Carries the server's clock at read time (see ApiFetchMeta.serverNowMs)
* alongside the messages: a Task still running has no Trace entry for the event currently in
* flight, so its elapsed can only be measured by differencing this against the Task's first
* message timestamp — both server-side values, so no client clock offset enters the result
* (see pushMessages).
*/
export const getMessages = (sessionId: string) =>
apiFetch<MessagesResponse>(`/api/sessions/${encodeURIComponent(sessionId)}/messages`);
apiFetchWithMeta<MessagesResponse>(
`/api/sessions/${encodeURIComponent(sessionId)}/messages`,
).then(({ data, serverNowMs }) => ({ ...data, serverNowMs }));
// Task execution, approval, abort, compaction ------------------------------------------------------