Repository navigation
Conversation
Plugins can now ask whether a live file target can be opened externally: the target resolves to a path on its host (a ready environment on an active host, a host, or thread storage) and this client has an external file target for that host. The hook is false while either is loading and re-renders the component when the answer changes. Core uses the same check. useCanOpenFileExternally resolves the target with useResolvedLiveFileRoot and checks the preferred file target with useLocalOpenTargets, the hooks the external-open dispatcher uses. It backs the plugin hook, the file-link menu's Open externally item, and the thread and New-thread file previews' Open in editor controls, which now open through the same host intent as experimental_openFileExternally. This replaces buildOpenInEditorHandler and the per-view open-context plumbing. resolveLiveFileRoot is the one place that resolves a target's host and root. Bumps @get-bb/plugin-sdk to 0.6.89. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/can-this-file-open-in-an-external-editor-on-useb-thr_pjj3w6hneu
branch
from
October 27, 2026 03:57
f7ef4b9 to
28563b4
Compare
ymichael
deleted the
bb/can-this-file-open-in-an-external-editor-on-useb-thr_pjj3w6hneu
branch
October 27, 2026 04:04
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 open a live file externally (
useBbNavigate().experimental_openFileExternally) but had no way to know beforehand whether that open would succeed, so they couldn't disable an "Open externally" control. Core had the same question answered in several places: the file-link menu's Open externally item, the thread view's three Open in editor handlers (buildOpenInEditorHandlerplus per-view open-context plumbing), and the New-thread file preview each resolved the target's host and checked editor support on their own.What changed
experimental_useCanOpenFileExternally(target: ExperimentalLiveFileTarget): booleanfrom@get-bb/plugin-sdk/app. It is true when the target resolves to a path on its host (a ready environment on an active host, a host, or thread storage) and this client has a preferred external file target for that host. It is false while either is loading, and the component re-renders when the answer changes. The SDK test harness answers it through thecanOpenFileExternallyoption.useCanOpenFileExternally(root)resolves the target withuseResolvedLiveFileRootand checksuseLocalOpenTargets(...).canOpenPreferredFileTarget, the same hooks the external-open dispatcher uses, so "can open" and "open" agree.experimental_openFileExternally.buildOpenInEditorHandlerand the per-view open-context plumbing inRootComposePanelTabContent.resolveLiveFileRootis now the one place that resolves a target's host and root folder. A workspace target now also requires a ready environment on an active host.docs/api_to_audit.mdentry and a Plugin Guide surface (surfaces.ts), and updated the SDK README and bb-guide references, including the frontend API index.@get-bb/plugin-sdkto 0.6.89. No wire changes.How you verified
pnpm exec turbo run typecheck lint test --filter=@bb/app --filter=@get-bb/plugin-sdk --filter=bb-plugin-plugin-api-docs --filter=bb-plugin-bb-guide: 18/18 tasks green.turbo run typecheck --filter='...[origin/main]'passed before the rebase.useCanOpenFileExternally.test.tsx: false → true once a workspace target resolves, with one fetch; a host target is checked against its own host's open context. Forcing every host to count as local makes it fail.useResolvedLiveFileTarget.test.ts: environment status × host lifecycle cases.pnpm start:worktree(BB_* unset), clicked in a browser:POST /open-in-targetfor the file at line 2, and VS Code opened.experimental_FileLinkmenu: Open externally was enabled for a ready workspace and disabled for a missing environment.🤖 Generated with Claude Code