Git for the intent behind agent-written code. Records what your coding agent decided and why, and links every commit to it.
JavaScript ai-codingclaudeclaude-codeclaude-code-pluginclicoding-agentsdeveloper-toolsgitllmtypescript
fix(map): keep sessions the search opened out of the stored open sessions
Erenc8690e4130e7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 99eba48..018c5d9 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).## [Unreleased]+### Fixed+- Sessions the map search opened no longer stay open after a reload: they close again when the search is cleared or stops matching them, unless you clicked into one.+### Changed- The large "Copy resume command" button is now two small buttons for the session: **Resume** copies `claude --resume <id>`, and **Fork** copies the same with `--fork-session`, so the chat goes on as a new session and the original stays. The command shows only when copying fails.- Dates read the same everywhere: the side panel, the inbox and the project panel show `2026-10-30 21:09` like the map's rows, and the project tabs `10-30`, instead of the browser's locale (`10/30/2026, 9:09:30 PM`, `Oct 30`).diff --git a/packages/template/src/Graph.tsx b/packages/template/src/Graph.tsxindex 17a37a8..088dcc7 100644--- a/packages/template/src/Graph.tsx+++ b/packages/template/src/Graph.tsx@@ -32,6 +32,7 @@ import { RowEdge, type RowWidths, rowWidthsOf } from "./RowEdge.js";import { OPEN_LINK_DROP, SessionMap } from "./SessionMap.js";import { DrillDown, type Selection } from "./SidePanel.js";import { usePageWheel } from "./scroll.js";+import { applySearchHits, storedOpen } from "./searchOpen.js";import { layoutSessionGraph, openAtLoad, type SessionGraph } from "./sessionLayout.js";import { useTheme } from "./ThemeButton.js";import { UnreadView } from "./UnreadView.js";@@ -239,6 +240,17 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchStaconst [openIds, setOpenIds] = useState<ReadonlySet<string>>(() =>openAtLoad(model, model.openSessions, initial),);+ /** Open sessions only the search opened: closed again when they stop matching, never stored. */+ const [searchOpened, setSearchOpened] = useState<ReadonlySet<string>>(() => new Set());+ /** The user took a search-opened session over (a click in it): it stays and is stored. */+ const keep = useCallback((sessionId: string) => {+ setSearchOpened((previous) => {+ if (!previous.has(sessionId)) return previous;+ const next = new Set(previous);+ next.delete(sessionId);+ return next;+ });+ }, []);const [selection, setSelection] = useState<Selection | null>(() => {if (initial === null || initial.quiet) return null;if (initial.messageId === undefined) return { type: "session", sessionId: initial.sessionId };@@ -279,12 +291,13 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchStaconst token = pageToken();if (token === null || !viewLoaded.current) return;const timer = window.setTimeout(() => {- void saveOpenSessions(model.project.path, [...openIds], token).catch((err: unknown) => {+ const stored = storedOpen({ open: openIds, bySearch: searchOpened });+ void saveOpenSessions(model.project.path, stored, token).catch((err: unknown) => {console.warn("cogit: could not save the open sessions", err);});}, 300);return () => window.clearTimeout(timer);- }, [openIds, model.project.path]);+ }, [openIds, searchOpened, model.project.path]);const resizeRows = useCallback((sessionId: string, width: number) => {setRowWidths((previous) => {// Back at the default (double-click): forget the session.@@ -385,19 +398,20 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta);const hitSessions = useMemo(() => hitSessionIds(search.hits), [search.hits]);- // Opening the accordion for every match is what makes the highlights visible.+ // Opening the accordion for every match is what makes the highlights visible;+ // a session the search opened closes again once it no longer matches. Read+ // through refs so a user's own open or close does not rerun the search's.+ const openRef = useRef(openIds);+ openRef.current = openIds;+ const searchOpenedRef = useRef(searchOpened);+ searchOpenedRef.current = searchOpened;useEffect(() => {- if (hitSessions.length === 0) return;- setOpenIds((previous) => {- let changed = false;- const next = new Set(previous);- for (const id of hitSessions) {- if (next.has(id)) continue;- next.add(id);- changed = true;- }- return changed ? next : previous;- });+ const next = applySearchHits(+ { open: openRef.current, bySearch: searchOpenedRef.current },+ hitSessions,+ );+ if (!sameSet(next.open, openRef.current)) setOpenIds(next.open);+ if (!sameSet(next.bySearch, searchOpenedRef.current)) setSearchOpened(next.bySearch);}, [hitSessions]);/** The open drill-down's message, if any. */@@ -552,13 +566,18 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta[search.step, searchPoint],);- const ensureOpen = useCallback((sessionId: string) => {- setOpenIds((previous) =>- previous.has(sessionId) ? previous : new Set([...previous, sessionId]),- );- }, []);+ const ensureOpen = useCallback(+ (sessionId: string) => {+ keep(sessionId);+ setOpenIds((previous) =>+ previous.has(sessionId) ? previous : new Set([...previous, sessionId]),+ );+ },+ [keep],+ );const toggleSession = useCallback((sessionId: string) => {+ keep(sessionId);if (openIds.has(sessionId)) {const next = new Set(openIds);next.delete(sessionId);@@ -571,7 +590,7 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchStasetOpenIds(new Set([...openIds, sessionId]));setFocusedId(`session:${sessionId}`);},- [openIds],+ [openIds, keep],);const openNode = useCallback((sessionId: string, messageId: string) => {@@ -732,6 +751,7 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta// "All" means the whole map: every session opens (or closes), not// only the folded branches of the sessions already open.setOpenIds(openAll ? new Set() : new Set(sessionGraph.sessions.keys()));+ setSearchOpened(new Set());if (openAll) setFits((value) => value + 1);setOpenAll((value) => !value);setUnfolded(new Set());diff --git a/packages/template/src/searchOpen.ts b/packages/template/src/searchOpen.tsnew file mode 100644index 0000000..ac35037--- /dev/null+++ b/packages/template/src/searchOpen.ts@@ -0,0 +1,33 @@+/**+ * Sessions the map search opened, kept apart from the ones the user opened: the+ * search opens a match's session so its highlights show, closes it again once it+ * no longer matches, and never stores it as open for the next reload.+ */+export interface SearchOpen {+ /** Every open session, the search's included. */+ open: ReadonlySet<string>;+ /** The open sessions only the search opened. */+ bySearch: ReadonlySet<string>;+}++/** Opens the sessions with a hit and closes the ones an earlier search opened that no longer match. */+export function applySearchHits(state: SearchOpen, hits: readonly string[]): SearchOpen {+ const matching = new Set(hits);+ const open = new Set(state.open);+ const bySearch = new Set<string>();+ for (const id of state.bySearch) {+ if (matching.has(id)) bySearch.add(id);+ else open.delete(id);+ }+ for (const id of matching) {+ if (open.has(id)) continue;+ open.add(id);+ bySearch.add(id);+ }+ return { open, bySearch };+}++/** The open sessions a reload should open again: the user's, not the search's. */+export function storedOpen(state: SearchOpen): string[] {+ return [...state.open].filter((id) => !state.bySearch.has(id));+}diff --git a/packages/template/test/searchOpen.test.ts b/packages/template/test/searchOpen.test.tsnew file mode 100644index 0000000..7129000--- /dev/null+++ b/packages/template/test/searchOpen.test.ts@@ -0,0 +1,33 @@+import { describe, expect, it } from "vitest";+import { applySearchHits, storedOpen } from "../src/searchOpen.js";++const state = (open: string[], bySearch: string[] = []) => ({+ open: new Set(open),+ bySearch: new Set(bySearch),+});++describe("applySearchHits", () => {+ it("opens a matching session and remembers the search opened it", () => {+ const next = applySearchHits(state(["a"]), ["a", "b"]);+ expect([...next.open].sort()).toEqual(["a", "b"]);+ expect([...next.bySearch]).toEqual(["b"]);+ });++ it("closes a session the search opened once it stops matching, not the user's", () => {+ const next = applySearchHits(state(["a", "b", "c"], ["b", "c"]), ["c"]);+ expect([...next.open].sort()).toEqual(["a", "c"]);+ expect([...next.bySearch]).toEqual(["c"]);+ });++ it("closes every search-opened session when the search is cleared", () => {+ const next = applySearchHits(state(["a", "b"], ["b"]), []);+ expect([...next.open]).toEqual(["a"]);+ expect(next.bySearch.size).toBe(0);+ });+});++describe("storedOpen", () => {+ it("stores only the sessions the user opened", () => {+ expect(storedOpen(state(["a", "b"], ["b"]))).toEqual(["a"]);+ });+});