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
feat(map): tell your sessions from your teammates' and filter by person
Eren507c01139fe3
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex b57e40c..590dab0 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]+### Added+- The map tells your sessions from your teammates': a teammate's session always shows their name and yours never needs to, the side panel marks yours "(you)", and a new Everyone / You / teammate choice in the toolbar fades the other people's sessions.+### Changed- A session records its author's git email next to their name, and people are told apart by email, as in git.- A session only continues its author's own earlier sessions: after a pull, a teammate's sessions are no longer offered as the start of yours, and the map no longer draws a session as the continuation of someone else's.diff --git a/docs/guide/teams-and-git.md b/docs/guide/teams-and-git.mdindex 2d09ab9..3f93f65 100644--- a/docs/guide/teams-and-git.md+++ b/docs/guide/teams-and-git.md@@ -57,6 +57,9 @@ and `user.email`, and like git it tells people apart by email. Your sessions onlcontinue your own earlier sessions; a teammate's session is never taken for the start ofyours, so everyone's line of thought stays their own on the map.+On the map a teammate's session shows their name (yours shows none), and the toolbar's+Everyone / You / teammate choice fades everyone else's sessions while keeping them in place.+Raw conversations stay on each author's machine unless they turn `shareConversations` on, soteammates see the record (titles, decisions, reasons) but not the chat itself.diff --git a/packages/cli/src/author.ts b/packages/cli/src/author.tsindex d55b3dc..1983dca 100644--- a/packages/cli/src/author.ts+++ b/packages/cli/src/author.ts@@ -1,28 +1,9 @@import { userInfo } from "node:os";import { findGitRoot, gitUserEmail, gitUserName } from "./git.js";-/**- * Who a session belongs to (Story 9.3): the git identity it was recorded with.- * Like git, a person is their email when there is one, else their name. A- * session's thoughts are its author's own; another person's session is never- * taken for a continuation of yours.- */-export interface Author {- author?: string | undefined;- authorEmail?: string | undefined;-}+export { type Author, sameAuthor } from "./view/people.js";-/**- * Whether two sessions were recorded by the same person. Emails decide when both- * have one, else names; a record from before authors were stamped matches- * anyone, since it was made before teammates' records could be told apart.- */-export function sameAuthor(a: Author, b: Author): boolean {- if (a.authorEmail !== undefined && b.authorEmail !== undefined)- return a.authorEmail.toLowerCase() === b.authorEmail.toLowerCase();- if (a.author !== undefined && b.author !== undefined) return a.author === b.author;- return true;-}+import type { Author } from "./view/people.js";/*** Who gets credited for a session (Story 9.3): the git name this repositorydiff --git a/packages/cli/src/view/people.ts b/packages/cli/src/view/people.tsnew file mode 100644index 0000000..3ef0169--- /dev/null+++ b/packages/cli/src/view/people.ts@@ -0,0 +1,34 @@+/* Kept free of Node imports: the map template uses these too. */++/**+ * Who a session belongs to (Story 9.3): the git identity it was recorded with.+ * Like git, a person is their email when there is one, else their name. A+ * session's thoughts are its author's own; another person's session is never+ * taken for a continuation of yours.+ */+export interface Author {+ author?: string | undefined;+ authorEmail?: string | undefined;+}++/**+ * Whether two sessions were recorded by the same person. Emails decide when both+ * have one, else names; a record from before authors were stamped matches+ * anyone, since it was made before teammates' records could be told apart.+ */+export function sameAuthor(a: Author, b: Author): boolean {+ if (a.authorEmail !== undefined && b.authorEmail !== undefined)+ return a.authorEmail.toLowerCase() === b.authorEmail.toLowerCase();+ if (a.author !== undefined && b.author !== undefined) return a.author === b.author;+ return true;+}++/** A person's label on the map: their name, else their email. */+export function personLabel(person: Author): string | undefined {+ return person.author ?? person.authorEmail;+}++/** One key per person, for grouping: the email when there is one, else the name. */+export function personKey(person: Author): string | undefined {+ return person.authorEmail?.toLowerCase() ?? person.author;+}diff --git a/packages/template/src/Graph.tsx b/packages/template/src/Graph.tsxindex 088dcc7..9caedb2 100644--- a/packages/template/src/Graph.tsx+++ b/packages/template/src/Graph.tsx@@ -28,6 +28,7 @@ import { type GitLayout, layoutGitGraph, ROW_WIDTH } from "./gitLayout.js";import { centreViewport, headOf, type MapPoint } from "./graph.js";import type { MapSearchState } from "./MapSearch.js";import { Outline, type OutlineTarget } from "./Outline.js";+import { filterOf, type PersonFilter, peopleOf, valueOf } from "./people.js";import { RowEdge, type RowWidths, rowWidthsOf } from "./RowEdge.js";import { OPEN_LINK_DROP, SessionMap } from "./SessionMap.js";import { DrillDown, type Selection } from "./SidePanel.js";@@ -65,6 +66,9 @@ const GraphActions = createContext<{/** Sets the width of the open sessions' message rows (their right edge). */resizeRows: (sessionId: string, width: number) => void;storeRowWidth: (sessionId: string, width: number) => void;+ /** The person filter (Everyone, You, a teammate); null for everyone. */+ person: PersonFilter;+ people: ReturnType<typeof peopleOf>;}>({selection: null,openIds: new Set(),@@ -76,6 +80,8 @@ const GraphActions = createContext<{unfold: () => {},resizeRows: () => {},storeRowWidth: () => {},+ person: null,+ people: peopleOf({ sessions: [] }),});/** An opened session: its message graph and where it sits on the canvas. */@@ -106,13 +112,23 @@ function SessionMessages({highlights: ReadonlySet<string> | undefined;activeHitId: string | null;}) {- const { selection, readIds, bigChangeLines, openNode, unfold, resizeRows, storeRowWidth } =- useContext(GraphActions);+ const {+ selection,+ readIds,+ bigChangeLines,+ openNode,+ unfold,+ resizeRows,+ storeRowWidth,+ person,+ people,+ } = useContext(GraphActions);const own = selection?.sessionId === session.sessionId;if (git.rows.length === 0)return <p className="graph-status empty">No messages recorded in this session yet.</p>;+ const dimmed = !people.matches(session, person);return (- <div className="session-rows">+ <div className={dimmed ? "session-rows is-dimmed" : "session-rows"}><GitGraphgit={git}selectedId={selection?.type === "node" && own ? selection.nodeId : null}@@ -133,7 +149,7 @@ function SessionMessages({}function ProjectBox({ data }: NodeProps<ProjectFlowNode>) {- const { openSession, openContinue, selection, openIds } = useContext(GraphActions);+ const { openSession, openContinue, selection, openIds, person } = useContext(GraphActions);return (<div className="map-node"><SessionMap@@ -143,6 +159,7 @@ function ProjectBox({ data }: NodeProps<ProjectFlowNode>) {selectedSessionId={selection?.type === "session" ? selection.sessionId : null}openIds={openIds}highlightSessionIds={data.sessionHits}+ person={person}onOpen={openSession}onContinue={openContinue}/>@@ -327,6 +344,9 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta// The files, unread and outline views share the left column; only one shows.const [showFiles, setShowFiles] = useState(false);const [showUnread, setShowUnread] = useState(false);+ const [person, setPerson] = useState<PersonFilter>(null);+ const people = useMemo(() => peopleOf(model), [model]);+ const personOptions = useMemo(() => people.options(), [people]);const { expanded: fullscreen, toggle: toggleFullscreen } = useFullscreen();// Story 10.3: the read marks the page was built with. A live rebuild refreshes// them; the toggle updates this set at once so the row answers the click.@@ -672,6 +692,8 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchStaunfold,resizeRows,storeRowWidth,+ person,+ people,}),[selection,@@ -684,6 +706,8 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchStaunfold,resizeRows,storeRowWidth,+ person,+ people,],);@@ -759,6 +783,21 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta>{openAll ? "Fold all" : "Unfold all"}</button>+ {personOptions.length > 0 ? (+ <select+ className="person-filter"+ aria-label="Whose sessions"+ title="Fade the other people's sessions; the lines between them stay"+ value={valueOf(person)}+ onChange={(event) => setPerson(filterOf(event.target.value))}+ >+ {personOptions.map((option) => (+ <option key={option.value} value={option.value}>+ {option.label}+ </option>+ ))}+ </select>+ ) : null}<buttontype="button"className="outline-button"diff --git a/packages/template/src/SessionMap.tsx b/packages/template/src/SessionMap.tsxindex 3fdda7c..34ec7c9 100644--- a/packages/template/src/SessionMap.tsx+++ b/packages/template/src/SessionMap.tsx@@ -2,6 +2,7 @@ import type { MouseEvent } from "react";import type { LineageViewModel, ViewSession } from "../../cli/src/view/model.js";import { formatStamp } from "./format.js";import { branchPath, type GitMessageRow, type GitRow, LANE_COLORS } from "./gitLayout.js";+import { type PersonFilter, peopleOf } from "./people.js";import type { SessionGraph } from "./sessionLayout.js";/**@@ -22,6 +23,7 @@ function SessionRow({row,session,showAuthor,+ dimmed,selected,open,searchHit,@@ -30,8 +32,10 @@ function SessionRow({}: {row: GitMessageRow;session: ViewSession;- /** More than one person recorded sessions here; otherwise the name says nothing. */+ /** Whose session it is: shown for a teammate's, never for your own. */showAuthor: boolean;+ /** Left out by the person filter: kept in place, faded, so the lines stay whole. */+ dimmed: boolean;selected: boolean;/** Its messages are open below the row. */open: boolean;@@ -48,6 +52,7 @@ function SessionRow({selected ? "is-selected" : "",open ? "is-open" : "",searchHit ? "is-search-hit" : "",+ dimmed ? "is-dimmed" : "",].filter(Boolean).join(" ");@@ -104,6 +109,7 @@ export function SessionMap({selectedSessionId,openIds,highlightSessionIds,+ person = null,onOpen,onContinue,}: {@@ -114,15 +120,14 @@ export function SessionMap({openIds: ReadonlySet<string>;/** Sessions whose title or status matched the map search. */highlightSessionIds: ReadonlySet<string>;+ /** The person filter: everyone when left out. */+ person?: PersonFilter;onOpen: (sessionId: string) => void;onContinue: (sessionId: string, messageId: string) => void;}) {const { git } = graph;const segments = new Map(git.segments.map((segment) => [segment.id, segment]));- const authors = new Set(- [...graph.sessions.values()].flatMap((s) => (s.author ? [s.author] : [])),- );- const showAuthor = authors.size > 1;+ const people = peopleOf(model);const open: (row: GitRow) => void = (row) => {if (row.kind === "message") onOpen(row.message.id);@@ -211,7 +216,8 @@ export function SessionMap({key={row.message.id}row={row}session={session}- showAuthor={showAuthor}+ showAuthor={people.showAuthor(session)}+ dimmed={!people.matches(session, person)}selected={selectedSessionId === session.sessionId}open={openIds.has(session.sessionId)}searchHit={highlightSessionIds.has(session.sessionId)}diff --git a/packages/template/src/SidePanel.tsx b/packages/template/src/SidePanel.tsxindex 907e923..3662d46 100644--- a/packages/template/src/SidePanel.tsx+++ b/packages/template/src/SidePanel.tsx@@ -22,6 +22,7 @@ import {toNodeDetail,} from "./graph.js";import type { OutlineTarget } from "./Outline.js";+import { peopleOf } from "./people.js";import { ResumeButton } from "./ResumeButton.js";/**@@ -121,7 +122,12 @@ function SessionSummary({ model, session }: { model: LineageViewModel; session:<><dl className="drilldown-meta"><Field label="Agent">{session.agent}</Field>- {session.author ? <Field label="Recorded by">{session.author}</Field> : null}+ {session.author ? (+ <Field label="Recorded by">+ {session.author}+ {peopleOf(model).mine(session) ? " (you)" : ""}+ </Field>+ ) : null}<Field label="Session"><code>{session.sessionId}</code></Field>diff --git a/packages/template/src/people.ts b/packages/template/src/people.tsnew file mode 100644index 0000000..4588fff--- /dev/null+++ b/packages/template/src/people.ts@@ -0,0 +1,68 @@+import type { LineageViewModel, ViewSession } from "../../cli/src/view/model.js";+import { personKey, personLabel, sameAuthor } from "../../cli/src/view/people.js";++/** The map's person filter: everyone, the viewer's own sessions, or one person's by key. */+export type PersonFilter = null | "you" | { key: string };++export interface PersonOption {+ value: string;+ label: string;+}++/**+ * Whose sessions are whose on one map. The viewer is the git identity of the+ * machine that built the page; without it (an older page) the map falls back to+ * naming every author once there is more than one.+ */+export function peopleOf(model: Pick<LineageViewModel, "sessions" | "viewer">) {+ const viewer = model.viewer;+ const known = viewer !== undefined && personKey(viewer) !== undefined;+ const others = new Map<string, string>();+ for (const session of model.sessions) {+ const key = personKey(session);+ const label = personLabel(session);+ if (key === undefined || label === undefined) continue;+ if (known && sameAuthor(session, viewer)) continue;+ if (!others.has(key)) others.set(key, label);+ }+ const mine = (session: ViewSession): boolean | undefined =>+ known && personKey(session) !== undefined ? sameAuthor(session, viewer) : undefined;+ return {+ /** Whether the session is the viewer's own, by git identity; undefined when unknown. */+ mine,+ /** A teammate's session always says whose it is; your own never needs to. */+ showAuthor(session: ViewSession): boolean {+ if (session.author === undefined) return false;+ const own = mine(session);+ return own === undefined ? others.size > 1 : !own;+ },+ matches(session: ViewSession, filter: PersonFilter): boolean {+ if (filter === null) return true;+ if (filter === "you") return mine(session) !== false;+ return personKey(session) === filter.key;+ },+ /** The filter's choices; empty when everything on the map is one person's. */+ options(): PersonOption[] {+ const people = [...others].map(([key, label]) => ({ value: `person:${key}`, label }));+ if (people.length === 0 || (!known && people.length < 2)) return [];+ return [+ { value: "everyone", label: "Everyone" },+ ...(known ? [{ value: "you", label: "You" }] : []),+ ...people,+ ];+ },+ };+}++/** The select's value back to a filter. */+export function filterOf(value: string): PersonFilter {+ if (value === "you") return "you";+ if (value.startsWith("person:")) return { key: value.slice("person:".length) };+ return null;+}++/** A filter as the select's value. */+export function valueOf(filter: PersonFilter): string {+ if (filter === null) return "everyone";+ return filter === "you" ? "you" : `person:${filter.key}`;+}diff --git a/packages/template/src/styles.css b/packages/template/src/styles.cssindex e146cef..ad3e3d0 100644--- a/packages/template/src/styles.css+++ b/packages/template/src/styles.css@@ -889,6 +889,23 @@ body:has(.map-shell.is-expanded) {height: auto;}+/* Whose sessions (Everyone / You / a teammate): sits with the toolbar buttons. */+.person-filter {+ padding: 4px 8px;+ color: var(--muted);+ background: var(--raised);+ border: 1px solid var(--line);+ border-radius: 7px;+ font: inherit;+ font-size: 13px;+}++/* Another person's sessions under the filter: in place, faded, so the lines stay whole. */+.session-row.is-dimmed,+.session-rows.is-dimmed {+ opacity: 0.35;+}+.outline-button {padding: 5px 12px;color: var(--muted);diff --git a/packages/template/test/people.test.ts b/packages/template/test/people.test.tsnew file mode 100644index 0000000..3733177--- /dev/null+++ b/packages/template/test/people.test.ts@@ -0,0 +1,64 @@+import { describe, expect, it } from "vitest";+import type { ViewSession } from "../../cli/src/view/model.js";+import { filterOf, peopleOf, valueOf } from "../src/people.js";++const session = (sessionId: string, author?: string, authorEmail?: string): ViewSession => ({+ sessionId,+ agent: "claude-code",+ title: sessionId,+ ...(author === undefined ? {} : { author }),+ ...(authorEmail === undefined ? {} : { authorEmail }),+ startedAt: "2026-10-22T09:00:00.000Z",+ updatedAt: "2026-10-22T09:00:00.000Z",+ status: { goal: "", done: [], pending: [], next: "" },+ messages: [],+ transcriptAvailable: true,+});++const mine = session("a", "Eren", "[email protected]");+const theirs = session("b", "Ayşe", "[email protected]");+const old = session("c");+const viewer = { author: "Eren", authorEmail: "[email protected]" };++describe("peopleOf", () => {+ it("names a teammate's session and never your own", () => {+ const people = peopleOf({ sessions: [mine, theirs, old], viewer });+ expect(people.showAuthor(mine)).toBe(false);+ expect(people.showAuthor(theirs)).toBe(true);+ expect(people.showAuthor(old)).toBe(false);+ });++ it("offers Everyone, You and each teammate, and fades the rest", () => {+ const people = peopleOf({ sessions: [mine, theirs, old], viewer });+ expect(people.options()).toEqual([+ { value: "everyone", label: "Everyone" },+ { value: "you", label: "You" },+ { value: "person:[email protected]", label: "Ayşe" },+ ]);+ expect(people.matches(theirs, "you")).toBe(false);+ expect(people.matches(old, "you")).toBe(true);+ expect(people.matches(theirs, { key: "[email protected]" })).toBe(true);+ expect(people.matches(mine, { key: "[email protected]" })).toBe(false);+ expect(people.matches(theirs, null)).toBe(true);+ });++ it("offers nothing on a map that is all one person's", () => {+ expect(peopleOf({ sessions: [mine, old], viewer }).options()).toEqual([]);+ });++ it("without a viewer, names authors once there are two", () => {+ const one = peopleOf({ sessions: [mine, old] });+ expect(one.showAuthor(mine)).toBe(false);+ expect(one.options()).toEqual([]);+ const two = peopleOf({ sessions: [mine, theirs] });+ expect(two.showAuthor(mine)).toBe(true);+ expect(two.options().map((option) => option.label)).toEqual(["Everyone", "Eren", "Ayşe"]);+ });+});++describe("the filter's select value", () => {+ it("round-trips", () => {+ for (const filter of [null, "you", { key: "[email protected]" }] as const)+ expect(filterOf(valueOf(filter))).toEqual(filter);+ });+});