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): select only the clicked message, not its whole branch

Eren9ef6015267b1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index afc16e8..4ddf01e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,8 @@ 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]
+### Changed
+- Clicking a message on the map selects only that message, as the outline does, instead of also tinting its whole branch; the side panel shows the message's branch either way.
## [0.23.1] - 2026-10-30
### Fixed
diff --git a/packages/template/src/GitGraph.tsx b/packages/template/src/GitGraph.tsx
index ffba034..7705306 100644
--- a/packages/template/src/GitGraph.tsx
+++ b/packages/template/src/GitGraph.tsx
@@ -30,7 +30,6 @@ function Row({
row,
sameDay,
selected,
- branchSelected,
searchHit,
searchActive,
read,
@@ -42,7 +41,6 @@ function Row({
/** The row above is on the same day, so this one shows only the time. */
sameDay: boolean;
selected: boolean;
- branchSelected: boolean;
/** The message matches the search (Story 8.14). */
searchHit: boolean;
/** The hit the ↑/↓ counter is on. */
@@ -57,7 +55,6 @@ function Row({
const style = {
top: row.y - row.height / 2,
height: row.height,
- borderColor: branchSelected ? color(row.colorIndex) : undefined,
};
if (row.kind === "more") {
@@ -85,7 +82,6 @@ function Row({
const className = [
"git-row",
selected ? "is-selected" : "",
- branchSelected ? "in-branch" : "",
searchHit ? "is-search-hit" : "",
searchActive ? "is-search-active" : "",
unreadBig ? "is-unread-big" : "",
@@ -146,7 +142,6 @@ function Row({
export function GitGraph({
git,
selectedId,
- activeSegmentId,
highlightIds,
activeHitId,
readIds,
@@ -158,7 +153,6 @@ export function GitGraph({
/** Message id of the open drill-down, if it belongs to this session. */
selectedId: string | null;
/** Branch the drill-down belongs to. */
- activeSegmentId: string | null;
/** Messages that match the map search (Story 8.14); undefined when none. */
highlightIds: ReadonlySet<string> | undefined;
/** The search hit the counter is on, if it belongs to this session. */
@@ -256,7 +250,6 @@ export function GitGraph({
row={row}
sameDay={sameDay}
selected={messageId !== null && selectedId !== null && messageId === selectedId}
- branchSelected={activeSegmentId !== null && row.segmentId === activeSegmentId}
searchHit={messageId !== null && highlightIds?.has(messageId) === true}
searchActive={messageId !== null && activeHitId !== null && messageId === activeHitId}
read={messageId !== null && readIds.has(messageId)}
diff --git a/packages/template/src/Graph.tsx b/packages/template/src/Graph.tsx
index 1e5ab2e..2a5fe48 100644
--- a/packages/template/src/Graph.tsx
+++ b/packages/template/src/Graph.tsx
@@ -58,7 +58,7 @@ const GraphActions = createContext<{
/** Unread messages at or above this many lines get the quiet highlight. */
bigChangeLines: number;
openSession: (sessionId: string) => void;
- openNode: (sessionId: string, messageId: string, branchId?: string) => void;
+ openNode: (sessionId: string, messageId: string) => void;
openContinue: (sessionId: string, messageId: string) => void;
unfold: (segmentId: string) => void;
/** Sets the width of the open sessions' message rows (their right edge). */
@@ -115,12 +115,11 @@ function SessionMessages({
<GitGraph
git={git}
selectedId={selection?.type === "node" && own ? selection.nodeId : null}
- activeSegmentId={selection?.type === "node" && own ? (selection.branchId ?? null) : null}
highlightIds={highlights}
activeHitId={activeHitId}
readIds={readIds}
bigChangeLines={bigChangeLines}
- onSelect={(row) => openNode(session.sessionId, row.message.id, row.segmentId)}
+ onSelect={(row) => openNode(session.sessionId, row.message.id)}
onUnfold={unfold}
/>
<RowEdge
@@ -574,15 +573,10 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta
[openIds],
);
const openNode = useCallback(
- (sessionId: string, messageId: string, branchId?: string) => {
+ (sessionId: string, messageId: string) => {
ensureOpen(sessionId);
setFocusedId(`node:session:${sessionId}:${messageId}`);
- setSelection({
- type: "node",
- sessionId,
- nodeId: messageId,
- ...(branchId === undefined ? {} : { branchId }),
- });
+ setSelection({ type: "node", sessionId, nodeId: messageId });
},
[ensureOpen],
);
diff --git a/packages/template/src/SidePanel.tsx b/packages/template/src/SidePanel.tsx
index 1d94bea..76e55de 100644
--- a/packages/template/src/SidePanel.tsx
+++ b/packages/template/src/SidePanel.tsx
@@ -31,7 +31,7 @@ import { ResumeButton } from "./ResumeButton.js";
* showing stale text.
*/
export type Selection =
- | { type: "node"; sessionId: string; nodeId: string; branchId?: string | undefined }
+ | { type: "node"; sessionId: string; nodeId: string }
| { type: "session"; sessionId: string };
function findSession(model: LineageViewModel, sessionId: string): ViewSession | undefined {
@@ -256,7 +256,7 @@ function branchOf(session: ViewSession, messageId: string): string | undefined {
)?.id;
}
-/** The branch summary a clicked row opens the panel with (Story 8.2). */
+/** The branch summary of the selected message (Story 8.2), wherever it was opened from. */
function BranchDetails({
session,
branchId,
@@ -325,7 +325,6 @@ function MessageNav({
type: "node",
sessionId: session.sessionId,
nodeId: target.id,
- ...(branchOf(session, target.id) ? { branchId: branchOf(session, target.id) } : {}),
},
})
: undefined;
@@ -344,7 +343,6 @@ function MessageNav({
function NodeDetails({
model,
node,
- branchId,
onNavigate,
read,
onToggleRead,
@@ -353,7 +351,6 @@ function NodeDetails({
}: {
model: LineageViewModel;
node: NodeDetail;
- branchId?: string | undefined;
onNavigate: ((target: OutlineTarget) => void) | undefined;
/** The user marked this message read (Story 10.3). */
read: boolean;
@@ -516,7 +513,9 @@ function NodeDetails({
<p className="muted">Open with `cogit open` to see diffs.</p>
) : null}
{node.kind === "message" ? <Conversation session={session} id={node.nodeId} /> : null}
- {session ? <BranchDetails session={session} branchId={branchId} /> : null}
+ {session ? (
+ <BranchDetails session={session} branchId={branchOf(session, node.nodeId)} />
+ ) : null}
<dl className="drilldown-meta">
<Field label={node.kind === "message" ? "Sent" : "Recorded"}>
{formatTime(node.at ?? node.addedAt ?? null)}
@@ -771,7 +770,6 @@ export function DrillDown({
<NodeDetails
model={model}
node={node}
- branchId={selection.branchId}
onNavigate={onNavigate}
read={read}
onToggleRead={onToggleRead}
diff --git a/packages/template/src/styles.css b/packages/template/src/styles.css
index e56f4a9..f6c5e9c 100644
--- a/packages/template/src/styles.css
+++ b/packages/template/src/styles.css
@@ -2160,10 +2160,6 @@ time {
background: var(--hover);
}
-.git-row.in-branch {
- background: color-mix(in srgb, var(--accent) 6%, transparent);
-}
-
.git-row.is-selected {
background: var(--active);
outline: 1px solid var(--accent);
diff --git a/packages/template/test/session-git.test.ts b/packages/template/test/session-git.test.ts
index 2c12262..f267274 100644
--- a/packages/template/test/session-git.test.ts
+++ b/packages/template/test/session-git.test.ts
@@ -70,4 +70,16 @@ describe("Story 9.3 on the map", () => {
);
expect(html).toContain("This conversation is not on this machine");
});
+
+ it("shows the message's branch however the message was opened", () => {
+ // The selection carries no branch: the outline and a map click open it alike.
+ const html = renderToStaticMarkup(
+ createElement(DrillDown, {
+ model: modelOf(session),
+ selection: { type: "node", sessionId: "s1", nodeId: "h1" },
+ onClose: () => {},
+ }),
+ );
+ expect(html).toContain('class="branch-detail fold"');
+ });
});
diff --git a/packages/template/test/unread.test.ts b/packages/template/test/unread.test.ts
index 0a3444f..a89ea68 100644
--- a/packages/template/test/unread.test.ts
+++ b/packages/template/test/unread.test.ts
@@ -76,7 +76,6 @@ function renderGraph(readIds: ReadonlySet<string>): string {
createElement(GitGraph, {
git: layoutGitGraph(session.messages),
selectedId: null,
- activeSegmentId: null,
highlightIds: undefined,
activeHitId: null,
readIds,
@@ -110,7 +109,6 @@ describe("how much code landed on the map (10.3)", () => {
createElement(GitGraph, {
git: layoutGitGraph(session.messages),
selectedId: null,
- activeSegmentId: null,
highlightIds: undefined,
activeHitId: null,
readIds: new Set(),