Skip to content

armgit / cogit

Public Imported from GitHub
0

Git for the intent behind agent-written code. Records what your coding agent decided and why, and links every commit to it.

fix(map): scroll the outline to the search hit and the clicked message

Erenee7196c3dd24
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c429e50..39cbf7c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `cogit init --help` and `cogit config git --help` named the removed `commit` policy; they now say `share` or `ignore`.
- `cogit pr` and `cogit show <sha>` no longer tell a reviewer that a teammate's thought is "not recorded yet" when it may never arrive: for someone else's commit they say it is not in this clone's record, because its author has not pushed it or it came from a fork.
- `cogit build` in a fresh clone of a shared project downloads the team's sessions first, instead of writing an empty map.
+- The map's outline follows the search: it marks and scrolls to the hit you are on, and scrolls to a message you click on the map.
## [1.0.0] - 2026-11-04
### Changed
diff --git a/packages/template/src/Graph.tsx b/packages/template/src/Graph.tsx
index be251d1..2e9543e 100644
--- a/packages/template/src/Graph.tsx
+++ b/packages/template/src/Graph.tsx
@@ -398,6 +398,15 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta
: { sessionId: activeHit.sessionId, messageId: activeHit.messageId },
[hashHit?.sessionId, hashHit?.messageId, activeHit?.sessionId, activeHit?.messageId],
);
+ // The outline follows the hit the search is on, like a click on the map.
+ useEffect(() => {
+ if (searchTarget === null) return;
+ setFocusedId(
+ searchTarget.messageId === null
+ ? `session:${searchTarget.sessionId}`
+ : `node:session:${searchTarget.sessionId}:${searchTarget.messageId}`,
+ );
+ }, [searchTarget]);
const highlights = useMemo(() => hitMessageIds(search.hits), [search.hits]);
const sessionHits = useMemo(
() => new Set(search.hits.flatMap((hit) => (hit.messageId === null ? [hit.sessionId] : []))),
diff --git a/packages/template/src/Outline.tsx b/packages/template/src/Outline.tsx
index 120c02b..148f508 100644
--- a/packages/template/src/Outline.tsx
+++ b/packages/template/src/Outline.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useState } from "react";
+import { useEffect, useRef, useState } from "react";
import type { LineageViewModel, ViewSession } from "../../cli/src/view/model.js";
import { kindLabel } from "./format.js";
import { nodeId, sessionId } from "./graph.js";
@@ -168,6 +168,18 @@ export function Outline({
});
}, [activeId, model]);
+ // Bring the active row into view, a frame later so its ancestors have expanded.
+ // Only a new target scrolls: opening or closing another row never jumps the list.
+ const list = useRef<HTMLDivElement>(null);
+ useEffect(() => {
+ if (!activeId) return;
+ const timer = window.setTimeout(() => {
+ const row = list.current?.querySelector(".outline-item.is-active");
+ row?.scrollIntoView?.({ block: "nearest" });
+ }, 0);
+ return () => window.clearTimeout(timer);
+ }, [activeId]);
+
const toggle = (id: string): void => {
setExpanded((previous) => {
const next = new Set(previous);
@@ -190,7 +202,7 @@ export function Outline({
×
</button>
</header>
- <div className="outline-scroll">
+ <div className="outline-scroll" ref={list}>
{model.sessions.length === 0 ? (
<p className="empty">No sessions recorded yet.</p>
) : (