Repository navigation
Preview a workspace file at a git revision - #6348
Merged
ymichael merged 1 commit intoOct 26, 2026
Merged
Conversation
Add experimental_ref to the workspace variant of ExperimentalLiveFileTarget. experimental_openFilePreview and experimental_FileLink with a ref open a read-only preview of the file at that revision, labelled with the ref and read through the existing revision file route; experimental_openFileExternally ignores the ref and opens the working copy. Refs follow the route's rule: HEAD or a 4-40 character commit SHA. Deleted rows in the Info tab and composer changed-files lists now open their HEAD or merge-base content through usePanelFiles.openFilePreview with a ref, replacing the bespoke source/"deleted" status label path. Panel tabs keep the existing head/merge-base wire sources so shipped mobile builds still parse synced tabs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
deleted the
bb/preview-a-workspace-file-at-a-git-revision-thr_g25g8yw9gp
branch
October 26, 2026 23:44
ymichael
pushed a commit
that referenced
this pull request
Oct 27, 2026
…ugin The Git plugin now draws the Diff tab, the Info tab's branch, merge base, git status, Commits and Uncommitted files rows, and the composer's changed-files segment through the public slots, on top of the panel controller (#6356), experimental_useCanOpenFileExternally (#6357), automatic Add to chat (#6353) and experimental_ref (#6348). - Thread tabs and Info rows receive environment: { id } | null straight from the thread, null only without one. The Git plugin reads everything else itself: the Diff tab's loading, failure and Retry come from its bb--git status read, and a missing workspace folder shows "Workspace not found" in Info. - experimental_useTabVisible() tells any panel tab whether it is selected in an open panel; the Diff tab pauses its file list, patch and Viewed reads while it is false. - Mod+D is the Git plugin's toggle-diff command, calling the panel controller's toggleTab. - InfoListRow, its row actions and InfoRowTime move to @bb/shared-ui for core and the plugin; the subheading and commit rail live in the plugin. - Keyed RPC reads gain refetchKeys for a per-row Retry. - Plugin SDK 0.6.90. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
pushed a commit
that referenced
this pull request
Oct 27, 2026
…ugin The Git plugin now draws the Diff tab, the Info tab's branch, merge base, git status, Commits and Uncommitted files rows, and the composer's changed-files segment through the public slots, on top of the panel controller (#6356), experimental_useCanOpenFileExternally (#6357), automatic Add to chat (#6353) and experimental_ref (#6348). - Thread tabs and Info rows receive environment: { id } | null straight from the thread, null only without one. The Git plugin reads everything else itself: the Diff tab's loading, failure and Retry come from its bb--git status read, and a missing workspace folder shows "Workspace not found" in Info. - experimental_useTabVisible() tells any panel tab whether it is selected in an open panel; the Diff tab pauses its file list, patch and Viewed reads while it is false. - Mod+D is the Git plugin's toggle-diff command, calling the panel controller's toggleTab. - InfoListRow, its row actions and InfoRowTime move to @bb/shared-ui for core and the plugin; the subheading and commit rail live in the plugin. - Keyed RPC reads gain refetchKeys for a per-row Retry. - Plugin SDK 0.6.90. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Oct 27, 2026
…ugin (#6157) ## Human comments ## What was wrong Since #6165, the Git plugin owns every git read, but core still drew the Diff tab, the Info tab's branch, merge base, git status, Commits and Uncommitted files rows, and the composer's changed-files segment. Plugins couldn't replace them, and turning the plugin off left them showing errors. This PR moves that UI into the Git plugin, through the same public slots any plugin uses, on top of the four prep PRs: the panel controller (#6356), `experimental_useCanOpenFileExternally` (#6357), automatic Add to chat on diff and code views (#6353) and `experimental_ref` on workspace file targets (#6348). ## What changed **Moved into the Git plugin (`plugins/git/app.tsx`, `plugins/git/ui/`)** - **Diff tab**: a thread fixed `experimental_tab` with `{ kind: "file", path }` and `{ kind: "commit", sha }` targets. - It shows its own loading state, failure and Retry from its `bb--git` status read, and hides for a workspace that isn't a git repository. - Filters are kept per environment, so they survive switching tabs. - Open in editor is decided per file card with `experimental_useCanOpenFileExternally`. The workspace path for copying absolute paths comes from the plugin's own environment read. - **Mod+D**: the plugin's `toggle-diff` command calls `ctx.experimental_panel.toggleTab`. A user's saved `diff.toggle` binding migrates to it, as before. - **Info**: - Branch, Merge base and Git status rows, plus the Commits and Uncommitted files sections. - A missing workspace folder shows "Workspace not found" from the plugin's status read. - Changed files with status D preview read-only at `HEAD` or the merge base through `experimental_ref`. - **Composer**: the changed-files segment with its merge-base picker. - **Merge-base picker**: takes its branch from the plugin's own status read, not from an environment record. - **Removed from core**: - The Diff tab and its panel code, the Info git rows and sections, and the changed-files segment. - The status, files, patches, branches and Viewed query hooks. - `diff.toggle`, and the core Diff case in the panel controller contract table. - Core still reads status through the plugin for the Commit button and the composer branch chip. **Components** - Moved to `@bb/shared-ui`, because both core and the plugin render them: - The diff card body and header, diff parsing and patch text, renderers, and `BranchPicker` with its picker helpers. - Git status display, the workspace change summary and changes list, and the diff stats tally. - The file path link, Open in editor button, copy button, image preview and diff loading skeleton. - `InfoListRow` with its row actions, and `InfoRowTime`. Core's Related threads and thread storage sections use these too. - Kept inside the plugin, because only it uses them: the Diff panel, toolbar, filters, the Info subheading and the commit rail. **Plugin SDK 0.6.90** (all in `docs/api_to_audit.md` and the Plugin Guide) - **`environment` on thread tabs and Info rows.** - Thread tabs (fixed and action, including `useVisible` and action `run`) and Info rows receive `environment: { id } | null`. It comes straight from the thread and is null only when the thread has no environment. - Components read the environment's state themselves. - Core no longer filters Info rows' environment through its "can use git UI" check. - New type: `ExperimentalThreadTabProps`. - **`experimental_useTabVisible(): boolean`**: - True while the panel tab it renders in is selected and the side panel is open. False when the panel is closed or suppressed, when another tab is selected, and outside a tab. - Core keeps a closed panel's tab mounted, as before. `ThreadSecondaryPanel` provides the value for every surface. - The Diff tab pauses its file list, patch, Viewed and branch-list reads while it is false, as core's Diff did with `isDiffPanelLive`. - The test harness answers it with `tabVisible`, default true. - **`refetchKeys(keys)` on keyed reads**: reads only those keys again and keeps every other row. The Diff tab retries one failed patch with it, and Retry re-reads one environment's status. **Dropped from the previous version of this PR** - `environmentState`, `threadArchived` and `isOpen` on tab props, and keeping visited fixed tabs mounted. - `useVisible` returning `"pending"` for context segments. - `experimental_shortcutCommandId` (on main the shortcut appeared only in the Diff tab's screen-reader label) and `experimental_inactiveInInputs`. - `experimental_InfoRowTime`, `experimental_InfoSubheading`, `InfoList` `rail` and `InfoListRow` `actions` as SDK members. - `DiffProps.experimental_addSelectionToChat`, now automatic since #6353. - `experimental_deleted`, replaced by `experimental_ref`. - `ctx.experimental_toggleTab`, replaced by the panel controller. **Differences from main (accepted)** - Mod+D also toggles the Diff tab while typing. - The composer context row appears when git status arrives, instead of being held back until then. - Turning the Git plugin off hides the Diff tab, the Info git rows and the composer segment. With the plugin off, Commit returns 409 `git_plugin_unavailable`. ## How you verified - **Turbo checks:** - `pnpm exec turbo run typecheck lint --filter='...[origin/main]'` passes. - Tests pass for `@bb/app` (6286), the Git plugin, `@bb/shared-ui`, `@get-bb/plugin-sdk`, `@bb/query-tags`, `@bb/client-core`, the Plugin Guide, the GitHub, Side chat, Tasks, Workflows, Docs and Automations plugins, and the server's authoring-docs and keybinding tests. - **New tests (each fails without its change):** - `ThreadSecondaryPanel.tabVisible.test.tsx`: true while selected and open; false once closed, still mounted. - The panel controller contract table: "reports the shown tab visible only while the side panel is open", run against the thread view, plugin page and New thread surfaces. - `DiffTab.test.tsx`: visibility from status; the status failure with Retry; no file list while the tab isn't showing; Open in editor only for a valid per-file target. - `DiffFilesPanel.test.tsx`: no patch or Viewed reads while the tab is hidden. - `PluginThreadFixedTabs.test.tsx`: the tab and its `useVisible` receive the thread's environment. - `plugins/git/app.test.tsx`: Mod+D calls `toggleTab` on the Diff tab. - **Squash tests on Windows:** in `plugins/git/host/workspace-status-cache.test.ts`, the squash-detection tests now read again until the check completes, as bb does on the next refresh. The plugin package now also runs the Diff and Info UI tests, and that extra load on Windows runners pushed single reads past the 1 s squash budget (three runs, three different tests). The tests of the timeout itself are unchanged. - **Real app QA:** this branch and `main` built side by side on the same data and repository (a rename, edits, a deletion, a binary file, an image, a mode change). | Check | Branch | Main | |---|---|---| | Diff tab opens and closes with Mod+D and lists the same files | Pass | Pass | | Open in editor on every Diff card (7) | Pass | Pass | | Mod+D while typing in the composer | Toggles (accepted) | Does nothing | | Composer context row "Uncommitted · 7 files, +3 −74" and merge-base picker | Pass | Pass | | Info: branch, merge base, git status, Uncommitted files | Pass | Pass | | Merge-base picker opens with the branch list | Pass | Pass | | Add to chat on selected diff lines inserts the quoted diff | Pass | Pass | | A deleted file opens a read-only preview at `HEAD` | Pass | Pass | | A thread whose workspace folder is gone shows "Workspace not found" | Pass | n/a | | No file list, patch or Viewed reads after an edit while the Diff tab is closed; reads resume on reopen | Pass | Pass | > AGENT GENERATED Co-authored-by: Michael Yong <review@local> Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Human comments
What was wrong
Plugins could only preview a workspace file's working copy:
ExperimentalLiveFileTargethad no way to name a Git revision. Core already showed deleted changed files at HEAD or the merge base, but through a bespoke path (head/merge-basesources plus a"deleted"status label built inresolveWorkspaceChangedFileOpenTarget) that plugins could not use.What changed
ExperimentalLiveFileTargetgains optionalexperimental_ref("HEAD"or a 4–40 character commit SHA, the formsGET /environments/:id/revisions/:ref/files/*accepts; anything else makes the target invalid, so links stay inert and navigate calls returnfalse). SDK bumped 0.6.85 → 0.6.86.experimental_openFilePreviewandexperimental_FileLinkwith a ref open a read-only preview of the file at that revision, labelled with the ref (e.g.kept.ts (5cf801c)). The link menu hides "Open with", because plugin file openers only read the working copy.experimental_openFileExternallyignores the ref and opens the working copy. AMarkdownexperimental_documenttarget with a ref keeps it on relative links and loads relative images at that revision.usePanelFiles.openFilePreviewwith refHEAD(uncommitted) or the merge-base SHA (committed). The bespoke source/status-label path is deleted. Tab and header labels come from the source ref, so deleted files read(HEAD)/(<sha>)instead of(deleted).head/merge-basesources, because shipped mobile builds parse the synced tab schema strictly (see Omit a null hostId from thread tabs responses so older mobile builds still sync #2144).statusLabelstays on the wire and new tabs writenull.docs/api_to_audit.mdentry (Workspace file revisions), Plugin Guide symbol inplugins/plugin-api-docs/src/surfaces.ts, and a note in the plugin-authoringfrontend-components.md.Production code: +111 / −75 (net +36).
How you verified
pnpm exec turbo run typecheck lint test --filter=@bb/app --filter=@get-bb/plugin-sdk --filter=@bb/client-core --filter=bb-plugin-plugin-api-docs --filter=bb-plugin-bb-guide: 20/20 tasks, 0 lint errors.@bb/app6403 passed, 1 skipped;@get-bb/plugin-sdk402;@bb/client-core287;plugin-api-docs75;bb-guide7.HEAD, a SHA) and rejected (HEAD~1,origin/main, empty,null, ref on thread storage);pnpm start:worktree, fixture repo with a deletedgone.mdand an editedkept.ts, clicked in a browser):gone.mdrow in the composer changed-files list opensgone.md (HEAD)with the HEAD content.experimental_FileLinkwith ref5cf801copenskept.ts (5cf801c)with that commit's content;experimental_openFilePreviewwithHEADreturnstrueand opensgone.md (HEAD);experimental_openFileExternallyreturnstrue..tsfile opener installed), external opening (no local editor targets in headless Chrome), and the Info-tab rows (they share the composer rows' click handler).