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.

feat(map): replace the resume button with small Resume and Fork buttons

Eren9156afa5558b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 91892ed..dbaf053 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
+- 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.
## [0.23.2] - 2026-10-30
### Changed
diff --git a/docs/guide/map.md b/docs/guide/map.md
index 64c82bd..ebc2ec1 100644
--- a/docs/guide/map.md
+++ b/docs/guide/map.md
@@ -51,8 +51,10 @@ Click a row to open its details on the right:
- the commits and files, each one opening git's own diff
- the conversation turn itself: your message as written and the agent's written replies (tool
output is left out). This comes from your machine only; see [Privacy](privacy.md).
-- previous and next message buttons, and a **Copy resume command** button:
- `cd '<project>' && claude --resume <session-id>` reopens that chat where it was.
+- previous and next message buttons, and two small buttons that copy a command for the
+ whole session: **Resume** (`cd '<project>' && claude --resume <session-id>`) reopens the
+ chat where it left off, and **Fork** adds `--fork-session`, so the chat goes on as a new
+ session with the same history and the original stays as it was.
## "Your turn"
diff --git a/packages/cli/src/view/resume.ts b/packages/cli/src/view/resume.ts
index b34a0ce..7d743d6 100644
--- a/packages/cli/src/view/resume.ts
+++ b/packages/cli/src/view/resume.ts
@@ -13,7 +13,11 @@ function sessionArg(sessionId: string): string {
return /^[A-Za-z0-9._:/-]+$/.test(sessionId) ? sessionId : shellQuote(sessionId);
}
-/** `cd '<project path>' && claude --resume <sessionId>` */
-export function resumeCommand(projectPath: string, sessionId: string): string {
- return `cd ${shellQuote(projectPath)} && claude --resume ${sessionArg(sessionId)}`;
+/**
+ * `cd '<project path>' && claude --resume <sessionId>`; with `fork`, adds
+ * `--fork-session` so the chat continues as a new session and the original stays.
+ */
+export function resumeCommand(projectPath: string, sessionId: string, fork = false): string {
+ const command = `cd ${shellQuote(projectPath)} && claude --resume ${sessionArg(sessionId)}`;
+ return fork ? `${command} --fork-session` : command;
}
diff --git a/packages/cli/test/resume.test.ts b/packages/cli/test/resume.test.ts
index 8d727b5..bbd3722 100644
--- a/packages/cli/test/resume.test.ts
+++ b/packages/cli/test/resume.test.ts
@@ -34,6 +34,12 @@ describe("resumeCommand", () => {
expect(resumeCommand("/tmp/it's here", "id")).toContain("cd '/tmp/it'\\''s here'");
});
+ it("adds --fork-session for a fork", () => {
+ expect(resumeCommand("/p", "abc-123", true)).toBe(
+ "cd '/p' && claude --resume abc-123 --fork-session",
+ );
+ });
+
it("quotes an unusual session id", () => {
expect(resumeCommand("/p", "a b")).toBe("cd '/p' && claude --resume 'a b'");
});
diff --git a/packages/template/src/Inbox.tsx b/packages/template/src/Inbox.tsx
index c5f5e3c..e206680 100644
--- a/packages/template/src/Inbox.tsx
+++ b/packages/template/src/Inbox.tsx
@@ -149,7 +149,6 @@ export function Inbox({
projectPath={row.projectPath}
sessionId={row.sessionId}
available={row.transcriptAvailable}
- revealCommand
/>
</div>
</li>
diff --git a/packages/template/src/ResumeButton.tsx b/packages/template/src/ResumeButton.tsx
index 4278b8a..02875a5 100644
--- a/packages/template/src/ResumeButton.tsx
+++ b/packages/template/src/ResumeButton.tsx
@@ -2,62 +2,90 @@ import { useState } from "react";
import { resumeCommand } from "../../cli/src/view/resume.js";
import { type CopyState, copyText } from "./clipboard.js";
+type Action = "resume" | "fork";
+
+const LABELS: Record<Action, string> = { resume: "Resume", fork: "Fork" };
+
+const HINTS: Record<Action, string> = {
+ resume: "Copy the command that reopens this session where it left off",
+ fork: "Copy the command that continues this session as a new one; the original stays as it is",
+};
+
/**
- * The resume control (Story 8.7, reused by the inbox in 11.1): copies
- * `cd '<project>' && claude --resume <id>` so the user can go back to the
- * session in a terminal. `onFailed` lets a page that shows the command select
- * it, so Ctrl+C still works when both clipboard paths fail over `file://`.
+ * The resume controls (Story 8.7, reused by the inbox in 11.1): Resume copies
+ * `cd '<project>' && claude --resume <id>`, Fork the same with `--fork-session`.
+ * Both act on the whole session, wherever they are shown. When the clipboard
+ * fails over `file://`, the command is shown selected so Ctrl+C still works.
*/
export function ResumeButton({
projectPath,
sessionId,
available = true,
- revealCommand = false,
- onFailed,
}: {
projectPath: string;
sessionId: string;
/** False when the transcript is gone, so resuming cannot work. */
available?: boolean;
- /**
- * Shows the command when the clipboard fails, for a page with no command of
- * its own on screen (the inbox row); the side panel already prints it.
- */
- revealCommand?: boolean;
- onFailed?: () => void;
}) {
+ const [action, setAction] = useState<Action>("resume");
const [state, setState] = useState<CopyState>("idle");
if (!available) {
return (
- <button type="button" className="resume-button" disabled>
- Copy resume command
- </button>
+ <span className="resume-actions">
+ <button type="button" className="resume-button" disabled>
+ Resume
+ </button>
+ <button type="button" className="resume-button" disabled>
+ Fork
+ </button>
+ <span className="muted resume-note">session no longer available</span>
+ </span>
);
}
- const copy = (): void => {
+ const copy = (next: Action): void => {
+ setAction(next);
setState("idle");
- void copyText(resumeCommand(projectPath, sessionId)).then((ok) => {
- if (!ok) onFailed?.();
- setState(ok ? "copied" : "failed");
- });
+ void copyText(resumeCommand(projectPath, sessionId, next === "fork")).then((ok) =>
+ setState(ok ? "copied" : "failed"),
+ );
};
return (
- <>
- <button type="button" className="resume-button" onClick={copy}>
- Copy resume command
- </button>
- {state === "copied" ? <span className="muted resume-note">Copied.</span> : null}
- {state === "failed" ? (
- <span className="muted resume-note">Copy failed — press Ctrl+C to copy.</span>
+ <span className="resume-actions">
+ {(["resume", "fork"] as const).map((each) => (
+ <button
+ key={each}
+ type="button"
+ className="resume-button"
+ title={`${HINTS[each]}: ${resumeCommand(projectPath, sessionId, each === "fork")}`}
+ onClick={() => copy(each)}
+ >
+ {LABELS[each]}
+ </button>
+ ))}
+ {state === "copied" ? (
+ <span className="muted resume-note">Copied the {action} command.</span>
) : null}
- {revealCommand && state === "failed" ? (
- <code className="resume-command inbox-resume-command">
- {resumeCommand(projectPath, sessionId)}
- </code>
+ {state === "failed" ? (
+ <>
+ <span className="muted resume-note">Copy failed — press Ctrl+C to copy.</span>
+ <code
+ className="resume-command"
+ ref={(element) => {
+ if (!element) return;
+ const range = document.createRange();
+ range.selectNodeContents(element);
+ const selection = window.getSelection();
+ selection?.removeAllRanges();
+ selection?.addRange(range);
+ }}
+ >
+ {resumeCommand(projectPath, sessionId, action === "fork")}
+ </code>
+ </>
) : null}
- </>
+ </span>
);
}
diff --git a/packages/template/src/SidePanel.tsx b/packages/template/src/SidePanel.tsx
index 76e55de..907e923 100644
--- a/packages/template/src/SidePanel.tsx
+++ b/packages/template/src/SidePanel.tsx
@@ -6,7 +6,6 @@ import type {
ViewNode,
ViewSession,
} from "../../cli/src/view/model.js";
-import { resumeCommand } from "../../cli/src/view/resume.js";
import { type CopyState, copyText } from "./clipboard.js";
import { parseSubject, splitPath, typeColour } from "./codeRefs.js";
import { DiffView } from "./DiffView.js";
@@ -86,39 +85,13 @@ function MessageHash({ value }: { value: string }) {
}
function ResumeRow({ model, session }: { model: LineageViewModel; session: ViewSession }) {
- const code = useRef<HTMLElement>(null);
- const command = resumeCommand(model.project.path, session.sessionId);
-
- if (!session.transcriptAvailable) {
- return (
- <div className="resume">
- <button type="button" className="resume-button" disabled>
- Copy resume command
- </button>
- <p className="muted resume-note">session no longer available</p>
- </div>
- );
- }
-
return (
<div className="resume">
- {/* Last resort on a failed copy: selecting the command allows Ctrl+C. */}
<ResumeButton
projectPath={model.project.path}
sessionId={session.sessionId}
- onFailed={() => {
- const element = code.current;
- if (!element) return;
- const range = document.createRange();
- range.selectNodeContents(element);
- const selection = window.getSelection();
- selection?.removeAllRanges();
- selection?.addRange(range);
- }}
+ available={session.transcriptAvailable}
/>
- <pre className="resume-command">
- <code ref={code}>{command}</code>
- </pre>
</div>
);
}
diff --git a/packages/template/src/styles.css b/packages/template/src/styles.css
index f6c5e9c..8ad5503 100644
--- a/packages/template/src/styles.css
+++ b/packages/template/src/styles.css
@@ -1654,14 +1654,22 @@ button.file-row:hover {
border-top: 1px solid var(--line);
}
+/* Two small, equal controls: they copy a command, they do not run anything. */
+.resume-actions {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 6px;
+}
+
.resume-button {
- width: 100%;
- padding: 8px 12px;
+ padding: 2px 10px;
color: var(--text);
background: var(--active);
border: 1px solid var(--line);
border-radius: 7px;
font: inherit;
+ font-size: 12px;
cursor: pointer;
}
@@ -1676,12 +1684,13 @@ button.file-row:hover {
}
.resume-note {
- margin-top: 6px;
+ font-size: 12px;
}
.resume-command {
- margin: 10px 0 0;
- padding: 8px;
+ flex-basis: 100%;
+ margin: 0;
+ padding: 6px 8px;
overflow-x: auto;
background: var(--row-bg);
border: 1px solid var(--line);
@@ -1794,27 +1803,6 @@ time {
color: var(--accent);
}
-/* The shared resume button fills its side-panel column; an inbox row wants a
- compact control next to the link and Dismiss. */
-.inbox-actions .resume-button {
- width: auto;
- padding: 2px 8px;
- font-size: 12px;
-}
-
-.inbox-actions .resume-note {
- margin: 0;
- font-size: 12px;
-}
-
-.inbox-resume-command {
- flex-basis: 100%;
- margin: 0;
- padding: 6px 8px;
- overflow-wrap: anywhere;
- font-size: 12px;
-}
-
/* The close button in a row's top-right corner: hides the row until the agent
writes in that session again. */
.inbox-dismiss {
diff --git a/packages/template/test/session-git.test.ts b/packages/template/test/session-git.test.ts
index f267274..0029489 100644
--- a/packages/template/test/session-git.test.ts
+++ b/packages/template/test/session-git.test.ts
@@ -82,4 +82,23 @@ describe("Story 9.3 on the map", () => {
);
expect(html).toContain('class="branch-detail fold"');
});
+
+ it("offers Resume and Fork for the session, disabled when its chat is gone", () => {
+ const render = (current: ViewSession) =>
+ renderToStaticMarkup(
+ createElement(DrillDown, {
+ model: modelOf(current),
+ selection: { type: "node", sessionId: "s1", nodeId: "h1" },
+ onClose: () => {},
+ }),
+ );
+ const live = render({ ...session, transcriptAvailable: true });
+ expect(live).toContain(">Resume</button>");
+ expect(live).toContain(">Fork</button>");
+ expect(live).toContain("claude --resume s1 --fork-session");
+ expect(live).not.toContain("disabled");
+ const gone = render(session);
+ expect(gone).toContain("session no longer available");
+ expect(gone.match(/class="resume-button" disabled/g)).toHaveLength(2);
+ });
});