feat(desktop,host-service): show full commit message on hover in v2 changes tab

Closed
RO
1mo ago
+366-10

Closes #6043.

Hovering a commit in the v2 Changes tab now shows its full message — subject plus body — without leaving the app.

Hover card showing a commit's full message in the v2 Changes tab

Why hovering couldn't already do this

git.listCommits builds its rows with git log <base>..HEAD --format=%H\t%h\t%s\t%an\t%ae\t%aI. %s is the subject only, so Commit.message can never hold more than the first line. The truncated row is the visible half of the problem; the other half is that a tooltip over it would only repeat that same subject, because nothing else is in the payload. Trailers like Co-Authored-By: were invisible for the same reason.

The first test in workers/tasks/git.test.ts pins that down against a real temp repo, so the gap can't quietly reopen.

What changed

Backend. A git/getCommitMessage worker task runs git log -1 --format=%B <hash> --, and splitCommitMessage() splits the result into { subject, body }. It folds a wrapped subject onto one line the way git's own %s does, so the card header matches the row that opened it. isValidCommitHash() restricts the ref to a hex object name so it can't reach git log as a flag or a revision expression — enforced inside the task, not just at the call site.

The getCommitMessage query goes through offLoop(), so no ctx.git() and no createUserSimpleGit on the event loop. The no-main-loop-blocking counts for trpc/router/git/git.ts are unchanged at 12 and 2.

I fetch the body on demand rather than widening listCommits: that query is polled and can carry every commit ahead of the base branch, so sending every body on each refresh would cost far more than a field the UI reads one commit at a time. %b also contains newlines, which would break the tab-separated line parsing listCommits depends on.

Renderer. CommitRow wraps its existing markup in a Tooltip. The query is enabled only while the card is open and uses an infinite staleTime — commit messages don't change, so reopening the same card never refetches. Only the message area scrolls; the arrow and the hash line stay put, since bodies are unbounded and a long one would otherwise grow the card past the window. workspaceId is threaded down from ChangesTabContent so the row can query.

Both the filter dropdown and the range modal render CommitRow, so this covers both.

Scope

Kept narrow on purpose, following the note on #6044:

  • v2 only — the v1 ChangesView is untouched.
  • A tooltip rather than a popover. The row sits inside a Radix DropdownMenuItem, where a popover means nested portals and focus-trap conflicts; a tooltip takes no focus and needed no structural change to the menu.
  • No new setting. "See all commits" is already covered by the base-branch selector, and listCommits has no cap. Full history or a commit graph is a different ask and belongs to the #5594 tracker.

One drive-by: resolveWorktreePath is narrowed to Pick<ctx, "db">. It only ever reads db, and the old signature demanded a request-scoped context that an offLoop() prepare stage doesn't have. Every existing caller still satisfies it.

Credit

The investigation and the splitCommitMessage / isValidCommitHash shape come from #6044, which was closed for targeting the v1 surface and for predating the no-main-process-blocking ratchet added in #6093. This is the same feature rebuilt on v2 with the git read going through the worker pool, as suggested there.

Tests

utils/commit-message.test.ts — 11 tests: subject-only, blank lines and indentation preserved in the body, trailers kept, wrapped-subject folding, CRLF, empty input; hash validation accepts short/full/uppercase hex and rejects --output=…, HEAD~1, branch names, and too-short input.

workers/tasks/git.test.ts — 4 tests over a real temp repo: the %s reproduction, subject + body from a full hash, the same from an abbreviated hash, and rejection of non-hex refs.

bun test src/workers/tasks/git.test.ts \
         src/trpc/router/git/utils/commit-message.test.ts \
         src/no-main-loop-blocking.test.ts   → 19 pass, 0 fail
bun run lint        → exit 0
bun run typecheck   → 34/34

Mutation-checked; each deliberate break failed exactly the tests that should catch it — %B→%s (2 fail), hash guard removed (1 fail), subject folding disabled (2 fail).

The screenshot above is this branch driven over CDP against a local stack, hovering a commit in this repo's own history. I opened the dropdown and hovered rows with dispatched pointer events and read the rendered card back to confirm it matches the hovered row, so the card content is verified, not just its presence.

bun run test in full shows 35 pre-existing failures in @superset/host-service on my machine (ENOENT reading node_modules/better-sqlite3). The count is identical on a clean main, so it's unrelated; this branch takes that package from 711 to 726 passing.


Summary by cubic

Show the full commit message (subject + body) on hover in the v2 Changes tab. Adds a lightweight backend query and a tooltip UI so you can read details, including trailers, without leaving the app.

  • New Features
    • Backend (@superset/host-service): git/getCommitMessage worker task via offLoop runs git log -1 --format=%B, splits to { subject, body }, and validates refs with isValidCommitHash.
    • UI (@superset/ui/tooltip, @superset/workspace-client): Tooltip in CommitRow fetches on hover only, caches forever, and scrolls the message area while keeping header/meta fixed.
    • Scope: v2 only; applies to the commit filter dropdown and the range modal.
    • Performance: listCommits stays slim; query is coalesced/deduped; no main-loop blocking.
    • Minor: resolveWorktreePath narrowed to Pick<ctx, "db">.

Summary by CodeRabbit

  • New Features

    • Commit entries now provide expandable tooltips with full commit messages, subjects, bodies, and metadata.
    • Commit messages can be retrieved for both full and abbreviated commit hashes.
    • Commit history range views now retain workspace context consistently.
  • Bug Fixes

    • Improved validation prevents invalid commit references and option-like values from being processed.
  • Tests

    • Added coverage for commit-message formatting, line endings, trailers, hash validation, and Git message retrieval.