Compare commits

...
Author SHA1 Message Date
Julius Marminge cd9ef00636 Mark active thread visited on selection
- Dispatch `MARK_THREAD_VISITED` when `activeThreadId` changes in root route
- Add reducer handling to update a thread's `lastVisitedAt`
- Add reducer test coverage for selecting a thread updates visit time
2026-02-19 00:11:02 -08:00
3 changed files with 39 additions and 0 deletions

No files matched your search

+9
View File
@@ -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) => {
+18
View File
@@ -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({
+12
View File
@@ -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 };
@@ -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,