Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions apps/web/src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ function EventRouter() {
});
}, [activeThreadId, api, dispatch, queryClient]);

useEffect(() => {
if (!activeThreadId) return;
dispatch({
type: "MARK_THREAD_VISITED",
threadId: activeThreadId,
visitedAt: new Date().toISOString(),
});
}, [activeThreadId, dispatch]);

useEffect(() => {
if (!api) return;
return api.terminal.onEvent((event) => {
Expand Down
18 changes: 18 additions & 0 deletions apps/web/src/store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,24 @@ describe("store reducer thread continuity", () => {
expect(next.threads[0]?.lastVisitedAt).toBe(completedAt);
});

it("marks a thread as visited when selected", () => {
const state = makeState(
makeThread({
latestTurnCompletedAt: "2026-02-08T10:00:10.000Z",
lastVisitedAt: "2026-02-08T10:00:00.000Z",
}),
);

const nextVisitedAt = "2026-02-08T10:00:20.000Z";
const next = reducer(state, {
type: "MARK_THREAD_VISITED",
threadId: "thread-local-1",
visitedAt: nextVisitedAt,
});

expect(next.threads[0]?.lastVisitedAt).toBe(nextVisitedAt);
});

it("reverts thread state to a checkpoint snapshot", () => {
const state = makeState(
makeThread({
Expand Down
12 changes: 12 additions & 0 deletions apps/web/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ type Action =
branch: string | null;
worktreePath: string | null;
}
| { type: "MARK_THREAD_VISITED"; threadId: string; visitedAt?: string }
| { type: "SET_RUNTIME_MODE"; mode: RuntimeMode }
| { type: "DELETE_THREAD"; threadId: string };

Expand Down Expand Up @@ -1141,6 +1142,17 @@ export function reducer(state: AppState, action: Action): AppState {
};
}

case "MARK_THREAD_VISITED": {
const visitedAt = action.visitedAt ?? new Date().toISOString();
return {
...state,
threads: updateThread(state.threads, action.threadId, (t) => ({
...t,
lastVisitedAt: visitedAt,
})),
};
}

case "SET_RUNTIME_MODE":
return {
...state,
Expand Down