feat(desktop): view full commit message from the Diffs tab commit list

Draft
GI
3mo ago
+373-17

What

Adds a way to read a commit's full message (subject + body) from the Diffs tab commit list, without leaving the app.

Why it wasn't possible before

This is a data-layer gap, not just a UI one. The commit list is built by getBranchComparison in apps/desktop/src/lib/trpc/routers/changes/workers/git-task-handlers.ts:193, which runs:

git log origin/<base>..HEAD --max-count=500 --format=%H|%h|%s|%an|%aI

%s is the subject only — the body is never fetched, so CommitInfo.message can only ever hold the first line. That's why the existing tooltip on CommitItem "reveals the same truncated subject line": there is nothing more in the payload to reveal.

I added a test that pins this down against a real temp repo (commit-message.test.ts, first case): a commit whose message has a body comes back from executeGitTask("getStatus", …) with message === subject and no trace of the body.

The change

Backend — fetch the message on demand

  • utils/commit-message.ts: readCommitMessage(git, hash) runs git log -1 --format=%B <hash> -- and splitCommitMessage() splits it into { subject, body }, folding a wrapped subject onto one line the way git's own %s does so the popover header matches the list row.
  • isValidCommitHash() restricts the ref to a hex object name, so the input can't reach git log as a flag or revision expression. Enforced inside readCommitMessage, not just at the call site.
  • commits.ts: new changes.getCommitMessage procedure, guarded by assertRegisteredWorktree.

On-demand rather than widening the status payload on purpose: getStatus is polled frequently and carries up to MAX_COMMIT_LIST_COUNT (500) commits, so shipping every body with each refresh would be a real cost for a rarely-read field.

Renderer — popover on the commit row

  • New CommitMessagePopover: a hover-revealed icon button on each commit row that opens a popover with the subject and the full body. The query is enabled only while open and uses an infinite staleTime (commit messages are immutable). Body text is whitespace-pre-wrap and select-text, so it can be read and copied — the renderer sets user-select: none globally.
  • CollapsibleRow gains an optional trailing slot. The row header lives inside Radix's CollapsibleTrigger (a <button>), so the popover trigger had to be a sibling rather than nested — that also keeps click-to-expand-files on the row working unchanged. CommitItem is the only consumer of CollapsibleRow.

Tests

apps/desktop/src/lib/trpc/routers/changes/utils/commit-message.test.ts — 11 tests:

  • reproduction: the commit list payload carries only the subject
  • readCommitMessage recovers subject + body for that same commit, from both the full and short hash
  • rejects non-hex refs (--output=…, HEAD; rm -rf /)
  • splitCommitMessage: subject-only, blank lines and indentation preserved in the body, wrapped subject folding, CRLF, empty input
  • isValidCommitHash: accepts short/full/uppercase hex, rejects flags, HEAD~1, branch names, too-short input
bun test apps/desktop/src/lib/trpc/routers/changes/   → 77 pass, 0 fail

bun run lint clean; bun run typecheck clean in apps/desktop.

Not verified / out of scope

  • No CDP run. This environment has no running desktop instance, so the popover has not been exercised end-to-end in the real app. The backend behavior is covered by the tests above; the rendering is not. Worth a manual pass before merge.
  • The RightSidebar renderer test suite has one pre-existing failure (useOrderedSections.test.tsx, missing electronTRPC global) that reproduces on a clean tree — unrelated to this change, and the reason no component-level test was added here.
  • The v2 workspace sidebar has a separate commit list (CommitFilterDropdown → CommitRow) with the same subject-only truncation, fed by host-service's git.listCommits. Left alone: the issue describes the v1 Diffs tab specifically (the tooltip behavior only exists there). The same getCommitMessage shape would port over.

Closes #6043


Open in Stage

Summary by cubic

View the full commit message (subject + body) from the Diffs tab via a popover on each commit row, without leaving the app. Addresses #6043 and avoids enlarging the polled status payload by fetching bodies on demand.

  • New Features
    • Backend: added changes.getCommitMessage to read git log -1 --format=%B and return { subject, body }, with strict commit-hash validation.
    • UI: new popover button on each commit row shows the full message; loads only while open and caches forever; body is selectable and preserves formatting.
    • Collapsible rows now support a trailing slot so the popover trigger sits beside (not inside) the row’s button.
    • Tests cover message splitting, hash validation, short/full hashes, and the subject-only behavior in the existing commit list.