TermAl

Feature Brief: Diff Review Workflow

Backlog source: docs/bugs.md

The detailed diff-preview and review-plan content below was moved out of docs/bugs.md.

Related:

Agent replies in diff review comments

Severity: Medium — closes the review feedback loop.

When the user leaves review comments on a diff preview and hands them off to an agent, the agent currently has no way to reply inline. Comments are one-directional: user writes, agent reads.

Desired behavior:

Tasks:

This is the concrete delivery plan for the diff-preview and saved-review workflow.

Goals

Non-goals for v1

Current constraints

Proposed architecture

Introduce a typed in-app link system so navigation is explicit and reusable.

type LinkTarget =
  | { kind: "session"; sessionId: string }
  | { kind: "message"; sessionId: string; messageId: string }
  | { kind: "source"; path: string }
  | { kind: "diffPreview"; changeSetId: string; originSessionId: string; originMessageId: string };

Rules:

2. Generic workspace tabs

Refactor the workspace model so a pane can hold first-class tabs instead of only session IDs.

type WorkspaceTab =
  | { id: string; kind: "session"; sessionId: string }
  | { id: string; kind: "source"; path: string }
  | {
      id: string;
      kind: "diffPreview";
      changeSetId: string;
      originSessionId: string;
      originMessageId: string;
    };

Rules:

3. Change-set identity

Every diff preview needs a stable ID that survives reopening and review-file lookup.

Proposal:

Minimum backend metadata to add to diff-like messages:

Diff preview plan

Rendering model

Phase 1:

Phase 2:

Why not add a library first

The repo currently has no diff-viewer dependency and no routing layer. The first implementation should minimize moving pieces:

Review comment plan

Comment scopes

Support these scopes in v1:

Stable anchors

Never anchor comments to DOM position. Use structured targets:

type ReviewAnchor =
  | { kind: "changeSet" }
  | { kind: "file"; filePath: string }
  | { kind: "hunk"; filePath: string; hunkHeader: string }
  | {
      kind: "line";
      filePath: string;
      hunkHeader: string;
      oldLine: number | null;
      newLine: number | null;
    };

Review file format

Persist review state under the existing TermAl workspace data directory:

.termal/
  termal.sqlite
  reviews/
    <change-set-id>.json
    <change-set-id>.md   # optional export later

Proposed JSON schema:

{
  "version": 1,
  "changeSetId": "change-session-3-message-42",
  "origin": {
    "sessionId": "session-3",
    "messageId": "message-42",
    "agent": "Codex",
    "workdir": "/Users/greg/GitHub/Personal/termal",
    "createdAt": "2026-03-09T18:55:00Z"
  },
  "files": [
    {
      "filePath": "docs/bugs.md",
      "changeType": "edit"
    }
  ],
  "comments": [
    {
      "id": "comment-1",
      "anchor": {
        "kind": "line",
        "filePath": "docs/bugs.md",
        "hunkHeader": "@@ -10,3 +10,8 @@",
        "oldLine": null,
        "newLine": 17
      },
      "body": "This should mention Codex attachment support explicitly.",
      "status": "open",
      "author": "user",
      "createdAt": "2026-03-09T19:02:00Z",
      "updatedAt": "2026-03-09T19:02:00Z"
    }
  ]
}

Rules:

API plan

Add a small review API beside the existing session routes.

Suggested routes:

Notes:

UI plan

Conversation surface

Diff preview tab

Header actions:

Body:

Agent handoff plan

The point of saving review files is to make them usable in later turns without manual copy-paste.

V1 handoff flow:

  1. User opens diff preview.
  2. User adds comments and saves review.
  3. UI shows the saved review path, for example .termal/reviews/change-session-3-message-42.json.
  4. User clicks Insert review into prompt.
  5. The composer gets a short, structured handoff message like: Please address the open review comments in .termal/reviews/change-session-3-message-42.json
  6. The later agent turn reads the file from disk and resolves comments one by one.

Implementation phases

Phase 1: metadata and navigation

Phase 2: diff preview

Phase 3: saved review comments

Phase 4: agent handoff and polish

Testing plan

Backend:

Frontend:

Integration:

Acceptance criteria