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
5 changes: 4 additions & 1 deletion apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,10 @@
const lastVisitedAt = activeThreadLastVisitedAt ? Date.parse(activeThreadLastVisitedAt) : NaN;
if (!Number.isNaN(lastVisitedAt) && lastVisitedAt >= turnCompletedAt) return;

markThreadVisited(scopedThreadKey(scopeThreadRef(serverThread.environmentId, serverThread.id)));
markThreadVisited(
scopedThreadKey(scopeThreadRef(serverThread.environmentId, serverThread.id)),
activeLatestTurn.completedAt,
);
}, [
activeLatestTurn?.completedAt,
activeThreadLastVisitedAt,
Expand Down Expand Up @@ -1576,7 +1579,7 @@
);

const focusComposer = useCallback(() => {
composerRef.current?.focusAtEnd();

Check warning on line 1582 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

eslint-plugin-react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'composerRef.current'
}, []);
const scheduleComposerFocus = useCallback(() => {
window.requestAnimationFrame(() => {
Expand All @@ -1584,7 +1587,7 @@
});
}, [focusComposer]);
const addTerminalContextToDraft = useCallback((selection: TerminalContextSelection) => {
composerRef.current?.addTerminalContext(selection);

Check warning on line 1590 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

eslint-plugin-react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'composerRef.current'
}, []);
const setTerminalOpen = useCallback(
(open: boolean) => {
Expand Down Expand Up @@ -2263,7 +2266,7 @@
const shortcutContext = {
terminalFocus: isTerminalFocused(),
terminalOpen: Boolean(terminalState.terminalOpen),
modelPickerOpen: composerRef.current?.isModelPickerOpen() ?? false,

Check warning on line 2269 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

eslint-plugin-react-hooks(exhaustive-deps)

React Hook useEffect has a missing dependency: 'composerRef.current'
};

const command = resolveShortcutCommand(event, keybindings, {
Expand Down Expand Up @@ -2798,7 +2801,7 @@
};
});
promptRef.current = "";
composerRef.current?.resetCursorState({ cursor: 0 });

Check warning on line 2804 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

eslint-plugin-react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'composerRef.current'
},
[activePendingProgress?.activeQuestion, activePendingUserInput],
);
Expand All @@ -2825,7 +2828,7 @@
),
},
}));
const snapshot = composerRef.current?.readSnapshot();

Check warning on line 2831 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

eslint-plugin-react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'composerRef.current'
if (
snapshot?.value !== value ||
snapshot.cursor !== nextCursor ||
Expand Down Expand Up @@ -2888,7 +2891,7 @@
return;
}

const sendCtx = composerRef.current?.getSendContext();

Check warning on line 2894 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

eslint-plugin-react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'composerRef.current'
if (!sendCtx) {
return;
}
Expand Down Expand Up @@ -3024,7 +3027,7 @@
return;
}

const sendCtx = composerRef.current?.getSendContext();

Check warning on line 3030 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

eslint-plugin-react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'composerRef.current'
if (!sendCtx) {
return;
}
Expand Down
23 changes: 23 additions & 0 deletions apps/web/src/uiStateStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import {
clearThreadUi,
hydratePersistedProjectState,
markThreadVisited,
markThreadUnread,
PERSISTED_STATE_KEY,
type PersistedUiState,
Expand All @@ -27,6 +28,28 @@
}

describe("uiStateStore pure functions", () => {
it("markThreadVisited stores the provided server timestamp", () => {
const threadId = ThreadId.make("thread-1");
const initialState = makeUiState();

const next = markThreadVisited(initialState, threadId, "2026-02-25T12:30:00.700Z");

expect(next.threadLastVisitedAtById[threadId]).toBe("2026-02-25T12:30:00.700Z");
});

it("markThreadVisited does not move visit state backwards under clock skew", () => {
const threadId = ThreadId.make("thread-1");
const initialState = makeUiState({
threadLastVisitedAtById: {
[threadId]: "2026-02-25T12:30:00.700Z",
},
});

const next = markThreadVisited(initialState, threadId, "2026-02-25T12:30:00.000Z");

expect(next).toBe(initialState);
});

it("markThreadUnread moves lastVisitedAt before completion for a completed thread", () => {
const threadId = ThreadId.make("thread-1");
const latestTurnCompletedAt = "2026-02-25T12:30:00.000Z";
Expand Down Expand Up @@ -409,7 +432,7 @@
});

describe("uiStateStore persistence round-trip", () => {
function createLocalStorageStub(): Storage {

Check warning on line 435 in apps/web/src/uiStateStore.test.ts

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

eslint-plugin-unicorn(consistent-function-scoping)

Function `createLocalStorageStub` does not capture any variables from its parent scope
const store = new Map<string, string>();
return {
clear: () => {
Expand Down
Loading