Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
237ffdb790 | ||
|
|
e24259db42 |
No files matched your search
@@ -10,6 +10,7 @@ import {
|
|||||||
getVisibleThreadsForProject,
|
getVisibleThreadsForProject,
|
||||||
getProjectSortTimestamp,
|
getProjectSortTimestamp,
|
||||||
hasUnseenCompletion,
|
hasUnseenCompletion,
|
||||||
|
hasUnseenCompletionSinceVisit,
|
||||||
isContextMenuPointerDown,
|
isContextMenuPointerDown,
|
||||||
orderItemsByPreferredIds,
|
orderItemsByPreferredIds,
|
||||||
resolveProjectStatusIndicator,
|
resolveProjectStatusIndicator,
|
||||||
@@ -67,6 +68,32 @@ describe("hasUnseenCompletion", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("hasUnseenCompletionSinceVisit", () => {
|
||||||
|
it("returns false when repeated visit updates stay after the completion", () => {
|
||||||
|
expect(
|
||||||
|
hasUnseenCompletionSinceVisit({
|
||||||
|
completedAt: "2026-03-09T10:05:00.000Z",
|
||||||
|
lastVisitedAt: "2026-03-09T10:06:00.000Z",
|
||||||
|
}),
|
||||||
|
).toBe(false);
|
||||||
|
expect(
|
||||||
|
hasUnseenCompletionSinceVisit({
|
||||||
|
completedAt: "2026-03-09T10:05:00.000Z",
|
||||||
|
lastVisitedAt: "2026-03-09T10:07:00.000Z",
|
||||||
|
}),
|
||||||
|
).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("preserves the invalid last-visit fallback as unseen", () => {
|
||||||
|
expect(
|
||||||
|
hasUnseenCompletionSinceVisit({
|
||||||
|
completedAt: "2026-03-09T10:05:00.000Z",
|
||||||
|
lastVisitedAt: "not-a-date",
|
||||||
|
}),
|
||||||
|
).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("createThreadJumpHintVisibilityController", () => {
|
describe("createThreadJumpHintVisibilityController", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.useFakeTimers();
|
vi.useFakeTimers();
|
||||||
|
|||||||
@@ -144,17 +144,27 @@ export function useThreadJumpHintVisibility(): {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function hasUnseenCompletion(thread: ThreadStatusInput): boolean {
|
export function hasUnseenCompletionSinceVisit(input: {
|
||||||
if (!thread.latestTurn?.completedAt) return false;
|
completedAt: string | null | undefined;
|
||||||
const completedAt = Date.parse(thread.latestTurn.completedAt);
|
lastVisitedAt?: string | null | undefined;
|
||||||
|
}): boolean {
|
||||||
|
if (!input.completedAt) return false;
|
||||||
|
const completedAt = Date.parse(input.completedAt);
|
||||||
if (Number.isNaN(completedAt)) return false;
|
if (Number.isNaN(completedAt)) return false;
|
||||||
if (!thread.lastVisitedAt) return true;
|
if (!input.lastVisitedAt) return true;
|
||||||
|
|
||||||
const lastVisitedAt = Date.parse(thread.lastVisitedAt);
|
const lastVisitedAt = Date.parse(input.lastVisitedAt);
|
||||||
if (Number.isNaN(lastVisitedAt)) return true;
|
if (Number.isNaN(lastVisitedAt)) return true;
|
||||||
return completedAt > lastVisitedAt;
|
return completedAt > lastVisitedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function hasUnseenCompletion(thread: ThreadStatusInput): boolean {
|
||||||
|
return hasUnseenCompletionSinceVisit({
|
||||||
|
completedAt: thread.latestTurn?.completedAt,
|
||||||
|
lastVisitedAt: thread.lastVisitedAt,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function shouldClearThreadSelectionOnMouseDown(target: HTMLElement | null): boolean {
|
export function shouldClearThreadSelectionOnMouseDown(target: HTMLElement | null): boolean {
|
||||||
if (target === null) return true;
|
if (target === null) return true;
|
||||||
return !target.closest(THREAD_SELECTION_SAFE_SELECTOR);
|
return !target.closest(THREAD_SELECTION_SAFE_SELECTOR);
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ import { useThreadSelectionStore } from "../threadSelectionStore";
|
|||||||
import { useCommandPaletteStore } from "../commandPaletteStore";
|
import { useCommandPaletteStore } from "../commandPaletteStore";
|
||||||
import {
|
import {
|
||||||
getSidebarThreadIdsToPrewarm,
|
getSidebarThreadIdsToPrewarm,
|
||||||
|
hasUnseenCompletionSinceVisit,
|
||||||
resolveAdjacentThreadId,
|
resolveAdjacentThreadId,
|
||||||
isContextMenuPointerDown,
|
isContextMenuPointerDown,
|
||||||
resolveProjectStatusIndicator,
|
resolveProjectStatusIndicator,
|
||||||
@@ -1047,14 +1048,21 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
|
|||||||
const projectExpanded = useUiStateStore(
|
const projectExpanded = useUiStateStore(
|
||||||
(state) => state.projectExpandedById[project.projectKey] ?? true,
|
(state) => state.projectExpandedById[project.projectKey] ?? true,
|
||||||
);
|
);
|
||||||
const threadLastVisitedAts = useUiStateStore(
|
const projectThreadHasUnseenCompletions = useUiStateStore(
|
||||||
useShallow((state) =>
|
useShallow(
|
||||||
projectThreads.map(
|
useMemo(() => {
|
||||||
(thread) =>
|
const completionInputs = projectThreads.map((thread) => ({
|
||||||
state.threadLastVisitedAtById[
|
completedAt: thread.latestTurn?.completedAt ?? null,
|
||||||
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id))
|
threadKey: scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)),
|
||||||
] ?? null,
|
}));
|
||||||
),
|
return (state) =>
|
||||||
|
completionInputs.map(({ completedAt, threadKey }) =>
|
||||||
|
hasUnseenCompletionSinceVisit({
|
||||||
|
completedAt,
|
||||||
|
lastVisitedAt: state.threadLastVisitedAtById[threadKey],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}, [projectThreads]),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
const [renamingThreadKey, setRenamingThreadKey] = useState<string | null>(null);
|
const [renamingThreadKey, setRenamingThreadKey] = useState<string | null>(null);
|
||||||
@@ -1099,20 +1107,25 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
|
|||||||
}, [memberProjectByScopedKey, project.memberProjects, projectThreads]);
|
}, [memberProjectByScopedKey, project.memberProjects, projectThreads]);
|
||||||
|
|
||||||
const { projectStatus, visibleProjectThreads, orderedProjectThreadKeys } = useMemo(() => {
|
const { projectStatus, visibleProjectThreads, orderedProjectThreadKeys } = useMemo(() => {
|
||||||
const lastVisitedAtByThreadKey = new Map(
|
const hasUnseenCompletionByThreadKey = new Map(
|
||||||
projectThreads.map((thread, index) => [
|
projectThreads.map(
|
||||||
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)),
|
(thread, index) =>
|
||||||
threadLastVisitedAts[index] ?? null,
|
[
|
||||||
]),
|
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)),
|
||||||
|
projectThreadHasUnseenCompletions[index] ?? false,
|
||||||
|
] as const,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
const resolveProjectThreadStatus = (thread: SidebarThreadSummary) => {
|
const resolveProjectThreadStatus = (thread: SidebarThreadSummary) => {
|
||||||
const lastVisitedAt = lastVisitedAtByThreadKey.get(
|
const threadKey = scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id));
|
||||||
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)),
|
const hasUnseenCompletion = hasUnseenCompletionByThreadKey.get(threadKey) ?? false;
|
||||||
);
|
const lastVisitedAt = hasUnseenCompletion
|
||||||
|
? undefined
|
||||||
|
: (thread.latestTurn?.completedAt ?? undefined);
|
||||||
return resolveThreadStatusPill({
|
return resolveThreadStatusPill({
|
||||||
thread: {
|
thread: {
|
||||||
...thread,
|
...thread,
|
||||||
...(lastVisitedAt !== null && lastVisitedAt !== undefined ? { lastVisitedAt } : {}),
|
...(lastVisitedAt !== undefined ? { lastVisitedAt } : {}),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -1130,7 +1143,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
|
|||||||
projectStatus,
|
projectStatus,
|
||||||
visibleProjectThreads,
|
visibleProjectThreads,
|
||||||
};
|
};
|
||||||
}, [projectThreads, threadLastVisitedAts, threadSortOrder]);
|
}, [projectThreadHasUnseenCompletions, projectThreads, threadSortOrder]);
|
||||||
|
|
||||||
const pinnedCollapsedThread = useMemo(() => {
|
const pinnedCollapsedThread = useMemo(() => {
|
||||||
const activeThreadKey = activeRouteThreadKey ?? undefined;
|
const activeThreadKey = activeRouteThreadKey ?? undefined;
|
||||||
@@ -1152,20 +1165,25 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
|
|||||||
showEmptyThreadState,
|
showEmptyThreadState,
|
||||||
shouldShowThreadPanel,
|
shouldShowThreadPanel,
|
||||||
} = useMemo(() => {
|
} = useMemo(() => {
|
||||||
const lastVisitedAtByThreadKey = new Map(
|
const hasUnseenCompletionByThreadKey = new Map(
|
||||||
projectThreads.map((thread, index) => [
|
projectThreads.map(
|
||||||
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)),
|
(thread, index) =>
|
||||||
threadLastVisitedAts[index] ?? null,
|
[
|
||||||
]),
|
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)),
|
||||||
|
projectThreadHasUnseenCompletions[index] ?? false,
|
||||||
|
] as const,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
const resolveProjectThreadStatus = (thread: SidebarThreadSummary) => {
|
const resolveProjectThreadStatus = (thread: SidebarThreadSummary) => {
|
||||||
const lastVisitedAt = lastVisitedAtByThreadKey.get(
|
const threadKey = scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id));
|
||||||
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)),
|
const hasUnseenCompletion = hasUnseenCompletionByThreadKey.get(threadKey) ?? false;
|
||||||
);
|
const lastVisitedAt = hasUnseenCompletion
|
||||||
|
? undefined
|
||||||
|
: (thread.latestTurn?.completedAt ?? undefined);
|
||||||
return resolveThreadStatusPill({
|
return resolveThreadStatusPill({
|
||||||
thread: {
|
thread: {
|
||||||
...thread,
|
...thread,
|
||||||
...(lastVisitedAt !== null && lastVisitedAt !== undefined ? { lastVisitedAt } : {}),
|
...(lastVisitedAt !== undefined ? { lastVisitedAt } : {}),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -1202,8 +1220,8 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
|
|||||||
pinnedCollapsedThread,
|
pinnedCollapsedThread,
|
||||||
projectExpanded,
|
projectExpanded,
|
||||||
projectThreads,
|
projectThreads,
|
||||||
|
projectThreadHasUnseenCompletions,
|
||||||
sidebarThreadPreviewCount,
|
sidebarThreadPreviewCount,
|
||||||
threadLastVisitedAts,
|
|
||||||
visibleProjectThreads,
|
visibleProjectThreads,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user