fix(desktop): render the sidebar PR badge on session rows and branch lanes - #89709
Draft
ethernet8023 wants to merge 3 commits into
Draft
fix(desktop): render the sidebar PR badge on session rows and branch lanes#89709ethernet8023 wants to merge 3 commits into
ethernet8023 wants to merge 3 commits into
Conversation
The desktop sidebar joins pull requests on git_repo_root and git_branch from the session row. The gateway did not write git_branch on the two usual paths: - Create: _ensure_session_db_row inserted the row after the only enrichment call. The generation claim found no row, and the enrichment did not start. - Resume: _init_session adopted the cwd of an existing row and did not start enrichment. A branchless row stayed branchless. As a result, the PR badge did not show in the sidebar. The composer statusline showed the PR because it probes git live. Now the create path starts enrichment after the insert. The adopt path starts enrichment when the row has no git metadata. Rows from before this fix heal on the next resume. The generation guard in publish_session_git_metadata prevents a stale probe from a write against a newer cwd claim. Tests run the real SessionDB against a temp state.db. With the fix removed, the two regression tests fail and the guard test passes.
The "Show PR" toggle badged session rows only. A branch lane in a project showed no PR, although the lane label is the branch name. The projects folder never read the pull-request store. The lane now renders the same PrTag as a session row, behind the same toggle. The kanban lane takes no badge, because it collects many branches into one lane. The trunk guard stays in the key helper, so a lane on main does not ask GitHub about main. Two changes make the store safe for a second caller: - Staleness is now per lookup. A repo that is fresh for the branches of the last fetch still fetches for a new branch. A lane that appears after the fetch gets an answer. - A narrow ask merges the lookups of the last fetch. The store replaces the PRs of a repo wholesale, so a one-branch ask would otherwise drop the PRs that the session rows show. Tests drive the real component and the real stores. With the renderer change removed, the two badge tests fail. The three guard tests (toggle off, no PR, kanban) pass in both states.
Contributor
૮ >ﻌ< ა ci reviewran on 855ea04 — test(desktop): add an end-to-end check for the sidebar PR ba
|
The spec builds a real git repository with four linked worktrees, creates four real desktop sessions through the gateway and the agent loop, and puts a `gh` stand-in on PATH that answers the real GraphQL query shape. Nothing about the pull-request join is faked. It covers both halves of this branch: - A session row badges the PR of the branch its session recorded. This fails without the gateway fix, because the row holds no branch. - A branch lane badges the PR for its own branch, for each PR state. The spec also writes the screenshots in the pull-request description. `RealSessionSpec` takes an optional `cwd`, so a session can start in a named checkout. The builder used the repository root for every session before this change. Known state on this machine: each test body passes and writes its snapshot, and then the run reports a per-test timeout during teardown. The untouched `worktree-branch-status.spec.ts` fails the same way on the same machine, so the cause is the harness or this host, not this spec.
ethernet8023
marked this pull request as draft
August 19, 2026 06:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
The desktop sidebar can badge a session with its pull request. The badge did not appear. This PR repairs the data that the badge needs, and adds the badge to project branch lanes.
There are two defects, one behind the other.
1. The gateway did not record
git_branchon desktop session rows.The sidebar joins pull requests on
git_repo_root+git_branchfrom the persistedsessionsrow (sessionPrKey,apps/desktop/src/store/pull-requests.ts). The composer status line shows a PR for the same branch, because it probes git live. That difference is why the feature looked half broken: the status line was correct and the sidebar was empty.In a real profile database, 146 of 156 rows with a
git_repo_roothad a NULLgit_branch. Both arms of session start failed to run the enrichment:_ensure_session_db_rowinserted the row AFTER the only call to the enrichment scheduler.update_session_cwdclaims a generation only for a row that exists, so the call returned None and the branch probe never started._init_sessionadopted thecwdof an existing row and skipped enrichment. A row with no branch stayed that way.2. The project branch lanes never read the pull-request store.
The
projects/folder had no reference to it. "Show PR" badged the session rows under a lane, but not the lane itself, although the lane label IS the branch name.Related Issue
No existing issue. Related but separate: #79623 reports the same NULL columns for cron and CLI sessions. This PR repairs the desktop gateway path only. The cron path writes its row elsewhere and needs its own fix.
Type of Change
Changes Made
Gateway (commit 1)
tui_gateway/server.py—_ensure_session_db_rowclaims a generation and starts the branch probe AFTERcreate_sessioninserts the row.tui_gateway/server.py—_init_sessionstarts the same enrichment when the adopted row has no git metadata. Rows from before this fix repair themselves on the next resume. The generation guard inpublish_session_git_metadatakeeps a concurrent workspace move authoritative.tests/tui_gateway/test_session_git_branch_persistence.py— 3 tests against a realSessionDBon a temp path.Desktop (commit 2)
apps/desktop/src/store/pull-requests.ts— newbranchLanePrKey(repoRoot, branch), the trunk-guarded key.sessionPrKeynow uses it, so both surfaces build the key one way.apps/desktop/src/app/chat/sidebar/projects/workspace-group.tsx— the lane reads the store behind the samerowMeta.includes('pr')toggle and requests its own branch.apps/desktop/src/app/chat/sidebar/projects/workspace-header.tsx— newmetaslot. The chip is a SIBLING of the toggle button, because a button inside a button is invalid HTML and the keyboard cannot reach it.apps/desktop/src/app/chat/sidebar/projects/entered-content.tsx— passesrepoPathto the lane.apps/desktop/src/store/pull-requests.test.ts,apps/desktop/src/app/chat/sidebar/projects/workspace-group.test.tsx.Two store changes that a second caller made necessary:
How to Test
Both screenshots below come from a real Electron run: a real git repository, four real linked worktrees, four real sessions built through the gateway and the agent loop, and a
ghstand-in that answers the real GraphQL query shape.Session rows (the gateway fix). Before this PR every row here had a NULL branch and no badge.
Branch lanes (the new surface). Each lane carries the PR for its branch: #8077 closed, #8140 draft, #8098 merged, #8123 open.
Both at once. An expanded lane: the lane header carries #8123 from its label, and the session row inside it carries the same #8123 from the branch its session recorded. The lane badge and the gateway fix, in one frame.
Manual steps:
Automated:
Results on this branch:
npx tsc --noEmitandnpx eslintare clean.Fault detection, which is the part that matters:
Notes for review
apps/desktop/e2e/sidebar-pr-badges.spec.ts). Every test body passes and writes its snapshot. The run then reports a per-test timeout during teardown. The untouchedworktree-branch-status.spec.tsfails the same way on the same machine, so the cause is the harness or this host, not this spec. CI runs no Playwright lane, so this spec does not gate the merge. It is here for a maintainer who runs the suite locally.RealSessionSpectakes an optionalcwd(apps/desktop/e2e/real-session-builder.ts). The builder placed every session at the repository root before. A session must start in a named worktree for this spec, and any later test that needs a specific checkout can now do the same.Checklist
Code
Documentation & Housekeeping
cli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/A