@@ -130,6 +496,7 @@ const surfaces: Surface[] = [
keys: "Click above the list, press Tab.",
sizing: "Any width. The trigger sets outline: none and nothing replaces it.",
source: "ui/src/data-display/accordion/accordion.css:58",
+ fix: "The trigger draws the 2px ring inset (offset -2px), since the list clips a full-width row.",
render: () => (
@@ -143,16 +510,357 @@ const surfaces: Surface[] = [
),
},
+ {
+ name: "New timeline tool row: background only",
+ failure: "Inconsistent",
+ target: '[data-slot="collapsible-trigger"]',
+ keys: "Turn on the new timeline, click the response above a tool row, press Tab.",
+ sizing: "Any width. The trigger also holds the gap below an open row.",
+ source: "session-ui/src/timeline-next/timeline-next.css",
+ fix: "Keyboard focus rings the row's line of text (tool-trigger) at the default 2px offset with a 4px radius, instead of filling it with the hover background. A ring on the trigger itself would take in the gap below an open row.",
+ render: () => (
+
+
+
+
+ Read src/session/timeline.tsx
+
+
+ Content
+
+
+ ),
+ },
+ {
+ name: "Compaction divider: thin accent ring",
+ failure: "Inconsistent",
+ target: '[data-slot="session-compaction-divider"]',
+ keys: "Click the message above a compaction, press Tab.",
+ sizing: "Any width.",
+ source: "session-ui/src/components/session-compaction.css",
+ fix: "Was 1px in --v2-text-text-accent. Now the shared 2px ring in the focus colour at a 2px offset.",
+ render: () => (
+
+
+ Compacted
+
+
+ ),
+ },
+ {
+ name: "Session link in a response: ring in the text colour",
+ failure: "Inconsistent",
+ target: ".markdown-session-link",
+ keys: "Click the response text, press Tab.",
+ sizing: "Any width.",
+ source: "session-ui/src/components/markdown.css",
+ fix: "Was 2px in currentColor, so it took the link's colour. Now the shared focus colour at a 2px offset.",
+ render: () => (
+
+ ),
+ },
+ {
+ name: "Sources chip: 1px ring",
+ failure: "Inconsistent",
+ target: '[data-component="sources-chip"]',
+ keys: "Turn on the Sources experiment, click a response that searched the web, press Tab.",
+ sizing: "Any width.",
+ source: "session-ui/src/sources/sources.css",
+ fix: "The chip was 1px at a 1px offset, and the panel's rows 1px inset. Now the shared 2px ring: outset on the chip, inset (-2px) on the rows, which fill the panel's scrolling list.",
+ render: () => (
+
+ 3 sources
+
+ ),
+ },
+ {
+ name: "Question progress: ring runs into the next segment",
+ failure: "Clipped",
+ target: '[data-slot="question-progress-segment"]',
+ keys: "Open a multi-question prompt, Tab to the progress segments.",
+ sizing: "Any width. Segments sit 2px apart.",
+ source: "session-ui/src/components/question-prompt.css, question-prompt-experimental.css",
+ fix: "Was 2px at a 1px offset, which overlapped the neighbouring segment. Now inset (-2px), inside the segment.",
+ render: () => (
+
+ ),
+ },
],
also: [
- "Shift+Tab from the session header's More actions to Copy response leaves it under the sticky header.",
- "The new timeline's command group loses the bottom of its shadow.",
- "The timeline ScrollView viewport and the diff viewer take focus with nothing visible.",
+ "Fixed: the new timeline's command group lost the bottom of its shadow. The 5px row clip margin above covers it.",
+ ],
+ },
+ {
+ name: "Home",
+ cases: [
+ {
+ name: "Home search results: Shift+Tab reaches a background-only option",
+ failure: "Invisible",
+ target: "input",
+ keys: "Type a Home search. Use ArrowDown to move the highlight and Shift+Tab to leave the field.",
+ sizing: "Results are controlled by the search input's active descendant.",
+ source: "app/src/home/sessions/view.tsx, view.css",
+ fix: "Remove result buttons from the Tab order. Give the active option a visible system highlight in forced colours.",
+ render: () =>
,
+ },
+ {
+ name: "Home viewport: invisible Tab stop",
+ failure: "Invisible",
+ target: '.scroll-view__viewport[tabindex="0"]',
+ keys: "Tab to the scrollable viewport, then use ArrowDown or PageDown. With no overflow, Tab skips the viewport.",
+ sizing: "The viewport only needs a keyboard stop when it can scroll.",
+ source: "ui/src/components/scroll-view.tsx, scroll-view.css",
+ fix: "Only include the viewport in the Tab order when it overflows, and draw the ring inside its edge.",
+ render: () => (
+
+
+ Recent sessions
+ Review focus states
+ Check mobile layout
+ Update the component lab
+
+
+ ),
+ },
+ ...(["Projects", "opencode"] as const).map(
+ (label): Case => ({
+ name: `Side tabs: ${label === "Projects" ? "Projects heading" : "project row"} has only a background change`,
+ failure: "Inconsistent",
+ target: '[data-slot="sidebar-project-row"] > button',
+ keys: `Open Side tabs and Tab to ${label}. Tab again to focus the adjacent icon button independently.`,
+ sizing: "The row spans the sidebar, including the trailing action.",
+ source: "app/src/shell/titlebar/sidebar-organized.tsx, sidebar-customized.tsx, tab-nav.css",
+ fix: "Draw the inset ring around the whole row when its main button has keyboard focus. The trailing button keeps its own ring.",
+ render: () => (
+
+
+ {label === "Projects" ? null : }
+ {label}
+
+
}
+ aria-label={label === "Projects" ? "Add project" : "More options"}
+ />
+
+ ),
+ }),
+ ),
+ {
+ name: "Recent sessions: keyboard focus looks like hover",
+ failure: "Inconsistent",
+ target: '[data-component="home-session-row"]',
+ keys: "In Home, Tab from New session into Recent sessions. Click the example or move the pointer over it to compare.",
+ sizing: "Each session is its own full-width Tab stop.",
+ source: "app/src/home/sessions/view.tsx, view.css",
+ fix: "Use a rounded 2px inset ring for the session button. Hover keeps its background; search results, row actions and inline rename keep their existing focus styles.",
+ render: () => (
+
+
+
+ Test message
+ opencode
+
+
+ ),
+ },
+ {
+ name: "Search sessions: Tab shows only a caret",
+ failure: "Invisible",
+ target: "input",
+ keys: "Focus the preceding button and Tab into Search sessions. Click the field to clear the ring.",
+ sizing: "The field spans the Home results column. The ring belongs on the field, not just its editable text.",
+ source: "app/src/home/sessions/view.tsx, view.css, ui/src/context/field-focus.tsx",
+ fix: "Tab, Find and other non-pointer focus entry draw the shared outset ring around the field. Click-to-type keeps the field background and caret without the ring.",
+ render: (forced) =>
,
+ },
+ {
+ name: "Project row: focus looks like selection",
+ failure: "Inconsistent",
+ target: '[data-component="home-project-row"]',
+ keys: "In Home › Projects, Tab from Add project to a project row.",
+ sizing: "The row fills the scrolling list, and its hover actions sit over its trailing edge.",
+ source: "app/src/home/projects/view.tsx, view.css",
+ fix: "Replace the faint shadow with a 2px inset ring around the selected or unselected row. Paint it above the hover actions without blocking clicks.",
+ render: () => (
+
+
+
+
+ opencode
+
+
+ }
+ aria-label="More options"
+ />
+
+
+
+ ),
+ },
+ ...(["Settings", "Help"] as const).map(
+ (action): Case => ({
+ name: `${action}: barely visible keyboard focus`,
+ failure: "Inconsistent",
+ target: "button",
+ keys: `Tab to ${action} below the Projects list or in the Home footer.`,
+ sizing: "The same control is used in the sidebar and the narrower footer.",
+ source: "app/src/home/projects/view.tsx, view.css",
+ fix: "Replace the faint shadow with the shared 2px keyboard ring, inset so the edges stay visible.",
+ render: () => (
+
+
+ {action}
+
+ ),
+ }),
+ ),
],
+ also: [],
+ },
+ {
+ name: "Browser device toolbar",
+ cases: (["width", "height"] as const).map((axis) => ({
+ name: `${axis === "width" ? "Side" : "Bottom"} resize grip: the preview clips the keyboard ring`,
+ failure: "Clipped",
+ target: `[data-axis="${axis}"]`,
+ keys: "Enable the browser device toolbar, choose a device size, and Tab to the resize grip.",
+ sizing: "The preview clips at its outer edge. Each grip has a 14px hit area.",
+ source: "gui-plugins/src/browser/bar.css",
+ fix: "Draw the shared 2px ring inset around the rounded hit area so the preview cannot clip it. The grip still resizes the same way.",
+ render: () => (
+
+ ),
+ })),
+ also: [],
},
{
name: "Right panel",
cases: [
+ {
+ name: "Files and Review tree: ArrowDown moves focus without a visible cue",
+ failure: "Invisible",
+ target: '[data-slot="lab-tree-host"]',
+ keys: "Tab to a file tree and use the arrow keys. The focus outline follows the row without changing selection.",
+ sizing: "The tree rows are full width inside the plugin's shadow root.",
+ source: "gui-plugins/src/file/pierre-tree.tsx, tree-focus.css",
+ fix: "Use the shared inset ring on the keyboard-focused row, independently of the selected background.",
+ render: () =>
,
+ },
+ {
+ name: "Review diff viewer: no visible keyboard focus",
+ failure: "Invisible",
+ target: '[data-component="file"]',
+ keys: "Open a changed file in Review and Tab from the diff toolbar to the code.",
+ sizing: "The file viewer sits inside a scrolling preview.",
+ source: "session-ui/src/components/file.tsx, file.css",
+ fix: "Keep keyboard access to the diff and paint the shared inset ring above the code, clear of the scrollport edge.",
+ render: () => (
+
+
+
+ ),
+ },
+ {
+ name: "Git changes: file-tree toggle covers the start of the ring",
+ failure: "Occluded",
+ target: '[data-component="select-v2"]',
+ keys: "In Review, focus the file-tree toggle and press Tab.",
+ sizing: "The toggle ends 2px before the selector, in both the sidebar and the collapsed toolbar.",
+ source: "session-ui/src/v2/components/session-review-v2.css",
+ fix: "Draw the mode selector's ring inset so the floating toggle cannot cover it.",
+ render: () => (
+
+ undefined} />}
+ sidebar={
+ undefined}
+ title={
+ undefined}
+ />
+ }
+ />
+ }
+ />
+
+ ),
+ },
{
name: "Tab strip: End puts the last tab under the sticky Add tab",
failure: "Occluded",
@@ -161,175 +869,1158 @@ const surfaces: Surface[] = [
sizing: "Side panel 360px wide with 13 tabs open.",
source:
"app/src/runtime/plugin/side-region.tsx:333 (sticky +), ui tabs.css:605–621 (strip mask), tabs.css:100 (no ring)",
+ fix: 'Kobalte moved focus without scrolling, so End left the tab where it was. The strip now scrolls a keyboard-focused tab into view (tab-strip-scroll.ts), and its scroll-padding-inline, --tab-strip-add plus the 24px fade (tabs.css), keeps it clear of the "+". The ring covers the whole tab, close button included.',
from: { scroller: '[data-slot="tabs-list"]', edge: "start" },
render: () =>
,
},
{
- name: "Selected panel tab: no visible focus",
- failure: "Invisible",
- target: '[data-pane-tab="changes"]',
- keys: "From any tab, press Home.",
- sizing: "Any panel width.",
- source: "ui/src/navigation/tabs/tabs.css:100–103 (outline: none, box-shadow: none)",
- from: { scroller: '[data-slot="tabs-list"]', edge: "end" },
- render: () =>
,
+ name: "Selected panel tab: no visible focus",
+ failure: "Invisible",
+ target: '[data-pane-tab="changes"]',
+ keys: "From any tab, press Home.",
+ sizing: "Any panel width.",
+ source: "ui/src/navigation/tabs/tabs.css:100–103 (outline: none, box-shadow: none)",
+ fix: "The tab draws the 2px ring inset (offset -2px) around its label and close button, since the strip scrolls and would clip a ring outside.",
+ from: { scroller: '[data-slot="tabs-list"]', edge: "end" },
+ render: () =>
,
+ },
+ ],
+ also: [
+ "Review header at a 164px preview: Previous and Next overlap the line buttons, and Split diff is cut off.",
+ "CSV preview at 80px: Copy content overflows the header.",
+ "Line comment More options runs past the panel edge at 360px.",
+ ],
+ },
+ {
+ name: "Settings",
+ cases: [
+ {
+ name: "Interface layout: selection and focus use the same blue",
+ failure: "Inconsistent",
+ target: "input",
+ keys: "Tab onto the selected Interface layout card.",
+ sizing: "The card has a separate selected border and an outset focus ring.",
+ source: "app/src/settings/general/interface-mode.css",
+ fix: "Selection is a 2px neutral border, a check outside the corner and a faded sketch on the other cards. Blue is only the keyboard ring.",
+ render: () =>
,
+ },
+ ...(["Work account", "Add account"] as const).map(
+ (label): Case => ({
+ name: `Connect: ${label} has only a background change`,
+ failure: "Inconsistent",
+ target: "button",
+ keys: "Open a provider with saved accounts in Connect and Tab through the accounts and Add account.",
+ sizing: "Each button is a separate Tab stop in the scrolling dialog.",
+ source: "app/src/providers/connect/dialog.tsx",
+ fix: "Show a shared inset ring, rather than reusing the hover background as the only cue.",
+ render: () => (
+
+ {label}
+
+ ),
+ }),
+ ),
+ {
+ name: "Extensions tab panel: the ring loses both sides",
+ failure: "Clipped",
+ target: '[role="tabpanel"]',
+ keys: "Open Settings › Extensions › MCPs and Tab from the selected tab onto its panel.",
+ sizing: "The panel stretches edge to edge inside a clipping tabs root.",
+ source: "app/src/settings/settings.css (.settings-subtabs)",
+ fix: "Keep the tab panel reachable, including when it has no interactive content. Draw its ring inset, independently of the rings on its children.",
+ render: () => (
+
+
+
+ MCPs
+ Plugins
+
+
+
+ Available to all projects
+ Manage in opencode.json
+
+
+ Manage plugins
+
+
+ ),
+ },
+ {
+ name: "Connect provider dialog: breadcrumb focus only changes text colour",
+ failure: "Inconsistent",
+ target: "nav button",
+ keys: "Open Connect, choose a provider, then Tab or Shift+Tab to the Connect breadcrumb.",
+ sizing: "The breadcrumb is a compact text button, not a full-width row.",
+ source: "app/src/providers/connect/dialog.tsx",
+ fix: "Both interactive breadcrumbs use the shared outset keyboard ring with a 4px radius. Non-interactive breadcrumb labels remain plain text.",
+ render: () => (
+
+
+
+ Connect
+
+
+ OpenCode Go
+
+
+ ),
+ },
+ {
+ name: "Providers: Show more providers draws a full-width square ring",
+ failure: "Inconsistent",
+ target: ".settings-providers-view-all",
+ keys: "In Settings › Providers, Tab from the last Connect button to Show more providers.",
+ sizing: "The section is a column; by default its children stretch across the panel.",
+ source: "app/src/settings/settings.css (.settings-providers-view-all)",
+ fix: "Size the text action to its label, give it a 4px corner radius, and use the shared 2px outset ring.",
+ render: () => (
+
+
Popular providers
+
+
+ Connect
+
+
+
+ Show more providers
+
+
+ ),
+ },
+ {
+ name: "Models: Shift+Tab hides the focused switch under the sticky header",
+ failure: "Occluded",
+ target: '[data-component="settings-row"]:nth-child(5) [data-slot="switch-input"]',
+ keys: "Click the last row's name, then press Shift+Tab until a row scrolls up.",
+ sizing: "Audited at 1280×800 and 390×680. The panel has no scroll padding for its sticky header.",
+ source: "app/src/settings/settings.css:587–611 (.settings-panel, sticky .settings-tab-header)",
+ fix: "tab-header.ts writes the header's height to --settings-tab-header-height; focusable controls in .settings-tab-body take it, plus the 24px fade, as their top scroll-margin.",
+ from: { scroller: ".settings-panel", edge: "end" },
+ render: () =>
,
+ },
+ {
+ name: "Extensions: Check for updates and How to add skills cut at the right",
+ failure: "Clipped",
+ target: ".settings-extension-link",
+ keys: "Open Extensions › Skills (or Plugins), press Tab until the link (or Check for updates) is focused.",
+ sizing: "Any width. Both sit flush with the sub-tab panel's end edge.",
+ source:
+ "ui tabs-current.css (tabs-v2 root overflow: clip), settings.css (.settings-subtabs panel overflow: auto), extensions.tsx",
+ fix: "The tabs root clips with a 5px overflow-clip-margin, and the scrolling sub-tab panel pads its sides by 5px and takes it back with a negative margin, so a ring at either edge shows.",
+ render: () => (
+
+ ),
+ },
+ {
+ name: "Worktrees: Delete ring cut at the top and right by its row",
+ failure: "Clipped",
+ target: '[aria-label="Delete “opencode-dialogs”?"]',
+ keys: "Click the path, press Tab.",
+ sizing: "Audited at 1280×800. Delete is the row's top-right control.",
+ source: "app/src/settings/settings.css:1919–27 (row overflow: hidden), workspaces.tsx:543–553",
+ fix: "The row clips with overflow: clip and a 5px overflow-clip-margin instead of overflow: hidden, so the removal animation still clips and the ring shows.",
+ render: () => (
+
+ ),
+ },
+ {
+ name: "Language: inline select shows no focus",
+ failure: "Invisible",
+ target: '[data-component="select-v2"]',
+ keys: "Click the row title, press Tab.",
+ sizing: "Any width. Inline appearance sets outline: none, and focus only recolours that outline.",
+ source: "ui/src/forms/select/select.css:100–103, 193–204",
+ fix: "Inline Select draws the default ring immediately on keyboard focus, with no outline at rest. A transparent rest outline would show in forced colours. Bordered selects keep their normal field border.",
+ render: () => (
+
+
+
+ undefined}
+ />
+
+
+
+ ),
+ },
+ {
+ name: "Project colour: the selected swatch looks the same focused",
+ failure: "Invisible",
+ target: '[aria-label="Cyan"]',
+ keys: "Click the row title, press Tab three times.",
+ sizing: "Any width. Focus and selection share one ring.",
+ source: "app/src/settings/workspaces/project.css:328–332",
+ fix: "Focus is the default outline and selection a neutral ring in --v2-border-border-inverse, so the two read apart.",
+ render: () => (
+
+
+
+
+
+ {(color) => (
+
+
+
+
+
+
+ )}
+
+
+
+
+
+ ),
+ },
+ {
+ name: "Navigation and sub-tabs: square ring on a rounded tab",
+ failure: "Inconsistent",
+ target: '[data-slot="tabs-v2-trigger"]',
+ keys: "Click the page title, press Shift+Tab to the navigation (or Tab to a sub-tab), then the arrow keys.",
+ sizing: "Any width.",
+ source: "ui/src/navigation/tabs/tabs-current.css",
+ fix: "The trigger inside the tab has no radius, so its ring was square. The ring now goes on the tab's wrapper (:has(trigger:focus-visible)), inset 2px, and follows the tab's radius. It also shows only for the keyboard (:focus-visible), not after a click.",
+ render: () => (
+
+
+
+ MCPs
+ Plugins
+ Skills
+
+
+
+ ),
+ },
+ {
+ name: "Timeline › Advanced: background only",
+ failure: "Inconsistent",
+ target: '[data-slot="collapsible-trigger"]',
+ keys: "Open Settings › Timeline, Tab to Advanced.",
+ sizing: "Any width.",
+ source: "ui/src/components/collapsible.css",
+ fix: "A standalone disclosure, not a list row, so it takes the default ring (2px offset) with a 4px radius instead of the hover background.",
+ render: () => (
+
+
+
+ Advanced
+
+
+ Content
+
+
+ ),
+ },
+ {
+ name: "Projects: thin square ring inside the row's highlight",
+ failure: "Inconsistent",
+ target: ".settings-project-card > button",
+ keys: "Open Settings › Projects, press Tab to a project row.",
+ sizing: "Any width.",
+ source: "app/src/settings/settings.css, settings/workspaces/project-row.tsx",
+ fix: "The row's inner button drew a 1px inset box-shadow with square corners inside the row's highlight. The ring is now on the whole row (.settings-project-card:has(> button:first-child:focus-visible)), 2px, inset 2px, with its radius. The options button keeps its own ring.",
+ render: () => (
+
+ ),
+ },
+ ],
+ also: [
+ "Fixed: the sticky header's scroll margin (Models, above) now applies on every Settings page, not just Models (navigation.tsx).",
+ "Section headings and Timeline detail controls lose their bottom stroke at the scrollport edge.",
+ "Fixed: the selected Settings navigation tab looked the same focused and blurred. The tab ring above covers it.",
+ ],
+ },
+ {
+ name: "Consolidated navigation and other dev changes",
+ cases: [
+ {
+ name: "Sidebar actions: New session, Sessions and Settings draw an outset ring",
+ failure: "Inconsistent",
+ target: '[data-action="vertical-tabs-home"]',
+ keys: "With Consolidated navigation, Tab from Toggle sidebar to Sessions.",
+ sizing: "Full-width 28px rows; the outset ring ran 2px past the row into the sidebar's padding.",
+ source: "app/src/shell/titlebar/titlebar.tsx (SidebarAction), tab-nav.css",
+ fix: "[data-titlebar-tab-action] rows draw the shared ring inset (-2px), as the session tabs below them do. That covers the sidebar actions, the recently closed list and project session rows.",
+ render: () => (
+
+
+ {([action, icon, label]) => (
+
+
+ {label}
+
+ )}
+
+
+ ),
+ },
+ {
+ name: "Toggle sidebar: the ring loses 1px on the right",
+ failure: "Clipped",
+ target: '[aria-label="Toggle sidebar"]',
+ keys: "Tab from New session to Toggle sidebar in the sidebar header.",
+ sizing: "The 32px button sits flush with the sidebar's end edge, which clips.",
+ source: "app/src/shell/sidebar-toggle.tsx",
+ fix: "The toggle draws the shared ring inset (-2px), wherever it sits.",
+ render: () => (
+
+ }
+ />
+
+ ),
+ },
+ {
+ name: "Recent and Inbox Show more: a full-width button with an outset ring cut at both sides",
+ failure: "Clipped",
+ target: '[data-component="button-v2"]',
+ keys: "Tab past the last Recent row to Show more.",
+ sizing: "w-full in the sidebar's scroller; the ring reached 4px past each side.",
+ source: "app/src/shell/titlebar/recent-sessions.tsx, inbox.tsx",
+ fix: "Show more, Show less and Archived draw the shared ring inset (-2px).",
+ render: () => (
+
+
+ Show more
+
+
+ ),
+ },
+ {
+ name: "Inbox rows and headings: keyboard focus only changes the background",
+ failure: "Inconsistent",
+ target: '[data-slot="sidebar-inbox-item"]',
+ keys: "With the Inbox layout, Tab into the list and move with the arrow keys.",
+ sizing: "Roving focus: one row is the Tab stop, arrows move between rows.",
+ source: "app/src/shell/titlebar/inbox.tsx",
+ fix: "Roving focus shows a ring on the focused row. Rows and section headings take the shared ring inset (-2px); the selected row keeps its pressed background, so selection stays distinct.",
+ render: () => (
+
+
+ Needs attention
+
+
+ Refactor the session store
+
+
+ ),
+ },
+ {
+ name: "Tab groups: the header, colour swatches and menu draw no ring",
+ failure: "Invisible",
+ target: "[data-tab-group-header] button",
+ keys: "With tab groups on, Tab to a group's header, then open its menu and Tab to the colours.",
+ sizing: "The header fills its row; the swatches sit in a menu; the menu trigger is 20px.",
+ source: "app/src/shell/titlebar/tab-groups-ui.tsx",
+ fix: "All three suppressed the outline. The header and its menu trigger take the shared ring inset (-2px); swatches take the default ring, over the selected swatch's neutral ring.",
+ render: () => (
+
+
+ Release
+
+
+
+
+
+ ),
+ },
+ {
+ name: "Mobile tabs drawer: New session, Home, Settings and Help only change the background",
+ failure: "Inconsistent",
+ target: '[data-action="mobile-tabs-new-session"]',
+ keys: "Below the mobile breakpoint, open the tabs drawer and Tab past the tabs.",
+ sizing: "Full-width rows in the drawer.",
+ source: "app/src/shell/titlebar/titlebar.tsx",
+ fix: "The rows take the shared ring inset (-2px); hover keeps its background.",
+ render: () => (
+
+
+ New session
+
+ ),
+ },
+ {
+ name: "Model picker and MCP error: rows and Back only change the background",
+ failure: "Inconsistent",
+ target: '[data-component="settings-row"]',
+ keys: "Open the model picker and Tab into the list; or open an MCP's error and Tab to Back.",
+ sizing: "Full-width catalog rows; a 20px back button in the dialog header.",
+ source: "app/src/providers/models/select-dialog.tsx, providers/connect/mcp-dialog.tsx",
+ fix: "Rows that are Tab stops take the shared ring inset (-2px); the arrow-key highlight stays a background. Back takes the default ring.",
+ render: () => (
+
+ ),
+ },
+ {
+ name: "Pinned group: keyboard focus only changes the background",
+ failure: "Inconsistent",
+ target: '[data-slot="pinned-group-trigger"]',
+ keys: "With Consolidated navigation, pin sessions into a group, then Tab to the group.",
+ sizing: "A 28px square in the clipped titlebar row; a full-width row in side tabs.",
+ source: "app/src/shell/titlebar/pinned-area.tsx, pinned-area.css",
+ fix: "The group takes the shared ring inset (-2px), like the pinned tabs beside it, and sits above the group's outline so it covers none of the ring.",
+ render: () => (
+
+
+
+
+
+ ),
+ },
+ {
+ name: "Pinned group menu: Escape drops focus on the page",
+ failure: "Lost",
+ target: '[data-slot="pinned-group-trigger"]',
+ keys: "In top tabs, focus a group and press Shift+F10 or right-click it, then Escape.",
+ sizing: "The top-tabs menu's only trigger is a hidden span, so Kobalte had nothing to return to.",
+ source: "app/src/shell/titlebar/pinned-area.tsx",
+ fix: "The menu records how it opened (createOverlayFocus) and returns focus to the control that opened it: the group, or the ⋯ in side tabs.",
+ render: () => (
+
+
+
+ ),
+ },
+ {
+ name: "Recent group heading: keyboard focus only changes the background",
+ failure: "Inconsistent",
+ target: "button[aria-expanded]",
+ keys: "With Recent grouped by date, status or project, Tab to a heading.",
+ sizing: "A full-width heading in the sidebar's scroller.",
+ source: "app/src/shell/titlebar/recent-sessions.tsx",
+ fix: "The heading takes the shared ring inset (-2px).",
+ render: () => (
+
+
+ Today
+
+
+ ),
+ },
+ {
+ name: "Recent view options: the ring loses its top edge",
+ failure: "Clipped",
+ target: '[data-slot="recent-view-trigger"]',
+ keys: "With nothing pinned, Tab to the options button beside the Recent heading.",
+ sizing: "A 20px button centred in a 24px heading at the top of the scroller.",
+ source: "app/src/shell/titlebar/recent-view-menu.tsx",
+ fix: "The trigger draws the shared ring inset (-2px), inside the scroller's edge.",
+ render: () => (
+
+ Recent
+ }
+ />
+
+ ),
+ },
+ {
+ name: "Find previous and next: a 1px ring on an outline that is always there",
+ failure: "Inconsistent",
+ target: "button",
+ keys: "Press ⌘F in a session, then Tab from the field to the arrows.",
+ sizing: "20px buttons inside the compact Find field.",
+ source: "app/src/session/timeline/search-bar.tsx",
+ fix: "No outline at rest; the shared ring inset (-2px) with a 4px radius on keyboard focus, as the close button beside them does.",
+ render: () => (
+
+
+ {(label, index) => (
+
+
+
+ )}
+
+
+ ),
+ },
+ {
+ name: "Navigation mode: the selected card looks focused",
+ failure: "Inconsistent",
+ target: "input",
+ keys: "In Settings › General with Consolidated on, look at the Tabs and List cards, then Tab onto one.",
+ sizing: "The selected card had a focus-blue border and a focus-blue inset shadow.",
+ source: "app/src/settings/general/interface-mode.css",
+ fix: "As with the layout cards: a 2px neutral border, a check outside the corner and a faded sketch on the other card. Blue is only the keyboard ring.",
+ render: () =>
,
+ },
+ {
+ name: "Home sessions: Shift+Tab hides the row under the sticky date header",
+ failure: "Occluded",
+ target: '[data-component="home-session-row"]',
+ keys: "Scroll Home down, then Shift+Tab up through the sessions.",
+ sizing:
+ "The sticky search (68, 84 or 108px) and the 28px date header now stay at the top while the list scrolls.",
+ source: "app/src/home/sessions/view.css",
+ fix: "Rows take a top scroll-margin of 100, 116 or 140px, so focus scrolls them clear of both.",
+ render: () => (
+
+ Refactor the session store
+
+ ),
+ },
+ ],
+ also: [
+ "Rebased onto origin/dev, which retired the Projects sidebar (sidebar-organized.tsx) and added Consolidated navigation, Home's sticky date headers and Find's previous and next buttons. The Home project scope trigger it added also takes the ring and createOverlayFocus.",
+ ],
+ },
+ {
+ name: "Focus after removal",
+ cases: [
+ {
+ name: "Tab strip: closing a background tab drops focus on the page",
+ failure: "Lost",
+ target: '[aria-label="Close Draft"]',
+ keys: "Tab to a tab's close button and press Enter. Focus moves to the next tab, or the previous one after the last.",
+ sizing: "Titlebar and sidebar tab strips. The right panel's Kobalte tabs select themselves on focus, so rescue stays out of them.",
+ source: "ui/src/context/focus-rescue.tsx, app/src/shell/titlebar/tab-strip.tsx",
+ fix: "Chromium leaves focus on when the focused element goes, with no event. focus-rescue watches what had focus and, inside a [data-focus-scope], moves it to the next item, or the previous one after the last. The tab strips, the sidebar, the titlebar and the right panel are scopes.",
+ render: () =>
,
+ },
+ {
+ name: "Settings rows: deleting a row from its confirm dialog drops focus",
+ failure: "Lost",
+ target: '[data-component="settings-row"]:nth-child(2) [data-component="button-v2"]',
+ keys: "Tab to a row's Delete, press Enter, then confirm. Focus moves to the next row's Delete.",
+ sizing:
+ "Worktrees, providers, servers and every SettingsList. The dialog returns focus to the row before the row goes.",
+ source: "ui/src/context/focus-rescue.tsx, app/src/settings/list.tsx, ui/src/context/dialog.tsx",
+ fix: "SettingsList and the settings screen are scopes. When the dialog's opener is gone, focus moves from where that row was.",
+ render: () =>
,
+ },
+ {
+ name: "Row menu: removing a row from its own menu drops focus",
+ failure: "Lost",
+ target: '[aria-label="More for Website"]',
+ keys: "Tab to a row's ⋯, press Enter, then choose Remove. Focus moves to the next row's ⋯.",
+ sizing: "Home projects and sessions, servers, sidebar rows, line comments and queued messages.",
+ source: "ui/src/context/focus-rescue.tsx, ui/src/navigation/menu/menu.tsx",
+ fix: "The menu returns focus to its trigger, which went with the row. Focus rescue walks back past the menu's items to that trigger and moves focus from where its row was.",
+ render: () =>
,
+ },
+ {
+ name: "Composer chips: removing the last chip drops focus",
+ failure: "Lost",
+ target: '[aria-label="Remove notes.md"]',
+ keys: "Tab to a chip's remove button and press Enter. Focus moves to the next chip, and to the prompt after the last.",
+ sizing: "Attachments, context files, comments and quotes above the prompt; the queue and the docks below it.",
+ source:
+ "ui/src/context/focus-rescue.tsx, app/src/composer/editor/editor.tsx, session/composer/session-composer-region.tsx",
+ fix: "The chip row is a scope inside the composer dock's scope. With no chip left, focus widens to the dock and takes the next control after the row: the prompt.",
+ render: () =>
,
+ },
+ {
+ name: "Toasts: dismissing the only toast drops focus",
+ failure: "Lost",
+ target: '[aria-label="Dismiss"]',
+ keys: "Press Show toast, Tab to the toast's Dismiss and press Enter. Focus returns to Show toast.",
+ sizing: "Any toast with an action or dismiss button.",
+ source: "ui/src/context/focus-rescue.tsx, ui/src/feedback/toast/toast.tsx",
+ fix: "The toast region is a scope. Dismissing a toast moves focus to the next toast; when none is left, focus goes back to what had it before.",
+ render: () =>
,
+ },
+ {
+ name: "Inline rename: Enter ends the edit and drops focus",
+ failure: "Lost",
+ target: '[contenteditable="true"]',
+ keys: "Edit the title, then press Enter. Focus returns to the tab.",
+ sizing: "Titlebar tab titles, terminal tabs.",
+ source: "ui/src/context/focus-rescue.tsx, app/src/shell/titlebar/tab-nav.tsx",
+ fix: "A field that stops being editable stays in place. Focus moves to the control around it, here the tab link.",
+ render: () =>
,
+ },
+ {
+ name: "Reset: the button disables itself and drops focus",
+ failure: "Lost",
+ target: '[data-action="reset"]',
+ keys: "Tab to Reset and press Enter. Focus moves to the next control.",
+ sizing: "Settings › Shortcuts Reset, and any button disabled by its own action.",
+ source: "ui/src/context/focus-rescue.tsx, app/src/settings/keybinds/keybinds.tsx",
+ fix: "A focused control that becomes disabled counts as gone. Focus moves to the next control in its scope.",
+ render: () =>
,
+ },
+ ],
+ also: [
+ "The same rule covers: Home sessions and projects, the sidebar's Inbox, Recent and pinned rows, the queue, the question and permission docks, banners above the composer, line comments, the review panel, the timeline's message menus, Show more buttons, and inline confirms in dialogs.",
+ "An item inside an overlay (a menu item, a dialog button) leaves its overlay to return focus. Focus rescue steps in only when the overlay's opener is gone too, from where that opener was.",
+ ],
+ },
+ {
+ name: "Overlay focus return",
+ cases: [
+ {
+ name: "Select: Escape after a click rings the trigger",
+ failure: "Inconsistent",
+ target: '[data-component="select-v2"]',
+ keys: "Click the select, press Escape: no ring. Tab to it, press ArrowDown, then Escape or Enter: the ring returns.",
+ sizing:
+ "Any select. Kobalte returns focus with a plain focus(), and Chromium rings it because Escape is a key press.",
+ source: "ui/src/forms/select/select.tsx, ui/src/context/overlay-focus.tsx",
+ fix: "The wrapper records how the list opened (createOverlayFocus) and restores the trigger with that ring: none after a pointer open, the ring after a keyboard open, however it closed.",
+ render: () => (
+
undefined} />
+ ),
+ },
+ {
+ name: "Context menu: Escape after a right-click rings the row",
+ failure: "Inconsistent",
+ target: "button",
+ keys: "Right-click the row, then press Escape: no ring.",
+ sizing: "Any context menu: titlebar tabs, Home sessions and projects, file trees.",
+ source: "ui/src/navigation/menu/menu.tsx (Menu.Context)",
+ fix: "Context menus returned focus through Kobalte alone. They now record how they opened, as dropdown menus do, and return focus to what had it with that ring.",
+ render: () => (
+
+
+
+ Refactor the session store
+
+
+
+
+ Rename
+ Archive
+
+
+
+ ),
+ },
+ {
+ name: "Home project picker: no keyboard ring, then a ring after Escape",
+ failure: "Invisible",
+ target: '[data-component="home-projects-dropdown"]',
+ keys: "On a narrow Home, Tab to the project picker. Click it and press Escape: no ring.",
+ sizing: "Below the Home breakpoint, the picker replaces the projects panel and fills its column.",
+ source: "app/src/home/projects/view.tsx",
+ fix: "The trigger suppressed its outline, so it never showed focus. It now takes the shared ring inset (-2px), and the popover restores it with createOverlayFocus, as Select does.",
+ render: () => ,
+ },
+ {
+ name: "Composer todo and plugin pills: Escape after a click rings the pill",
+ failure: "Inconsistent",
+ target: '[data-component="session-todo-pill"]',
+ keys: "Click the todo pill, press Escape: no ring. Tab to it, press Enter, then Escape: the ring returns.",
+ sizing: "The pills in the lane above the composer.",
+ source: "app/src/session/composer/todo-pill.tsx, plugin-pills.tsx",
+ fix: "Both popovers restore their pill with createOverlayFocus instead of Kobalte's plain focus().",
+ render: () => ,
+ },
+ ],
+ also: [
+ "Reviewed, left as is: the Home browse dialog's fallback focus (home/projects/browse.tsx) runs only when the opener has gone; the mobile panel drawer's Back and the location picker's Choose return follow the key or click that closed them.",
+ "The workspace selector (new-session/workspace/selector.tsx) returns focus to the composer, whose field ring follows field-focus.tsx.",
+ ],
+ },
+ {
+ name: "Provider dialogs",
+ cases: [
+ {
+ name: "Connect provider list: Tab and arrow keys only change the background",
+ failure: "Inconsistent",
+ target: "[data-provider-id]",
+ keys: "Open Connect, then press ArrowDown in the search field, or Tab into the list.",
+ sizing: "Full-width rows in a scroller with no side padding.",
+ source: "app/src/providers/connect/dialog.tsx (ProviderList)",
+ fix: "The rows picked their background on :focus, so a click drew it too, and drew no ring. They now take the shared ring inset (-2px) on :focus-visible; hover and the arrow-key highlight keep the background.",
+ render: () => (
+
+
+ {(name) => (
+
+
+ {name}
+
+ )}
+
+
+ ),
+ },
+ {
+ name: "Sign-in method: keyboard focus only changes the background",
+ failure: "Inconsistent",
+ target: '[data-action="provider-connect-method"]',
+ keys: "Open Connect, choose a provider with more than one sign-in method, then Tab to a method.",
+ sizing: "Full-width rows.",
+ source: "app/src/providers/connect/dialog.tsx (MethodSelection)",
+ fix: "The shared ring inset (-2px) replaces the background. The chevron still appears on hover and keyboard focus.",
+ render: () => (
+
+
+ {(label) => (
+
+
+ {label}
+
+
+ )}
+
+
+ ),
+ },
+ {
+ name: "Paste the redirect URL: focus only underlines the toggle",
+ failure: "Inconsistent",
+ target: "button[aria-expanded]",
+ keys: "Start a browser sign-in, then Tab to the paste toggle under the waiting button.",
+ sizing: "The toggle stretches across the step, between its top and bottom borders.",
+ source: "app/src/providers/connect/dialog.tsx (OAuth paste)",
+ fix: "The underline is gone. The toggle takes a 6px radius and the shared ring inset (-2px), inside the borders.",
+ render: () => (
+
+
+
+ Paste the redirect URL instead
+
+
+ ),
+ },
+ {
+ name: "Remote server label: focus only changes the text colour",
+ failure: "Inconsistent",
+ target: '[tabindex="0"]',
+ keys: "Connect a provider on a remote server, then Tab to the server label in the dialog header.",
+ sizing: "A compact label that opens a tooltip.",
+ source: "app/src/providers/connect/dialog.tsx (DialogHeader)",
+ fix: "The label uses the shared 2px outset ring with its 4px radius; the text colour no longer changes.",
+ render: () => (
+
+
+
+ On devbox
+
+
+ ),
+ },
+ {
+ name: "First models after connecting: keyboard focus only changes the background",
+ failure: "Inconsistent",
+ target: ".connected-model-row",
+ keys: "Connect a provider for the first time, then Tab to a model.",
+ sizing: "Full-width radio rows in a list that clips them.",
+ source: "app/src/providers/connect/dialog.tsx (ConnectionModelList), models.css",
+ fix: "The row draws the shared ring inset (-2px) instead of the hover background, inside the list's clip. A checked row keeps its check, so selection stays distinct.",
+ render: () => (
+
+
+
+ {(name, index) => (
+
+ )}
+
+
+
+ ),
+ },
+ {
+ name: "Choose a model, no paid provider: rows and cards only change the background",
+ failure: "Inconsistent",
+ target: "[data-provider-id]",
+ keys: "Without a paid provider, open the model picker, then Tab or press ArrowDown.",
+ sizing: "Full-width model rows, two-column provider cards and a full-width View more row.",
+ source: "app/src/providers/models/unpaid.tsx",
+ fix: "All three picked a background on :focus, so a click drew it too. Rows and View more take the shared ring inset (-2px); the cards have room, so they take it outset (2px). Hover keeps the background.",
+ render: () => (
+
+
+ Big Pickle
+
+
+
+ {(name) => (
+
+ {name}
+
+ )}
+
+
+ View more providers
+
+
+
+ ),
+ },
+ ],
+ also: [],
+ },
+ {
+ name: "Shared controls",
+ cases: [
+ {
+ name: "Error details: thin focus outline",
+ failure: "Inconsistent",
+ target: "pre",
+ keys: "Tab into the selectable details on an error.",
+ sizing: "The details fill a scrollable area.",
+ source: "ui/src/components/error-details.css",
+ fix: "Use the same inset 2px ring as other scrollable regions.",
+ render: () => (
+
+
+
+ ),
+ },
+ ...(["palette-menu-row", "search-list-row"] as const).map(
+ (row): Case => ({
+ name: `${row === "palette-menu-row" ? "Palette" : "Search list"}: active option loses contrast in forced colours`,
+ failure: "Invisible",
+ target: "input",
+ keys: "Enable forced colours and use the arrow keys while focus stays in the search input.",
+ sizing: "Applies to active options rather than independent Tab stops.",
+ source: `app/src/shell/${row === "palette-menu-row" ? "palette-menu" : "search-list"}.css`,
+ fix: "Use system Highlight and HighlightText colours for the active option.",
+ render: () => ,
+ }),
+ ),
+ {
+ name: "Focus ring colour: the default did not adapt to the scheme",
+ failure: "Inconsistent",
+ target: "button",
+ keys: "Switch Scheme between Light and Dark. With forced focus off, Tab to the button in each scheme.",
+ sizing: "The ring keeps the same width and offset in both schemes.",
+ source: "ui/src/styles/tokens/theme.css, ui/src/theme/v2/mapping.ts",
+ fix: "Use Blue 500 in light mode and Blue 400 in dark mode. The Settings colour experiment is no longer needed.",
+ render: () => Focus ring ,
+ },
+ {
+ name: "Links: the browser's orange, square ring",
+ failure: "Inconsistent",
+ target: "a",
+ keys: "Tab to any link without its own focus rule, such as Help & feedback.",
+ sizing: "Any width. The colour is the system accent, orange with an orange macOS accent.",
+ source: "ui/src/styles/base.css",
+ fix: "base.css makes the shared ring the default for every :focus-visible element, so nothing falls back to the browser's, and gives links a 4px radius like the other rings.",
+ render: () => (
+
+ Help & feedback
+
+
+ ),
+ },
+ {
+ name: "Switch: a black ring flashes as focus arrives",
+ failure: "Inconsistent",
+ target: '[data-slot="switch-input"]',
+ keys: "Tab onto a switch and watch the ring appear.",
+ sizing: "Any width. Tab with forced colours enabled to check that the unfocused switch has no ring.",
+ source: "ui/src/forms/switch/switch.css",
+ fix: "Draw the full ring immediately on keyboard focus, with no outline at rest. In forced colours, a system-colour border keeps the track and thumb visible.",
+ render: () => Compact switch ,
+ },
+ {
+ name: "Radio: forced colours show a ring before focus",
+ failure: "Inconsistent",
+ target: '[data-slot="radio-v2-item-input"]',
+ keys: "Tab to the selected radio, then use an arrow key to move to the next radio.",
+ sizing:
+ "Reproduces in Chromium with forced colours enabled. The regular radio border is separate from its ring.",
+ source: "ui/src/forms/radio/radio.css",
+ fix: "Remove the transparent rest outline and show the focus ring immediately. A system-colour border and selected dot keep the radio visible in forced colours.",
+ render: () => (
+
+
+
+
+ ),
+ },
+ {
+ name: "Standard checkbox and switch: blue border and soft shadow",
+ failure: "Inconsistent",
+ target: '[data-slot="checkbox-checkbox-input"]',
+ keys: "Tab onto a standard (legacy) checkbox or switch.",
+ sizing: "Any width.",
+ source: "ui/src/forms/checkbox/checkbox.css, switch/switch.css",
+ fix: "Was a blue border with the --shadow-xs-border-focus box-shadow. Now the shared 2px outline at a 2px offset.",
+ render: () => Standard checkbox ,
},
- ],
- also: [
- "Review header at a 164px preview: Previous and Next overlap the line buttons, and Split diff is cut off.",
- "CSV preview at 80px: Copy content overflows the header.",
- "Line comment More options runs past the panel edge at 360px.",
- "Files and Review trees: ArrowDown from the selected file moves focus with no visible change (pierre-tree.tsx:41–42, 84–92).",
- "Git changes inline select, and the source and diff viewers: no visible focus (same pattern as the Language select below).",
- ],
- },
- {
- name: "Settings",
- cases: [
{
- name: "Models: Shift+Tab hides the focused switch under the sticky header",
- failure: "Occluded",
- target: '[data-component="settings-row"]:nth-child(5) [data-slot="switch-input"]',
- keys: "Click the last row's name, then press Shift+Tab until a row scrolls up.",
- sizing: "Audited at 1280×800 and 390×680. The panel has no scroll padding for its sticky header.",
- source: "app/src/settings/settings.css:587–611 (.settings-panel, sticky .settings-tab-header)",
- from: { scroller: ".settings-panel", edge: "end" },
+ name: "Segmented control: ring runs into the next item",
+ failure: "Clipped",
+ target: '[data-slot="segmented-control-v2-item"]',
+ keys: "Tab onto a segmented control.",
+ sizing: "Any width. Items sit edge to edge in a 28px track.",
+ source: "ui/src/navigation/segmented-control/segmented-control.css",
+ fix: "Was 2px at a 1px offset, over the neighbouring item and the track. Now inset (-2px), inside the item.",
render: () => (
-
-
-
-
-
- {(name) => (
-
-
-
- {name}
-
-
-
- )}
-
-
-
-
+
+ One
+ Two
+
),
},
{
- name: "Worktrees: Delete ring cut at the top and right by its row",
+ name: "Text field clear button: ring runs past the field's edge",
failure: "Clipped",
- target: '[aria-label="Delete “opencode-dialogs”?"]',
- keys: "Click the path, press Tab.",
- sizing: "Audited at 1280×800. Delete is the row's top-right control.",
- source: "app/src/settings/settings.css:1919–27 (row overflow: hidden), workspaces.tsx:543–553",
+ target: '[data-slot="text-input-v2-icon-button"]',
+ keys: "Type in a clearable field, press Tab to the clear button.",
+ sizing: "Any width. The button sits at the field's end.",
+ source: "ui/src/forms/text-input/text-input.css",
+ fix: "Was 2px at a 1px offset, over the field's border. Now inset (-2px), inside the button.",
render: () => (
-
-
+
+
),
},
{
- name: "Language: inline select shows no focus",
+ name: "Busy button: the ring disappears while it works",
failure: "Invisible",
- target: '[data-component="select-v2"]',
- keys: "Click the row title, press Tab.",
- sizing: "Any width. Inline appearance sets outline: none, and focus only recolours that outline.",
- source: "ui/src/forms/select/select.css:100–103, 193–204",
+ target: '[data-component="button-v2"]',
+ keys: "Start a provider sign-in that waits for the browser, then Tab to the waiting button.",
+ sizing: "Any Button with the loading variant that keeps focus.",
+ source: "ui/src/actions/button/button.css, button.tsx, app/src/providers/connect/step-actions.tsx",
+ fix: "The loading variant no longer drops the ring. The ring alone can't say whether the button works, so Button also sets aria-busy for it, and the spinner and its text show the wait.",
+ render: () =>
Waiting for the browser… ,
+ },
+ {
+ name: "Accordion rows: the next row covers the bottom of the ring",
+ failure: "Clipped",
+ target: '[data-slot="accordion-trigger"]',
+ keys: "Open the Context tab in the right panel and Tab through Raw messages.",
+ sizing: "Rows overlap by 1px so their borders merge, and each sticky header has the same z-index.",
+ source: "ui/src/data-display/accordion/accordion.css, ui/src/components/sticky-accordion-header.css",
+ fix: "The header holding the focused trigger is raised above its neighbours, so the whole inset ring shows. Sticky headers rise above the other sticky headers.",
render: () => (
-
-
-
- undefined}
- />
-
-
+
+
+
+ {(role) => (
+
+
+ {role}
+
+ Message
+
+ )}
+
+
),
},
{
- name: "Project colour: the selected swatch looks the same focused",
- failure: "Invisible",
- target: '[aria-label="Cyan"]',
- keys: "Click the row title, press Tab three times.",
- sizing: "Any width. Focus and selection share one ring.",
- source: "app/src/settings/workspaces/project.css:328–332",
+ name: "Small controls: 2.5px and 1px offsets",
+ failure: "Inconsistent",
+ target: '[data-component="button-v2"]',
+ keys: "Tab through any form.",
+ sizing: "At 1x, a 2.5px offset lands on a half pixel and the ring's edges blur.",
+ source: "ui button.css, icon-button.css, checkbox, switch, radio, select, field, and every app rule at 2.5px",
+ fix: "One rule: 2px outset by default, -2px inset for rows and controls flush with a clipping or scrolling edge. 2.5px became 2px; compact switch, radio and the field info icon went from 1px to 2px.",
render: () => (
-
-
-
-
-
- {(color) => (
-
-
-
-
-
-
- )}
-
-
-
-
+
+ Button
+
+ Compact switch
+
),
},
],
- also: [
- "Section headings and Timeline detail controls lose their bottom stroke at the scrollport edge.",
- "The selected Settings navigation tab looks the same focused and blurred.",
- ],
+ also: [],
},
]
function FocusVisibility(props: VisibilityArgs) {
+ onMount(() => onCleanup(installFocusRescue()))
+
createEffect(() => {
if (!props.forced) return
@@ -352,12 +2043,13 @@ function FocusVisibility(props: VisibilityArgs) {
Focus visibility
- Where focus is clipped, covered or invisible. Each case opens with its target focused; the dashed box marks
- where that target is. Follow the keys to reproduce it with real focus.
+ Where focus was clipped, covered, invisible or inconsistent with the shared ring, and how each was fixed. The
+ cases stay here as checks that the fixes hold: each opens with its target focused and the dashed box marks
+ where it is. Follow the keys to check it with real focus.
- {(surface) => (
+ {(surface, sectionIndex) => (
{surface.name}
- {(item) => }
+ {(item, caseIndex) => (
+ count + section.cases.length, 1) +
+ caseIndex()
+ }
+ forced={props.forced}
+ locator={props.locator}
+ />
+ )}
-
-
Same audit, not rendered here
-
-
+
+
+
Same audit, not rendered here
+
+
+
)}
@@ -384,7 +2088,7 @@ function FocusVisibility(props: VisibilityArgs) {
)
}
-function CaseCard(props: { case: Case; forced: boolean; locator: boolean }) {
+function CaseCard(props: { case: Case; number: number; forced: boolean; locator: boolean }) {
let stage: HTMLDivElement | undefined
const [box, setBox] = createSignal<{ left: number; top: number; width: number; height: number }>()
@@ -468,8 +2172,12 @@ function CaseCard(props: { case: Case; forced: boolean; locator: boolean }) {
}}
>
- {props.case.name}
- {props.case.failure}
+
+ {props.number}. {props.case.name}
+
+
+ Fixed · {props.case.failure}
+
- {props.case.render()}
+ {props.case.render(() => props.forced)}
{(rect) => (
{props.case.source}
+
Fix
+
{props.case.fix}
)
}
+function createPreviewFieldFocus(forced: () => boolean) {
+ const focus = createFieldFocus()
+ const [entered, setEntered] = createSignal(false)
+
+ return {
+ visible: () => focus.visible() || (forced() && !entered()) || undefined,
+ enter: (element: HTMLElement) => {
+ setEntered(true)
+ focus.enter(element)
+ },
+ pointer: focus.pointer,
+ leave: focus.leave,
+ }
+}
+
+function SearchHighlightExample(props: { kind: "home-session-search-row" | "palette-menu-row" | "search-list-row" }) {
+ const [active, setActive] = createSignal(0)
+
+ const list = createUniqueId()
+
+ return (
+
+
{
+ if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return
+
+ event.preventDefault()
+ setActive((index) => 1 - index)
+ }}
+ />
+
+
+ {(label, index) => (
+ event.preventDefault()}
+ onClick={() => setActive(index())}
+ >
+ {label}
+
+ )}
+
+
+
+ )
+}
+
+function TreeFocusExample() {
+ return (
+
{
+ const root = host.attachShadow({ mode: "open" })
+
+ const style = document.createElement("style")
+
+ style.textContent = `
+ ${treeFocusCss}
+ ${treeFocusCss.replaceAll(":focus-visible", "[data-lab-focus]")}
+ button { display: block; width: 100%; height: 28px; border: 0; border-radius: 4px;
+ background: transparent; color: inherit; text-align: start; padding-inline: 8px; font: inherit; }
+ button[aria-selected="true"] { background: var(--v2-overlay-simple-overlay-pressed); }
+ `
+ root.append(style)
+
+ const rows = ["README.md", "index.ts"].map((name, index) => {
+ const row = document.createElement("button")
+
+ row.dataset.type = "item"
+ row.dataset.itemFocused = String(index === 0)
+ row.setAttribute("role", "treeitem")
+ row.setAttribute("aria-selected", String(index === 0))
+ row.tabIndex = -1
+ row.textContent = name
+ root.append(row)
+
+ return row
+ })
+
+ host.onkeydown = (event) => {
+ if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return
+
+ event.preventDefault()
+ rows.forEach((row, index) => (row.dataset.itemFocused = String(index === (event.key === "ArrowUp" ? 0 : 1))))
+ }
+ }}
+ />
+ )
+}
+
+function HomeSearchFocusExample(props: { forced: boolean }) {
+ const focus = createPreviewFieldFocus(() => props.forced)
+
+ return (
+
+ Previous control
+
+
+ focus.enter(event.currentTarget)}
+ onBlur={focus.leave}
+ />
+
+
+ )
+}
+
+function ComposerFocusExample(props: { forced: boolean }) {
+ const focus = createPreviewFieldFocus(() => props.forced)
+
+ return (
+
+ )
+}
+
+// The Models page, with its header measured the way Settings measures it.
+function ModelsPanel() {
+ let panel: HTMLDivElement | undefined
+
+ onMount(() => {
+ const header = panel?.querySelector
(".settings-tab-header")
+
+ if (panel && header) onCleanup(trackTabHeader(panel, header))
+ })
+
+ return (
+
+
+
+
+
+ {(name) => (
+
+
+
+ {name}
+
+
+
+ )}
+
+
+
+
+ )
+}
+
function TabStrip() {
return (
} aria-label="Add tab" />
+ {/* The panel actions slot, here only the space side-region.tsx keeps for the panel toggle. */}
+
@@ -580,3 +2507,289 @@ export default {
}
export const AllSurfaces = { render: (args: VisibilityArgs) => }
+
+// The popover wiring the Home project picker and the composer pills share.
+function OverlayPopover(props: { component: string; label: string; width?: string }) {
+ const overlayFocus = createOverlayFocus()
+
+ let trigger: HTMLButtonElement | undefined
+
+ return (
+
+
+ {props.label}
+
+
+
+ overlayFocus.restore(event, trigger)}
+ >
+ Popover content
+
+
+
+ )
+}
+
+function RemovalTabs() {
+ const [tabs, setTabs] = createSignal(["Refactor store", "Draft", "Fix tests", "Release notes"])
+
+ return (
+
+
+
+ {(tab) => (
+
+ )}
+
+
+
setTabs(["Refactor store", "Draft", "Fix tests", "Release notes"])}
+ >
+ Restore tabs
+
+
+ )
+}
+
+function RemovalSettingsRows() {
+ const dialog = useDialog()
+
+ const initial = ["main", "focus-rings", "session-store"]
+
+ const [rows, setRows] = createSignal(initial)
+
+ const confirm = (name: string) =>
+ dialog.show(() => (
+
+
+ Delete {name}?
+
+ The worktree and its changes are removed.
+
+ dialog.close()}>
+ Cancel
+
+ {
+ dialog.close()
+ // The row goes once the request returns, after the dialog has returned focus to it.
+ setTimeout(() => setRows((list) => list.filter((item) => item !== name)), 300)
+ }}
+ >
+ Delete
+
+
+
+ ))
+
+ return (
+
+
+
+ {(name) => (
+
+ confirm(name)}>
+ Delete
+
+
+ )}
+
+
+ setRows(initial)}>
+ Restore rows
+
+
+ )
+}
+
+function RemovalChips() {
+ const initial = ["notes.md", "store.ts", "plan.md"]
+
+ const [chips, setChips] = createSignal(initial)
+
+ return (
+
+
+
+ {(chip) => (
+
+ {chip}
+ }
+ aria-label={`Remove ${chip}`}
+ onClick={() => setChips((list) => list.filter((item) => item !== chip))}
+ />
+
+ )}
+
+
+
+
setChips(initial)}>
+ Restore chips
+
+
+ )
+}
+
+function RemovalToast() {
+ const [shown, setShown] = createSignal(true)
+
+ return (
+
+
setShown(true)}>
+ Show toast
+
+
+
+
+ Session archived
+ }
+ aria-label="Dismiss"
+ onClick={() => setShown(false)}
+ />
+
+
+
+
+ )
+}
+
+function RemovalRename() {
+ const [editing, setEditing] = createSignal(true)
+
+ return (
+
+ )
+}
+
+function RemovalReset() {
+ const [changed, setChanged] = createSignal(true)
+
+ return (
+
+ setChanged(false)}>
+ Reset
+
+ setChanged(true)}>
+ Change a shortcut
+
+
+ )
+}
+
+function RemovalRowMenu() {
+ const initial = ["Desktop", "Website", "Docs"]
+
+ const [rows, setRows] = createSignal(initial)
+
+ return (
+
+
+
+ {(row) => (
+
+ {row}
+
+ }
+ aria-label={`More for ${row}`}
+ />
+
+
+ Rename
+ setRows((list) => list.filter((item) => item !== row))}>
+ Remove
+
+
+
+
+
+ )}
+
+
+
setRows(initial)}>
+ Restore rows
+
+
+ )
+}
+
+// The selected style both card groups in Settings › General share: a 2px neutral border and a check at the corner.
+function ModeCards(props: { group: "interface" | "navigation" }) {
+ const name = createUniqueId()
+
+ const labels = props.group === "interface" ? ["Top tabs", "Side tabs", "Inbox"] : ["Tabs", "List"]
+
+ return (
+
+
+ {(label, index) => (
+
+
+
+ {label}
+
+
+
+
+
+
+ )}
+
+
+ )
+}
diff --git a/packages/app/src/composer/adapter.ts b/packages/app/src/composer/adapter.ts
index 6822d7b919bc..8bf3ef3eaa6b 100644
--- a/packages/app/src/composer/adapter.ts
+++ b/packages/app/src/composer/adapter.ts
@@ -96,6 +96,8 @@ export type ComposerSession = {
location: { command: Pick }
session: {
prompt: (input: Parameters[0]) => ReturnType
+ // Runs a request in the session's send chain, after the sends made before it have settled.
+ sequence: Data["session"]["sequence"]
setStatus: Data["session"]["setStatus"]
// Records an accepted user send so the desktop list promotes the session immediately.
acceptSend: (sessionID: string) => void
diff --git a/packages/app/src/composer/attachments/destination.ts b/packages/app/src/composer/attachments/destination.ts
index 04efe6518533..efd940829521 100644
--- a/packages/app/src/composer/attachments/destination.ts
+++ b/packages/app/src/composer/attachments/destination.ts
@@ -1,7 +1,7 @@
import type { Accessor } from "solid-js"
import { useServer } from "@/runtime/server/current"
import { useServerSDK } from "@/runtime/server/client"
-import { authTokenFromCredentials } from "@/runtime/server/api"
+import { createApiForServer } from "@/runtime/server/api"
import { uuid } from "@opencode/util/uuid"
import { useWorkspaceLocation } from "@/workspaces/location"
import type { ComposerControls } from "../adapter"
@@ -26,13 +26,20 @@ export function useAttachmentDestination(controls: Accessor) {
local: server.isLocal,
upload: async (file, report, signal) => {
const info = await sdk.api.server.info({ signal })
+ const api = createApiForServer({ server: sdk.http, fetch: progressFetch(report) })
+
// One directory per upload keeps the original filename without collisions; the server
// normalizes the separators and returns the resolved path.
- const url = new URL("/api/experimental/fs/write", sdk.http.url)
- url.searchParams.set("location[directory]", location().directory)
- url.searchParams.set("path", `${info.paths.tmp}/uploads/${uuid()}/${file.name}`)
+ const written = await api.experimental.file.write(
+ {
+ location: { directory: location().directory },
+ path: `${info.paths.tmp}/uploads/${uuid()}/${file.name}`,
+ payload: file,
+ },
+ { signal },
+ )
- return write(url, file, sdk.http.password, report, signal)
+ return written.data.path
},
})
}
@@ -40,30 +47,35 @@ export function useAttachmentDestination(controls: Accessor) {
// fetch cannot report upload progress and Chromium only streams request bodies over HTTP/2, so
// the one request that needs both goes through XMLHttpRequest. The browser streams the File
// from disk; nothing is buffered in the renderer.
-function write(
- url: URL,
- file: File,
- password: string | undefined,
- report: (loaded: number) => void,
- signal: AbortSignal,
-) {
- return new Promise((resolve, reject) => {
- if (signal.aborted) return reject(new DOMException("Upload aborted", "AbortError"))
- const xhr = new XMLHttpRequest()
- xhr.open("POST", url)
- xhr.responseType = "json"
- xhr.setRequestHeader("content-type", "application/octet-stream")
+function progressFetch(report: (loaded: number) => void): typeof globalThis.fetch {
+ const send = (input: RequestInfo | URL, init?: RequestInit) =>
+ new Promise((resolve, reject) => {
+ const signal = init?.signal
+
+ if (signal?.aborted) return reject(new DOMException("Upload aborted", "AbortError"))
+
+ const xhr = new XMLHttpRequest()
+ xhr.open(init?.method ?? "GET", input instanceof Request ? input.url : String(input))
- if (password) xhr.setRequestHeader("authorization", `Basic ${authTokenFromCredentials({ password })}`)
- xhr.upload.addEventListener("progress", (event) => report(event.loaded))
- xhr.addEventListener("load", () => {
- if (xhr.status !== 200) return reject(new Error(`Upload failed with status ${xhr.status}`))
- // SAFETY: a 200 from `fs.write` is its declared success body, `Location.response(FileSystem.Write)`.
- resolve((xhr.response as { data: { path: string } }).data.path)
+ new Headers(init?.headers).forEach((value, name) => xhr.setRequestHeader(name, value))
+ xhr.upload.addEventListener("progress", (event) => report(event.loaded))
+ xhr.addEventListener("load", () => {
+ const type = xhr.getResponseHeader("content-type")
+ const empty = [204, 205, 304].includes(xhr.status)
+ resolve(
+ new Response(empty ? null : xhr.responseText, {
+ status: xhr.status,
+ headers: type ? { "content-type": type } : undefined,
+ }),
+ )
+ })
+ xhr.addEventListener("error", () => reject(new TypeError("Upload failed")))
+ xhr.addEventListener("abort", () => reject(new DOMException("Upload aborted", "AbortError")))
+ signal?.addEventListener("abort", () => xhr.abort(), { once: true })
+ // SAFETY: only `experimental.file.write` uses this fetch, and its body is the File it was given.
+ xhr.send((init?.body ?? null) as XMLHttpRequestBodyInit | null)
})
- xhr.addEventListener("error", () => reject(new Error("Upload failed")))
- xhr.addEventListener("abort", () => reject(new DOMException("Upload aborted", "AbortError")))
- signal.addEventListener("abort", () => xhr.abort(), { once: true })
- xhr.send(file)
- })
+
+ // Bun's fetch type carries preconnect; the browser never calls it.
+ return Object.assign(send, { preconnect: () => {} })
}
diff --git a/packages/app/src/composer/editor/editor.css b/packages/app/src/composer/editor/editor.css
index dc6fb9504824..3cabc787b315 100644
--- a/packages/app/src/composer/editor/editor.css
+++ b/packages/app/src/composer/editor/editor.css
@@ -2,6 +2,12 @@
content: "\200B";
}
+/* Outline the frame, not the editor inside the masked scroll viewport. */
+[data-component="composer"]:has([data-component="composer-editor"][data-keyboard-focus]:focus) {
+ outline: 2px solid var(--v2-border-border-focus);
+ outline-offset: -2px;
+}
+
/* Transcript session references match this (packages/session-ui/src/components/markdown.css). */
[data-component="composer-editor"] [data-mention="session"] {
color: var(--v2-text-text-muted);
@@ -68,9 +74,12 @@
);
}
-/* The controls viewport scrolls and clips, so toolbar rings sit inside each control where no edge can cut them. */
+/* Toolbar controls keep their ring inside. Send sits outside the scroller with room for the default outset ring. */
[data-component="composer"]
- :is([data-component="button-v2"], [data-component="icon-button-v2"]):is(:focus-visible, [data-state="focus"]) {
+ :is([data-component="button-v2"], [data-component="icon-button-v2"]):not([data-action="composer-submit"]):is(
+ :focus-visible,
+ [data-state="focus"]
+ ) {
outline-offset: -2px;
}
diff --git a/packages/app/src/composer/editor/editor.tsx b/packages/app/src/composer/editor/editor.tsx
index 0c0d870a2719..dce39cc6d9aa 100644
--- a/packages/app/src/composer/editor/editor.tsx
+++ b/packages/app/src/composer/editor/editor.tsx
@@ -50,6 +50,7 @@ import type {
import type { ComposerEditorModel, ComposerSelectControl } from "./interaction"
import { isAttachment, promptLength } from "../prompt-parts"
import { editorMatchesPrompt, getCursorPosition, isEditorDomBlank, isPromptInlineBlank } from "./dom"
+import { createFieldFocus } from "@opencode/ui/context/field-focus"
import {
INITIAL_EDITOR_SYNC_STATE,
INPUT_PARSED,
@@ -102,6 +103,8 @@ export type ComposerEditorProps = {
}
export function ComposerEditor(props: ComposerEditorProps) {
+ const keyboardFocus = createFieldFocus()
+
const i18n = useI18n()
const markdown = useMarkdown()
const state = props.controller.state
@@ -172,6 +175,7 @@ export function ComposerEditor(props: ComposerEditorProps) {
})
})
let sync = INITIAL_EDITOR_SYNC_STATE
+ let firstFocus = true
const updateCursor = () => {
const cursor = editor && getCursorPosition(editor)
@@ -425,7 +429,21 @@ export function ComposerEditor(props: ComposerEditorProps) {
if (caret.top < bounds.top + 16) viewport.scrollTop += caret.top - bounds.top - 16
})
}}
- onFocus={() => props.controller.dispatch({ type: "focus.editor" })}
+ data-field-focus
+ data-keyboard-focus={keyboardFocus.visible() || undefined}
+ onPointerDown={keyboardFocus.pointer}
+ onClick={(event) => {
+ if (event.detail > 0) keyboardFocus.pointer()
+ }}
+ onBlur={keyboardFocus.leave}
+ onFocus={(event) => {
+ keyboardFocus.enter(event.currentTarget)
+
+ // A request dock can replace the editor. Keyboard focus on the new editor must keep the draft's caret.
+ if (firstFocus && keyboardFocus.visible()) props.controller.restoreCaret()
+ firstFocus = false
+ props.controller.dispatch({ type: "focus.editor" })
+ }}
/>
{
- props.controller.dispatch({ type: "mode.normal" })
+ // Before the mode change unmounts this button, so focus keeps its ring state.
props.controller.restoreFocus()
+ props.controller.dispatch({ type: "mode.normal" })
}}
>
{i18n.t("ui.promptInput.exitShell")}
@@ -779,7 +798,7 @@ function ComposerAttachments(props: {
(props.files?.length ?? 0) > 0
}
>
-
+
{
- props.controller.dispatch({ type: "mode.normal" })
props.controller.restoreFocus()
+ props.controller.dispatch({ type: "mode.normal" })
}}
>
{i18n.t("ui.promptInput.exitShell")}
diff --git a/packages/app/src/composer/editor/interaction.ts b/packages/app/src/composer/editor/interaction.ts
index bc73927b3d94..062ce023721c 100644
--- a/packages/app/src/composer/editor/interaction.ts
+++ b/packages/app/src/composer/editor/interaction.ts
@@ -2,6 +2,7 @@ import { Predicate } from "effect"
import { createEffect, createMemo, createSignal, on, onCleanup, untrack, type Accessor } from "solid-js"
import { unwrap } from "solid-js/store"
import { useFilteredList } from "@opencode/ui/hooks"
+import { focusField, handOffFocus, handoffRing } from "@opencode/ui/context/field-focus"
import { abort } from "@opencode/util/abort"
import { createComposerAttachments, type ComposerAttachmentConfig } from "../attachments/attachments"
import type { Upload } from "../attachments/uploads"
@@ -115,24 +116,26 @@ export function createComposerEditor(input: {
let editor: HTMLElement | undefined
let fileInput: HTMLInputElement | undefined
let focusFrame: number | undefined
- let focusCursor: number | undefined
+ let focusRequest: { cursor: number; visible: boolean | undefined } | undefined
const cancelFocus = () => {
if (focusFrame === undefined) return
cancelAnimationFrame(focusFrame)
focusFrame = undefined
- focusCursor = undefined
+ focusRequest = undefined
}
const flushFocus = () => {
- const cursor = focusCursor
+ const request = focusRequest
- if (cursor === undefined) return
+ if (!request) return
cancelFocus()
if (!editor) return
- editor.focus()
- setCursorPosition(editor, cursor)
+
+ if (request.visible === undefined) editor.focus()
+ else focusField(editor, request.visible)
+ setCursorPosition(editor, request.cursor)
}
onCleanup(cancelFocus)
@@ -201,7 +204,9 @@ export function createComposerEditor(input: {
},
}),
editor: () => editor,
- focusEditor: () => editor?.focus(),
+ focusEditor: () => {
+ if (editor) handOffFocus(editor)
+ },
addPart,
setDraggingType: (type) => dispatch({ type: type ? "drag.enter" : "drag.leave" }),
})
@@ -558,9 +563,9 @@ export function createComposerEditor(input: {
if (contextList.grouped.state === "ready" && contextList.flat().length === 0) dispatch({ type: "popover.close" })
})
- const restoreFocus = (cursor = draft.state.cursor ?? promptLength(draft.state.prompt)) => {
+ const restoreFocus = (cursor = draft.state.cursor ?? promptLength(draft.state.prompt), visible?: boolean) => {
cancelFocus()
- focusCursor = cursor
+ focusRequest = { cursor, visible: visible ?? handoffRing(editor) }
focusFrame = requestAnimationFrame(flushFocus)
}
@@ -700,6 +705,9 @@ export function createComposerEditor(input: {
editor = element
input.onEditor?.(element)
},
+ restoreCaret() {
+ if (editor) setCursorPosition(editor, draft.state.cursor ?? promptLength(draft.state.prompt))
+ },
restoreFocus,
onInput(value: string, prompt?: ComposerPersistedState["prompt"], cursor?: number) {
cancelFocus()
diff --git a/packages/app/src/composer/editor/quote-comment.tsx b/packages/app/src/composer/editor/quote-comment.tsx
index fc806a61635f..796c7ecb0df8 100644
--- a/packages/app/src/composer/editor/quote-comment.tsx
+++ b/packages/app/src/composer/editor/quote-comment.tsx
@@ -132,6 +132,7 @@ export function QuoteCommentEditor(props: {
})
}}
data-component="composer-quote-comment"
+ data-floating-overlay
data-prevent-autofocus
class="fixed z-50"
style={{
diff --git a/packages/app/src/composer/machine.test.ts b/packages/app/src/composer/machine.test.ts
index 610ffa8beb2b..83c2aed218be 100644
--- a/packages/app/src/composer/machine.test.ts
+++ b/packages/app/src/composer/machine.test.ts
@@ -55,6 +55,7 @@ const session: ComposerSession = {
payload: { text: value.text },
delivery: value.delivery ?? "steer",
}),
+ sequence: (_sessionID, send) => send(),
setStatus() {},
acceptSend() {},
},
@@ -128,6 +129,12 @@ const states = {
running: replay([{ type: "submit", snapshot: snapshot({ clientCommand: () => undefined }), done }]).state,
preparing: replay([{ type: "submit", snapshot: snapshot(), done }]).state,
"handing-off": replay([{ type: "submit", snapshot: snapshot(), done }, started(1)]).state,
+ sending: replay([
+ { type: "submit", snapshot: snapshot(), done },
+ started(1),
+ { type: "handoff.ready", attempt: 1, prompt: undefined },
+ ]).state,
+ quoting: replay([{ type: "quote", snapshot: quoteSnapshot(), done }]).state,
}
describe("composer submit machine", () => {
@@ -147,6 +154,7 @@ describe("composer submit machine", () => {
session,
ready,
},
+ { type: "gate.settled", attempt: 1 },
{ type: "handoff.ready", attempt: 1, prompt: undefined },
])
@@ -253,6 +261,7 @@ describe("composer submit machine", () => {
[
{ type: "hold.loaded", attempt: 1, selection, commands: [{ name: "review" }] },
started(1),
+ { type: "gate.settled", attempt: 1 },
{ type: "handoff.ready", attempt: 1, prompt: undefined },
],
shown.state,
@@ -305,6 +314,97 @@ describe("composer submit machine", () => {
])
})
+ // What the plugins prepare for a prompt or a server command is part of sending it. Until it is ready nothing of the
+ // send has reached the server, the composer takes no other send, and Stop cancels this one.
+ test("a send whose gate is still pending when the composer clears keeps the composer until its request may leave", () => {
+ const handing = states["handing-off"]
+ expect(handing).toMatchObject({ type: "handing-off", gate: "pending" })
+
+ const cleared = transitionComposerSubmit(handing, { type: "handoff.ready", attempt: 1, prompt: undefined })
+ expect(cleared.state).toEqual({ type: "sending", attempt: 1, done })
+ // The composer clears, as the prompt already shows in its Session, and the submit has not settled yet.
+ expect(cleared.effects.map((effect) => effect.type)).toEqual(["composer.clear"])
+ expect(composerSubmitView(cleared.state)).toEqual({ held: true, busy: true, canSubmit: false })
+
+ expect(transitionComposerSubmit(cleared.state, { type: "gate.settled", attempt: 1 })).toEqual({
+ state: { type: "idle", attempt: 1 },
+ effects: [{ type: "done", done, sent: true }],
+ })
+ })
+
+ test("a gate that settles before the composer clears lets the send through as before", () => {
+ const settled = transitionComposerSubmit(states["handing-off"], { type: "gate.settled", attempt: 1 })
+ expect(settled).toMatchObject({ state: { type: "handing-off", gate: "settled" }, effects: [] })
+
+ const cleared = transitionComposerSubmit(settled.state, { type: "handoff.ready", attempt: 1, prompt: undefined })
+ expect(cleared.state).toEqual({ type: "idle", attempt: 1 })
+ expect(cleared.effects.map((effect) => effect.type)).toEqual(["composer.clear", "done"])
+ })
+
+ test.each([
+ { name: "a prompt", input: {}, gated: true },
+ { name: "a server command", input: { text: "/review", commands: [{ name: "review" }] }, gated: true },
+ { name: "a shell command", input: { mode: "shell" }, gated: false },
+ ] satisfies { name: string; input: Partial
; gated: boolean }[])("$name waits on the gate: $gated", (row) => {
+ const result = replay([{ type: "submit", snapshot: snapshot(row.input), done }, started(1)])
+
+ expect(result.effects.find((effect) => effect.type === "handoff")).toMatchObject({ gated: row.gated })
+ expect(result.state).toMatchObject({ type: "handing-off", gate: row.gated ? "pending" : "none" })
+ // A send with no gate settles as it always did.
+ expect(
+ transitionComposerSubmit(result.state, { type: "handoff.ready", attempt: 1, prompt: undefined }).state.type,
+ ).toBe(row.gated ? "sending" : "idle")
+ })
+
+ test("Stop cancels a send that still waits on the gate, and interrupts the Session only when none does", () => {
+ const cancel: ComposerSubmitTransition = {
+ state: { type: "idle", attempt: 1 },
+ effects: [
+ { type: "send.cancel", attempt: 1 },
+ { type: "done", done, sent: false },
+ ],
+ }
+
+ expect(transitionComposerSubmit(states.sending, { type: "stop" })).toEqual(cancel)
+ expect(transitionComposerSubmit(states["handing-off"], { type: "stop" })).toEqual(cancel)
+
+ // A quote's own send settles the run, once it fails as cancelled.
+ const quoting = transitionComposerSubmit(states.quoting, { type: "stop" })
+ expect(quoting).toEqual({ state: states.quoting, effects: [{ type: "send.cancel", attempt: 1 }] })
+ expect(transitionComposerSubmit(quoting.state, { type: "run.settled", attempt: 1, sent: false })).toEqual({
+ state: { type: "idle", attempt: 1 },
+ effects: [{ type: "done", done, sent: false }],
+ })
+
+ // Once the gate settled the request may have left: Stop is for the Session again, and never both.
+ for (const state of [states["handing-off"], states.quoting]) {
+ const settled = transitionComposerSubmit(state, { type: "gate.settled", attempt: 1 }).state
+ expect(transitionComposerSubmit(settled, { type: "stop" })).toEqual({ state: settled, effects: [{ type: "interrupt" }] })
+ }
+
+ expect(transitionComposerSubmit(states.running, { type: "stop" }).effects).toEqual([{ type: "interrupt" }])
+ })
+
+ test("a gate result for a cancelled or another send changes nothing", () => {
+ const cancelled = transitionComposerSubmit(states.sending, { type: "stop" }).state
+
+ for (const state of [cancelled, states.sending, states["handing-off"], states.quoting, states.preparing, states.running]) {
+ const attempt = state === cancelled ? 1 : 2
+ expect(transitionComposerSubmit(state, { type: "gate.settled", attempt }).state).toBe(state)
+ }
+
+ // The next send's gate is its own.
+ const next = replay([{ type: "submit", snapshot: snapshot(), done }, started(2), { type: "gate.settled", attempt: 1 }], cancelled)
+ expect(next.state).toMatchObject({ type: "handing-off", attempt: 2, gate: "pending" })
+ })
+
+ test("a composer that unmounts while its send waits on the gate leaves the send to finish", () => {
+ expect(transitionComposerSubmit(states.sending, { type: "unmounted" })).toEqual({
+ state: { type: "idle", attempt: 1 },
+ effects: [{ type: "done", done, sent: true }],
+ })
+ })
+
test.each([
{ name: "a slash command", input: { text: "/review" } },
{ name: "a shell command", input: { mode: "shell" } },
diff --git a/packages/app/src/composer/machine.ts b/packages/app/src/composer/machine.ts
index f9fb2c326a9f..d82c64a3b9b6 100644
--- a/packages/app/src/composer/machine.ts
+++ b/packages/app/src/composer/machine.ts
@@ -40,8 +40,11 @@ export type CapturedDraft = {
sources: { key: string; source: QuoteSource }[]
}
-/** A prompt sent before the composer cleared; `settled` restores the draft through `restore` when it fails. */
-export type PromptSend = { settled: (restore: () => boolean) => Promise }
+/**
+ * A prompt sent before the composer cleared; `settled` restores the draft through `restore` when it fails, which
+ * hears whether the send was cancelled rather than refused.
+ */
+export type PromptSend = { settled: (restore: (cancelled: boolean) => boolean) => Promise }
/** Settles the caller of `submit` or `submitQuote`; `sent` is false when nothing was sent. */
export type SubmitDone = (sent: boolean) => void
@@ -49,14 +52,22 @@ export type SubmitDone = (sent: boolean) => void
/** A held prompt that already shows in its Session's timeline; `cleared` is the composer it left, once cleared. */
export type ShownHold = { session: ComposerSession; cleared: Prompt | undefined }
+/**
+ * What a send waits for before its request may leave: whatever the plugins prepare for a prompt or a server command,
+ * such as attaching to the session. `none` for a send that starts no step, as a shell command. While `pending`,
+ * nothing of the send has reached the server, so Stop cancels the send itself.
+ */
+export type SendGate = "none" | "pending" | "settled"
+
export type ComposerSubmitState =
| { type: "idle"; attempt: number }
// A send pressed while a cold Location loads its agents and models; it goes through once they load. A prompt to a
// Session shows in its timeline at once and leaves the composer (`shown`); any other send waits in the composer,
// where an edit cancels it.
| { type: "held"; attempt: number; snapshot: SubmitSnapshot; shown: ShownHold | undefined; done: SubmitDone }
- // A client command or a quote runs; neither takes the draft, but the composer submits nothing else meanwhile.
- | { type: "running"; attempt: number; done: SubmitDone }
+ // A client command or a quote runs; neither takes the draft, but the composer submits nothing else meanwhile. A quote
+ // is a prompt, so it waits on the gate as one does.
+ | { type: "running"; attempt: number; gate: SendGate; done: SubmitDone }
// Image attachments resolve and, for a new Session, the Session starts. Nothing is sent yet. `cleared` is the
// composer a shown hold already cleared.
| {
@@ -79,8 +90,12 @@ export type ComposerSubmitState =
comments: PromptHistoryComment[]
cleared: Prompt | undefined
session: ComposerSession
+ gate: SendGate
done: SubmitDone
}
+ // The composer cleared and the send shows in its Session, but its request still waits on the gate. The composer
+ // submits nothing else, so sends leave in the order they were made, and Stop cancels this one.
+ | { type: "sending"; attempt: number; done: SubmitDone }
export type SubmitSnapshot = {
draft: CapturedDraft
@@ -138,12 +153,19 @@ export type ComposerSubmitEvent =
| { type: "session.retargeted"; attempt: number; target: ComposerStateTarget; preserveDraft: boolean }
| { type: "submit.aborted"; attempt: number }
| { type: "handoff.ready"; attempt: number; prompt: PromptSend | undefined }
+ /** What the send of `attempt` waited for is ready, or timed out: its request may leave. */
+ | { type: "gate.settled"; attempt: number }
export type ComposerSubmitEffect =
| { type: "done"; done: SubmitDone; sent: boolean }
| { type: "notify.missing-selection" }
| { type: "notify.unqueueable" }
| { type: "interrupt" }
+ /**
+ * Cancels the send of `attempt` before its request leaves: it is removed from its Session, and a draft the composer
+ * already gave up for it comes back.
+ */
+ | { type: "send.cancel"; attempt: number }
| { type: "submit.retry"; alternate: boolean; first?: boolean; done: SubmitDone }
/** Shows a held prompt in its Session's timeline and clears the composer it came from. */
| { type: "hold.show"; attempt: number; session: ComposerSession; snapshot: SubmitSnapshot }
@@ -174,6 +196,8 @@ export type ComposerSubmitEffect =
value: ComposerSubmission
/** A prompt shows in the Session as soon as it starts, before the composer clears. */
sendFirst: boolean
+ /** The send waits on the gate: the driver starts it and reports `gate.settled`. */
+ gated: boolean
ready: Promise
complete?: () => Promise
}
@@ -182,6 +206,7 @@ export type ComposerSubmitEffect =
draft: CapturedDraft
value: ComposerSubmission
kind: SubmissionKind
+ attempt: number
comments: PromptHistoryComment[]
session: ComposerSession
prompt: PromptSend | undefined
@@ -203,12 +228,28 @@ export function transitionComposerSubmit(
if (event.type === "quote") return quote(state, event.snapshot, event.done)
- // Stopping a held send cancels it and leaves the prompt in the composer.
- if (event.type === "stop")
- return state.type === "held" ? cancelHold(state, []) : { state, effects: [{ type: "interrupt" }] }
+ if (event.type === "stop") return stop(state)
+
+ // A promoted new-session composer unmounts while its first prompt hands off, so only a held send ends here. A send
+ // that waits on the gate goes on without its composer.
+ if (event.type === "unmounted") {
+ if (state.type === "held") return cancelHold(state, [])
+
+ return state.type === "sending" ? settle(state, true, []) : unchanged(state)
+ }
+
+ if (event.type === "gate.settled") {
+ if (current(state, "sending", event.attempt)) return settle(state, true, [])
- // A promoted new-session composer unmounts while its first prompt hands off, so only a held send ends here.
- if (event.type === "unmounted") return state.type === "held" ? cancelHold(state, []) : unchanged(state)
+ if (
+ (current(state, "handing-off", event.attempt) || current(state, "running", event.attempt)) &&
+ state.gate === "pending"
+ )
+ return { state: { ...state, gate: "settled" }, effects: [] }
+
+ // A result for a send that was cancelled, or that another one has replaced.
+ return unchanged(state)
+ }
// Only a prompt still in the composer cancels on an edit; a shown one left it, so the composer holds a new draft.
if (event.type === "hold.changed")
@@ -257,9 +298,11 @@ export function transitionComposerSubmit(
if (event.type === "session.started") {
if (!current(state, "preparing", event.attempt)) return unchanged(state)
const value = { ...state.value, images: event.images }
+ // A shell command starts no step, so nothing prepares for it.
+ const gate: SendGate = state.kind.type === "shell" ? "none" : "pending"
return {
- state: { ...state, type: "handing-off", value, session: event.session },
+ state: { ...state, type: "handing-off", value, session: event.session, gate },
effects: [
// A shown hold recorded it when it left the composer.
...(state.cleared ? [] : [{ type: "history.record" as const, prompt: value.prompt, mode: value.mode }]),
@@ -269,6 +312,7 @@ export function transitionComposerSubmit(
session: event.session,
value,
sendFirst: state.kind.type === "prompt",
+ gated: gate === "pending",
ready: event.ready,
complete: event.complete,
},
@@ -297,24 +341,32 @@ export function transitionComposerSubmit(
if (!current(state, "handing-off", event.attempt)) return unchanged(state)
- return settle(state, true, [
- {
- type: "composer.clear",
- draft: state.draft,
- value: state.value,
- kind: state.kind,
- comments: state.comments,
- session: state.session,
- prompt: event.prompt,
- cleared: state.cleared,
- },
- ])
+ const clear: ComposerSubmitEffect = {
+ type: "composer.clear",
+ attempt: state.attempt,
+ draft: state.draft,
+ value: state.value,
+ kind: state.kind,
+ comments: state.comments,
+ session: state.session,
+ prompt: event.prompt,
+ cleared: state.cleared,
+ }
+
+ // The composer clears now, as the send already shows in its Session. Its request has not left yet, so the composer
+ // waits with it rather than taking the next send.
+ if (state.gate === "pending")
+ return { state: { type: "sending", attempt: state.attempt, done: state.done }, effects: [clear] }
+
+ return settle(state, true, [clear])
}
export function composerSubmitView(state: ComposerSubmitState) {
return {
- held: state.type === "held",
- busy: state.type === "held" || state.type === "preparing" || state.type === "handing-off",
+ // Stop and Escape cancel the send rather than interrupt the Session.
+ held: state.type === "held" || state.type === "sending",
+ busy:
+ state.type === "held" || state.type === "preparing" || state.type === "handing-off" || state.type === "sending",
canSubmit: state.type === "idle",
}
}
@@ -324,13 +376,29 @@ export function composerSubmitTarget(state: ComposerSubmitState, attempt: number
if (current(state, "preparing", attempt) || current(state, "handing-off", attempt)) return state.draft.target
}
+// Stop and Escape. A send whose request has not left yet is cancelled, and nothing of it reaches the server: a held
+// one, and one that waits on the gate. Otherwise they interrupt the Session, never both.
+function stop(state: ComposerSubmitState): ComposerSubmitTransition {
+ if (state.type === "held") return cancelHold(state, [])
+
+ // The composer still has its draft, or gets it back from the send that fails as cancelled.
+ if (state.type === "sending" || (state.type === "handing-off" && state.gate === "pending"))
+ return settle(state, false, [{ type: "send.cancel", attempt: state.attempt }])
+
+ // The quote's own send settles the run once it fails as cancelled.
+ if (state.type === "running" && state.gate === "pending")
+ return { state, effects: [{ type: "send.cancel", attempt: state.attempt }] }
+
+ return { state, effects: [{ type: "interrupt" }] }
+}
+
function submit(state: ComposerSubmitState, snapshot: SubmitSnapshot, done: SubmitDone): ComposerSubmitTransition {
if (state.type !== "idle") return { state, effects: [{ type: "done", done, sent: false }] }
const attempt = state.attempt + 1
if (snapshot.mode === "normal" && snapshot.clientCommand)
return {
- state: { type: "running", attempt, done },
+ state: { type: "running", attempt, gate: "none", done },
effects: [{ type: "command.run", attempt, prompt: snapshot.draft.prompt, run: snapshot.clientCommand }],
}
@@ -427,7 +495,7 @@ function quote(state: ComposerSubmitState, snapshot: QuoteSnapshot, done: Submit
const attempt = state.attempt + 1
return {
- state: { type: "running", attempt, done },
+ state: { type: "running", attempt, gate: "pending", done },
effects: [
{
type: "quote.send",
diff --git a/packages/app/src/composer/model.ts b/packages/app/src/composer/model.ts
index 9520c38c73b7..adf5a8402a00 100644
--- a/packages/app/src/composer/model.ts
+++ b/packages/app/src/composer/model.ts
@@ -314,6 +314,7 @@ export function createComposerModel(adapter: ComposerAdapter, options?: { queue?
return (alternate ? queue.alternate() : queue.delivery()) ?? "steer"
},
queueFirst: (inboxID) => options?.queue?.first(inboxID),
+ ready: (sessionID) => plugins.ready(server.key, sessionID),
notify: {
missingSelection: () =>
showToast({
diff --git a/packages/app/src/composer/submit.test.ts b/packages/app/src/composer/submit.test.ts
index 7e41e28cac44..e9bec7c9acb7 100644
--- a/packages/app/src/composer/submit.test.ts
+++ b/packages/app/src/composer/submit.test.ts
@@ -1,7 +1,10 @@
-import { describe, expect, jest, test } from "bun:test"
+import { afterEach, describe, expect, jest, test } from "bun:test"
+import type { SessionRef } from "@opencode/plugin/gui"
import type { ModelSelection } from "@/providers/models/selection"
+import { PROMPT_GATE_TIMEOUT_MS, settlePromptGates } from "@/runtime/plugin/prompt-gate"
import type { SessionMessageHandoff } from "@/session/handoff"
import { Skill } from "@opencode/schema/skill"
+import { createRoot } from "solid-js"
import type {
ActiveComposerAdapter,
ComposerControls,
@@ -86,9 +89,11 @@ function submitInput(
history: string[] = [],
clientCommand?: (text: string) => (() => void | Promise) | undefined,
delivery: (alternate: boolean) => ComposerDelivery = () => "steer",
+ ready?: Parameters[0]["ready"],
) {
return createComposerSubmit({
adapter,
+ ready,
mode: () => mode,
commands,
clientCommand,
@@ -121,7 +126,27 @@ function session(input: {
switchModel?: ComposerSession["api"]["switchModel"]
background?: ComposerSession["background"]
accept?: () => void
+ /** Requests leave as the data layer's send chain lets them: each once the one before it has settled. */
+ chained?: boolean
}): ComposerSession {
+ // The requests made so far, settled or not: the next one starts once they all have.
+ const chain: Promise[] = []
+
+ const sequence: ComposerSession["data"]["session"]["sequence"] = (_sessionID, send, prepare) => {
+ const run = async () => {
+ await prepare?.()
+
+ return send()
+ }
+
+ if (!input.chained) return run()
+ const next = Promise.all(chain.splice(0)).then(run)
+
+ chain.push(next.catch(() => undefined))
+
+ return next
+ }
+
return {
// Unique per test: what this client knows about a session outlives the test that sent to it.
id: `session-${++sessions.count}`,
@@ -162,22 +187,26 @@ function session(input: {
input.calls.push("accept-send")
input.accept?.()
},
- // Like the data layer: admit locally, prepare, then send.
- prompt: async (value) => {
+ sequence,
+ // Like the data layer: admit locally, then prepare and send in the session's send chain.
+ prompt: (value) => {
input.calls.push("admit")
- await value.prepare?.()
- input.calls.push("send")
- await input.prompt?.(value)
-
- // The admitted inbox item, as the server returns it.
- return {
- id: value.id ?? "msg_admitted",
- sessionID: value.sessionID,
- time: { created: 0 },
- type: "user" as const,
- payload: { text: value.text },
- delivery: value.delivery ?? "steer",
- }
+
+ return sequence(value.sessionID, async () => {
+ await value.prepare?.()
+ input.calls.push("send")
+ await input.prompt?.(value)
+
+ // The admitted inbox item, as the server returns it.
+ return {
+ id: value.id ?? "msg_admitted",
+ sessionID: value.sessionID,
+ time: { created: 0 },
+ type: "user" as const,
+ payload: { text: value.text },
+ delivery: value.delivery ?? "steer",
+ }
+ })
},
},
},
@@ -213,6 +242,310 @@ describe("Composer submission", () => {
expect(calls).toContain("admit")
})
+ // Runs the promise jobs queued so far: more turns than a send's longest chain before its request leaves.
+ const flush = async () => {
+ for (const _ of Array.from({ length: 32 })) await Promise.resolve()
+ }
+
+ const typed = (content: string): Prompt => [{ type: "text", content, start: 0, end: content.length }]
+
+ // A composer of `target` whose sends wait on `ready`, with what it reported as failed.
+ const gated = (
+ target: ComposerSession,
+ ready: (sessionID: string) => Promise,
+ input: { prompt: string; mode?: "normal" | "shell"; calls?: string[] },
+ ) => {
+ const state = createMemoryComposerState({ prompt: input.prompt }).capture()
+ const failures: string[] = []
+ const history: string[] = []
+ const adapter = { ...active(state, target), interrupt: async () => void input.calls?.push("interrupt") }
+
+ const submission = submitInput(
+ adapter,
+ { missingSelection() {}, unqueueable() {}, failed: (kind) => failures.push(kind) },
+ input.mode ?? "normal",
+ () => [{ name: "review" }],
+ history,
+ undefined,
+ () => "steer",
+ ready,
+ )
+
+ return { state, submission, failures, history }
+ }
+
+ test("a prompt shows at once, and its composer takes no other send until what the plugins prepare is ready", async () => {
+ const calls: string[] = []
+ const gate = Promise.withResolvers()
+ const sent = Promise.withResolvers()
+ const target = session({ calls, prompt: async () => sent.resolve() })
+
+ const composer = gated(
+ target,
+ (sessionID) => {
+ calls.push(sessionID === target.id ? "gate" : "gate for another session")
+
+ return gate.promise
+ },
+ { prompt: "Hello" },
+ )
+
+ const submitted = composer.submission.submit(new Event("submit"))
+ await flush()
+
+ // The prompt is admitted locally and the composer cleared, but nothing has left, and the send is still the
+ // composer's: its view offers Stop for it.
+ expect(calls.filter((call) => call === "gate" || call === "admit" || call === "send")).toEqual(["gate", "admit"])
+ expect(text(composer.state)).toBe("")
+ expect(composer.submission.state().type).toBe("sending")
+
+ // A second Enter, on whatever was typed meanwhile, starts no second send.
+ composer.state.set(typed("again"), 5)
+ await composer.submission.submit(new Event("submit"))
+ expect(calls.filter((call) => call === "gate" || call === "admit")).toEqual(["gate", "admit"])
+ expect(text(composer.state)).toBe("again")
+
+ gate.resolve()
+ await submitted
+ await sent.promise
+ expect(calls.filter((call) => call === "gate" || call === "admit" || call === "send")).toEqual(["gate", "admit", "send"])
+ expect(composer.submission.state()).toEqual({ type: "idle", attempt: 1 })
+ })
+
+ test.each([
+ { name: "a prompt", prompt: "Hello", left: "Hello" },
+ { name: "a prompt, with a draft typed since", prompt: "Hello", edit: "next", left: "Hello\n\nnext" },
+ { name: "a server command", prompt: "/review now", left: "/review now" },
+ ])("Stop while $name waits on the gate cancels that send: nothing reaches the server and its text comes back", async (row) => {
+ const calls: string[] = []
+ const timeline: string[] = []
+ const statuses: ("idle" | "running")[] = []
+ const gate = Promise.withResolvers()
+
+ const target = session({
+ calls,
+ statuses,
+ handoff: { set: () => timeline.push("set"), hold() {}, settle: () => timeline.push("settle"), clear: () => timeline.push("clear") },
+ command: async () => void calls.push("command"),
+ })
+
+ const composer = gated(target, () => gate.promise, { prompt: row.prompt, calls })
+ const submitted = composer.submission.submit(new Event("submit"))
+ await flush()
+ expect(composer.submission.state().type).toBe("sending")
+ expect(text(composer.state)).toBe("")
+
+ if (row.edit) composer.state.set(typed(row.edit), row.edit.length)
+ await composer.submission.stop()
+ await submitted
+ await flush()
+
+ // Neither the request nor an interrupt: the Session was never told of this send.
+ expect(calls.filter((call) => call === "send" || call === "command" || call === "interrupt")).toEqual([])
+ expect(text(composer.state)).toBe(row.left)
+ expect(composer.failures).toEqual([])
+ expect(composer.submission.state()).toEqual({ type: "idle", attempt: 1 })
+ // A prompt that showed in the Session is taken out of it again, and the Session is not left looking busy.
+ expect(timeline).toEqual(row.prompt.startsWith("/") ? [] : ["set", "clear"])
+ expect(statuses.at(-1) ?? "idle").toBe("idle")
+ expect(composer.history).toEqual([`add:${row.prompt}`, `remove:${row.prompt}`])
+
+ // What the send waited for is ready later: the result belongs to a send that no longer exists.
+ gate.resolve()
+ await flush()
+ expect(calls.filter((call) => call === "send" || call === "command")).toEqual([])
+ expect(composer.submission.state()).toEqual({ type: "idle", attempt: 1 })
+ })
+
+ test.each([
+ {
+ name: "a prompt into a staged revert, with another agent and model selected",
+ prompt: "Hello",
+ current: { agent: "plan", model: { id: "old", providerID: "old" }, revert: { messageID: "msg_reverted" } },
+ },
+ {
+ name: "a prompt with another agent and model selected",
+ prompt: "Hello",
+ current: { agent: "plan", model: { id: "old", providerID: "old" } },
+ },
+ {
+ name: "a server command with another agent and model selected",
+ prompt: "/review now",
+ current: { agent: "plan", model: { id: "old", providerID: "old" } },
+ },
+ ])("Stop while $name waits on the gate changes nothing on the server", async (row) => {
+ const calls: string[] = []
+ const gate = Promise.withResolvers()
+ const target = session({ calls, current: () => row.current, command: async () => void calls.push("command") })
+ const composer = gated(target, () => gate.promise, { prompt: row.prompt, calls })
+ const submitted = composer.submission.submit(new Event("submit"))
+
+ await flush()
+ await composer.submission.stop()
+ await submitted
+ gate.resolve()
+ await flush()
+
+ // Only the prompt's local admission, which the cancelled send takes back: no revert commit, switch or request.
+ expect(calls.filter((call) => call !== "admit")).toEqual([])
+ expect(text(composer.state)).toBe(row.prompt)
+ })
+
+ test("Stop while a prompt waits on the gate keeps a comment added meanwhile, though no text was typed", async () => {
+ const gate = Promise.withResolvers()
+ const composer = gated(session({ calls: [] }), () => gate.promise, { prompt: "Hello" })
+ composer.state.context.add({ type: "file", path: "src/sent.ts", comment: "Sent with it", commentID: "sent" })
+ const submitted = composer.submission.submit(new Event("submit"))
+
+ await flush()
+ expect(composer.state.context.items()).toEqual([])
+ composer.state.context.add({ type: "file", path: "src/later.ts", comment: "Added while it waited", commentID: "later" })
+ await composer.submission.stop()
+ await submitted
+ await flush()
+
+ expect(text(composer.state)).toBe("Hello")
+ expect(composer.state.context.items().map((item) => item.type === "file" && item.comment)).toEqual([
+ "Sent with it",
+ "Added while it waited",
+ ])
+ })
+
+ // The composer the person presses Stop in is not always the one that made the send: a new session's composer
+ // unmounts as soon as Enter is pressed, and a tab switch away and back mounts a session's composer anew.
+ test.each([
+ { name: "a new session's first prompt, from the session's own composer", draft: true },
+ { name: "a prompt whose composer a tab switch has replaced", draft: false },
+ ])("Stop cancels $name while it waits on the gate", async (row) => {
+ const calls: string[] = []
+ const timeline: string[] = []
+ const failures: string[] = []
+ const gate = Promise.withResolvers()
+ // The send ends one way or the other: its prompt leaves the timeline, or its request leaves the window.
+ const ended = Promise.withResolvers()
+
+ const target = session({
+ calls,
+ prompt: async () => ended.resolve(),
+ handoff: {
+ set: () => timeline.push("set"),
+ hold() {},
+ settle() {},
+ clear: () => {
+ timeline.push("clear")
+ ended.resolve()
+ },
+ },
+ })
+
+ const image = {
+ type: "image" as const,
+ id: "attachment",
+ filename: "shot.png",
+ mime: "image/png",
+ blob: { id: "attachment", url: "data:image/png;base64,YQ==" },
+ }
+
+ const draft = createMemoryComposerState({ prompt: "first prompt" }).capture()
+ draft.set([...draft.current(), image])
+ // What the session's composer holds: its own draft, which a new session's first prompt is moved to.
+ const seen = row.draft ? createMemoryComposerState().capture() : draft
+
+ const sender = row.draft
+ ? fresh(draft, async (_selection, submission) => {
+ submission.retarget(seen)
+
+ return { session: target, cleanupReady: Promise.resolve() }
+ })
+ : active(draft, target)
+
+ const notify = { missingSelection() {}, unqueueable() {}, failed: (kind: string) => void failures.push(kind) }
+
+ const compose = (adapter: ActiveComposerAdapter | NewSessionComposerAdapter) =>
+ submitInput(adapter, notify, undefined, undefined, undefined, undefined, undefined, () => gate.promise)
+
+ const unmount = createRoot((dispose) => {
+ void compose(sender).submit(new Event("submit"))
+
+ return dispose
+ })
+
+ // A new session's composer goes at Enter; a tab switch comes once the prompt shows and waits.
+ if (row.draft) unmount()
+ await flush()
+
+ if (!row.draft) unmount()
+ expect(timeline).toEqual(["set"])
+ expect(text(seen)).toBe("")
+
+ await compose({ ...active(seen, target), interrupt: async () => void calls.push("interrupt") }).stop()
+ // What the send waited for is ready later: the cancelled prompt must not leave then either.
+ gate.resolve()
+ await ended.promise
+ await flush()
+
+ expect(calls.filter((call) => call === "send" || call === "interrupt")).toEqual([])
+ expect(timeline).toEqual(["set", "clear"])
+ expect(text(seen)).toBe("first prompt")
+ expect(seen.current()).toContainEqual(image)
+ expect(failures).toEqual([])
+
+ // Nothing waits any more, so the next Stop interrupts the session as before.
+ await compose({ ...active(seen, target), interrupt: async () => void calls.push("interrupt") }).stop()
+ expect(calls.filter((call) => call === "interrupt")).toEqual(["interrupt"])
+ })
+
+ // A session's draft composer and its own composer are two of these. Each press of Enter is one send, and the server
+ // must receive them in that order, whatever each waited for: here the prompt waits on the gate, the server command
+ // on the gate and on the prompt, and the shell command, which has no gate, on both.
+ describe("order", () => {
+ afterEach(() => void jest.useRealTimers())
+
+ test.each(["is ready", "times out"] as const)(
+ "a prompt, a server command and a shell command reach the server in that order when the gate %s",
+ async (how) => {
+ if (how === "times out") jest.useFakeTimers()
+ const calls: string[] = []
+ const gate = Promise.withResolvers()
+
+ const target = session({
+ calls,
+ chained: true,
+ prompt: async () => void calls.push("prompt"),
+ command: async () => void calls.push("command"),
+ shell: async () => void calls.push("shell"),
+ })
+
+ // SAFETY: the gate under test never reads the session.
+ const ref = { key: `server\n${target.id}`, id: target.id } as SessionRef
+ const never = { plugin: "browser", value: { ready: () => new Promise(() => undefined) } }
+
+ const ready = () =>
+ how === "times out" ? settlePromptGates([never], () => true, ref) : gate.promise
+
+ const sends = [
+ gated(target, ready, { prompt: "Hello" }),
+ gated(target, ready, { prompt: "/review now" }),
+ gated(target, ready, { prompt: "ls", mode: "shell" }),
+ ].map((composer) => composer.submission.submit(new Event("submit")))
+
+ await flush()
+ // The shell command has nothing to wait for of its own, and still does not go first.
+ expect(calls.filter((call) => call === "prompt" || call === "command" || call === "shell")).toEqual([])
+
+ if (how === "times out") jest.advanceTimersByTime(PROMPT_GATE_TIMEOUT_MS)
+ gate.resolve()
+ await Promise.all(sends)
+ await flush()
+ expect(calls.filter((call) => call === "prompt" || call === "command" || call === "shell")).toEqual([
+ "prompt",
+ "command",
+ "shell",
+ ])
+ },
+ )
+ })
+
test("marks the session accepted only once the send is admitted", async () => {
const calls: string[] = []
const accepted = Promise.withResolvers()
diff --git a/packages/app/src/composer/submit.ts b/packages/app/src/composer/submit.ts
index fa2ab11f4b9f..4aa857b5ca5e 100644
--- a/packages/app/src/composer/submit.ts
+++ b/packages/app/src/composer/submit.ts
@@ -44,6 +44,48 @@ const switched = new Map()
// the follow-ups sent from its own composer go through different submit machines. A session left out is `server`.
const statuses = new Map()
+// Each session's last send, until it has joined the data layer's send chain. A send first builds its request
+// (attachments read, mentions checked), which takes one longer than another, and must still join after the sends made
+// before it. Module-wide for the same reason as `statuses`.
+const joining = new Map>()
+
+/** A send's place in its session's order: `before` is the send made before it, until that one has joined the chain. */
+type Turn = { before: Promise | undefined; joined: () => void }
+
+/**
+ * Runs one send in its session's order. Call it before the first await. `send` builds its request in whatever time
+ * that takes, waits for `before`, puts the request in the data layer's send chain and calls `joined` at once. A send
+ * that ends without joining does not hold the next one back.
+ */
+function inTurn(sessionID: string, send: (turn: Turn) => Promise) {
+ const mine = Promise.withResolvers()
+ const turn = { before: joining.get(sessionID), joined: () => mine.resolve() }
+
+ joining.set(sessionID, mine.promise)
+ void mine.promise.then(() => {
+ if (joining.get(sessionID) === mine.promise) joining.delete(sessionID)
+ })
+ const sending = send(turn)
+
+ void sending.then(turn.joined, turn.joined)
+
+ return sending
+}
+
+/** What a cancelled send fails with: Stop pressed while its request still waited on the gate. */
+const CANCELLED = new Error("The send was cancelled before its request left.")
+
+/**
+ * A send's gate. `open` settles once its request may leave, and rejects with `CANCELLED` when `cancel` is called
+ * first.
+ */
+type Gate = { open: Promise; cancel: () => void }
+
+// The gates each session's sends still wait on, by session ID, until each settles. Module-wide for the same reason as
+// `statuses`: a new session's composer unmounts while its first prompt waits, and a tab switch remounts a session's
+// composer, so the composer the person presses Stop in is not always the one that made the send.
+const waiting = new Map>()
+
type ComposerSubmitInput = {
adapter: ComposerAdapter
mode: Accessor<"normal" | "shell">
@@ -57,6 +99,11 @@ type ComposerSubmitInput = {
delivery?: (alternate: boolean) => ComposerDelivery
queueFirst?: (inboxID: string) => void
clientCommand?: (text: string) => (() => void | Promise) | undefined
+ /**
+ * What a prompt or a server command waits for before its request goes out: whatever the plugins prepare for the
+ * session's next step. It never rejects and is bounded by the plugin host.
+ */
+ ready?: (sessionID: string) => Promise
notify: {
missingSelection: () => void
unqueueable: () => void
@@ -80,15 +127,70 @@ export function createComposerSubmit(input: ComposerSubmitInput) {
result.effects.forEach(run)
}
+ // The gate of each send that still waits on it, by attempt.
+ const gates = new Map()
+
+ // Starts what the send of `attempt` waits for, and tells the machine when it is ready. A send cancelled meanwhile
+ // fails as `CANCELLED` and its late result is one the machine ignores.
+ const openGate = (attempt: number, session: ComposerSession): Gate => {
+ const ready = input.ready?.(session.id)
+ const cancelled = Promise.withResolvers()
+
+ // Nothing may be waiting on it when it is cancelled.
+ void cancelled.promise.catch(() => undefined)
+
+ const gate = {
+ open: ready ? Promise.race([ready, cancelled.promise]) : Promise.resolve(),
+ cancel: () => cancelled.reject(CANCELLED),
+ }
+
+ const settled = () => {
+ if (gates.get(attempt) === gate) gates.delete(attempt)
+ dispatch({ type: "gate.settled", attempt })
+ }
+
+ gates.set(attempt, gate)
+
+ if (ready) {
+ const pending = waiting.get(session.id) ?? new Set()
+
+ waiting.set(session.id, pending.add(gate))
+ void gate.open
+ .catch(() => undefined)
+ .then(() => {
+ pending.delete(gate)
+
+ if (pending.size === 0 && waiting.get(session.id) === pending) waiting.delete(session.id)
+ })
+ void ready.then(settled)
+ } else settled()
+
+ return gate
+ }
+
const run = (effect: ComposerSubmitEffect) => {
if (effect.type === "done") return effect.done(effect.sent)
+ if (effect.type === "send.cancel") {
+ const gate = gates.get(effect.attempt)
+
+ gates.delete(effect.attempt)
+
+ return gate?.cancel()
+ }
+
if (effect.type === "notify.missing-selection") return input.notify.missingSelection()
if (effect.type === "notify.unqueueable") return input.notify.unqueueable()
if (effect.type === "interrupt") {
- if (input.adapter.kind === "active-session") void input.adapter.interrupt()
+ if (input.adapter.kind !== "active-session") return
+ // A send to this session that another composer made still waits on its gate. Nothing of it has reached the
+ // server, so Stop cancels it, as this composer's own machine does for its own send, and interrupts nothing.
+ const pending = waiting.get(input.adapter.session().id)
+
+ if (pending?.size) return pending.forEach((gate) => gate.cancel())
+ void input.adapter.interrupt()
return
}
@@ -146,7 +248,7 @@ export function createComposerSubmit(input: ComposerSubmitInput) {
input.adapter.beforeSubmit?.()
const target = input.adapter.state
- void dispatchPrompt(input, effect.session, effect.value)
+ void dispatchPrompt(input, effect.session, effect.value, openGate(effect.attempt, effect.session))
.settled(() => {
target.context.updateComment(effect.quote.commentID, { comment: effect.comment })
@@ -215,7 +317,8 @@ export function createComposerSubmit(input: ComposerSubmitInput) {
}
if (effect.type === "handoff") {
- const prompt = effect.sendFirst ? dispatchPrompt(input, effect.session, effect.value) : undefined
+ const gate = effect.gated ? openGate(effect.attempt, effect.session) : undefined
+ const prompt = effect.sendFirst ? dispatchPrompt(input, effect.session, effect.value, gate) : undefined
void effect.ready
.then(() => effect.complete?.())
@@ -230,7 +333,7 @@ export function createComposerSubmit(input: ComposerSubmitInput) {
return
}
- clearSubmission(input, effect)
+ clearSubmission(input, effect, gates.get(effect.attempt))
}
// A held send goes through once the Location's agents and models load. One still in the composer ends if the draft
@@ -385,15 +488,23 @@ async function startSession(
function clearSubmission(
input: ComposerSubmitInput,
effect: Extract,
+ gate: Gate | undefined,
) {
const held = effect.cleared
const clear = held ? undefined : clearComposer(input, effect.draft, effect.kind.type)
- // A held prompt cleared the composer at Enter, so what it goes back to is read only once the send fails.
- const restore = () => {
- const back = clear ?? (held && afterHold(effect.draft, held))
+ // A held prompt cleared the composer at Enter, so what it goes back to is read only once the send fails. A
+ // cancelled send comes back as a cancelled hold does: in front of a draft typed since, not dropped for it.
+ const restore = (cancelled: boolean) => {
+ const cleared = cancelled ? (clear?.cleared ?? held) : held
+ const back = cleared ? afterHold(effect.draft, cleared) : clear
+
+ if (!back) return false
+
+ // A cancelled send loses nothing: a comment added while it waited stays, though no text was typed with it.
+ const kept = cancelled && effect.draft.target.context.items().some(isCommentItem)
- return !!back && restoreSubmission(input, effect, back)
+ return restoreSubmission(input, effect, kept ? { ...back, edited: true } : back)
}
if (effect.prompt) return void effect.prompt.settled(restore)
@@ -409,6 +520,7 @@ function clearSubmission(
effect.value,
effect.kind.command,
input.adapter.controls().model.selection.trackSessionCommit,
+ gate,
).catch((error) => failSubmission(input, effect.session, "command", error, restore, effect.value.id))
}
@@ -532,7 +644,12 @@ function currentSelection(input: ComposerSubmitInput): ComposerSelection | undef
}
}
-function dispatchPrompt(input: ComposerSubmitInput, session: ComposerSession, value: ComposerSubmission): PromptSend {
+function dispatchPrompt(
+ input: ComposerSubmitInput,
+ session: ComposerSession,
+ value: ComposerSubmission,
+ gate: Gate | undefined,
+): PromptSend {
// A steer appears in the timeline before the composer clears; queued prompts appear in the queue on admission.
if (value.delivery === "steer")
session.handoff.set({
@@ -552,7 +669,7 @@ function dispatchPrompt(input: ComposerSubmitInput, session: ComposerSession, va
updateStatus(session, { type: "dispatched", id: value.id, working })
- const sending = sendPrompt(session, value, input.adapter.controls().model.selection.trackSessionCommit).then(
+ const sending = sendPrompt(session, value, input.adapter.controls().model.selection.trackSessionCommit, gate).then(
() => ({ ok: true as const }),
(error) => ({ ok: false as const, error }),
)
@@ -705,35 +822,64 @@ function restoreDraft(
return true
}
-async function sendShell(session: ComposerSession, value: ComposerSubmission) {
- await session.api.shell({ sessionID: session.id, id: value.id, command: value.text })
+// A shell command, a server command and a prompt all leave through the session's one send chain, each in its turn, so
+// the server receives them in the order of the Enter presses, whatever each had to build or wait for first.
+function sendShell(session: ComposerSession, value: ComposerSubmission) {
+ return inTurn(session.id, async (turn) => {
+ if (turn.before) await turn.before
+
+ const sending = session.data.session.sequence(session.id, () =>
+ session.api.shell({ sessionID: session.id, id: value.id, command: value.text }),
+ )
+
+ turn.joined()
+ await sending
+ })
}
-async function sendCommand(
+function sendCommand(
session: ComposerSession,
value: ComposerSubmission,
command: { command: string; arguments: string },
- track?: ModelSelection["trackSessionCommit"],
+ track: ModelSelection["trackSessionCommit"] | undefined,
+ gate: Gate | undefined,
) {
- const request = await buildSubmissionRequest(session, value)
+ return inTurn(session.id, async (turn) => {
+ const request = await buildSubmissionRequest(session, value)
+
+ if (turn.before) await turn.before
+
+ const sending = session.data.session.sequence(
+ session.id,
+ () =>
+ session.api.command({
+ sessionID: session.id,
+ name: command.command,
+ text: command.arguments,
+ files: request.files.map((file) => ({
+ uri: file.uri,
+ name: file.name,
+ description: file.description,
+ mention: file.mention,
+ })),
+ agents: request.agents,
+ skills: request.skills,
+ delivery: value.delivery,
+ }),
+ // What the request waits for is not part of its place in the chain's order. A send cancelled while it waits on
+ // the gate stops there, before the composer's selection is committed: nothing of it reaches the server.
+ async () => {
+ await gate?.open
- // Like queued prompts, queued commands must not apply the composer's selection to active work.
- if (value.delivery === "steer") await applySelection(session, value.selection, track)
- await session.api.command({
- sessionID: session.id,
- name: command.command,
- text: command.arguments,
- files: request.files.map((file) => ({
- uri: file.uri,
- name: file.name,
- description: file.description,
- mention: file.mention,
- })),
- agents: request.agents,
- skills: request.skills,
- delivery: value.delivery,
+ // Like queued prompts, queued commands must not apply the composer's selection to active work.
+ if (value.delivery === "steer") await applySelection(session, value.selection, track)
+ },
+ )
+
+ turn.joined()
+ await sending
+ session.data.session.acceptSend(session.id)
})
- session.data.session.acceptSend(session.id)
}
async function applySelection(
@@ -776,10 +922,21 @@ async function applySelection(
}
}
-async function sendPrompt(
+function sendPrompt(
session: ComposerSession,
value: ComposerSubmission,
track: ModelSelection["trackSessionCommit"] | undefined,
+ gate: Gate | undefined,
+) {
+ return inTurn(session.id, (turn) => admitPrompt(session, value, track, gate, turn))
+}
+
+async function admitPrompt(
+ session: ComposerSession,
+ value: ComposerSubmission,
+ track: ModelSelection["trackSessionCommit"] | undefined,
+ gate: Gate | undefined,
+ turn: Turn,
) {
const request = await buildSubmissionRequest(session, value)
@@ -801,9 +958,15 @@ async function sendPrompt(
// pending.
const staged = !!session.current()?.revert
- if (staged) await commit()
+ // A send cancelled while it waits on the gate stops before anything of it reaches the server: the staged revert
+ // stays staged, and the agent and model stay as they were.
+ if (staged) {
+ await gate?.open
+ await commit()
+ }
+
// A retried admission reuses the first commit rather than switching again.
- let committed: Promise | undefined
+ let committed: Promise | undefined
const admission = {
id: value.id,
@@ -825,10 +988,17 @@ async function sendPrompt(
agent: value.selection.agent,
model: selectionModel(value.selection),
},
- prepare: staged ? undefined : () => (committed ??= commit()),
+ // The data layer runs this in the prompt's turn of the send chain. The selection's commit follows what the
+ // plugins prepare, so a send cancelled meanwhile stops here and nothing of it reaches the server.
+ prepare: () => (committed ??= (gate?.open ?? Promise.resolve()).then(() => (staged ? undefined : commit()))),
}
- await session.data.session.prompt(admission).catch(() => session.data.session.prompt(admission))
+ if (turn.before) await turn.before
+ const sending = session.data.session.prompt(admission)
+
+ turn.joined()
+ // An admission that fails is tried once more. A cancelled one is not: the person stopped it.
+ await sending.catch((error) => (error === CANCELLED ? Promise.reject(error) : session.data.session.prompt(admission)))
session.data.session.acceptSend(session.id)
}
@@ -880,12 +1050,14 @@ function failSubmission(
kind: "shell" | "command" | "prompt",
// oxlint-disable-next-line anti-slop/no-unknown-parameters -- a rejected send is opaque; the notifier formats it
error: unknown,
- restore: () => boolean,
+ restore: (cancelled: boolean) => boolean,
messageID?: string,
) {
if (messageID && session.admitted(messageID)) return true
- restore()
- input.notify.failed(kind, error)
+ restore(error === CANCELLED)
+
+ // A cancelled send is what the person asked for, not a failure to report.
+ if (error !== CANCELLED) input.notify.failed(kind, error)
return false
}
diff --git a/packages/app/src/entry.tsx b/packages/app/src/entry.tsx
index 969f506c1f6a..f9a06a0f135e 100644
--- a/packages/app/src/entry.tsx
+++ b/packages/app/src/entry.tsx
@@ -53,7 +53,9 @@ const clearAuthToken = () => {
const web = createWebPlatform(import.meta.env.VITE_OPENCODE_VERSION ?? pkg.version)
if (import.meta.env.PROD && "serviceWorker" in navigator) {
- window.addEventListener("load", () => void navigator.serviceWorker.register("/sw.js"), { once: true })
+ window.addEventListener("load", () => void navigator.serviceWorker.register(`${import.meta.env.BASE_URL}sw.js`), {
+ once: true,
+ })
}
if (import.meta.env.VITE_SENTRY_DSN) {
diff --git a/packages/app/src/env.d.ts b/packages/app/src/env.d.ts
index afe80ccababe..64057f079c3b 100644
--- a/packages/app/src/env.d.ts
+++ b/packages/app/src/env.d.ts
@@ -1,4 +1,6 @@
interface ImportMetaEnv {
+ /** Vite's `base`, the path the build is served under, such as `/opencode/`; `/` at the root. */
+ readonly BASE_URL: string
readonly VITE_OPENCODE_SERVER_MODE?: "none" | "origin"
readonly VITE_OPENCODE_SERVER_HOST: string
readonly VITE_OPENCODE_SERVER_PORT: string
diff --git a/packages/app/src/home/projects/view.css b/packages/app/src/home/projects/view.css
index c046934c30b3..9199c111e879 100644
--- a/packages/app/src/home/projects/view.css
+++ b/packages/app/src/home/projects/view.css
@@ -1,3 +1,23 @@
+[data-slot="home-project-nav-button"]:focus-visible {
+ outline-offset: -2px;
+}
+
+/* Paint the project's ring above the hover actions without covering their hit targets. */
+[data-home-row] > [data-slot="home-project-nav-button"]:focus-visible {
+ outline: none;
+}
+
+[data-home-row]:has(> [data-slot="home-project-nav-button"]:focus-visible)::after {
+ content: "";
+ position: absolute;
+ inset: 0;
+ z-index: 1;
+ border-radius: inherit;
+ outline: 2px solid var(--v2-border-border-focus);
+ outline-offset: -2px;
+ pointer-events: none;
+}
+
/* Home server/project rows keep the label underneath the hover actions.
The actions carry a tab-style background with a fade on the left, and the
label fades out where it slides underneath. Mirrors tab-nav.css. */
diff --git a/packages/app/src/home/projects/view.tsx b/packages/app/src/home/projects/view.tsx
index e09339e0bad2..8734ed384a7f 100644
--- a/packages/app/src/home/projects/view.tsx
+++ b/packages/app/src/home/projects/view.tsx
@@ -2,6 +2,7 @@ import { createMemo, For, type JSX, onCleanup, Show, splitProps } from "solid-js
import { createStore } from "solid-js/store"
import { createResizeObserver } from "@solid-primitives/resize-observer"
import { Popover } from "@kobalte/core/popover"
+import { createOverlayFocus } from "@opencode/ui/context/overlay-focus"
import {
displayName,
getProjectAvatarGenerated,
@@ -86,6 +87,11 @@ export type HomeProjectsViewProps = {
export function HomeProjectsView(props: HomeProjectsViewProps) {
const [state, setState] = createStore({ open: false })
+
+ const overlayFocus = createOverlayFocus()
+
+ let trigger: HTMLButtonElement | undefined
+
const selected = createMemo(() => props.projects.find((project) => project.worktree === props.selection.directory))
const server = createMemo(() =>
@@ -96,7 +102,10 @@ export function HomeProjectsView(props: HomeProjectsViewProps) {
}>
setState("open", open)}
+ onOpenChange={(open) => {
+ overlayFocus.openChanged(open)
+ setState("open", open)
+ }}
placement={props.scope ? "bottom-end" : "bottom-start"}
sameWidth={!props.scope}
gutter={props.scope ? 8 : 6}
@@ -105,9 +114,10 @@ export function HomeProjectsView(props: HomeProjectsViewProps) {
when={props.scope}
fallback={
}>
{(project) => }
@@ -131,9 +141,10 @@ export function HomeProjectsView(props: HomeProjectsViewProps) {
}
>
event.preventDefault()}
>
{(project) => }
@@ -148,6 +159,7 @@ export function HomeProjectsView(props: HomeProjectsViewProps) {
overlayFocus.restore(event, trigger)}
dir={props.language.direction()}
style={props.scope ? { width: "280px" } : undefined}
class="z-50 max-h-[min(70dvh,var(--kb-popper-content-available-height))] overflow-hidden rounded-[10px] bg-v2-background-bg-base p-1.5 shadow-[var(--v2-elevation-floating)] outline-none data-[expanded]:animate-in data-[expanded]:fade-in data-[expanded]:slide-in-from-top-2 duration-150 ease-out motion-reduce:animate-none"
@@ -246,6 +258,7 @@ function HomeProjectsPanel(props: HomeProjectsViewProps) {
{
@@ -706,14 +719,13 @@ function HomeProjectNavButton(props: JSX.ButtonHTMLAttributes
return (
)
}
@@ -62,6 +66,7 @@ export function HomeView(props: {
projectScope?: boolean
/** Search filters the list in place rather than opening a results panel. */
searchInline?: boolean
+ providerTip?: boolean
}) {
const mobile = createMediaQuery("(max-width: 767px)")
@@ -80,35 +85,40 @@ export function HomeView(props: {
-
scroll.viewport.update(event.currentTarget.scrollTop)}
- >
-
+
scroll.viewport.update(event.currentTarget.scrollTop)}
+ >
+
-
-
-
- : undefined}
- searchInline={props.searchInline}
- />
-
-
+ }
+ >
+
+
+
+
: undefined}
+ searchInline={props.searchInline}
+ />
+
+
+
+
+
+
)
}
+
+// Home sits outside any server's context, so the tip reads the current server's default Location.
+function HomeProviderTip() {
+ const servers = useServers()
+ const server = createMemo(() => servers.list.find(servers.current))
+
+ return (
+
+ {(conn) => (
+
+
+
+ )}
+
+ )
+}
+
+function HomeProviderTipContent() {
+ const tip = createProviderTip(() => undefined)
+
+ return (
+ <>
+
+
+ >
+ )
+}
diff --git a/packages/app/src/home/sessions/view.css b/packages/app/src/home/sessions/view.css
index b7e327ee4e68..d85e714e3510 100644
--- a/packages/app/src/home/sessions/view.css
+++ b/packages/app/src/home/sessions/view.css
@@ -75,3 +75,35 @@
transition: none;
}
}
+[data-slot="home-session-search-field"]:has(> input[data-keyboard-focus]:focus) {
+ outline: 2px solid var(--v2-border-border-focus);
+ outline-offset: 2px;
+}
+
+@media (forced-colors: active) {
+ [data-component="home-session-search-row"][aria-selected="true"] {
+ background-color: Highlight;
+ color: HighlightText;
+ }
+
+ [data-component="home-session-search-row"][aria-selected="true"] * {
+ color: inherit;
+ }
+}
+
+[data-component="home-session-row"]:focus-visible {
+ outline-offset: -2px;
+}
+
+/* Keyboard focus scrolls a row clear of the sticky search and date header above it (68/84/108px plus 28px). */
+[data-component="home-session-row"] {
+ scroll-margin-top: 100px;
+
+ @media (width >= 48rem) {
+ scroll-margin-top: 116px;
+ }
+
+ @media (width >= 64rem) {
+ scroll-margin-top: 140px;
+ }
+}
diff --git a/packages/app/src/home/sessions/view.tsx b/packages/app/src/home/sessions/view.tsx
index 1d8eb8dc0343..b895ee863642 100644
--- a/packages/app/src/home/sessions/view.tsx
+++ b/packages/app/src/home/sessions/view.tsx
@@ -25,6 +25,7 @@ import { Menu } from "@opencode/ui/menu"
import { MenuScroll } from "@opencode/ui/menu-scroll"
import { Tooltip } from "@opencode/ui/tooltip"
import { useLanguage } from "@/runtime/i18n/language"
+import { createFieldFocus } from "@opencode/ui/context/field-focus"
import { ServerConnection } from "@/runtime/server/registry"
import { SessionTabAvatarView } from "@/shell/layout/session-tab-avatar"
import { showToast } from "@/shell/notifications/toast"
@@ -270,6 +271,7 @@ export function HomeSessionsView(props: HomeSessionsViewProps) {
props.searchScope)
+ const keyboardFocus = createFieldFocus()
+
return (
{
+ if (event.detail > 0) keyboardFocus.pointer()
+ }}
class={`
relative z-20 flex h-9 w-full items-center gap-2 rounded-[6px] py-1 ps-3 pe-2
bg-v2-background-bg-layer-02/60 text-v2-icon-icon-muted transition-[background-color,box-shadow]
@@ -532,7 +541,13 @@ function HomeSessionSearch(
aria-activedescendant={
props.searchActive && props.searchOpen ? `home-session-search-option-${props.searchActive}` : undefined
}
- onFocus={props.onSearchFocus}
+ data-field-focus
+ data-keyboard-focus={keyboardFocus.visible() || undefined}
+ onBlur={keyboardFocus.leave}
+ onFocus={(event) => {
+ keyboardFocus.enter(event.currentTarget)
+ props.onSearchFocus()
+ }}
onInput={(event) => props.onSearchInput(event.currentTarget.value)}
onKeyDown={(event) => {
if (event.key === "Escape") {
@@ -622,6 +637,7 @@ function HomeSessionSearchResultRow(
data-component="home-session-search-row"
data-project-name={!!showProjectName()}
role="option"
+ tabIndex={-1}
aria-selected={props.selected}
class={`
flex h-10 w-full shrink-0 cursor-default items-center border-0 py-3 pl-[18px] pr-6 text-left text-v2-text-text-muted
@@ -804,7 +820,7 @@ function HomeSessionRow(
flex h-10 min-w-0 w-full flex-1 shrink-0 cursor-default items-center rounded-[6px] border-0
bg-transparent py-3 ps-1.5 pe-3 md:ps-3 text-start text-v2-text-text-muted [font-weight:530]
transition-[background-color,color,box-shadow] duration-[120ms] ease-in-out
- hover:bg-v2-overlay-simple-overlay-hover focus-visible:bg-v2-overlay-simple-overlay-hover focus-visible:outline-none
+ hover:bg-v2-overlay-simple-overlay-hover
`}
classList={{ "gap-1.5": props.desktop, "gap-2": !props.desktop, "md:pe-10": SHOW_HOME_SESSION_ARCHIVE }}
onMouseDown={(event) => {
diff --git a/packages/app/src/index.css b/packages/app/src/index.css
index 19ecf51539c4..05b8afaaceea 100644
--- a/packages/app/src/index.css
+++ b/packages/app/src/index.css
@@ -106,6 +106,10 @@
);
}
+ [data-slot="session-timeline-scroll"] > .scroll-view__viewport:has(> [data-slot="session-header-inset"]) {
+ scroll-padding-block-start: calc(var(--sticky-accordion-top, 0px) + 16px);
+ }
+
/* The review panel's visible width, which the header fade below tracks while the panel animates. Its fixed-width
content holds nothing else that reads it. */
#review-panel,
diff --git a/packages/app/src/new-session/commands.tsx b/packages/app/src/new-session/commands.tsx
index 378422d4e053..e2a091c7c2f0 100644
--- a/packages/app/src/new-session/commands.tsx
+++ b/packages/app/src/new-session/commands.tsx
@@ -5,7 +5,7 @@ import { useLanguage } from "@/runtime/i18n/language"
import { projectSearchCommand } from "@/shell/titlebar/titlebar"
export function useNewSessionCommands(input: {
- restoreFocus: () => void
+ restoreFocus: (cursor?: number, visible?: boolean) => void
project: {
empty: () => boolean
open: () => void
@@ -37,7 +37,8 @@ export function useNewSessionCommands(input: {
title: language.t("command.input.focus"),
category: language.t("command.category.view"),
keybind: "ctrl+l",
- onSelect: input.restoreFocus,
+ // A shortcut moved focus, so the ring shows.
+ onSelect: () => input.restoreFocus(undefined, true),
},
{
id: "session.location.cycle",
diff --git a/packages/app/src/new-session/project/selector.tsx b/packages/app/src/new-session/project/selector.tsx
index ec3879f9f260..19b162a7ed74 100644
--- a/packages/app/src/new-session/project/selector.tsx
+++ b/packages/app/src/new-session/project/selector.tsx
@@ -97,7 +97,7 @@ export function PromptProjectAddButton(props: { controller: PromptProjectControl
props.controller.add()}
>
diff --git a/packages/app/src/new-session/screen.tsx b/packages/app/src/new-session/screen.tsx
index 9e5054209503..34d2971dd75b 100644
--- a/packages/app/src/new-session/screen.tsx
+++ b/packages/app/src/new-session/screen.tsx
@@ -76,7 +76,7 @@ export default function NewSessionPage(props: { draftId: string }) {
// Search projects opened this draft; the picker returns focus to the composer when it closes.
if (layout.draft.projectSearch.take(props.draftId)) location()
- else model.restoreFocus()
+ else model.restoreFocus(undefined, false)
}),
)
createEffect(() => {
diff --git a/packages/app/src/new-session/view.tsx b/packages/app/src/new-session/view.tsx
index 3be8cb111d71..411722ccbc93 100644
--- a/packages/app/src/new-session/view.tsx
+++ b/packages/app/src/new-session/view.tsx
@@ -1,4 +1,3 @@
-import { useDialog } from "@opencode/ui/context/dialog"
import { Tooltip } from "@opencode/ui/tooltip"
import { Icon } from "@opencode/ui/icon"
import { Keybind } from "@opencode/ui/keybind"
@@ -14,7 +13,6 @@ import {
ProjectAvatar,
} from "@opencode/ui/project-avatar"
import { Schema } from "effect"
-import { createPresence } from "@/runtime/presence"
import { Composer } from "@/composer/composer"
import { ComposerDropzone } from "@/composer/dropzone"
import type { ComposerModel } from "@/composer/model"
@@ -26,7 +24,7 @@ import {
import type { useNewSessionLocationDialog } from "@/new-session/location/dialog"
import { useLanguage } from "@/runtime/i18n/language"
import { useWorkspaceLocation } from "@/workspaces/location"
-import { useProviders } from "@/providers/catalog/providers"
+import { createProviderTip, ProviderTip } from "@/providers/connect/tip"
import { NEW_SESSION_CONTENT_WIDTH } from "@/new-session/layout"
import { Persist, persisted } from "@/runtime/persistence/storage"
import { Persistence } from "@/runtime/persistence/schema"
@@ -51,16 +49,10 @@ import {
type WordmarkEvent,
} from "./wordmark-machine"
-const providerTipDismissalDuration = 30 * 24 * 60 * 60 * 1000
-
export const WorkspaceOnboardingSchema = Persistence.struct({
used: Schema.Boolean,
})
-export const ProviderTipSchema = Persistence.struct({
- dismissedAt: Schema.Finite,
-})
-
export function NewSessionView(props: {
composer: ComposerModel
project: PromptProjectController
@@ -101,6 +93,7 @@ export function NewSessionView(props: {
void }) {
- const language = useLanguage()
- const dialog = useDialog()
const sdk = useWorkspaceLocation()
- const providers = useProviders(() => sdk().directory)
-
- const [providerState, setProviderState, , providerReady] = persisted(
- Persist.global("new-session.provider-tip"),
- ProviderTipSchema,
- { dismissedAt: 0 },
- )
-
- const providerVisible = createMemo(
- () =>
- providerReady() &&
- providers.anyConnection() === false &&
- Date.now() - providerState.dismissedAt >= providerTipDismissalDuration,
- )
+ const tip = createProviderTip(() => sdk().directory)
- const tip = providerVisible
- const [ref, setRef] = createSignal()
-
- const presence = createPresence({
- show: tip,
- element: () => ref() ?? null,
- })
-
- const open = () => {
- if (!tip()) return
-
- void import("@/providers/connect/dialog").then(({ DialogConnectProvider }) => {
- void dialog.show(() => (
-
- ))
- })
- }
-
- const dismiss = () => {
- if (!tip()) return
-
- setProviderState("dismissedAt", Date.now())
- }
-
- return (
-
-
-
-
- {language.t("home.providerTip")}
-
-
-
-
-
-
-
-
-
-
-
-
- )
+ return
}
// Keeps as many leading segments as fit, then "…/", then the last two segments. The cut always lands on a slash.
@@ -276,7 +192,7 @@ function fitPath(value: string, width: number, font: string) {
}
const TRIGGER =
- "flex h-7 items-center gap-1.5 rounded-sm text-start ps-1.5 pe-2 text-v2-text-text-muted transition-colors hover:bg-v2-overlay-simple-overlay-hover hover:text-v2-text-text-base focus-visible:bg-v2-overlay-simple-overlay-hover focus-visible:text-v2-text-text-base focus-visible:outline-none"
+ "flex h-7 items-center gap-1.5 rounded-[4px] text-start ps-1.5 pe-2 text-v2-text-text-muted transition-colors hover:bg-v2-overlay-simple-overlay-hover hover:text-v2-text-text-base"
function NewSessionLocation(props: {
project: PromptProject
diff --git a/packages/app/src/providers/catalog/order.test.ts b/packages/app/src/providers/catalog/order.test.ts
index b3fad851d747..43e1eadbe1b0 100644
--- a/packages/app/src/providers/catalog/order.test.ts
+++ b/packages/app/src/providers/catalog/order.test.ts
@@ -4,6 +4,7 @@ import { connectPopular, omitHiddenProviderCatalog, popularProviders, withoutHid
test("keeps Anthropic visible and drops Claude Agent from provider menus", () => {
expect(popularProviders).toContain("anthropic")
expect(connectPopular).toContain("anthropic")
+ expect(connectPopular.slice(0, 2)).toEqual(["opencode-go", "opencode"])
expect(popularProviders).not.toContain("claude-agent")
expect(connectPopular).not.toContain("claude-agent")
diff --git a/packages/app/src/providers/catalog/order.ts b/packages/app/src/providers/catalog/order.ts
index 3e83a4047852..d65a421b9c87 100644
--- a/packages/app/src/providers/catalog/order.ts
+++ b/packages/app/src/providers/catalog/order.ts
@@ -14,7 +14,7 @@ export const popularProviders = [
]
// Connect dialog group order. Matches the TUI priority list.
-export const connectPopular = ["opencode", "opencode-go", "openai", "github-copilot", "anthropic", "google"]
+export const connectPopular = ["opencode-go", "opencode", "openai", "github-copilot", "anthropic", "google"]
// App catalogs that call these helpers omit the upstream Claude Agent id.
// Other list surfaces call isHiddenProvider themselves.
diff --git a/packages/app/src/providers/connect/chatgpt-usage-limit.stories.tsx b/packages/app/src/providers/connect/chatgpt-usage-limit.stories.tsx
index 233bff92b361..733e3083c4b4 100644
--- a/packages/app/src/providers/connect/chatgpt-usage-limit.stories.tsx
+++ b/packages/app/src/providers/connect/chatgpt-usage-limit.stories.tsx
@@ -3,9 +3,9 @@ import { useDialog } from "@opencode/ui/context/dialog"
import { onMount } from "solid-js"
import { DialogChatGPTUsageLimit } from "./chatgpt-usage-limit"
-function UsageLimitStory() {
+function UsageLimitStory(props: { workspace?: boolean }) {
const dialog = useDialog()
- const open = () => dialog.show(() => )
+ const open = () => dialog.show(() => )
onMount(open)
return (
@@ -21,3 +21,5 @@ export default {
}
export const ChatGPTUsageLimit = { render: () => }
+
+export const ChatGPTWorkspaceUsageLimit = { render: () => }
diff --git a/packages/app/src/providers/connect/chatgpt-usage-limit.tsx b/packages/app/src/providers/connect/chatgpt-usage-limit.tsx
index 9a55b00f3e8c..8e54940a8acc 100644
--- a/packages/app/src/providers/connect/chatgpt-usage-limit.tsx
+++ b/packages/app/src/providers/connect/chatgpt-usage-limit.tsx
@@ -2,13 +2,17 @@ import { Button } from "@opencode/ui/button"
import { useDialog } from "@opencode/ui/context/dialog"
import { Dialog, DialogTitle } from "@opencode/ui/dialog"
import { ProviderIcon } from "@opencode/ui/provider-icon"
+import { writeClipboard } from "@opencode/session-ui/copy"
+import { Show, createSignal } from "solid-js"
import { useLanguage } from "@/runtime/i18n/language"
import { usePlatform } from "@/runtime/platform/platform"
-export function DialogChatGPTUsageLimit() {
+export function DialogChatGPTUsageLimit(props: { workspace?: boolean }) {
const dialog = useDialog()
const language = useLanguage()
const platform = usePlatform()
+ const [copied, setCopied] = createSignal()
+ const request = () => language.t("provider.connect.chatgptUsageLimit.request")
return (
@@ -20,7 +24,13 @@ export function DialogChatGPTUsageLimit() {
- {language.t("provider.connect.chatgptUsageLimit.description")}
+
+ {language.t(
+ props.workspace
+ ? "provider.connect.chatgptUsageLimit.workspaceDescription"
+ : "provider.connect.chatgptUsageLimit.description",
+ )}
+
{
+ if (props.workspace) {
+ // writeClipboard falls back to a selected textarea where the async clipboard API is missing (plain HTTP).
+ void (
+ platform.writeClipboardText
+ ? platform.writeClipboardText(request()).then(() => true)
+ : writeClipboard(request())
+ )
+ .catch(() => false)
+ .then(setCopied)
+
+ return
+ }
+
platform.openExternal("https://chatgpt.com/settings/usage")
dialog.close()
}}
>
- {language.t("provider.connect.chatgptUsageLimit.manage")}
+ {language.t(
+ props.workspace
+ ? "provider.connect.chatgptUsageLimit.copyRequest"
+ : "provider.connect.chatgptUsageLimit.manage",
+ )}
+
+
+ {language.t("provider.connect.chatgptUsageLimit.requestCopied")}
+
+
+
+
+ {language.t("provider.connect.chatgptUsageLimit.requestCopyFailed")}
+
+
+ {request()}
+
+
dialog.close()}>
{language.t("provider.connect.chatgptUsageLimit.close")}
diff --git a/packages/app/src/providers/connect/dialog.tsx b/packages/app/src/providers/connect/dialog.tsx
index 63da5108dd11..5f7fb63588b3 100644
--- a/packages/app/src/providers/connect/dialog.tsx
+++ b/packages/app/src/providers/connect/dialog.tsx
@@ -108,10 +108,8 @@ export const DialogConnectProvider: Component<{
return (
{
if (view().completed && props.selection && props.onDone) {
@@ -128,13 +126,11 @@ export const DialogConnectProvider: Component<{
}}
class="[font-family:var(--v2-font-family-sans)]"
classList={{
- "[&_[data-slot=dialog-header]]:!px-4 [&_[data-slot=dialog-header]]:!pt-4 [&_[data-slot=dialog-close-button]]:!mt-0 [&_[data-slot=dialog-close-button]]:!-me-0.5": true,
+ "[&_[data-slot=dialog-header]]:!px-4 [&_[data-slot=dialog-header]]:!pt-3.5 [&_[data-slot=dialog-close-button]]:!mt-0 [&_[data-slot=dialog-close-button]]:!-me-0.5": true,
"[&_[data-slot=dialog-header]]:!pb-2": frame() !== "models",
"[&_[data-slot=dialog-header-title]]:!text-[15px] [&_[data-slot=dialog-header-title]]:!tracking-[-0.13px]":
frame() === "models",
"search-dialog": frame() === "picker" || frame() === "accounts",
- "[&_[data-slot=dialog-description]]:!text-[13px] [&_[data-slot=dialog-description]]:!tracking-[-0.04px]":
- frame() === "picker",
}}
>
@@ -195,7 +191,7 @@ export const DialogConnectProvider: Component<{
{(value) => (
controller.navigate(value())}
>
{content()}
@@ -207,7 +203,7 @@ export const DialogConnectProvider: Component<{
{(value) => (
controller.navigate(value())}
>
{content()}
@@ -246,7 +242,7 @@ export const DialogConnectProvider: Component<{
placement="bottom"
contentClass="!max-w-64 !whitespace-normal"
triggerTabIndex={0}
- class="me-3 flex min-w-0 shrink-0 !cursor-default items-center gap-1.5 rounded-sm text-[13px] font-[440] leading-5 tracking-[-0.04px] text-v2-text-text-muted focus-visible:outline-none focus-visible:text-v2-text-text-base"
+ class="me-3 flex min-w-0 shrink-0 !cursor-default items-center gap-1.5 rounded-sm text-[13px] font-[440] leading-5 tracking-[-0.04px] text-v2-text-text-muted"
>
{language.t("provider.connect.remote.label", { server: server() })}
@@ -292,9 +288,15 @@ const METHOD_ICON = {
external: "server",
} as const satisfies Record
-// The TUI's integration groups and order, with connected integrations pulled up into their own group first.
+// The TUI's integration groups, with connected integrations pulled up into their own group first.
const POPULAR: readonly string[] = connectPopular
+const providerNote = (id: string) => {
+ if (id === "opencode-go") return "dialog.provider.opencodeGo.tagline" as const
+
+ if (id === "opencode") return "dialog.provider.opencode.note" as const
+}
+
function ProviderPicker(props: { directory?: string; onSelect: (provider: string) => void; onPrepare?: () => void }) {
const integrations = useIntegrations(() => props.directory)
const language = useLanguage()
@@ -422,7 +424,7 @@ function ProviderPicker(props: { directory?: string; onSelect: (provider: string
setStore("active", provider.id)}
disabled={disabled(provider)}
@@ -446,6 +448,13 @@ function ProviderPicker(props: { directory?: string; onSelect: (provider: string
{language.t("dialog.provider.environmentOnly")}
+
+ {(key) => (
+
+ {language.t(key())}
+
+ )}
+
{(label) => (
@@ -833,7 +842,7 @@ function ProviderSteps(props: { provider: string; controller: ProviderDialogCont
props.controller.input({ type: "method.selected", index: index() })}
>
@@ -1058,7 +1067,7 @@ function ProviderSteps(props: { provider: string; controller: ProviderDialogCont
props.controller.input({ type: "paste.toggled", open: !pasteOpen() })}
>
props.controller.chooseAccount(account)}
>
@@ -1237,7 +1246,7 @@ function ProviderSteps(props: { provider: string; controller: ProviderDialogCont
props.controller.dispatch({ type: "account.add" })}
>
@@ -1321,7 +1330,7 @@ function ProviderSteps(props: { provider: string; controller: ProviderDialogCont
data-first-provider-model=""
data-selected={checked() ? "" : undefined}
aria-checked={checked()}
- class="connected-model-row text-start focus-visible:outline-none"
+ class="connected-model-row text-start"
onClick={() => props.controller.dispatch({ type: "model.selected", modelKey: modelKey(model) })}
>
diff --git a/packages/app/src/providers/connect/mcp-dialog.tsx b/packages/app/src/providers/connect/mcp-dialog.tsx
index 3c4b3a524fc4..d2cf4e5a94b2 100644
--- a/packages/app/src/providers/connect/mcp-dialog.tsx
+++ b/packages/app/src/providers/connect/mcp-dialog.tsx
@@ -189,7 +189,7 @@ export function McpDialog(props: {
ref={backRef}
type="button"
autofocus
- class="flex size-5 shrink-0 items-center justify-center rounded-sm text-v2-icon-icon-muted hover:bg-v2-overlay-simple-overlay-hover focus-visible:bg-v2-overlay-simple-overlay-hover focus-visible:outline-none"
+ class="flex size-5 shrink-0 items-center justify-center rounded-sm text-v2-icon-icon-muted hover:bg-v2-overlay-simple-overlay-hover"
onClick={back}
aria-label={language.t("common.goBack")}
>
diff --git a/packages/app/src/providers/connect/models.css b/packages/app/src/providers/connect/models.css
index 6f791cddca8c..0a6c7478e2ca 100644
--- a/packages/app/src/providers/connect/models.css
+++ b/packages/app/src/providers/connect/models.css
@@ -30,8 +30,9 @@
}
}
+/* The list clips its rows, so the ring sits inside the row. */
.connected-model-row:focus-visible {
- background-color: var(--v2-background-bg-layer-03);
+ outline-offset: -2px;
}
[data-component="first-provider-models"] [data-component="settings-list"] {
diff --git a/packages/app/src/providers/connect/step-actions.tsx b/packages/app/src/providers/connect/step-actions.tsx
index 0ffc46f907fd..e448e178867d 100644
--- a/packages/app/src/providers/connect/step-actions.tsx
+++ b/packages/app/src/providers/connect/step-actions.tsx
@@ -10,7 +10,7 @@ export function StepActions(props: { children: JSX.Element }) {
// The main action while the sign-in finishes elsewhere: the browser, a command, or the Claude Code check.
export function WaitingButton(props: { children: JSX.Element }) {
return (
-
+
{props.children}
diff --git a/packages/app/src/providers/connect/tip.tsx b/packages/app/src/providers/connect/tip.tsx
new file mode 100644
index 000000000000..ee538aae8608
--- /dev/null
+++ b/packages/app/src/providers/connect/tip.tsx
@@ -0,0 +1,110 @@
+import { useDialog } from "@opencode/ui/context/dialog"
+import { Icon } from "@opencode/ui/icon"
+import { Tooltip } from "@opencode/ui/tooltip"
+import { Schema } from "effect"
+import { createMemo, createSignal, Show, type Accessor } from "solid-js"
+import { useProviders } from "@/providers/catalog/providers"
+import type { ModelSelection } from "@/providers/models/selection"
+import { useLanguage } from "@/runtime/i18n/language"
+import { Persistence } from "@/runtime/persistence/schema"
+import { Persist, persisted } from "@/runtime/persistence/storage"
+import { createPresence } from "@/runtime/presence"
+
+const dismissalDuration = 30 * 24 * 60 * 60 * 1000
+
+export const ProviderTipSchema = Persistence.struct({
+ dismissedAt: Schema.Finite,
+})
+
+// Undefined directory reads the server's default Location.
+export function createProviderTip(directory: Accessor) {
+ const providers = useProviders(directory)
+
+ const [state, setState, , ready] = persisted(Persist.global("new-session.provider-tip"), ProviderTipSchema, {
+ dismissedAt: 0,
+ })
+
+ return {
+ directory,
+ visible: createMemo(
+ () => ready() && providers.anyConnection() === false && Date.now() - state.dismissedAt >= dismissalDuration,
+ ),
+ dismiss: () => setState("dismissedAt", Date.now()),
+ }
+}
+
+export function ProviderTip(props: {
+ tip: ReturnType
+ selection?: ModelSelection
+ onDone?: () => void
+}) {
+ const language = useLanguage()
+ const dialog = useDialog()
+ const [ref, setRef] = createSignal()
+
+ const presence = createPresence({
+ show: props.tip.visible,
+ element: () => ref() ?? null,
+ })
+
+ const open = () => {
+ if (!props.tip.visible()) return
+ const directory = props.tip.directory()
+
+ void import("@/providers/connect/dialog").then(({ DialogConnectProvider }) => {
+ void dialog.show(() => (
+
+ ))
+ })
+ }
+
+ const dismiss = () => {
+ if (!props.tip.visible()) return
+ props.tip.dismiss()
+ }
+
+ return (
+
+
+
+
+ {language.t("home.providerTip")}
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
diff --git a/packages/app/src/providers/models/manage.css b/packages/app/src/providers/models/manage.css
index d9bc9b4f3048..03ebdef21cd6 100644
--- a/packages/app/src/providers/models/manage.css
+++ b/packages/app/src/providers/models/manage.css
@@ -1,6 +1,11 @@
.manage-models-search {
flex-shrink: 0;
- padding: 0 6px 8px;
+ padding: 0 8px 8px;
+}
+
+/* Reaches the dialog edges past the 8px inset, as in the integrations dialog. */
+.manage-models-search.search-dialog-search::after {
+ margin-inline: -8px;
}
.settings-manage-models-dialog .settings-panel.settings-models {
diff --git a/packages/app/src/providers/models/manage.tsx b/packages/app/src/providers/models/manage.tsx
index b7e01403b31e..9bae0bc241ea 100644
--- a/packages/app/src/providers/models/manage.tsx
+++ b/packages/app/src/providers/models/manage.tsx
@@ -102,7 +102,7 @@ export const DialogManageModels: Component = () => {
title={language.t("dialog.model.manage")}
description={language.t("dialog.model.manage.description")}
/>
-
+
{language.t("command.provider.connect")}
@@ -111,7 +111,7 @@ export const DialogManageModels: Component = () => {
}
value={list.filter()}
onInput={(event) => list.onInput(event.currentTarget.value)}
diff --git a/packages/app/src/providers/models/select-dialog.tsx b/packages/app/src/providers/models/select-dialog.tsx
index 73feba571623..911f61a67e67 100644
--- a/packages/app/src/providers/models/select-dialog.tsx
+++ b/packages/app/src/providers/models/select-dialog.tsx
@@ -195,7 +195,7 @@ const ModelList: Component<{
data-component="settings-row"
data-option-key={modelKey(item)}
aria-pressed={controller.current() === modelKey(item)}
- class="-mx-4 w-[calc(100%+32px)] px-4 text-start first:rounded-t-lg last:rounded-b-lg hover:bg-v2-overlay-simple-overlay-hover focus-visible:bg-v2-overlay-simple-overlay-hover focus-visible:outline-none"
+ class="-mx-4 w-[calc(100%+32px)] px-4 text-start first:rounded-t-lg last:rounded-b-lg hover:bg-v2-overlay-simple-overlay-hover focus-visible:-outline-offset-2"
classList={{ "bg-v2-overlay-simple-overlay-hover": store.active === modelKey(item) }}
onMouseEnter={() => setStore("active", modelKey(item))}
onMouseLeave={() => setStore("active", "")}
diff --git a/packages/app/src/providers/models/unpaid.tsx b/packages/app/src/providers/models/unpaid.tsx
index 4abbfb1c5184..87cdb1d92376 100644
--- a/packages/app/src/providers/models/unpaid.tsx
+++ b/packages/app/src/providers/models/unpaid.tsx
@@ -84,7 +84,7 @@ export const DialogSelectModelUnpaid: Component<{ model?: ModelState }> = (props
-
+
{language.t("dialog.model.unpaid.addMore.title")}
@@ -152,11 +158,11 @@ export const DialogSelectModelUnpaid: Component<{ model?: ModelState }> = (props
openProviders(provider.id)}
>
@@ -170,7 +176,7 @@ export const DialogSelectModelUnpaid: Component<{ model?: ModelState }> = (props
{language.t(
provider.id === "opencode"
- ? "dialog.provider.opencode.tagline"
+ ? "dialog.provider.opencode.note"
: "dialog.provider.opencodeGo.tagline",
)}
@@ -181,7 +187,7 @@ export const DialogSelectModelUnpaid: Component<{ model?: ModelState }> = (props
openProviders()}
>
{language.t("dialog.model.unpaid.viewMoreProviders")}
diff --git a/packages/app/src/runtime/i18n/am.ts b/packages/app/src/runtime/i18n/am.ts
index 8b2679e096ba..8b08f8e3ad36 100644
--- a/packages/app/src/runtime/i18n/am.ts
+++ b/packages/app/src/runtime/i18n/am.ts
@@ -1078,10 +1078,13 @@ export const dict = {
"session.timeline.status.working": "በመስራት ላይ",
"session.running.stop.subagent": "ንዑስ ወኪሉን አቋርጥ",
"session.running.stop.shell": "የሼል ትዕዛዙን አቁም",
+ "session.running.stop.script": "ስክሪፕቱን ሰርዝ",
"session.activity.subagents.one": "{{count}} ንዑስ ወኪል",
"session.activity.subagents.other": "{{count}} ንዑስ ወኪሎች",
"session.activity.shells.one": "{{count}} ሼል",
"session.activity.shells.other": "{{count}} ሼሎች",
+ "session.activity.scripts.one": "{{count}} ስክሪፕት",
+ "session.activity.scripts.other": "{{count}} ስክሪፕቶች",
"session.activity.shell.back": "ወደ ዳራ ሥራ ተመለስ",
"session.activity.shell.stop": "አቁም",
"session.activity.shell.stopping": "በማቆም ላይ…",
diff --git a/packages/app/src/runtime/i18n/ar.ts b/packages/app/src/runtime/i18n/ar.ts
index 104ad94a5b97..572627a65c66 100644
--- a/packages/app/src/runtime/i18n/ar.ts
+++ b/packages/app/src/runtime/i18n/ar.ts
@@ -1177,6 +1177,7 @@ export const dict = {
"session.timeline.status.working": "جارٍ العمل",
"session.running.stop.subagent": "مقاطعة الوكيل الفرعي",
"session.running.stop.shell": "إنهاء أمر shell",
+ "session.running.stop.script": "إلغاء النص البرمجي",
"session.activity.subagents.zero": "{{count}} وكلاء فرعيين",
"session.activity.subagents.one": "{{count}} وكيل فرعي",
"session.activity.subagents.two": "{{count}} وكيلان فرعيان",
@@ -1189,6 +1190,12 @@ export const dict = {
"session.activity.shells.few": "{{count}} عمليات shell",
"session.activity.shells.many": "{{count}} عملية shell",
"session.activity.shells.other": "{{count}} عملية shell",
+ "session.activity.scripts.zero": "{{count}} نصوص برمجية",
+ "session.activity.scripts.one": "{{count}} نص برمجي",
+ "session.activity.scripts.two": "{{count}} نصان برمجيان",
+ "session.activity.scripts.few": "{{count}} نصوص برمجية",
+ "session.activity.scripts.many": "{{count}} نصًا برمجيًا",
+ "session.activity.scripts.other": "{{count}} نص برمجي",
"session.activity.shell.back": "العودة إلى العمل في الخلفية",
"session.activity.shell.stop": "إيقاف",
"session.activity.shell.stopping": "جارٍ الإيقاف…",
diff --git a/packages/app/src/runtime/i18n/az.ts b/packages/app/src/runtime/i18n/az.ts
index 0c0bee042dbf..845987f3e68f 100644
--- a/packages/app/src/runtime/i18n/az.ts
+++ b/packages/app/src/runtime/i18n/az.ts
@@ -1136,10 +1136,13 @@ export const dict = {
"session.timeline.status.working": "İşləyir",
"session.running.stop.subagent": "Alt-agenti dayandır",
"session.running.stop.shell": "Shell əmrini öldür",
+ "session.running.stop.script": "Skripti ləğv et",
"session.activity.subagents.one": "{{count}} alt-agent",
"session.activity.subagents.other": "{{count}} alt-agent",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shell",
+ "session.activity.scripts.one": "{{count}} skript",
+ "session.activity.scripts.other": "{{count}} skript",
"session.activity.shell.back": "Fon işlərinə qayıt",
"session.activity.shell.stop": "Dayandır",
"session.activity.shell.stopping": "Dayandırılır…",
diff --git a/packages/app/src/runtime/i18n/bg.ts b/packages/app/src/runtime/i18n/bg.ts
index e4abeeb0bdd2..0c1d0ae69363 100644
--- a/packages/app/src/runtime/i18n/bg.ts
+++ b/packages/app/src/runtime/i18n/bg.ts
@@ -1143,10 +1143,13 @@ export const dict = {
"session.timeline.status.working": "Работи",
"session.running.stop.subagent": "Прекъсване на субагента",
"session.running.stop.shell": "Прекратяване на командата shell",
+ "session.running.stop.script": "Отказване на скрипта",
"session.activity.subagents.one": "{{count}} субагент",
"session.activity.subagents.other": "{{count}} субагента",
"session.activity.shells.one": "{{count}} shell процес",
"session.activity.shells.other": "{{count}} shell процеса",
+ "session.activity.scripts.one": "{{count}} скрипт",
+ "session.activity.scripts.other": "{{count}} скрипта",
"session.activity.shell.back": "Назад към фоновата работа",
"session.activity.shell.stop": "Спиране",
"session.activity.shell.stopping": "Спиране…",
diff --git a/packages/app/src/runtime/i18n/bn.ts b/packages/app/src/runtime/i18n/bn.ts
index b8cc3132beac..77cb717562ae 100644
--- a/packages/app/src/runtime/i18n/bn.ts
+++ b/packages/app/src/runtime/i18n/bn.ts
@@ -1133,10 +1133,13 @@ export const dict = {
"session.timeline.status.working": "কাজ চলছে",
"session.running.stop.subagent": "সাবএজেন্ট থামান",
"session.running.stop.shell": "শেল কমান্ড বন্ধ করুন",
+ "session.running.stop.script": "স্ক্রিপ্ট বাতিল করুন",
"session.activity.subagents.one": "{{count}}টি সাবএজেন্ট",
"session.activity.subagents.other": "{{count}}টি সাবএজেন্ট",
"session.activity.shells.one": "{{count}}টি শেল",
"session.activity.shells.other": "{{count}}টি শেল",
+ "session.activity.scripts.one": "{{count}}টি স্ক্রিপ্ট",
+ "session.activity.scripts.other": "{{count}}টি স্ক্রিপ্ট",
"session.activity.shell.back": "ব্যাকগ্রাউন্ড কাজে ফিরে যান",
"session.activity.shell.stop": "থামান",
"session.activity.shell.stopping": "থামানো হচ্ছে…",
diff --git a/packages/app/src/runtime/i18n/br.ts b/packages/app/src/runtime/i18n/br.ts
index 2b7b8d6f2911..d80dad6ed7d8 100644
--- a/packages/app/src/runtime/i18n/br.ts
+++ b/packages/app/src/runtime/i18n/br.ts
@@ -1169,12 +1169,16 @@ export const dict = {
"session.timeline.status.working": "Trabalhando",
"session.running.stop.subagent": "Interromper subagente",
"session.running.stop.shell": "Encerrar comando shell",
+ "session.running.stop.script": "Cancelar script",
"session.activity.subagents.one": "{{count}} subagente",
"session.activity.subagents.many": "{{count}} subagentes",
"session.activity.subagents.other": "{{count}} subagentes",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.many": "{{count}} shells",
"session.activity.shells.other": "{{count}} shells",
+ "session.activity.scripts.one": "{{count}} script",
+ "session.activity.scripts.many": "{{count}} scripts",
+ "session.activity.scripts.other": "{{count}} scripts",
"session.activity.shell.back": "Voltar ao trabalho em segundo plano",
"session.activity.shell.stop": "Parar",
"session.activity.shell.stopping": "Parando…",
diff --git a/packages/app/src/runtime/i18n/bs.ts b/packages/app/src/runtime/i18n/bs.ts
index e59c20f1e5e8..b20c3fb3ce0b 100644
--- a/packages/app/src/runtime/i18n/bs.ts
+++ b/packages/app/src/runtime/i18n/bs.ts
@@ -1207,12 +1207,16 @@ export const dict = {
"session.timeline.status.working": "U toku",
"session.running.stop.subagent": "Prekini podagenta",
"session.running.stop.shell": "Prekini shell komandu",
+ "session.running.stop.script": "Otkaži skriptu",
"session.activity.subagents.one": "{{count}} podagent",
"session.activity.subagents.few": "{{count}} podagenta",
"session.activity.subagents.other": "{{count}} podagenata",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.few": "{{count}} shella",
"session.activity.shells.other": "{{count}} shellova",
+ "session.activity.scripts.one": "{{count}} skripta",
+ "session.activity.scripts.few": "{{count}} skripte",
+ "session.activity.scripts.other": "{{count}} skripti",
"session.activity.shell.back": "Nazad na rad u pozadini",
"session.activity.shell.stop": "Zaustavi",
"session.activity.shell.stopping": "Zaustavljanje…",
diff --git a/packages/app/src/runtime/i18n/ca.ts b/packages/app/src/runtime/i18n/ca.ts
index fdb7c65f1ec9..ec5078d6d611 100644
--- a/packages/app/src/runtime/i18n/ca.ts
+++ b/packages/app/src/runtime/i18n/ca.ts
@@ -1164,6 +1164,7 @@ export const dict = {
"session.timeline.status.working": "S'està treballant",
"session.running.stop.subagent": "Interromp el subagent",
"session.running.stop.shell": "Mata l'ordre del shell",
+ "session.running.stop.script": "Cancel·la l'script",
"session.activity.subagents.one": "{{count}} subagent",
"session.activity.subagents.other": "{{count}} subagents",
"session.activity.shells.one": "{{count}} shell",
@@ -1501,6 +1502,9 @@ export const dict = {
"session.todo.label.many": "{{done}} de {{count}} tasques fetes",
"session.activity.subagents.many": "{{count}} subagents",
"session.activity.shells.many": "{{count}} shells",
+ "session.activity.scripts.one": "{{count}} script",
+ "session.activity.scripts.other": "{{count}} scripts",
+ "session.activity.scripts.many": "{{count}} scripts",
"sidebar.inbox.elapsed.seconds.many": "{{count}} s",
"sidebar.inbox.elapsed.minutes.many": "{{count}} min",
"sidebar.inbox.elapsed.hours.many": "{{count}} h",
diff --git a/packages/app/src/runtime/i18n/cs.ts b/packages/app/src/runtime/i18n/cs.ts
index f868bee5fe11..29e9fa0e672c 100644
--- a/packages/app/src/runtime/i18n/cs.ts
+++ b/packages/app/src/runtime/i18n/cs.ts
@@ -1157,6 +1157,7 @@ export const dict = {
"session.timeline.status.working": "Pracuje",
"session.running.stop.subagent": "Přerušit podagenta",
"session.running.stop.shell": "Ukončit příkaz shellu",
+ "session.running.stop.script": "Zrušit skript",
"session.activity.subagents.one": "{{count}} podagent",
"session.activity.subagents.few": "{{count}} podagenti",
"session.activity.subagents.many": "{{count}} podagentů",
@@ -1165,6 +1166,10 @@ export const dict = {
"session.activity.shells.few": "{{count}} shelly",
"session.activity.shells.many": "{{count}} shellů",
"session.activity.shells.other": "{{count}} shellů",
+ "session.activity.scripts.one": "{{count}} skript",
+ "session.activity.scripts.few": "{{count}} skripty",
+ "session.activity.scripts.many": "{{count}} skriptu",
+ "session.activity.scripts.other": "{{count}} skriptů",
"session.activity.shell.back": "Zpět na práci na pozadí",
"session.activity.shell.stop": "Zastavit",
"session.activity.shell.stopping": "Zastavování…",
diff --git a/packages/app/src/runtime/i18n/da.ts b/packages/app/src/runtime/i18n/da.ts
index 2699df8704ed..785b05199872 100644
--- a/packages/app/src/runtime/i18n/da.ts
+++ b/packages/app/src/runtime/i18n/da.ts
@@ -1185,10 +1185,13 @@ export const dict = {
"session.timeline.status.working": "Arbejder",
"session.running.stop.subagent": "Afbryd underagent",
"session.running.stop.shell": "Afslut shell-kommando",
+ "session.running.stop.script": "Annuller script",
"session.activity.subagents.one": "{{count}} underagent",
"session.activity.subagents.other": "{{count}} underagenter",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shells",
+ "session.activity.scripts.one": "{{count}} script",
+ "session.activity.scripts.other": "{{count}} scripts",
"session.activity.shell.back": "Tilbage til baggrundsarbejde",
"session.activity.shell.stop": "Stop",
"session.activity.shell.stopping": "Stopper…",
diff --git a/packages/app/src/runtime/i18n/de.ts b/packages/app/src/runtime/i18n/de.ts
index cd096891dd59..a2b22e95618c 100644
--- a/packages/app/src/runtime/i18n/de.ts
+++ b/packages/app/src/runtime/i18n/de.ts
@@ -1167,10 +1167,13 @@ export const dict = {
"session.timeline.status.working": "In Arbeit",
"session.running.stop.subagent": "Unteragent unterbrechen",
"session.running.stop.shell": "Shell-Befehl beenden",
+ "session.running.stop.script": "Skript abbrechen",
"session.activity.subagents.one": "{{count}} Unteragent",
"session.activity.subagents.other": "{{count}} Unteragenten",
"session.activity.shells.one": "{{count}} Shell",
"session.activity.shells.other": "{{count}} Shells",
+ "session.activity.scripts.one": "{{count}} Skript",
+ "session.activity.scripts.other": "{{count}} Skripte",
"session.activity.shell.back": "Zurück zur Hintergrundarbeit",
"session.activity.shell.stop": "Stoppen",
"session.activity.shell.stopping": "Wird gestoppt…",
diff --git a/packages/app/src/runtime/i18n/desktop-native.ts b/packages/app/src/runtime/i18n/desktop-native.ts
index e9ac685bdb2b..c1d3fca0c438 100644
--- a/packages/app/src/runtime/i18n/desktop-native.ts
+++ b/packages/app/src/runtime/i18n/desktop-native.ts
@@ -232,7 +232,8 @@ function locale(value: string) {
const normalizeScript = (script?: string) => (script === "Aran" ? "Arab" : script)
export const DESKTOP_NATIVE_ENGLISH = {
- "desktop.microphoneUsage": "OpenCode uses your microphone for voice calls.",
+ "desktop.microphoneUsage": "OpenCode uses your microphone for voice calls and lets websites you allow in the browser pane use it.",
+ "desktop.cameraUsage": "OpenCode lets websites you allow in the browser pane use your camera.",
"desktop.documentsFolderUsage":
"OpenCode uses files in your Documents folder for projects you open and commands you run there.",
"desktop.desktopFolderUsage": "OpenCode uses files on your Desktop for projects you open and commands you run there.",
diff --git a/packages/app/src/runtime/i18n/dv.ts b/packages/app/src/runtime/i18n/dv.ts
index f4867eb1e12e..1ad64f39bc7d 100644
--- a/packages/app/src/runtime/i18n/dv.ts
+++ b/packages/app/src/runtime/i18n/dv.ts
@@ -1171,10 +1171,13 @@ export const dict = {
"session.timeline.status.working": "މަސައްކަތް ކުރަމުން",
"session.running.stop.subagent": "ސަބްއޭޖެންޓް މެދުކަނޑާލާ",
"session.running.stop.shell": "ޝެލް ކޮމާންޑް ހުއްޓާލާ",
+ "session.running.stop.script": "ސްކްރިޕްޓް ކެންސަލް ކުރޭ",
"session.activity.subagents.one": "{{count}} ސަބްއޭޖެންޓް",
"session.activity.subagents.other": "{{count}} ސަބްއޭޖެންޓުން",
"session.activity.shells.one": "{{count}} ޝެލް",
"session.activity.shells.other": "{{count}} ޝެލްތައް",
+ "session.activity.scripts.one": "{{count}} ސްކްރިޕްޓް",
+ "session.activity.scripts.other": "{{count}} ސްކްރިޕްޓްތައް",
"session.activity.shell.back": "ބެކްގްރައުންޑް މަސައްކަތަށް އެނބުރި",
"session.activity.shell.stop": "ހުއްޓާލާ",
"session.activity.shell.stopping": "ހުއްޓާލަމުން…",
diff --git a/packages/app/src/runtime/i18n/dz.ts b/packages/app/src/runtime/i18n/dz.ts
index d71b39a33e93..f094a118d9e8 100644
--- a/packages/app/src/runtime/i18n/dz.ts
+++ b/packages/app/src/runtime/i18n/dz.ts
@@ -1156,10 +1156,13 @@ export const dict = {
"session.timeline.status.working": "ལཱ་འབད་དོ།",
"session.running.stop.subagent": "ཡན་ལག་ལས་ཚབ་བར་ཆད་བཟོ།",
"session.running.stop.shell": "Shell བརྡ་བཀོད་བཀག",
+ "session.running.stop.script": "Script ཆ་མེད་གཏང་",
"session.activity.subagents.one": "ཡན་ལག་ལས་ཚབ་ {{count}}",
"session.activity.subagents.other": "ཡན་ལག་ལས་ཚབ་ {{count}}",
"session.activity.shells.one": "Shell {{count}}",
"session.activity.shells.other": "Shell {{count}}",
+ "session.activity.scripts.one": "Script {{count}}",
+ "session.activity.scripts.other": "Script {{count}}",
"session.activity.shell.back": "རྒྱབ་གཞིའི་ལཱ་ལུ་ལོག",
"session.activity.shell.stop": "བཀག",
"session.activity.shell.stopping": "བཀག་དོ…",
diff --git a/packages/app/src/runtime/i18n/el.ts b/packages/app/src/runtime/i18n/el.ts
index 5eb6a1d64787..356f5b479eb0 100644
--- a/packages/app/src/runtime/i18n/el.ts
+++ b/packages/app/src/runtime/i18n/el.ts
@@ -1160,10 +1160,13 @@ export const dict = {
"session.timeline.status.working": "Εργάζεται",
"session.running.stop.subagent": "Διακοπή υποπράκτορα",
"session.running.stop.shell": "Τερματισμός εντολής κελύφους",
+ "session.running.stop.script": "Ακύρωση σεναρίου",
"session.activity.subagents.one": "{{count}} υποπράκτορας",
"session.activity.subagents.other": "{{count}} υποπράκτορες",
"session.activity.shells.one": "{{count}} κέλυφος",
"session.activity.shells.other": "{{count}} κελύφη",
+ "session.activity.scripts.one": "{{count}} σενάριο",
+ "session.activity.scripts.other": "{{count}} σενάρια",
"session.activity.shell.back": "Πίσω στην εργασία παρασκηνίου",
"session.activity.shell.stop": "Διακοπή",
"session.activity.shell.stopping": "Διακοπή…",
diff --git a/packages/app/src/runtime/i18n/en.ts b/packages/app/src/runtime/i18n/en.ts
index eef90e0c0b1d..7540701a82f9 100644
--- a/packages/app/src/runtime/i18n/en.ts
+++ b/packages/app/src/runtime/i18n/en.ts
@@ -218,6 +218,13 @@ export const dict = {
"provider.connect.chatgptUsageLimit.description": "Check your usage and limits in ChatGPT settings.",
"provider.connect.chatgptUsageLimit.manage": "Manage usage",
"provider.connect.chatgptUsageLimit.close": "Close",
+ "provider.connect.chatgptUsageLimit.workspaceDescription":
+ "You've reached your workspace's limit for using your ChatGPT plan in other apps. Copy a message below to ask your workspace admin for increased usage limits.",
+ "provider.connect.chatgptUsageLimit.copyRequest": "Copy request for admin",
+ "provider.connect.chatgptUsageLimit.requestCopied": "Request copied. Send it to your workspace admin.",
+ "provider.connect.chatgptUsageLimit.requestCopyFailed": "Couldn't copy. Send this to your workspace admin:",
+ "provider.connect.chatgptUsageLimit.request":
+ "I've reached the limit for using my ChatGPT plan in OpenCode. Could you increase our workspace's usage limits so I can continue?\n\nGo to admin.openai.com → Workspace → Usage limits. Thank you!",
"provider.connect.console.refreshFailed":
"Your account is connected, but we couldn't load your models. Try again to refresh them.",
"provider.connect.console.connected": "OpenCode connected",
@@ -606,7 +613,8 @@ export const dict = {
"tips.browse.description": "Let OpenCode work in your browser with your tabs, logins, and extensions.",
"tips.browse.install": "Install",
"tips.hex.title": "Use your voice",
- "tips.hex.description": "Hex lets you hold a key and speak your prompts. It runs on your computer and works in any app.",
+ "tips.hex.description":
+ "Hex lets you hold a key and speak your prompts. It runs on your computer and works in any app.",
"tips.hex.install": "Install Hex",
"home.workspaceTip": "Start next session in a new workspace to keep changes isolated",
@@ -673,6 +681,7 @@ export const dict = {
"session.timeline.status.working": "Working",
"session.running.stop.subagent": "Interrupt subagent",
"session.running.stop.shell": "Kill shell command",
+ "session.running.stop.script": "Cancel script",
"session.files.selectToOpen": "Select a file to open",
@@ -682,6 +691,8 @@ export const dict = {
"session.activity.subagents.other": "{{count}} subagents",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shells",
+ "session.activity.scripts.one": "{{count}} script",
+ "session.activity.scripts.other": "{{count}} scripts",
"session.activity.shell.back": "Back to background work",
"session.activity.shell.stop": "Stop",
"session.activity.shell.stopping": "Stopping…",
@@ -876,8 +887,7 @@ export const dict = {
"settings.experimental.row.newQuestionUI.title": "New question UI",
"settings.experimental.row.newQuestionUI.description": "Preview the keyboard-first question dock",
"settings.experimental.row.tabGroups.title": "Tab groups",
- "settings.experimental.row.tabGroups.description":
- "Group session tabs in side tabs with inline session search",
+ "settings.experimental.row.tabGroups.description": "Group session tabs in side tabs with inline session search",
"settings.experimental.row.sidebarOrganize.title": "Organize vertical sidebar",
"settings.experimental.row.sidebarOrganize.description":
"Choose how to organize sessions in side tabs. On desktop, Customize replaces Home with Settings in the sidebar.",
@@ -1199,6 +1209,8 @@ export const dict = {
"settings.general.row.showCustomAgents.title": "Show agent",
"settings.general.row.showCustomAgents.description":
"Switch between agents in the composer. When hidden, defaults to Build agent.",
+ "settings.general.row.sharedSidePanel.title": "Keep side panel open across sessions",
+ "settings.general.row.sharedSidePanel.description": "Opening or closing it in one session applies to all",
"settings.general.row.followUpBehavior.title": "Follow-up behavior",
"settings.general.row.followUpBehavior.description":
"Choose whether to queue follow-ups or steer the current turn. Use {{keybind}} to switch.",
diff --git a/packages/app/src/runtime/i18n/es.ts b/packages/app/src/runtime/i18n/es.ts
index d04589d0dc94..902d30beff01 100644
--- a/packages/app/src/runtime/i18n/es.ts
+++ b/packages/app/src/runtime/i18n/es.ts
@@ -1223,6 +1223,7 @@ export const dict = {
"session.timeline.status.working": "Trabajando",
"session.running.stop.subagent": "Interrumpir subagente",
"session.running.stop.shell": "Detener comando de shell",
+ "session.running.stop.script": "Cancelar script",
"session.activity.subagents.one": "{{count}} subagente",
"session.activity.subagents.other": "{{count}} subagentes",
"session.activity.shells.one": "{{count}} shell",
@@ -1561,6 +1562,9 @@ export const dict = {
"session.todo.label.many": "{{done}} de {{count}} tareas completadas",
"session.activity.subagents.many": "{{count}} subagentes",
"session.activity.shells.many": "{{count}} shells",
+ "session.activity.scripts.one": "{{count}} script",
+ "session.activity.scripts.other": "{{count}} scripts",
+ "session.activity.scripts.many": "{{count}} scripts",
"sidebar.inbox.elapsed.seconds.many": "{{count}} s",
"sidebar.inbox.elapsed.minutes.many": "{{count}} min",
"sidebar.inbox.elapsed.hours.many": "{{count}} h",
diff --git a/packages/app/src/runtime/i18n/et.ts b/packages/app/src/runtime/i18n/et.ts
index a340695525b3..b8c9d08e7e28 100644
--- a/packages/app/src/runtime/i18n/et.ts
+++ b/packages/app/src/runtime/i18n/et.ts
@@ -1118,10 +1118,13 @@ export const dict = {
"session.timeline.status.working": "Töötab",
"session.running.stop.subagent": "Katkesta alamagent",
"session.running.stop.shell": "Lõpeta shellikäsk",
+ "session.running.stop.script": "Tühista skript",
"session.activity.subagents.one": "{{count}} alamagent",
"session.activity.subagents.other": "{{count}} alamagenti",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shelli",
+ "session.activity.scripts.one": "{{count}} skript",
+ "session.activity.scripts.other": "{{count}} skripti",
"session.activity.shell.back": "Tagasi taustatöö juurde",
"session.activity.shell.stop": "Peata",
"session.activity.shell.stopping": "Peatamine…",
diff --git a/packages/app/src/runtime/i18n/fa.ts b/packages/app/src/runtime/i18n/fa.ts
index fe9bd62cbeef..3508bd411b72 100644
--- a/packages/app/src/runtime/i18n/fa.ts
+++ b/packages/app/src/runtime/i18n/fa.ts
@@ -1125,10 +1125,13 @@ export const dict = {
"session.timeline.status.working": "در حال کار",
"session.running.stop.subagent": "قطع عامل فرعی",
"session.running.stop.shell": "پایان دادن به دستور پوسته",
+ "session.running.stop.script": "لغو اسکریپت",
"session.activity.subagents.one": "{{count}} عامل فرعی",
"session.activity.subagents.other": "{{count}} عامل فرعی",
"session.activity.shells.one": "{{count}} پوسته",
"session.activity.shells.other": "{{count}} پوسته",
+ "session.activity.scripts.one": "{{count}} اسکریپت",
+ "session.activity.scripts.other": "{{count}} اسکریپت",
"session.activity.shell.back": "بازگشت به کارهای پسزمینه",
"session.activity.shell.stop": "توقف",
"session.activity.shell.stopping": "در حال توقف…",
diff --git a/packages/app/src/runtime/i18n/fi.ts b/packages/app/src/runtime/i18n/fi.ts
index b4f2420d21d1..404b19b25115 100644
--- a/packages/app/src/runtime/i18n/fi.ts
+++ b/packages/app/src/runtime/i18n/fi.ts
@@ -1130,10 +1130,13 @@ export const dict = {
"session.timeline.status.working": "Työskennellään",
"session.running.stop.subagent": "Keskeytä aliagentti",
"session.running.stop.shell": "Lopeta shell-komento",
+ "session.running.stop.script": "Peruuta skripti",
"session.activity.subagents.one": "{{count}} aliagentti",
"session.activity.subagents.other": "{{count}} aliagenttia",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shelliä",
+ "session.activity.scripts.one": "{{count}} skripti",
+ "session.activity.scripts.other": "{{count}} skriptiä",
"session.activity.shell.back": "Takaisin taustatyöhön",
"session.activity.shell.stop": "Pysäytä",
"session.activity.shell.stopping": "Pysäytetään…",
diff --git a/packages/app/src/runtime/i18n/fo.ts b/packages/app/src/runtime/i18n/fo.ts
index 86a10dac432a..b47acdacb166 100644
--- a/packages/app/src/runtime/i18n/fo.ts
+++ b/packages/app/src/runtime/i18n/fo.ts
@@ -1125,10 +1125,13 @@ export const dict = {
"session.timeline.status.working": "Arbeiðir",
"session.running.stop.subagent": "Avbrót undiragent",
"session.running.stop.shell": "Drep shell-skipan",
+ "session.running.stop.script": "Ógilda skript",
"session.activity.subagents.one": "{{count}} undiragentur",
"session.activity.subagents.other": "{{count}} undiragentar",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shells",
+ "session.activity.scripts.one": "{{count}} skript",
+ "session.activity.scripts.other": "{{count}} skript",
"session.activity.shell.back": "Aftur til bakgrundsarbeiði",
"session.activity.shell.stop": "Steðga",
"session.activity.shell.stopping": "Steðgar…",
diff --git a/packages/app/src/runtime/i18n/fr.ts b/packages/app/src/runtime/i18n/fr.ts
index f44ba38c5148..ce306768e9d9 100644
--- a/packages/app/src/runtime/i18n/fr.ts
+++ b/packages/app/src/runtime/i18n/fr.ts
@@ -1182,12 +1182,16 @@ export const dict = {
"session.timeline.status.working": "En cours",
"session.running.stop.subagent": "Interrompre le sous-agent",
"session.running.stop.shell": "Arrêter la commande shell",
+ "session.running.stop.script": "Annuler le script",
"session.activity.subagents.one": "{{count}} sous-agent",
"session.activity.subagents.many": "{{count}} sous-agents",
"session.activity.subagents.other": "{{count}} sous-agents",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.many": "{{count}} shells",
"session.activity.shells.other": "{{count}} shells",
+ "session.activity.scripts.one": "{{count}} script",
+ "session.activity.scripts.many": "{{count}} scripts",
+ "session.activity.scripts.other": "{{count}} scripts",
"session.activity.shell.back": "Retour aux tâches en arrière-plan",
"session.activity.shell.stop": "Arrêter",
"session.activity.shell.stopping": "Arrêt…",
diff --git a/packages/app/src/runtime/i18n/he.ts b/packages/app/src/runtime/i18n/he.ts
index 52c2f1a0fadd..a9e9d33a47fe 100644
--- a/packages/app/src/runtime/i18n/he.ts
+++ b/packages/app/src/runtime/i18n/he.ts
@@ -1110,12 +1110,16 @@ export const dict = {
"session.timeline.status.working": "עובד",
"session.running.stop.subagent": "עצור את סוכן המשנה",
"session.running.stop.shell": "הפסק את פקודת המעטפת",
+ "session.running.stop.script": "בטל את הסקריפט",
"session.activity.subagents.one": "{{count}} סוכן משנה",
"session.activity.subagents.two": "{{count}} סוכני משנה",
"session.activity.subagents.other": "{{count}} סוכני משנה",
"session.activity.shells.one": "{{count}} מעטפת",
"session.activity.shells.two": "{{count}} מעטפות",
"session.activity.shells.other": "{{count}} מעטפות",
+ "session.activity.scripts.one": "{{count}} סקריפט",
+ "session.activity.scripts.two": "{{count}} סקריפטים",
+ "session.activity.scripts.other": "{{count}} סקריפטים",
"session.activity.shell.back": "חזרה לעבודה ברקע",
"session.activity.shell.stop": "עצור",
"session.activity.shell.stopping": "עוצר…",
diff --git a/packages/app/src/runtime/i18n/hi.ts b/packages/app/src/runtime/i18n/hi.ts
index edfa0d4b239b..294b90257ee3 100644
--- a/packages/app/src/runtime/i18n/hi.ts
+++ b/packages/app/src/runtime/i18n/hi.ts
@@ -1134,10 +1134,13 @@ export const dict = {
"session.timeline.status.working": "कार्य जारी है",
"session.running.stop.subagent": "सबएजेंट को बाधित करें",
"session.running.stop.shell": "शेल कमांड समाप्त करें",
+ "session.running.stop.script": "स्क्रिप्ट रद्द करें",
"session.activity.subagents.one": "{{count}} सबएजेंट",
"session.activity.subagents.other": "{{count}} सबएजेंट",
"session.activity.shells.one": "{{count}} शेल",
"session.activity.shells.other": "{{count}} शेल",
+ "session.activity.scripts.one": "{{count}} स्क्रिप्ट",
+ "session.activity.scripts.other": "{{count}} स्क्रिप्ट",
"session.activity.shell.back": "बैकग्राउंड कार्य पर वापस जाएँ",
"session.activity.shell.stop": "रोकें",
"session.activity.shell.stopping": "रोका जा रहा है…",
diff --git a/packages/app/src/runtime/i18n/hr.ts b/packages/app/src/runtime/i18n/hr.ts
index 380424071459..4873c20c109e 100644
--- a/packages/app/src/runtime/i18n/hr.ts
+++ b/packages/app/src/runtime/i18n/hr.ts
@@ -1151,12 +1151,16 @@ export const dict = {
"session.timeline.status.working": "U tijeku",
"session.running.stop.subagent": "Prekini podagenta",
"session.running.stop.shell": "Prekini naredbu ljuske",
+ "session.running.stop.script": "Otkaži skriptu",
"session.activity.subagents.one": "{{count}} podagent",
"session.activity.subagents.few": "{{count}} podagenta",
"session.activity.subagents.other": "{{count}} podagenata",
"session.activity.shells.one": "{{count}} ljuska",
"session.activity.shells.few": "{{count}} ljuske",
"session.activity.shells.other": "{{count}} ljuski",
+ "session.activity.scripts.one": "{{count}} skripta",
+ "session.activity.scripts.few": "{{count}} skripte",
+ "session.activity.scripts.other": "{{count}} skripti",
"session.activity.shell.back": "Natrag na pozadinski rad",
"session.activity.shell.stop": "Zaustavi",
"session.activity.shell.stopping": "Zaustavljanje…",
diff --git a/packages/app/src/runtime/i18n/hu.ts b/packages/app/src/runtime/i18n/hu.ts
index 598372eb1f1c..f81d5b3e2a85 100644
--- a/packages/app/src/runtime/i18n/hu.ts
+++ b/packages/app/src/runtime/i18n/hu.ts
@@ -1144,10 +1144,13 @@ export const dict = {
"session.timeline.status.working": "Dolgozik",
"session.running.stop.subagent": "Alügynök megszakítása",
"session.running.stop.shell": "Shell parancs leállítása",
+ "session.running.stop.script": "Szkript megszakítása",
"session.activity.subagents.one": "{{count}} alügynök",
"session.activity.subagents.other": "{{count}} alügynök",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shell",
+ "session.activity.scripts.one": "{{count}} szkript",
+ "session.activity.scripts.other": "{{count}} szkript",
"session.activity.shell.back": "Vissza a háttérfolyamatokhoz",
"session.activity.shell.stop": "Leállítás",
"session.activity.shell.stopping": "Leállítás…",
diff --git a/packages/app/src/runtime/i18n/hy.ts b/packages/app/src/runtime/i18n/hy.ts
index 0d7c3194ece0..e39f97f750b2 100644
--- a/packages/app/src/runtime/i18n/hy.ts
+++ b/packages/app/src/runtime/i18n/hy.ts
@@ -1129,10 +1129,13 @@ export const dict = {
"session.timeline.status.working": "Աշխատում է",
"session.running.stop.subagent": "Ընդհատել ենթագործակալը",
"session.running.stop.shell": "Դադարեցնել shell հրամանը",
+ "session.running.stop.script": "Չեղարկել սկրիպտը",
"session.activity.subagents.one": "{{count}} ենթագործակալ",
"session.activity.subagents.other": "{{count}} ենթագործակալ",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shell",
+ "session.activity.scripts.one": "{{count}} սկրիպտ",
+ "session.activity.scripts.other": "{{count}} սկրիպտ",
"session.activity.shell.back": "Վերադառնալ ֆոնային աշխատանքին",
"session.activity.shell.stop": "Կանգնեցնել",
"session.activity.shell.stopping": "Կանգնեցվում է…",
diff --git a/packages/app/src/runtime/i18n/id.ts b/packages/app/src/runtime/i18n/id.ts
index 87f57c5a84c0..8312c9355c0c 100644
--- a/packages/app/src/runtime/i18n/id.ts
+++ b/packages/app/src/runtime/i18n/id.ts
@@ -1196,10 +1196,13 @@ export const dict = {
"session.timeline.status.working": "Bekerja",
"session.running.stop.subagent": "Hentikan subagen",
"session.running.stop.shell": "Matikan perintah shell",
+ "session.running.stop.script": "Batalkan skrip",
"session.activity.subagents.one": "{{count}} subagen",
"session.activity.subagents.other": "{{count}} subagen",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shell",
+ "session.activity.scripts.one": "{{count}} skrip",
+ "session.activity.scripts.other": "{{count}} skrip",
"session.activity.shell.back": "Kembali ke pekerjaan latar belakang",
"session.activity.shell.stop": "Hentikan",
"session.activity.shell.stopping": "Menghentikan…",
diff --git a/packages/app/src/runtime/i18n/is.ts b/packages/app/src/runtime/i18n/is.ts
index 56970f51f64e..318b9a136971 100644
--- a/packages/app/src/runtime/i18n/is.ts
+++ b/packages/app/src/runtime/i18n/is.ts
@@ -1125,10 +1125,13 @@ export const dict = {
"session.timeline.status.working": "Að vinna",
"session.running.stop.subagent": "Rjúfa undirfulltrúa",
"session.running.stop.shell": "Drepa skeljarskipun",
+ "session.running.stop.script": "Hætta við skriftu",
"session.activity.subagents.one": "{{count}} undirfulltrúi",
"session.activity.subagents.other": "{{count}} undirfulltrúar",
"session.activity.shells.one": "{{count}} skel",
"session.activity.shells.other": "{{count}} skeljar",
+ "session.activity.scripts.one": "{{count}} skrifta",
+ "session.activity.scripts.other": "{{count}} skriftur",
"session.activity.shell.back": "Til baka í bakgrunnsvinnu",
"session.activity.shell.stop": "Stöðva",
"session.activity.shell.stopping": "Stöðvar…",
diff --git a/packages/app/src/runtime/i18n/it.ts b/packages/app/src/runtime/i18n/it.ts
index 157e58abf57c..4ab0319c44a2 100644
--- a/packages/app/src/runtime/i18n/it.ts
+++ b/packages/app/src/runtime/i18n/it.ts
@@ -1158,6 +1158,7 @@ export const dict = {
"session.timeline.status.working": "In elaborazione",
"session.running.stop.subagent": "Interrompi subagente",
"session.running.stop.shell": "Termina comando shell",
+ "session.running.stop.script": "Annulla script",
"session.activity.subagents.one": "{{count}} subagente",
"session.activity.subagents.other": "{{count}} subagenti",
"session.activity.shells.one": "{{count}} shell",
@@ -1495,6 +1496,9 @@ export const dict = {
"session.todo.label.many": "{{done}} di {{count}} attività completate",
"session.activity.subagents.many": "{{count}} subagenti",
"session.activity.shells.many": "{{count}} shell",
+ "session.activity.scripts.one": "{{count}} script",
+ "session.activity.scripts.other": "{{count}} script",
+ "session.activity.scripts.many": "{{count}} script",
"sidebar.inbox.elapsed.seconds.many": "{{count}}s",
"sidebar.inbox.elapsed.minutes.many": "{{count}}m",
"sidebar.inbox.elapsed.hours.many": "{{count}}h",
diff --git a/packages/app/src/runtime/i18n/ja.ts b/packages/app/src/runtime/i18n/ja.ts
index eeda45c289ce..df8682145b14 100644
--- a/packages/app/src/runtime/i18n/ja.ts
+++ b/packages/app/src/runtime/i18n/ja.ts
@@ -1142,10 +1142,13 @@ export const dict = {
"session.timeline.status.working": "作業中",
"session.running.stop.subagent": "サブエージェントを中断",
"session.running.stop.shell": "シェルコマンドを強制終了",
+ "session.running.stop.script": "スクリプトをキャンセル",
"session.activity.subagents.one": "サブエージェント{{count}}件",
"session.activity.subagents.other": "サブエージェント{{count}}件",
"session.activity.shells.one": "シェル{{count}}件",
"session.activity.shells.other": "シェル{{count}}件",
+ "session.activity.scripts.one": "スクリプト{{count}}件",
+ "session.activity.scripts.other": "スクリプト{{count}}件",
"session.activity.shell.back": "バックグラウンド作業に戻る",
"session.activity.shell.stop": "停止",
"session.activity.shell.stopping": "停止中…",
diff --git a/packages/app/src/runtime/i18n/ka.ts b/packages/app/src/runtime/i18n/ka.ts
index c6e20d12aec5..fb1cb8e94ac0 100644
--- a/packages/app/src/runtime/i18n/ka.ts
+++ b/packages/app/src/runtime/i18n/ka.ts
@@ -1132,10 +1132,13 @@ export const dict = {
"session.timeline.status.working": "მუშაობს",
"session.running.stop.subagent": "ქვეაგენტის შეწყვეტა",
"session.running.stop.shell": "Shell ბრძანების შეწყვეტა",
+ "session.running.stop.script": "სკრიპტის გაუქმება",
"session.activity.subagents.one": "{{count}} ქვეაგენტი",
"session.activity.subagents.other": "{{count}} ქვეაგენტი",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shell",
+ "session.activity.scripts.one": "{{count}} სკრიპტი",
+ "session.activity.scripts.other": "{{count}} სკრიპტი",
"session.activity.shell.back": "ფონურ სამუშაოზე დაბრუნება",
"session.activity.shell.stop": "შეჩერება",
"session.activity.shell.stopping": "ჩერდება…",
diff --git a/packages/app/src/runtime/i18n/km.ts b/packages/app/src/runtime/i18n/km.ts
index f009ec9aed7b..8e69b83c063e 100644
--- a/packages/app/src/runtime/i18n/km.ts
+++ b/packages/app/src/runtime/i18n/km.ts
@@ -1120,10 +1120,13 @@ export const dict = {
"session.timeline.status.working": "កំពុងធ្វើការ",
"session.running.stop.subagent": "រំខានភ្នាក់ងាររង",
"session.running.stop.shell": "សម្លាប់ពាក្យបញ្ជាសែល",
+ "session.running.stop.script": "បោះបង់ស្គ្រីប",
"session.activity.subagents.one": "ភ្នាក់ងាររង {{count}}",
"session.activity.subagents.other": "ភ្នាក់ងាររង {{count}}",
"session.activity.shells.one": "សែល {{count}}",
"session.activity.shells.other": "សែល {{count}}",
+ "session.activity.scripts.one": "ស្គ្រីប {{count}}",
+ "session.activity.scripts.other": "ស្គ្រីប {{count}}",
"session.activity.shell.back": "ត្រឡប់ទៅការងារផ្ទៃខាងក្រោយ",
"session.activity.shell.stop": "ឈប់",
"session.activity.shell.stopping": "កំពុងឈប់…",
diff --git a/packages/app/src/runtime/i18n/ko.ts b/packages/app/src/runtime/i18n/ko.ts
index 9f6c75aaf471..01ee7cbd74b1 100644
--- a/packages/app/src/runtime/i18n/ko.ts
+++ b/packages/app/src/runtime/i18n/ko.ts
@@ -1129,10 +1129,13 @@ export const dict = {
"session.timeline.status.working": "작업 중",
"session.running.stop.subagent": "하위 에이전트 중단",
"session.running.stop.shell": "셸 명령 종료",
+ "session.running.stop.script": "스크립트 취소",
"session.activity.subagents.one": "하위 에이전트 {{count}}개",
"session.activity.subagents.other": "하위 에이전트 {{count}}개",
"session.activity.shells.one": "셸 {{count}}개",
"session.activity.shells.other": "셸 {{count}}개",
+ "session.activity.scripts.one": "스크립트 {{count}}개",
+ "session.activity.scripts.other": "스크립트 {{count}}개",
"session.activity.shell.back": "백그라운드 작업으로 돌아가기",
"session.activity.shell.stop": "중지",
"session.activity.shell.stopping": "중지 중…",
diff --git a/packages/app/src/runtime/i18n/language.tsx b/packages/app/src/runtime/i18n/language.tsx
index 4100d3560fe0..a3d12ce43061 100644
--- a/packages/app/src/runtime/i18n/language.tsx
+++ b/packages/app/src/runtime/i18n/language.tsx
@@ -347,15 +347,19 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
const plural = (key: PluralKey, count: number, params?: Record) =>
pluralForm(key, pluralCategory(intl(), count), { ...params, count })
- // "2 subagents · 1 shell", or one group alone, as the iOS app's background-work capsule reads.
- const activitySummary = (counts: { subagents: number; shells: number }) => {
- const subagents = counts.subagents ? plural("session.activity.subagents", counts.subagents) : undefined
- const shells = counts.shells ? plural("session.activity.shells", counts.shells) : undefined
-
- if (subagents && shells) return t("session.activity.summary", { subagents, shells })
-
- return subagents ?? shells ?? ""
- }
+ // "2 subagents · 1 script · 1 shell", or one group alone, as the iOS app's background-work capsule reads.
+ const activityGroups = (counts: { subagents: number; scripts?: number; shells: number }) =>
+ [
+ counts.subagents ? plural("session.activity.subagents", counts.subagents) : undefined,
+ counts.scripts ? plural("session.activity.scripts", counts.scripts) : undefined,
+ counts.shells ? plural("session.activity.shells", counts.shells) : undefined,
+ ].filter((group) => group !== undefined)
+
+ const activitySummary = (counts: { subagents: number; scripts?: number; shells: number }) =>
+ activityGroups(counts).reduceRight(
+ (rest, group) => (rest ? t("session.activity.summary", { subagents: group, shells: rest }) : group),
+ "",
+ )
const tDynamic = >(
key: TranslationKey,
@@ -374,16 +378,14 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
}
const activitySummaryRich = (
- counts: { subagents: number; shells: number },
+ counts: { subagents: number; scripts?: number; shells: number },
render: (label: string) => JSX.Element,
- ) => {
- if (!counts.subagents || !counts.shells) return render(activitySummary(counts))
-
- return rich("session.activity.summary", {
- subagents: render(activitySummary({ subagents: counts.subagents, shells: 0 })),
- shells: render(activitySummary({ subagents: 0, shells: counts.shells })),
- })
- }
+ ): JSX.Element =>
+ activityGroups(counts).reduceRight(
+ (rest, group) =>
+ rest ? rich("session.activity.summary", { subagents: render(group), shells: rest }) : render(group),
+ undefined,
+ ) ?? render("")
const list = (items: readonly JSX.Element[]) => localizedListParts(intl(), items)
diff --git a/packages/app/src/runtime/i18n/lo.ts b/packages/app/src/runtime/i18n/lo.ts
index 15f390d351ba..e15fe4f7f27f 100644
--- a/packages/app/src/runtime/i18n/lo.ts
+++ b/packages/app/src/runtime/i18n/lo.ts
@@ -1113,10 +1113,13 @@ export const dict = {
"session.timeline.status.working": "ກຳລັງເຮັດວຽກ",
"session.running.stop.subagent": "ຂັດຈັງຫວະຕົວແທນຍ່ອຍ",
"session.running.stop.shell": "ຢຸດຄຳສັ່ງ shell",
+ "session.running.stop.script": "ຍົກເລີກ script",
"session.activity.subagents.one": "{{count}} ຕົວແທນຍ່ອຍ",
"session.activity.subagents.other": "{{count}} ຕົວແທນຍ່ອຍ",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shell",
+ "session.activity.scripts.one": "{{count}} script",
+ "session.activity.scripts.other": "{{count}} script",
"session.activity.shell.back": "ກັບໄປທີ່ວຽກເບື້ອງຫຼັງ",
"session.activity.shell.stop": "ຢຸດ",
"session.activity.shell.stopping": "ກຳລັງຢຸດ…",
diff --git a/packages/app/src/runtime/i18n/lt.ts b/packages/app/src/runtime/i18n/lt.ts
index a0bfbfe0494c..1aee25f82204 100644
--- a/packages/app/src/runtime/i18n/lt.ts
+++ b/packages/app/src/runtime/i18n/lt.ts
@@ -1165,6 +1165,7 @@ export const dict = {
"session.timeline.status.working": "Dirbama",
"session.running.stop.subagent": "Nutraukti subagentą",
"session.running.stop.shell": "Nutraukti apvalkalo komandą",
+ "session.running.stop.script": "Atšaukti scenarijų",
"session.activity.subagents.one": "{{count}} subagentas",
"session.activity.subagents.few": "{{count}} subagentai",
"session.activity.subagents.many": "{{count}} subagento",
@@ -1173,6 +1174,10 @@ export const dict = {
"session.activity.shells.few": "{{count}} apvalkalai",
"session.activity.shells.many": "{{count}} apvalkalo",
"session.activity.shells.other": "{{count}} apvalkalų",
+ "session.activity.scripts.one": "{{count}} scenarijus",
+ "session.activity.scripts.few": "{{count}} scenarijai",
+ "session.activity.scripts.many": "{{count}} scenarijaus",
+ "session.activity.scripts.other": "{{count}} scenarijų",
"session.activity.shell.back": "Atgal į foninį darbą",
"session.activity.shell.stop": "Stabdyti",
"session.activity.shell.stopping": "Stabdoma…",
diff --git a/packages/app/src/runtime/i18n/lv.ts b/packages/app/src/runtime/i18n/lv.ts
index 5d92fee223f2..807f9abad5c8 100644
--- a/packages/app/src/runtime/i18n/lv.ts
+++ b/packages/app/src/runtime/i18n/lv.ts
@@ -1155,12 +1155,16 @@ export const dict = {
"session.timeline.status.working": "Darbojas",
"session.running.stop.subagent": "Pārtraukt apakšaģentu",
"session.running.stop.shell": "Apturēt čaulas komandu",
+ "session.running.stop.script": "Atcelt skriptu",
"session.activity.subagents.zero": "{{count}} apakšaģentu",
"session.activity.subagents.one": "{{count}} apakšaģents",
"session.activity.subagents.other": "{{count}} apakšaģenti",
"session.activity.shells.zero": "{{count}} čaulu",
"session.activity.shells.one": "{{count}} čaula",
"session.activity.shells.other": "{{count}} čaulas",
+ "session.activity.scripts.zero": "{{count}} skriptu",
+ "session.activity.scripts.one": "{{count}} skripts",
+ "session.activity.scripts.other": "{{count}} skripti",
"session.activity.shell.back": "Atpakaļ uz fona darbiem",
"session.activity.shell.stop": "Apturēt",
"session.activity.shell.stopping": "Aptur…",
diff --git a/packages/app/src/runtime/i18n/mk.ts b/packages/app/src/runtime/i18n/mk.ts
index 67d8be934ff8..61ed6e69b043 100644
--- a/packages/app/src/runtime/i18n/mk.ts
+++ b/packages/app/src/runtime/i18n/mk.ts
@@ -1140,10 +1140,13 @@ export const dict = {
"session.timeline.status.working": "Работи",
"session.running.stop.subagent": "Прекини го субагентот",
"session.running.stop.shell": "Прекини ја командата во школка",
+ "session.running.stop.script": "Откажи ја скриптата",
"session.activity.subagents.one": "{{count}} субагент",
"session.activity.subagents.other": "{{count}} субагенти",
"session.activity.shells.one": "{{count}} школка",
"session.activity.shells.other": "{{count}} школки",
+ "session.activity.scripts.one": "{{count}} скрипта",
+ "session.activity.scripts.other": "{{count}} скрипти",
"session.activity.shell.back": "Назад кон позадинската работа",
"session.activity.shell.stop": "Запри",
"session.activity.shell.stopping": "Се запира…",
diff --git a/packages/app/src/runtime/i18n/mn.ts b/packages/app/src/runtime/i18n/mn.ts
index b2656a3da1a2..a8bf40b40876 100644
--- a/packages/app/src/runtime/i18n/mn.ts
+++ b/packages/app/src/runtime/i18n/mn.ts
@@ -1140,10 +1140,13 @@ export const dict = {
"session.timeline.status.working": "Ажиллаж байна",
"session.running.stop.subagent": "Дэд агентыг тасалдуулах",
"session.running.stop.shell": "Shell командыг зогсоох",
+ "session.running.stop.script": "Скриптийг цуцлах",
"session.activity.subagents.one": "{{count}} дэд агент",
"session.activity.subagents.other": "{{count}} дэд агент",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shell",
+ "session.activity.scripts.one": "{{count}} скрипт",
+ "session.activity.scripts.other": "{{count}} скрипт",
"session.activity.shell.back": "Арын ажил руу буцах",
"session.activity.shell.stop": "Зогсоох",
"session.activity.shell.stopping": "Зогсоож байна…",
diff --git a/packages/app/src/runtime/i18n/ms.ts b/packages/app/src/runtime/i18n/ms.ts
index e791363c01cb..3bac49e3bc17 100644
--- a/packages/app/src/runtime/i18n/ms.ts
+++ b/packages/app/src/runtime/i18n/ms.ts
@@ -1133,10 +1133,13 @@ export const dict = {
"session.timeline.status.working": "Sedang bekerja",
"session.running.stop.subagent": "Ganggu subagen",
"session.running.stop.shell": "Matikan arahan shell",
+ "session.running.stop.script": "Batalkan skrip",
"session.activity.subagents.one": "{{count}} subagen",
"session.activity.subagents.other": "{{count}} subagen",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shell",
+ "session.activity.scripts.one": "{{count}} skrip",
+ "session.activity.scripts.other": "{{count}} skrip",
"session.activity.shell.back": "Kembali ke kerja latar belakang",
"session.activity.shell.stop": "Henti",
"session.activity.shell.stopping": "Menghentikan…",
diff --git a/packages/app/src/runtime/i18n/my.ts b/packages/app/src/runtime/i18n/my.ts
index 0ac342766a82..8557c5cfd69a 100644
--- a/packages/app/src/runtime/i18n/my.ts
+++ b/packages/app/src/runtime/i18n/my.ts
@@ -1141,10 +1141,13 @@ export const dict = {
"session.timeline.status.working": "လုပ်ဆောင်နေသည်",
"session.running.stop.subagent": "အေးဂျင့်ခွဲကို ရပ်တန့်ရန်",
"session.running.stop.shell": "Shell အမိန့်ကို ရပ်စဲရန်",
+ "session.running.stop.script": "Script ကို ပယ်ဖျက်ရန်",
"session.activity.subagents.one": "အေးဂျင့်ခွဲ {{count}} ခု",
"session.activity.subagents.other": "အေးဂျင့်ခွဲ {{count}} ခု",
"session.activity.shells.one": "Shell {{count}} ခု",
"session.activity.shells.other": "Shell {{count}} ခု",
+ "session.activity.scripts.one": "Script {{count}} ခု",
+ "session.activity.scripts.other": "Script {{count}} ခု",
"session.activity.shell.back": "နောက်ခံအလုပ်များသို့ ပြန်သွားရန်",
"session.activity.shell.stop": "ရပ်ရန်",
"session.activity.shell.stopping": "ရပ်နေသည်…",
diff --git a/packages/app/src/runtime/i18n/ne.ts b/packages/app/src/runtime/i18n/ne.ts
index 6a78fc84bdcf..f5eb2b3f9008 100644
--- a/packages/app/src/runtime/i18n/ne.ts
+++ b/packages/app/src/runtime/i18n/ne.ts
@@ -1132,10 +1132,13 @@ export const dict = {
"session.timeline.status.working": "काम हुँदै छ",
"session.running.stop.subagent": "उप-एजेन्ट रोक्नुहोस्",
"session.running.stop.shell": "शेल आदेश बन्द गर्नुहोस्",
+ "session.running.stop.script": "स्क्रिप्ट रद्द गर्नुहोस्",
"session.activity.subagents.one": "{{count}} उप-एजेन्ट",
"session.activity.subagents.other": "{{count}} उप-एजेन्टहरू",
"session.activity.shells.one": "{{count}} शेल",
"session.activity.shells.other": "{{count}} शेलहरू",
+ "session.activity.scripts.one": "{{count}} स्क्रिप्ट",
+ "session.activity.scripts.other": "{{count}} स्क्रिप्टहरू",
"session.activity.shell.back": "पृष्ठभूमि काममा फर्कनुहोस्",
"session.activity.shell.stop": "रोक्नुहोस्",
"session.activity.shell.stopping": "रोक्दै…",
diff --git a/packages/app/src/runtime/i18n/nl.ts b/packages/app/src/runtime/i18n/nl.ts
index da7aab1cd2d5..fc7f897656de 100644
--- a/packages/app/src/runtime/i18n/nl.ts
+++ b/packages/app/src/runtime/i18n/nl.ts
@@ -1146,10 +1146,13 @@ export const dict = {
"session.timeline.status.working": "Bezig",
"session.running.stop.subagent": "Subagent onderbreken",
"session.running.stop.shell": "Shell-opdracht beëindigen",
+ "session.running.stop.script": "Script annuleren",
"session.activity.subagents.one": "{{count}} subagent",
"session.activity.subagents.other": "{{count}} subagents",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shells",
+ "session.activity.scripts.one": "{{count}} script",
+ "session.activity.scripts.other": "{{count}} scripts",
"session.activity.shell.back": "Terug naar achtergrondwerk",
"session.activity.shell.stop": "Stoppen",
"session.activity.shell.stopping": "Stoppen…",
diff --git a/packages/app/src/runtime/i18n/no.ts b/packages/app/src/runtime/i18n/no.ts
index 97dc77bc7048..92432a05a565 100644
--- a/packages/app/src/runtime/i18n/no.ts
+++ b/packages/app/src/runtime/i18n/no.ts
@@ -1194,10 +1194,13 @@ export const dict = {
"session.timeline.status.working": "Arbeider",
"session.running.stop.subagent": "Avbryt underagent",
"session.running.stop.shell": "Avslutt shell-kommando",
+ "session.running.stop.script": "Avbryt skript",
"session.activity.subagents.one": "{{count}} underagent",
"session.activity.subagents.other": "{{count}} underagenter",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shell",
+ "session.activity.scripts.one": "{{count}} skript",
+ "session.activity.scripts.other": "{{count}} skript",
"session.activity.shell.back": "Tilbake til bakgrunnsarbeid",
"session.activity.shell.stop": "Stopp",
"session.activity.shell.stopping": "Stopper …",
diff --git a/packages/app/src/runtime/i18n/pa.ts b/packages/app/src/runtime/i18n/pa.ts
index b5fb046b64fe..61ebea6b45dc 100644
--- a/packages/app/src/runtime/i18n/pa.ts
+++ b/packages/app/src/runtime/i18n/pa.ts
@@ -1138,10 +1138,13 @@ export const dict = {
"session.timeline.status.working": "کم ہو رہیا اے",
"session.running.stop.subagent": "سب ایجنٹ روکو",
"session.running.stop.shell": "شیل کمانڈ بند کرو",
+ "session.running.stop.script": "سکرپٹ رد کرو",
"session.activity.subagents.one": "{{count}} سب ایجنٹ",
"session.activity.subagents.other": "{{count}} سب ایجنٹ",
"session.activity.shells.one": "{{count}} شیل",
"session.activity.shells.other": "{{count}} شیل",
+ "session.activity.scripts.one": "{{count}} سکرپٹ",
+ "session.activity.scripts.other": "{{count}} سکرپٹ",
"session.activity.shell.back": "پس منظر دے کم تے واپس جاؤ",
"session.activity.shell.stop": "روکو",
"session.activity.shell.stopping": "رُک رہیا اے…",
diff --git a/packages/app/src/runtime/i18n/pl.ts b/packages/app/src/runtime/i18n/pl.ts
index a80db90b832c..ecd7b8e5e272 100644
--- a/packages/app/src/runtime/i18n/pl.ts
+++ b/packages/app/src/runtime/i18n/pl.ts
@@ -1175,6 +1175,7 @@ export const dict = {
"session.timeline.status.working": "Pracuje",
"session.running.stop.subagent": "Przerwij podagenta",
"session.running.stop.shell": "Zakończ polecenie powłoki",
+ "session.running.stop.script": "Anuluj skrypt",
"session.activity.subagents.one": "{{count}} podagent",
"session.activity.subagents.few": "{{count}} podagenty",
"session.activity.subagents.many": "{{count}} podagentów",
@@ -1183,6 +1184,10 @@ export const dict = {
"session.activity.shells.few": "{{count}} powłoki",
"session.activity.shells.many": "{{count}} powłok",
"session.activity.shells.other": "{{count}} powłoki",
+ "session.activity.scripts.one": "{{count}} skrypt",
+ "session.activity.scripts.few": "{{count}} skrypty",
+ "session.activity.scripts.many": "{{count}} skryptów",
+ "session.activity.scripts.other": "{{count}} skryptu",
"session.activity.shell.back": "Wróć do pracy w tle",
"session.activity.shell.stop": "Zatrzymaj",
"session.activity.shell.stopping": "Zatrzymywanie…",
diff --git a/packages/app/src/runtime/i18n/ro.ts b/packages/app/src/runtime/i18n/ro.ts
index 29c11781d9d4..2bbe9d4ac28d 100644
--- a/packages/app/src/runtime/i18n/ro.ts
+++ b/packages/app/src/runtime/i18n/ro.ts
@@ -1154,12 +1154,16 @@ export const dict = {
"session.timeline.status.working": "Lucrează",
"session.running.stop.subagent": "Întrerupe subagentul",
"session.running.stop.shell": "Oprește forțat comanda shell",
+ "session.running.stop.script": "Anulează scriptul",
"session.activity.subagents.one": "{{count}} subagent",
"session.activity.subagents.few": "{{count}} subagenți",
"session.activity.subagents.other": "{{count}} de subagenți",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.few": "{{count}} shell-uri",
"session.activity.shells.other": "{{count}} de shell-uri",
+ "session.activity.scripts.one": "{{count}} script",
+ "session.activity.scripts.few": "{{count}} scripturi",
+ "session.activity.scripts.other": "{{count}} de scripturi",
"session.activity.shell.back": "Înapoi la activitatea din fundal",
"session.activity.shell.stop": "Oprește",
"session.activity.shell.stopping": "Se oprește…",
diff --git a/packages/app/src/runtime/i18n/ru.ts b/packages/app/src/runtime/i18n/ru.ts
index f8e7ef8bbad3..deb009d9e541 100644
--- a/packages/app/src/runtime/i18n/ru.ts
+++ b/packages/app/src/runtime/i18n/ru.ts
@@ -1229,6 +1229,7 @@ export const dict = {
"session.timeline.status.working": "Работает",
"session.running.stop.subagent": "Прервать субагента",
"session.running.stop.shell": "Завершить команду оболочки",
+ "session.running.stop.script": "Отменить скрипт",
"session.activity.subagents.one": "{{count}} субагент",
"session.activity.subagents.few": "{{count}} субагента",
"session.activity.subagents.many": "{{count}} субагентов",
@@ -1237,6 +1238,10 @@ export const dict = {
"session.activity.shells.few": "{{count}} оболочки",
"session.activity.shells.many": "{{count}} оболочек",
"session.activity.shells.other": "{{count}} оболочки",
+ "session.activity.scripts.one": "{{count}} скрипт",
+ "session.activity.scripts.few": "{{count}} скрипта",
+ "session.activity.scripts.many": "{{count}} скриптов",
+ "session.activity.scripts.other": "{{count}} скрипта",
"session.activity.shell.back": "Назад к фоновым задачам",
"session.activity.shell.stop": "Остановить",
"session.activity.shell.stopping": "Остановка…",
diff --git a/packages/app/src/runtime/i18n/si.ts b/packages/app/src/runtime/i18n/si.ts
index 97de2f7bac62..7a27a155e632 100644
--- a/packages/app/src/runtime/i18n/si.ts
+++ b/packages/app/src/runtime/i18n/si.ts
@@ -1133,10 +1133,13 @@ export const dict = {
"session.timeline.status.working": "වැඩ කරමින්",
"session.running.stop.subagent": "උප නියෝජිතයාට බාධා කරන්න",
"session.running.stop.shell": "ෂෙල් විධානය නවත්වන්න",
+ "session.running.stop.script": "ස්ක්රිප්ටය අවලංගු කරන්න",
"session.activity.subagents.one": "උප නියෝජිතයන් {{count}}",
"session.activity.subagents.other": "උප නියෝජිතයන් {{count}}",
"session.activity.shells.one": "ෂෙල් {{count}}",
"session.activity.shells.other": "ෂෙල් {{count}}",
+ "session.activity.scripts.one": "ස්ක්රිප්ට් {{count}}",
+ "session.activity.scripts.other": "ස්ක්රිප්ට් {{count}}",
"session.activity.shell.back": "පසුබිම් වැඩ වෙත ආපසු",
"session.activity.shell.stop": "නවත්වන්න",
"session.activity.shell.stopping": "නවත්වමින්…",
diff --git a/packages/app/src/runtime/i18n/sk.ts b/packages/app/src/runtime/i18n/sk.ts
index 82a8aaa195a1..6929bf56b823 100644
--- a/packages/app/src/runtime/i18n/sk.ts
+++ b/packages/app/src/runtime/i18n/sk.ts
@@ -1163,6 +1163,7 @@ export const dict = {
"session.timeline.status.working": "Pracuje",
"session.running.stop.subagent": "Prerušiť podagenta",
"session.running.stop.shell": "Ukončiť príkaz shellu",
+ "session.running.stop.script": "Zrušiť skript",
"session.activity.subagents.one": "{{count}} podagent",
"session.activity.subagents.few": "{{count}} podagenti",
"session.activity.subagents.many": "{{count}} podagenta",
@@ -1171,6 +1172,10 @@ export const dict = {
"session.activity.shells.few": "{{count}} shelly",
"session.activity.shells.many": "{{count}} shellu",
"session.activity.shells.other": "{{count}} shellov",
+ "session.activity.scripts.one": "{{count}} skript",
+ "session.activity.scripts.few": "{{count}} skripty",
+ "session.activity.scripts.many": "{{count}} skriptu",
+ "session.activity.scripts.other": "{{count}} skriptov",
"session.activity.shell.back": "Späť na prácu na pozadí",
"session.activity.shell.stop": "Zastaviť",
"session.activity.shell.stopping": "Zastavuje sa…",
diff --git a/packages/app/src/runtime/i18n/sl.ts b/packages/app/src/runtime/i18n/sl.ts
index 0d3f543699e7..22d538fcca3e 100644
--- a/packages/app/src/runtime/i18n/sl.ts
+++ b/packages/app/src/runtime/i18n/sl.ts
@@ -1161,6 +1161,7 @@ export const dict = {
"session.timeline.status.working": "Deluje",
"session.running.stop.subagent": "Prekini podagenta",
"session.running.stop.shell": "Prekini ukaz lupine",
+ "session.running.stop.script": "Prekliči skripto",
"session.activity.subagents.one": "{{count}} podagent",
"session.activity.subagents.two": "{{count}} podagenta",
"session.activity.subagents.few": "{{count}} podagenti",
@@ -1169,6 +1170,10 @@ export const dict = {
"session.activity.shells.two": "{{count}} lupini",
"session.activity.shells.few": "{{count}} lupine",
"session.activity.shells.other": "{{count}} lupin",
+ "session.activity.scripts.one": "{{count}} skripta",
+ "session.activity.scripts.two": "{{count}} skripti",
+ "session.activity.scripts.few": "{{count}} skripte",
+ "session.activity.scripts.other": "{{count}} skript",
"session.activity.shell.back": "Nazaj na delo v ozadju",
"session.activity.shell.stop": "Ustavi",
"session.activity.shell.stopping": "Ustavljanje …",
diff --git a/packages/app/src/runtime/i18n/sq.ts b/packages/app/src/runtime/i18n/sq.ts
index 57f6a13398c8..9201194fe5f6 100644
--- a/packages/app/src/runtime/i18n/sq.ts
+++ b/packages/app/src/runtime/i18n/sq.ts
@@ -1135,10 +1135,13 @@ export const dict = {
"session.timeline.status.working": "Duke punuar",
"session.running.stop.subagent": "Ndërprit nënagjentin",
"session.running.stop.shell": "Ndalo komandën shell",
+ "session.running.stop.script": "Anulo skriptin",
"session.activity.subagents.one": "{{count}} nënagjent",
"session.activity.subagents.other": "{{count}} nënagjentë",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shell",
+ "session.activity.scripts.one": "{{count}} skript",
+ "session.activity.scripts.other": "{{count}} skripte",
"session.activity.shell.back": "Kthehu te puna në sfond",
"session.activity.shell.stop": "Ndalo",
"session.activity.shell.stopping": "Po ndalet…",
diff --git a/packages/app/src/runtime/i18n/sr.ts b/packages/app/src/runtime/i18n/sr.ts
index 629cdfd26b69..9a860a913364 100644
--- a/packages/app/src/runtime/i18n/sr.ts
+++ b/packages/app/src/runtime/i18n/sr.ts
@@ -1148,12 +1148,16 @@ export const dict = {
"session.timeline.status.working": "У току",
"session.running.stop.subagent": "Прекини подагента",
"session.running.stop.shell": "Прекини shell команду",
+ "session.running.stop.script": "Откажи скрипту",
"session.activity.subagents.one": "{{count}} подагент",
"session.activity.subagents.few": "{{count}} подагента",
"session.activity.subagents.other": "{{count}} подагената",
"session.activity.shells.one": "{{count}} љуска",
"session.activity.shells.few": "{{count}} љуске",
"session.activity.shells.other": "{{count}} љуски",
+ "session.activity.scripts.one": "{{count}} скрипта",
+ "session.activity.scripts.few": "{{count}} скрипте",
+ "session.activity.scripts.other": "{{count}} скрипти",
"session.activity.shell.back": "Назад на рад у позадини",
"session.activity.shell.stop": "Заустави",
"session.activity.shell.stopping": "Заустављање…",
diff --git a/packages/app/src/runtime/i18n/sv.ts b/packages/app/src/runtime/i18n/sv.ts
index bccb5c480b9f..5e0765ab6df5 100644
--- a/packages/app/src/runtime/i18n/sv.ts
+++ b/packages/app/src/runtime/i18n/sv.ts
@@ -1134,10 +1134,13 @@ export const dict = {
"session.timeline.status.working": "Arbetar",
"session.running.stop.subagent": "Avbryt underagent",
"session.running.stop.shell": "Avsluta shell-kommando",
+ "session.running.stop.script": "Avbryt skript",
"session.activity.subagents.one": "{{count}} underagent",
"session.activity.subagents.other": "{{count}} underagenter",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shells",
+ "session.activity.scripts.one": "{{count}} skript",
+ "session.activity.scripts.other": "{{count}} skript",
"session.activity.shell.back": "Tillbaka till bakgrundsarbete",
"session.activity.shell.stop": "Stoppa",
"session.activity.shell.stopping": "Stoppar…",
diff --git a/packages/app/src/runtime/i18n/tg.ts b/packages/app/src/runtime/i18n/tg.ts
index a7b7364ce584..aad44ce0befd 100644
--- a/packages/app/src/runtime/i18n/tg.ts
+++ b/packages/app/src/runtime/i18n/tg.ts
@@ -1147,10 +1147,13 @@ export const dict = {
"session.timeline.status.working": "Дар ҳоли кор",
"session.running.stop.subagent": "Қатъ кардани зер-агент",
"session.running.stop.shell": "Қатъ кардани фармони shell",
+ "session.running.stop.script": "Бекор кардани скрипт",
"session.activity.subagents.one": "{{count}} зер-агент",
"session.activity.subagents.other": "{{count}} зер-агент",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shell",
+ "session.activity.scripts.one": "{{count}} скрипт",
+ "session.activity.scripts.other": "{{count}} скрипт",
"session.activity.shell.back": "Бозгашт ба корҳои заминавӣ",
"session.activity.shell.stop": "Қатъ кардан",
"session.activity.shell.stopping": "Қатъ карда мешавад…",
diff --git a/packages/app/src/runtime/i18n/th.ts b/packages/app/src/runtime/i18n/th.ts
index 2aaa1206cccd..279f35c4ae5d 100644
--- a/packages/app/src/runtime/i18n/th.ts
+++ b/packages/app/src/runtime/i18n/th.ts
@@ -1165,10 +1165,13 @@ export const dict = {
"session.timeline.status.working": "กำลังทำงาน",
"session.running.stop.subagent": "ขัดจังหวะเอเจนต์ย่อย",
"session.running.stop.shell": "บังคับหยุดคำสั่งเชลล์",
+ "session.running.stop.script": "ยกเลิกสคริปต์",
"session.activity.subagents.one": "เอเจนต์ย่อย {{count}} ตัว",
"session.activity.subagents.other": "เอเจนต์ย่อย {{count}} ตัว",
"session.activity.shells.one": "เชลล์ {{count}} ตัว",
"session.activity.shells.other": "เชลล์ {{count}} ตัว",
+ "session.activity.scripts.one": "สคริปต์ {{count}} ตัว",
+ "session.activity.scripts.other": "สคริปต์ {{count}} ตัว",
"session.activity.shell.back": "กลับไปยังงานเบื้องหลัง",
"session.activity.shell.stop": "หยุด",
"session.activity.shell.stopping": "กำลังหยุด…",
diff --git a/packages/app/src/runtime/i18n/tk.ts b/packages/app/src/runtime/i18n/tk.ts
index 18a824e17d46..d7130cc2f719 100644
--- a/packages/app/src/runtime/i18n/tk.ts
+++ b/packages/app/src/runtime/i18n/tk.ts
@@ -1126,10 +1126,13 @@ export const dict = {
"session.timeline.status.working": "Işleýär",
"session.running.stop.subagent": "Kiçi agenti kesiň",
"session.running.stop.shell": "Shell buýrugyny duruzyň",
+ "session.running.stop.script": "Skripti ýatyr",
"session.activity.subagents.one": "{{count}} kiçi agent",
"session.activity.subagents.other": "{{count}} kiçi agent",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shell",
+ "session.activity.scripts.one": "{{count}} skript",
+ "session.activity.scripts.other": "{{count}} skript",
"session.activity.shell.back": "Fon işlerine dolan",
"session.activity.shell.stop": "Duruz",
"session.activity.shell.stopping": "Duruzylýar…",
diff --git a/packages/app/src/runtime/i18n/tr.ts b/packages/app/src/runtime/i18n/tr.ts
index cad8fe4b6afa..393781e9f35a 100644
--- a/packages/app/src/runtime/i18n/tr.ts
+++ b/packages/app/src/runtime/i18n/tr.ts
@@ -1206,10 +1206,13 @@ export const dict = {
"session.timeline.status.working": "Çalışıyor",
"session.running.stop.subagent": "Alt ajanı durdur",
"session.running.stop.shell": "Kabuk komutunu sonlandır",
+ "session.running.stop.script": "Betiği iptal et",
"session.activity.subagents.one": "{{count}} alt ajan",
"session.activity.subagents.other": "{{count}} alt ajan",
"session.activity.shells.one": "{{count}} kabuk",
"session.activity.shells.other": "{{count}} kabuk",
+ "session.activity.scripts.one": "{{count}} betik",
+ "session.activity.scripts.other": "{{count}} betik",
"session.activity.shell.back": "Arka plan işlerine dön",
"session.activity.shell.stop": "Durdur",
"session.activity.shell.stopping": "Durduruluyor…",
diff --git a/packages/app/src/runtime/i18n/uk.ts b/packages/app/src/runtime/i18n/uk.ts
index 76e4bd21b5b3..3409a54563d6 100644
--- a/packages/app/src/runtime/i18n/uk.ts
+++ b/packages/app/src/runtime/i18n/uk.ts
@@ -1229,6 +1229,7 @@ export const dict = {
"session.timeline.status.working": "Працює",
"session.running.stop.subagent": "Перервати субагента",
"session.running.stop.shell": "Завершити команду оболонки",
+ "session.running.stop.script": "Скасувати скрипт",
"session.activity.subagents.one": "{{count}} субагент",
"session.activity.subagents.few": "{{count}} субагенти",
"session.activity.subagents.many": "{{count}} субагентів",
@@ -1237,6 +1238,10 @@ export const dict = {
"session.activity.shells.few": "{{count}} оболонки",
"session.activity.shells.many": "{{count}} оболонок",
"session.activity.shells.other": "{{count}} оболонки",
+ "session.activity.scripts.one": "{{count}} скрипт",
+ "session.activity.scripts.few": "{{count}} скрипти",
+ "session.activity.scripts.many": "{{count}} скриптів",
+ "session.activity.scripts.other": "{{count}} скрипта",
"session.activity.shell.back": "Назад до фонової роботи",
"session.activity.shell.stop": "Зупинити",
"session.activity.shell.stopping": "Зупинення…",
diff --git a/packages/app/src/runtime/i18n/ur.ts b/packages/app/src/runtime/i18n/ur.ts
index 4303bc835861..7ecae87c76f0 100644
--- a/packages/app/src/runtime/i18n/ur.ts
+++ b/packages/app/src/runtime/i18n/ur.ts
@@ -1144,10 +1144,13 @@ export const dict = {
"session.timeline.status.working": "کام جاری ہے",
"session.running.stop.subagent": "ذیلی ایجنٹ کو روکیں",
"session.running.stop.shell": "شیل کمانڈ ختم کریں",
+ "session.running.stop.script": "اسکرپٹ منسوخ کریں",
"session.activity.subagents.one": "{{count}} ذیلی ایجنٹ",
"session.activity.subagents.other": "{{count}} ذیلی ایجنٹس",
"session.activity.shells.one": "{{count}} شیل",
"session.activity.shells.other": "{{count}} شیلز",
+ "session.activity.scripts.one": "{{count}} اسکرپٹ",
+ "session.activity.scripts.other": "{{count}} اسکرپٹس",
"session.activity.shell.back": "پس منظر کے کام پر واپس جائیں",
"session.activity.shell.stop": "روکیں",
"session.activity.shell.stopping": "روکا جا رہا ہے…",
diff --git a/packages/app/src/runtime/i18n/uz.ts b/packages/app/src/runtime/i18n/uz.ts
index 0f189509055b..2993ec5688ac 100644
--- a/packages/app/src/runtime/i18n/uz.ts
+++ b/packages/app/src/runtime/i18n/uz.ts
@@ -1144,10 +1144,13 @@ export const dict = {
"session.timeline.status.working": "Bajarilmoqda",
"session.running.stop.subagent": "Subagentni to‘xtatish",
"session.running.stop.shell": "Shell buyrug‘ini majburan to‘xtatish",
+ "session.running.stop.script": "Skriptni bekor qilish",
"session.activity.subagents.one": "{{count}} ta subagent",
"session.activity.subagents.other": "{{count}} ta subagent",
"session.activity.shells.one": "{{count}} ta shell",
"session.activity.shells.other": "{{count}} ta shell",
+ "session.activity.scripts.one": "{{count}} ta skript",
+ "session.activity.scripts.other": "{{count}} ta skript",
"session.activity.shell.back": "Fon ishlariga qaytish",
"session.activity.shell.stop": "To‘xtatish",
"session.activity.shell.stopping": "To‘xtatilmoqda…",
diff --git a/packages/app/src/runtime/i18n/vi.ts b/packages/app/src/runtime/i18n/vi.ts
index f5fd3d6612cc..8d49a1758b10 100644
--- a/packages/app/src/runtime/i18n/vi.ts
+++ b/packages/app/src/runtime/i18n/vi.ts
@@ -1130,10 +1130,13 @@ export const dict = {
"session.timeline.status.working": "Đang làm việc",
"session.running.stop.subagent": "Ngắt tác nhân phụ",
"session.running.stop.shell": "Dừng lệnh shell",
+ "session.running.stop.script": "Hủy script",
"session.activity.subagents.one": "{{count}} tác nhân phụ",
"session.activity.subagents.other": "{{count}} tác nhân phụ",
"session.activity.shells.one": "{{count}} shell",
"session.activity.shells.other": "{{count}} shell",
+ "session.activity.scripts.one": "{{count}} script",
+ "session.activity.scripts.other": "{{count}} script",
"session.activity.shell.back": "Quay lại tác vụ nền",
"session.activity.shell.stop": "Dừng",
"session.activity.shell.stopping": "Đang dừng…",
diff --git a/packages/app/src/runtime/i18n/zh.ts b/packages/app/src/runtime/i18n/zh.ts
index dcac1fe645d2..4645ad40c0ca 100644
--- a/packages/app/src/runtime/i18n/zh.ts
+++ b/packages/app/src/runtime/i18n/zh.ts
@@ -1142,10 +1142,13 @@ export const dict = {
"session.timeline.status.working": "工作中",
"session.running.stop.subagent": "中断子智能体",
"session.running.stop.shell": "终止 Shell 命令",
+ "session.running.stop.script": "取消脚本",
"session.activity.subagents.one": "{{count}} 个子智能体",
"session.activity.subagents.other": "{{count}} 个子智能体",
"session.activity.shells.one": "{{count}} 个 Shell",
"session.activity.shells.other": "{{count}} 个 Shell",
+ "session.activity.scripts.one": "{{count}} 个脚本",
+ "session.activity.scripts.other": "{{count}} 个脚本",
"session.activity.shell.back": "返回后台任务",
"session.activity.shell.stop": "停止",
"session.activity.shell.stopping": "正在停止…",
diff --git a/packages/app/src/runtime/i18n/zht.ts b/packages/app/src/runtime/i18n/zht.ts
index 3881eafedf68..15d6f42f6c59 100644
--- a/packages/app/src/runtime/i18n/zht.ts
+++ b/packages/app/src/runtime/i18n/zht.ts
@@ -1138,10 +1138,13 @@ export const dict = {
"session.timeline.status.working": "工作中",
"session.running.stop.subagent": "中斷子代理程式",
"session.running.stop.shell": "終止 Shell 命令",
+ "session.running.stop.script": "取消腳本",
"session.activity.subagents.one": "{{count}} 個子代理程式",
"session.activity.subagents.other": "{{count}} 個子代理程式",
"session.activity.shells.one": "{{count}} 個 Shell",
"session.activity.shells.other": "{{count}} 個 Shell",
+ "session.activity.scripts.one": "{{count}} 個腳本",
+ "session.activity.scripts.other": "{{count}} 個腳本",
"session.activity.shell.back": "返回背景工作",
"session.activity.shell.stop": "停止",
"session.activity.shell.stopping": "正在停止…",
diff --git a/packages/app/src/runtime/persistence/consumers.test.ts b/packages/app/src/runtime/persistence/consumers.test.ts
index 56b56febe3f4..72cee0cf10b5 100644
--- a/packages/app/src/runtime/persistence/consumers.test.ts
+++ b/packages/app/src/runtime/persistence/consumers.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, test } from "bun:test"
import { Schema } from "effect"
-import { WorkspaceOnboardingSchema, ProviderTipSchema } from "@/new-session/view"
+import { WorkspaceOnboardingSchema } from "@/new-session/view"
+import { ProviderTipSchema } from "@/providers/connect/tip"
import { ModelSelectionSchema } from "@/providers/models/selection"
import { Persistence } from "@/runtime/persistence/schema"
import { FileViewsSchema } from "@/workspaces/files/view-cache"
diff --git a/packages/app/src/runtime/platform/base-path-router.tsx b/packages/app/src/runtime/platform/base-path-router.tsx
new file mode 100644
index 000000000000..0dfe8857be1c
--- /dev/null
+++ b/packages/app/src/runtime/platform/base-path-router.tsx
@@ -0,0 +1,66 @@
+import {
+ type BaseRouterProps,
+ createBeforeLeave,
+ createRouter,
+ keepDepth,
+ notifyIfNotBlocked,
+ saveCurrentDepth,
+} from "@solidjs/router"
+import { basePath, stripBasePath, withBasePath } from "@/runtime/platform/base-path"
+
+/**
+ * A history router for builds served under a base path. Unlike the router's own `base`, it keeps every route path the
+ * app sees base-free, so code reading `useLocation().pathname` or navigating to it works the same under any base.
+ */
+export function BasePathRouter(props: BaseRouterProps) {
+ const read = () => {
+ const state = history.state
+
+ return {
+ value: stripBasePath(location.pathname + location.search + location.hash),
+ // The router marks its own entries with only a depth; that is not app state.
+ state: state && state._depth && Object.keys(state).length === 1 ? undefined : state,
+ }
+ }
+
+ const beforeLeave = createBeforeLeave()
+
+ return createRouter({
+ get: read,
+ set({ value, replace, scroll, state }) {
+ const url = withBasePath(value)
+
+ if (replace) history.replaceState(keepDepth(state), "", url)
+ else history.pushState(state, "", url)
+
+ const hash = decodeURIComponent(location.hash.slice(1))
+ const target = hash && document.getElementById(hash)
+
+ if (target) target.scrollIntoView()
+ else if (scroll) window.scrollTo(0, 0)
+
+ saveCurrentDepth()
+ },
+ init: (notify) => {
+ const handler = notifyIfNotBlocked(notify, (delta) => {
+ if (delta) return !beforeLeave.confirm(delta)
+
+ const source = read()
+
+ return !beforeLeave.confirm(source.value, { state: source.state })
+ })
+
+ window.addEventListener("popstate", handler)
+
+ return () => window.removeEventListener("popstate", handler)
+ },
+ utils: {
+ go: (delta) => history.go(delta),
+ renderPath: withBasePath,
+ parsePath: stripBasePath,
+ beforeLeave,
+ },
+ })(props)
+}
+
+export const baseRouter = basePath ? BasePathRouter : undefined
diff --git a/packages/app/src/runtime/platform/base-path.test.ts b/packages/app/src/runtime/platform/base-path.test.ts
new file mode 100644
index 000000000000..8bf1e00598b7
--- /dev/null
+++ b/packages/app/src/runtime/platform/base-path.test.ts
@@ -0,0 +1,50 @@
+import { describe, expect, test } from "bun:test"
+import { normalizeBasePath, stripBasePath, withBasePath } from "./base-path"
+
+describe("normalizeBasePath", () => {
+ test("is empty at the root", () => {
+ expect(normalizeBasePath(undefined)).toBe("")
+ expect(normalizeBasePath("/")).toBe("")
+ expect(normalizeBasePath("")).toBe("")
+ })
+
+ test("has a leading slash and no trailing slash", () => {
+ expect(normalizeBasePath("/opencode/")).toBe("/opencode")
+ expect(normalizeBasePath("opencode")).toBe("/opencode")
+ expect(normalizeBasePath("//a/b//")).toBe("/a/b")
+ })
+})
+
+describe("withBasePath", () => {
+ test("leaves paths alone at the root", () => {
+ expect(withBasePath("/new-session?x=1", "")).toBe("/new-session?x=1")
+ })
+
+ test("prefixes paths with the base", () => {
+ expect(withBasePath("/", "/opencode")).toBe("/opencode/")
+ expect(withBasePath("/server/a/session/b#m", "/opencode")).toBe("/opencode/server/a/session/b#m")
+ })
+})
+
+describe("stripBasePath", () => {
+ test("leaves paths alone at the root", () => {
+ expect(stripBasePath("/new-session", "")).toBe("/new-session")
+ })
+
+ test("removes the base", () => {
+ expect(stripBasePath("/opencode", "/opencode")).toBe("/")
+ expect(stripBasePath("/opencode/", "/opencode")).toBe("/")
+ expect(stripBasePath("/opencode?draftId=1", "/opencode")).toBe("/?draftId=1")
+ expect(stripBasePath("/opencode/new-session#top", "/opencode")).toBe("/new-session#top")
+ })
+
+ test("keeps paths outside the base", () => {
+ expect(stripBasePath("/opencode-other/x", "/opencode")).toBe("/opencode-other/x")
+ expect(stripBasePath("/elsewhere", "/opencode")).toBe("/elsewhere")
+ })
+
+ test("round-trips with withBasePath", () => {
+ for (const path of ["/", "/new-session", "/server/a/session/b?q=1#h"])
+ expect(stripBasePath(withBasePath(path, "/opencode"), "/opencode")).toBe(path)
+ })
+})
diff --git a/packages/app/src/runtime/platform/base-path.ts b/packages/app/src/runtime/platform/base-path.ts
new file mode 100644
index 000000000000..220a322f9450
--- /dev/null
+++ b/packages/app/src/runtime/platform/base-path.ts
@@ -0,0 +1,28 @@
+/** The path a build is served under, such as `/opencode`, without a trailing slash; empty at the root. */
+export const basePath = normalizeBasePath(import.meta.env.BASE_URL)
+
+export function normalizeBasePath(base: string | undefined) {
+ const trimmed = (base ?? "").replace(/^\/+|\/+$/g, "")
+
+ return trimmed ? `/${trimmed}` : ""
+}
+
+/** The browser path for an app path, such as `/opencode/new-session` for `/new-session`. */
+export function withBasePath(path: string, base = basePath) {
+ if (!base) return path
+
+ return path === "/" ? `${base}/` : `${base}${path}`
+}
+
+/** The app path for a browser path, or the path itself when it lies outside the base. */
+export function stripBasePath(path: string, base = basePath) {
+ if (!base || !path.startsWith(base)) return path
+
+ const rest = path.slice(base.length)
+
+ if (rest.startsWith("/")) return rest
+
+ if (rest === "" || rest.startsWith("?") || rest.startsWith("#")) return `/${rest}`
+
+ return path
+}
diff --git a/packages/app/src/runtime/platform/platform.tsx b/packages/app/src/runtime/platform/platform.tsx
index 38a12334f229..d0a8b168f6cb 100644
--- a/packages/app/src/runtime/platform/platform.tsx
+++ b/packages/app/src/runtime/platform/platform.tsx
@@ -48,9 +48,6 @@ type PlatformBase = {
/** Open a local path in a local app (desktop only) */
openPath?(path: string, app?: string): Promise
- /** Open a local file URL in its default app (desktop only) */
- openLocalFile?(url: string): void
-
/** Reveal a local path in the system file manager; false when the path does not exist (desktop only) */
revealPath?(path: string): Promise
diff --git a/packages/app/src/runtime/platform/pwa.ts b/packages/app/src/runtime/platform/pwa.ts
index 1fb7fc977662..611cd322aee8 100644
--- a/packages/app/src/runtime/platform/pwa.ts
+++ b/packages/app/src/runtime/platform/pwa.ts
@@ -1,5 +1,6 @@
import { useLocation } from "@solidjs/router"
import { createEffect } from "solid-js"
+import { stripBasePath, withBasePath } from "./base-path"
const LAST_ROUTE_KEY = "opencode.pwa.last-route"
@@ -11,7 +12,7 @@ export function isStandalone() {
}
export function restorePwaRoute() {
- if (location.pathname !== "/" || location.search || location.hash) return
+ if (stripBasePath(location.pathname) !== "/" || location.search || location.hash) return
try {
const value = localStorage.getItem(LAST_ROUTE_KEY)
@@ -27,7 +28,7 @@ export function restorePwaRoute() {
!/^\/server\/[^/]+\/session\/[^/]+$/.test(url.pathname)
)
return
- history.replaceState(history.state, "", url.pathname + url.search + url.hash)
+ history.replaceState(history.state, "", withBasePath(url.pathname) + url.search + url.hash)
} catch {
// Storage may be unavailable; keep the launch URL in that case.
}
diff --git a/packages/app/src/runtime/platform/web.ts b/packages/app/src/runtime/platform/web.ts
index 28944b06574a..b4c822cdab72 100644
--- a/packages/app/src/runtime/platform/web.ts
+++ b/packages/app/src/runtime/platform/web.ts
@@ -1,4 +1,5 @@
import { createBrowserDraftStore } from "@/runtime/persistence/drafts"
+import { basePath } from "./base-path"
import type { Platform } from "./platform"
export function createWebPlatform(version: string) {
@@ -57,5 +58,6 @@ function getCurrentServerUrl() {
return `http://${host}:${import.meta.env.VITE_OPENCODE_SERVER_PORT ?? "4096"}`
}
- return location.origin
+ // A build under a base path reaches the server through the same prefix.
+ return location.origin + basePath
}
diff --git a/packages/app/src/runtime/plugin/app-links.test.ts b/packages/app/src/runtime/plugin/app-links.test.ts
new file mode 100644
index 000000000000..d8e0e489fcd5
--- /dev/null
+++ b/packages/app/src/runtime/plugin/app-links.test.ts
@@ -0,0 +1,17 @@
+import { expect, test } from "bun:test"
+import { appLinkRoute } from "./app-links"
+
+// A mail address is the system mail app's with or without a reviewer; only an attachment parameter keeps it out.
+test.each([
+ ["mailto:hello@example.invalid", true, "mail"],
+ ["mailto:hello@example.invalid", false, "mail"],
+ ["MAILTO:hello@example.invalid?subject=Hi&body=There", false, "mail"],
+ ["mailto:hello@example.invalid?attach=C:/secrets.txt", true, "copy"],
+ ["mailto:hello@example.invalid?Attachment=/etc/passwd", false, "copy"],
+ ["tel:+15555550100", true, "review"],
+ ["tel:+15555550100", false, "copy"],
+ ["obsidian://open?vault=notes", true, "review"],
+ ["vscode://file/repo/index.ts", false, "copy"],
+] as const)("%s with a reviewer %s goes to %s", (href, reviewer, route) => {
+ expect(appLinkRoute(href, reviewer)).toBe(route)
+})
diff --git a/packages/app/src/runtime/plugin/app-links.ts b/packages/app/src/runtime/plugin/app-links.ts
new file mode 100644
index 000000000000..c64ec4329d71
--- /dev/null
+++ b/packages/app/src/runtime/plugin/app-links.ts
@@ -0,0 +1,88 @@
+import { makeEventListener } from "@solid-primitives/event-listener"
+
+function target(event: Event) {
+ const anchor = event.target instanceof Element ? event.target.closest("a") : null
+
+ if (!(anchor instanceof HTMLAnchorElement) || !anchor.closest("[data-pane-row]")) return
+ const href = anchor.dataset.appLink
+
+ if (!href || /^[a-z]:[\\/]/i.test(href)) return
+ const protocol = URL.parse(href)?.protocol
+
+ if (!protocol || /^(https?|file):$/.test(protocol)) return
+
+ return { anchor, href }
+}
+
+/**
+ * Where a click on another app's address goes. A mail address opens in the system mail app, as on dev, never in the
+ * browser pane; one with an attachment parameter could make the mail app attach a local file, so it is only copied.
+ * Any other address goes to the reviewer when one is installed, and is copied when none is.
+ */
+export function appLinkRoute(href: string, reviewer: boolean) {
+ if (/^mailto:/i.test(href))
+ return Array.from(URL.parse(href)?.searchParams.keys() ?? []).some((key) => /^(?:attach|attachment)$/i.test(key))
+ ? "copy"
+ : "mail"
+
+ return reviewer ? "review" : "copy"
+}
+
+function modified(event: MouseEvent | KeyboardEvent) {
+ return event.metaKey || event.shiftKey || event.ctrlKey || event.altKey
+}
+
+export function createAppLinks(review: (href: string) => void) {
+ let pressed: ReturnType
+ makeEventListener(
+ document,
+ "pointerdown",
+ (event) => {
+ pressed = event.isTrusted && event.button === 0 && !modified(event) ? target(event) : undefined
+ },
+ true,
+ )
+ makeEventListener(
+ document,
+ "pointercancel",
+ () => {
+ pressed = undefined
+ },
+ true,
+ )
+ makeEventListener(
+ document,
+ "keydown",
+ (event) => {
+ if (event.key !== "Enter") return
+ const link = target(event)
+
+ if (!link) return
+ event.preventDefault()
+ event.stopImmediatePropagation()
+
+ if (event.isTrusted && !modified(event) && !event.repeat && link.anchor === document.activeElement) review(link.href)
+ },
+ true,
+ )
+
+ const click = (event: MouseEvent) => {
+ const start = pressed
+ pressed = undefined
+ const link = target(event)
+
+ if (!link) return
+ event.preventDefault()
+ event.stopImmediatePropagation()
+
+ // A stream can replace the anchor or change its target between press and release.
+ if (event.type !== "click" || !event.isTrusted || modified(event) || event.button !== 0) return
+ const paired = event.detail !== 0 && start?.anchor === link.anchor && start.href === link.href
+ const assistive = !start && event.detail === 0 && link.anchor === document.activeElement
+
+ if (paired || assistive) review(link.href)
+ }
+
+ makeEventListener(document, "click", click, true)
+ makeEventListener(document, "auxclick", click, true)
+}
diff --git a/packages/app/src/runtime/plugin/embed-geometry.test.ts b/packages/app/src/runtime/plugin/embed-geometry.test.ts
new file mode 100644
index 000000000000..12782aa2df82
--- /dev/null
+++ b/packages/app/src/runtime/plugin/embed-geometry.test.ts
@@ -0,0 +1,18 @@
+import { expect, test } from "bun:test"
+import { embedBounds, overlaps } from "./embed-geometry"
+
+test("rounds physical edges separately in window DIPs after layout has resolved direction", () => {
+ expect(embedBounds({ left: 120.4, right: 220.8, top: 20.4, bottom: 30.4 }, 1.25)).toEqual({
+ x: 151,
+ y: 26,
+ width: 125,
+ height: 12,
+ })
+})
+
+test("only positive-area intersections cover a pane or put it on screen", () => {
+ const pane = { left: 12, right: 44, top: 10, bottom: 50 }
+ expect(overlaps(pane, { ...pane, left: 43 })).toBe(true)
+ expect(overlaps(pane, { ...pane, left: 44, right: 99 })).toBe(false)
+ expect(overlaps(pane, { ...pane, top: 22, bottom: 22 })).toBe(false)
+})
diff --git a/packages/app/src/runtime/plugin/embed-geometry.ts b/packages/app/src/runtime/plugin/embed-geometry.ts
new file mode 100644
index 000000000000..65556e39ab41
--- /dev/null
+++ b/packages/app/src/runtime/plugin/embed-geometry.ts
@@ -0,0 +1,19 @@
+type Edges = Pick
+
+// Both DOMRect and Electron measure from the physical left, including in RTL. Electron wants DIPs, not screen pixels:
+// only the window's page zoom belongs in this conversion, not the monitor's device scale factor.
+export function embedBounds(rect: Edges, zoom: number) {
+ const x = Math.round(rect.left * zoom)
+ const y = Math.round(rect.top * zoom)
+
+ return {
+ x,
+ y,
+ width: Math.max(0, Math.round(rect.right * zoom) - x),
+ height: Math.max(0, Math.round(rect.bottom * zoom) - y),
+ }
+}
+
+export function overlaps(a: Edges, b: Edges) {
+ return Math.min(a.right, b.right) > Math.max(a.left, b.left) && Math.min(a.bottom, b.bottom) > Math.max(a.top, b.top)
+}
diff --git a/packages/app/src/runtime/plugin/embed-snapshot-machine.test.ts b/packages/app/src/runtime/plugin/embed-snapshot-machine.test.ts
index 5c977c7f2821..e56e04065bd3 100644
--- a/packages/app/src/runtime/plugin/embed-snapshot-machine.test.ts
+++ b/packages/app/src/runtime/plugin/embed-snapshot-machine.test.ts
@@ -9,6 +9,7 @@ import {
selectSnapshotHidesNative,
selectSnapshotNeedsSync,
selectSnapshotUrl,
+ selectSnapshotWantsStill,
transitionEmbedSnapshot,
type EmbedSnapshotEffect,
type EmbedSnapshotEvent,
@@ -74,7 +75,7 @@ describe("bug replays", () => {
expect(selectSnapshotHidesNative(next.state, "embed-Alpha", true)).toBe(true)
})
- test("a failed or corrupt capture hides the native view without a still and thaws at once", () => {
+ test("a failed capture still gives the warm fallback a thaw interval", () => {
const failed = transitionEmbedSnapshot(capturing, settled(1, undefined))
expect(failed.state).toEqual({ status: "frozen", issued: 1, id: "embed-Alpha", url: undefined })
expect(failed.effects).toEqual([{ type: "capture-timer.stop" }, { type: "layout.schedule" }])
@@ -82,8 +83,24 @@ describe("bug replays", () => {
expect(selectSnapshotHidesNative(failed.state, "embed-Alpha", true)).toBe(true)
const uncovered = transitionEmbedSnapshot(failed.state, sync(false))
- expect(uncovered.state).toEqual({ status: "live", issued: 1 })
- expect(uncovered.effects).toEqual([])
+ expect(uncovered.state).toMatchObject({ status: "thawing", url: undefined })
+ expect(uncovered.effects).toEqual([{ type: "thaw-timer.start", delayMs: SNAPSHOT_THAW_DELAY_MS, attempt: 2 }])
+ expect(selectSnapshotHidesNative(uncovered.state, "embed-Alpha", false)).toBe(false)
+
+ const live = transitionEmbedSnapshot(uncovered.state, { type: "thaw.settled", attempt: 2 })
+ expect(live).toEqual({ state: { status: "live", issued: 2 }, effects: [{ type: "layout.schedule" }] })
+ })
+
+ test("a warm still hides the native view only once the capture, which needs the view visible, has returned", () => {
+ expect(selectSnapshotHidesNative(capturing, "embed-Alpha", true, true)).toBe(false)
+ expect(selectSnapshotHidesNative(painting, "embed-Alpha", true, false)).toBe(false)
+ expect(selectSnapshotHidesNative(painting, "embed-Alpha", true, true)).toBe(true)
+ expect(selectSnapshotHidesNative(painting, "embed-Beta", true, true)).toBe(false)
+ expect(selectSnapshotHidesNative(painting, "embed-Alpha", false, true)).toBe(false)
+ // The warm still keeps covering through the thaw, when the cover itself has ended.
+ expect(selectSnapshotWantsStill(thawing, "embed-Alpha", false)).toBe(true)
+ expect(selectSnapshotWantsStill(INITIAL_SNAPSHOT_STATE, "embed-Alpha", false)).toBe(false)
+ expect(selectSnapshotWantsStill(thawing, "embed-Beta", false)).toBe(false)
})
test("another embed taking a covered box gives up the previous still in the same step", () => {
@@ -114,6 +131,7 @@ describe("lifecycle", () => {
expect(decoded.effects).toEqual([
{ type: "capture-timer.stop" },
{ type: "paint-timer.start", attempt: 1, delayMs: SNAPSHOT_PAINT_TIMEOUT_MS },
+ { type: "layout.schedule" },
])
const presented = transitionEmbedSnapshot(decoded.state, { type: "snapshot.painted", url: "blob:a" })
@@ -128,7 +146,7 @@ describe("lifecycle", () => {
const released = transitionEmbedSnapshot(uncovered.state, { type: "thaw.settled", attempt: 2 })
expect(released.state).toEqual({ status: "live", issued: 2 })
- expect(released.effects).toEqual([{ type: "url.revoke", url: "blob:a" }])
+ expect(released.effects).toEqual([{ type: "url.revoke", url: "blob:a" }, { type: "layout.schedule" }])
})
test("covering again while thawing keeps the still and ignores the old thaw", () => {
diff --git a/packages/app/src/runtime/plugin/embed-snapshot-machine.ts b/packages/app/src/runtime/plugin/embed-snapshot-machine.ts
index 012cd3acfe5b..cd2bffae11a5 100644
--- a/packages/app/src/runtime/plugin/embed-snapshot-machine.ts
+++ b/packages/app/src/runtime/plugin/embed-snapshot-machine.ts
@@ -36,7 +36,7 @@ export type EmbedSnapshotState =
readonly issued: number
readonly attempt: number
readonly id: string
- readonly url: string
+ readonly url: string | undefined
}
| { readonly status: "disposed" }
@@ -85,6 +85,8 @@ const EMPTY_EFFECTS: readonly EmbedSnapshotEffect[] = Object.freeze([])
const LAYOUT: readonly EmbedSnapshotEffect[] = Object.freeze([{ type: "layout.schedule" }])
+const THAW_STOP: readonly EmbedSnapshotEffect[] = Object.freeze([{ type: "thaw-timer.stop" }])
+
export function transitionEmbedSnapshot(state: EmbedSnapshotState, event: EmbedSnapshotEvent): EmbedSnapshotTransition {
// A capture that settles after its attempt ended still owns its URL.
if (event.type === "capture.settled" && (state.status !== "capturing" || state.attempt !== event.attempt))
@@ -101,9 +103,11 @@ export function transitionEmbedSnapshot(state: EmbedSnapshotState, event: EmbedS
return {
state: { status: "painting", issued: state.issued, attempt: state.attempt, id: state.id, url: event.url },
+ // Measure again: a warm still already on screen can take over from the native view now the capture is done.
effects: [
{ type: "capture-timer.stop" },
{ type: "paint-timer.start", attempt: state.attempt, delayMs: SNAPSHOT_PAINT_TIMEOUT_MS },
+ { type: "layout.schedule" },
],
}
}
@@ -118,7 +122,11 @@ export function transitionEmbedSnapshot(state: EmbedSnapshotState, event: EmbedS
return frozen(state, state.url, LAYOUT)
if (event.type === "thaw.settled" && state.status === "thawing" && state.attempt === event.attempt)
- return { state: { status: "live", issued: state.issued }, effects: [{ type: "url.revoke", url: state.url }] }
+ return {
+ state: { status: "live", issued: state.issued },
+ // Measure again: a warm still that covered the thaw comes down with it.
+ effects: state.url ? [{ type: "url.revoke", url: state.url }, { type: "layout.schedule" }] : LAYOUT,
+ }
return unchanged(state)
}
@@ -132,9 +140,19 @@ export function selectSnapshotUrl(state: EmbedSnapshotState, id: string | undefi
return state.id === id ? state.url : undefined
}
-/** Whether the native view of `id` hides under the cover, because a frame has presented its still. */
-export function selectSnapshotHidesNative(state: EmbedSnapshotState, id: string | undefined, covered: boolean) {
- return covered && id !== undefined && state.status === "frozen" && state.id === id
+/**
+ * Whether the native view of `id` hides under the cover: a frame has presented its still, or a warm still is already
+ * on screen and the capture, which needs the view visible, has returned.
+ */
+export function selectSnapshotHidesNative(state: EmbedSnapshotState, id: string | undefined, covered: boolean, warm = false) {
+ if (!covered || id === undefined || state.status === "live" || state.status === "disposed" || state.id !== id) return false
+
+ return state.status === "frozen" || (warm && state.status === "painting")
+}
+
+/** Whether the box wants a still under or instead of the native view: while covered, and until the view repaints. */
+export function selectSnapshotWantsStill(state: EmbedSnapshotState, id: string | undefined, covered: boolean) {
+ return covered || (state.status === "thawing" && state.id === id)
}
/** The still Element Timing should report, or undefined when none waits for its frame. */
@@ -179,7 +197,7 @@ function syncStep(
if (state.status === "frozen") {
if (covered) return "keep"
- return shown && state.url !== undefined ? "thaw" : "release"
+ return shown ? "thaw" : "release"
}
if (covered) return "refreeze"
@@ -208,7 +226,7 @@ function sync(
}
}
- if (step === "thaw" && state.status === "frozen" && state.url !== undefined) {
+ if (step === "thaw" && state.status === "frozen") {
const attempt = state.issued + 1
return {
@@ -230,7 +248,8 @@ function release(state: EmbedSnapshotState): readonly EmbedSnapshotEffect[] {
if (state.status === "frozen") return state.url ? [{ type: "url.revoke", url: state.url }] : EMPTY_EFFECTS
- if (state.status === "thawing") return [{ type: "thaw-timer.stop" }, { type: "url.revoke", url: state.url }]
+ if (state.status === "thawing")
+ return state.url ? [{ type: "thaw-timer.stop" }, { type: "url.revoke", url: state.url }] : THAW_STOP
return EMPTY_EFFECTS
}
diff --git a/packages/app/src/runtime/plugin/embeds.tsx b/packages/app/src/runtime/plugin/embeds.tsx
index 16bcfa85338e..6f0a85bd6621 100644
--- a/packages/app/src/runtime/plugin/embeds.tsx
+++ b/packages/app/src/runtime/plugin/embeds.tsx
@@ -1,7 +1,7 @@
import { createEffect, createMemo, createSignal, on, onCleanup, Show, untrack } from "solid-js"
import { createEventListener } from "@solid-primitives/event-listener"
-import { createResizeObserver } from "@solid-primitives/resize-observer"
-import { observeReducedMotion, prefersReducedMotion } from "@opencode/ui/motion"
+import { embedBounds, overlaps } from "./embed-geometry"
+import { frameLoop, observeReducedMotion, prefersReducedMotion } from "@opencode/ui/motion"
import type { EmbedProps, Embeds } from "@opencode/plugin/gui"
import type { Bridge, BridgeLayout } from "@opencode/plugin/gui/host"
import {
@@ -18,6 +18,7 @@ import {
type EmbedStillEffect,
type EmbedStillEvent,
type EmbedStillState,
+ type KeptStill,
} from "./embed-flight-machine"
import {
INITIAL_SNAPSHOT_STATE,
@@ -25,6 +26,7 @@ import {
selectSnapshotHidesNative,
selectSnapshotNeedsSync,
selectSnapshotUrl,
+ selectSnapshotWantsStill,
transitionEmbedSnapshot,
type EmbedSnapshotEffect,
type EmbedSnapshotEvent,
@@ -32,7 +34,9 @@ import {
} from "./embed-snapshot-machine"
const geometry =
- /^(inset|left|right|top|bottom|translate|transform|scale|rotate|margin|padding|flex|grid|gap|row-gap|column-gap)|(^|-)(width|height)$/
+ /^(inset|left|right|top|bottom|translate|transform|scale|rotate|margin|padding|flex|grid|gap|row-?gap|column-?gap)|(?:width|height)$/i
+
+const overlay = '[data-floating-overlay], [data-popper-positioner]:not(:has([role="tooltip"])), [aria-modal="true"], dialog[open], :popover-open'
type Input = {
readonly bridge: Bridge | undefined
@@ -95,11 +99,13 @@ function EmbedView(props: EmbedProps & { input: Input; bridge: Bridge }) {
const documentVisible = createMemo(() => embedState().documentVisible)
// Decoded flight stills, kept decoded so a flight's first frame paints them without a blank decode.
const decodedStills = new Map()
+ const [coverStill, setCoverStill] = createSignal()
let element: HTMLDivElement | undefined
- let frame: number | undefined
+ let frame: (() => void) | undefined
let layout: string | undefined
- let until = 0
+ const motions = new Set()
+ let settlePosition: ((rect: DOMRectReadOnly) => void) | undefined
// The embed the last layout went to; it hides when another one takes the box.
let placed: string | undefined
let snapshotTimer: ReturnType | undefined
@@ -108,17 +114,26 @@ function EmbedView(props: EmbedProps & { input: Input; bridge: Bridge }) {
const canvas = document.createElement("canvas")
canvas.width = canvas.height = 1
const paint = canvas.getContext("2d", { willReadFrequently: true })
+ const colors = new Map()
// Let the browser resolve colors, including custom themes using color formats
// that Electron's color parser cannot read.
const resolve = (color: string) => {
if (!paint) return undefined
+ const kept = colors.get(color)
+
+ if (kept) return kept
paint.clearRect(0, 0, 1, 1)
paint.fillStyle = color
paint.fillRect(0, 0, 1, 1)
const data = paint.getImageData(0, 0, 1, 1).data
- return [data[0], data[1], data[2], data[3]] as const
+ const value = [data[0], data[1], data[2], data[3]] as const
+
+ if (colors.size >= 4) colors.clear()
+ colors.set(color, value)
+
+ return value
}
const revoke = (url: string) => {
@@ -229,6 +244,11 @@ function EmbedView(props: EmbedProps & { input: Input; bridge: Bridge }) {
}
const hide = () => {
+ setCoverStill(undefined)
+ frame?.()
+ frame = undefined
+ layout = undefined
+
if (placed) props.bridge.embed(placed)
placed = undefined
@@ -238,14 +258,29 @@ function EmbedView(props: EmbedProps & { input: Input; bridge: Bridge }) {
// The native embed always paints above the DOM, so hide it while a floating
// menu, select, or popover overlaps it. Tooltips are excluded.
const covered = (rect: DOMRect) => {
- const floating = document.querySelectorAll('[data-popper-positioner]:not(:has([role="tooltip"]))')
+ if (!element) return false
+ const floating = document.querySelectorAll(overlay)
+ const layer = Number(element.closest("[data-dialog-layer]")?.dataset.dialogLayer ?? -1)
// An index loop: this runs every frame of a transition or a drag.
for (let index = 0; index < floating.length; index++) {
- const r = floating[index].getBoundingClientRect()
+ if (floating[index].contains(element)) continue
+ // A dialog's own backdrop, and those of the dialogs beneath it, are behind an embed inside it.
+ const backdrop = floating[index].getAttribute("data-dialog-backdrop")
- if (r.width > 0 && r.left < rect.right && r.right > rect.left && r.top < rect.bottom && r.bottom > rect.top)
- return true
+ if (backdrop !== null && Number(backdrop) <= layer) continue
+
+ if (overlaps(rect, floating[index].getBoundingClientRect())) return true
+ }
+
+ // Surfaces portalled to the body after the embed's own root are above it even when nobody marked them, so an
+ // unmarked menu or panel is covered rather than painted over.
+ for (
+ let portal = ancestorBelow(document.body, element)?.nextElementSibling;
+ portal;
+ portal = portal.nextElementSibling
+ ) {
+ if (!portal.querySelector('[role="tooltip"]') && floats(portal, rect, 3)) return true
}
return false
@@ -276,13 +311,11 @@ function EmbedView(props: EmbedProps & { input: Input; bridge: Bridge }) {
if (!element) return
const id = props.id
- if (!id) return hide()
+ if (!id) return
const rect = element.getBoundingClientRect()
const zoom = props.input.zoom()
- const left = Math.round(rect.left * zoom)
- const top = Math.round(rect.top * zoom)
- const right = Math.round(rect.right * zoom)
- const bottom = Math.round(rect.bottom * zoom)
+ const bounds = embedBounds(rect, zoom)
+ // A scaled preview scrolls the box inside an ancestor; only the part inside that scrollport is shown.
const port = scrollport()
const clip = port && scrollClip(port, rect, zoom)
@@ -290,20 +323,17 @@ function EmbedView(props: EmbedProps & { input: Input; bridge: Bridge }) {
props.visible &&
current().documentVisible &&
!props.input.moving() &&
- (!clip || (clip.width > 0 && clip.height > 0))
+ (clip
+ ? clip.width > 0 && clip.height > 0
+ : bounds.width > 0 && bounds.height > 0 && overlaps(rect, { left: 0, top: 0, right: window.innerWidth, bottom: window.innerHeight }))
// A dialog's scrim covers the box like floating content does, so it dims a still of the page
// instead of a blank box, and the page does not blink out and back as the dialog opens and closes.
const cover =
!!props.frozen ||
- props.input.dialog() ||
+ (props.input.dialog() && !element.closest('[role="dialog"], [role="alertdialog"], dialog[open]')) ||
covered(clip ? new DOMRect(clip.x / zoom, clip.y / zoom, clip.width / zoom, clip.height / zoom) : rect)
- // Keep the embed on screen as a still under the floating content. The native view
- // stays visible until the still is on screen, so the box never flashes blank.
- syncSnapshot(id, shown, cover)
- const visible = shown && !selectSnapshotHidesNative(current().snapshot, id, cover)
-
// The cutout exposes the app backdrop outside the rounded card, not the embed inside it.
const color =
props.background ??
@@ -312,7 +342,31 @@ function EmbedView(props: EmbedProps & { input: Input; bridge: Bridge }) {
const ring = props.radius ? cardRing(element) : undefined
const viewport = { width: Math.round(window.innerWidth * zoom), height: Math.round(window.innerHeight * zoom) }
- const next = `${id}:${visible}:${left}:${top}:${right}:${bottom}:${clip?.x}:${clip?.y}:${clip?.width}:${clip?.height}:${viewport.width}:${viewport.height}:${color}:${ring?.color}:${ring?.width}:${window.devicePixelRatio}`
+ return { id, shown, cover, bounds, clip, color, ring, viewport, rect, zoom }
+ }
+
+ const place = (boxLayout: NonNullable>) => {
+ const { id, shown, cover, bounds, clip, color, ring, viewport, rect, zoom } = boxLayout
+ syncSnapshot(id, shown, cover)
+ const still = current().still
+ const kept = still.status !== "disposed" && still.kept
+ const snapshot = current().snapshot
+
+ const warm =
+ shown &&
+ selectSnapshotWantsStill(snapshot, id, cover) &&
+ kept &&
+ kept.id === id &&
+ kept.page === props.page &&
+ kept.width === bounds.width / zoom &&
+ kept.height === bounds.height / zoom
+ ? kept
+ : undefined
+
+ setCoverStill(warm)
+ const visible = shown && !selectSnapshotHidesNative(snapshot, id, cover, !!warm)
+
+ const next = `${id}:${visible}:${bounds.x}:${bounds.y}:${bounds.width}:${bounds.height}:${clip?.x}:${clip?.y}:${clip?.width}:${clip?.height}:${viewport.width}:${viewport.height}:${color}:${ring?.color}:${ring?.width}:${window.devicePixelRatio}`
if (next === layout) return
layout = next
@@ -320,20 +374,19 @@ function EmbedView(props: EmbedProps & { input: Input; bridge: Bridge }) {
const background = resolve(color)
const border = ring && resolve(ring.color)
- if (placed !== id) hide()
placed = id
- // The still lines up with the view's device-pixel-rounded bounds, so swapping one for the other moves nothing.
+ // Electron takes integer DIPs. A DIP-rounded edge need not be an integer physical pixel on a scaled display.
if (visible)
dispatchStill({
type: "placement.changed",
page: props.page,
placement: {
id,
- x: left / zoom - rect.left,
- y: top / zoom - rect.top,
- width: Math.max(0, right - left) / zoom,
- height: Math.max(0, bottom - top) / zoom,
+ x: bounds.x / zoom - rect.left,
+ y: bounds.y / zoom - rect.top,
+ width: bounds.width / zoom,
+ height: bounds.height / zoom,
},
})
@@ -341,7 +394,7 @@ function EmbedView(props: EmbedProps & { input: Input; bridge: Bridge }) {
const box: BridgeLayout = {
visible,
- bounds: { x: left, y: top, width: Math.max(0, right - left), height: Math.max(0, bottom - top) },
+ bounds,
...(clip && { clip }),
viewport,
radius: Math.round((props.radius ?? 0) * zoom),
@@ -355,17 +408,26 @@ function EmbedView(props: EmbedProps & { input: Input; bridge: Bridge }) {
)
}
+ let measured: ReturnType
+
const tick = () => {
frame = undefined
- measure()
- if (performance.now() < until) frame = requestAnimationFrame(tick)
- }
+ if (measured) place(measured)
+
+ motions.forEach((motion) => {
+ if (motion.playState !== "running") motions.delete(motion)
+ })
+
+ if (motions.size) schedule()
+
+ if (!motions.size && measured) settlePosition?.(measured.rect)
- const schedule = (duration = 0) => {
- until = Math.max(until, performance.now() + duration)
+ return false
+ }
- if (frame === undefined) frame = requestAnimationFrame(tick)
+ const schedule = () => {
+ frame ??= frameLoop.addMeasured(() => { measured = measure() }, tick)
}
// A navigation or reload makes the kept still another page's, as does another embed taking the box.
@@ -400,38 +462,168 @@ function EmbedView(props: EmbedProps & { input: Input; bridge: Bridge }) {
// The native views are not clipped by the retained panel's DOM. Hide before the next
// animation frame so closing the panel cannot leave the embed above the app.
if (!props.visible || !documentVisible() || moving || !props.id) return hide()
- schedule(300)
+
+ if (placed && placed !== props.id) hide()
+ schedule()
},
),
)
- // Measure in the same frame as a resize, including when wrapped controls move a fixed-size embed.
- createResizeObserver(() => [element, element?.parentElement, scrollport()], measure)
- createEventListener(
- document,
- "scroll",
- (event) => {
- if (event.target instanceof Element && event.target.contains(element ?? null)) measure()
- },
- { capture: true, passive: true },
- )
- createEventListener(window, "resize", () => schedule(300))
- // A layout transition elsewhere, such as the chat column's width while the side pane opens, can
- // move the box without resizing it. Track it from when it actually runs, and settle on its end.
- createEventListener(document, "transitionrun", (event) => {
- if (geometry.test(event.propertyName)) schedule(300)
- })
- createEventListener(document, ["transitionend", "transitioncancel"], (event) => {
- if (geometry.test(event.propertyName)) schedule()
+ createEffect(() => {
+ if (!element || !props.visible || !props.id || !documentVisible() || props.input.moving()) return
+ const box = element
+ // Watch the layout spine, not the conversation subtree: a sibling changing width or a banner being inserted
+ // can move a fixed-size pane. Only the portals outside the app root need subtree observation (menus and toasts).
+ const sizes = new ResizeObserver(schedule)
+ const nodes = new Set()
+ const neighbors = new Set()
+ const removeScroll = () => nodes.forEach(node => node.removeEventListener("scroll", schedule))
+
+ const changes = new MutationObserver((records) => {
+ if (!box.isConnected) {
+ if (!nodes.size) return
+ removeScroll()
+ sizes.disconnect()
+ changes.disconnect()
+ changes.observe(document, { childList: true, subtree: true })
+ hide()
+ nodes.clear()
+
+ return
+ }
+
+ if (
+ !nodes.size ||
+ records.some(
+ (record) => record.type === "childList" && record.target instanceof Element && nodes.has(record.target),
+ )
+ )
+ observe()
+ schedule()
+ })
+
+ const observe = () => {
+ removeScroll()
+ nodes.clear()
+ neighbors.clear()
+ sizes.disconnect()
+ changes.disconnect()
+
+ if (!box.isConnected) {
+ changes.observe(document, { childList: true, subtree: true })
+
+ return
+ }
+
+ for (let node: Element | null = box; node; node = node.parentElement) {
+ nodes.add(node)
+ node.addEventListener("scroll", schedule, { passive: true })
+ sizes.observe(node)
+ changes.observe(node, { attributes: true, childList: node !== box })
+
+ for (const sibling of node.parentElement?.children ?? []) {
+ if (sibling === node) continue
+ neighbors.add(sibling)
+ sizes.observe(sibling)
+ const portal = sibling.parentElement === document.body
+ changes.observe(sibling, { attributes: true, childList: portal, characterData: portal, subtree: portal })
+ }
+ }
+ }
+
+ observe()
+
+ const track = (target: Element) => {
+ for (const motion of target.getAnimations()) {
+ if (
+ motion.effect instanceof KeyframeEffect &&
+ motion.effect.target === target &&
+ Number.isFinite(motion.effect.getComputedTiming().endTime) &&
+ motion.effect.getKeyframes().some((key) => Object.keys(key).some((property) => geometry.test(property)))
+ )
+ motions.add(motion)
+ }
+ }
+
+ // Web Animations do not send CSS animation events. A tight intersection root wakes on the first displaced
+ // edge, then the animation itself drives the frames; no permanent frame job or patched Element.animate.
+ let position: IntersectionObserver | undefined
+
+ let previous: DOMRectReadOnly | undefined
+
+ const anchor = (rect: DOMRectReadOnly, visible = rect, threshold = 1, calibrated = false) => {
+ previous = rect
+ position?.disconnect()
+ const inset = [visible.top, window.innerWidth - visible.right, window.innerHeight - visible.bottom, visible.left]
+ position = new IntersectionObserver(([entry]) => {
+ if (!entry || !box.isConnected) return
+ const next = entry.boundingClientRect
+
+ if (next.x === rect.x && next.y === rect.y && next.width === rect.width && next.height === rect.height) {
+ // With an ancestor scrollport the full box may never intersect. Pin the *visible* rectangle instead.
+ if (!calibrated && entry.intersectionRatio > 0 && entry.intersectionRatio < 1)
+ anchor(rect, entry.intersectionRect, entry.intersectionRatio * 0.999999, true)
+
+ return
+ }
+
+ nodes.forEach(track)
+ neighbors.forEach(track)
+ schedule()
+
+ if (motions.size) {
+ position?.disconnect()
+ previous = undefined
+
+ return
+ }
+
+ anchor(next)
+ }, { rootMargin: inset.map((n) => `${-Math.floor(n)}px`).join(" "), threshold })
+ position.observe(box)
+ }
+
+ anchor(box.getBoundingClientRect())
+ settlePosition = (rect) => {
+ if (!previous || rect.x !== previous.x || rect.y !== previous.y || rect.width !== previous.width || rect.height !== previous.height) anchor(rect)
+ }
+
+ onCleanup(() => {
+ position?.disconnect()
+ settlePosition = undefined
+ })
+ createEventListener(document, ["transitionrun", "transitionstart", "animationstart"], (event) => {
+ const target = event.target
+
+ if (!(target instanceof Element) || (!nodes.has(target) && !neighbors.has(target) && !target.matches(overlay))) return
+ track(target)
+
+ schedule()
+ })
+ createEventListener(document, "scroll", schedule, { passive: true })
+ const scale = () => window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`)
+ let density = scale()
+
+ const changed = () => {
+ density.removeEventListener("change", changed)
+ density = scale()
+ density.addEventListener("change", changed)
+ schedule()
+ }
+
+ density.addEventListener("change", changed)
+ onCleanup(() => density.removeEventListener("change", changed))
+ createEventListener(window, "resize", schedule)
+ createEventListener(document, "toggle", (event) => {
+ if (event.target instanceof Element && event.target.matches("[popover], dialog")) schedule()
+ }, true)
+ createEventListener(window.matchMedia("(prefers-color-scheme: dark)"), "change", schedule)
+ onCleanup(() => {
+ removeScroll()
+ motions.clear()
+ changes.disconnect()
+ sizes.disconnect()
+ })
})
- // Floating content portals directly into ; keep measuring briefly so
- // the positioner has settled before the overlap check runs.
- const portals = new MutationObserver(() => schedule(300))
- portals.observe(document.body, { childList: true })
- onCleanup(() => portals.disconnect())
- const appearance = new MutationObserver(() => schedule(300))
- appearance.observe(document.documentElement, { attributes: true, attributeFilter: ["style", "data-theme", "dir"] })
- onCleanup(() => appearance.disconnect())
- createEventListener(window.matchMedia("(prefers-color-scheme: dark)"), "change", () => schedule(300))
createEventListener(document, "visibilitychange", () =>
setEmbedState({ ...current(), documentVisible: document.visibilityState === "visible" }),
)
@@ -449,7 +641,6 @@ function EmbedView(props: EmbedProps & { input: Input; bridge: Bridge }) {
),
)
onCleanup(() => {
- if (frame !== undefined) cancelAnimationFrame(frame)
hide()
// Stops every timer and gives up every still, including ones still decoding.
dispatchSnapshot(DISPOSED_EVENT)
@@ -460,7 +651,12 @@ function EmbedView(props: EmbedProps & { input: Input; bridge: Bridge }) {
const snapshotUrl = createMemo(() => selectSnapshotUrl(embedState().snapshot, props.id, props.visible))
- const flightStill = createMemo(() => selectFlightStill(embedState().flight, embedState().still, props.id, props.page))
+ // A warm still stays under a fresh capture until a frame has presented it.
+ const flightStill = createMemo(
+ () =>
+ selectFlightStill(embedState().flight, embedState().still, props.id, props.page) ??
+ (selectPaintingUrl(embedState().snapshot) || !snapshotUrl() ? coverStill() : undefined),
+ )
return (
@@ -495,6 +691,31 @@ function EmbedView(props: EmbedProps & { input: Input; bridge: Bridge }) {
)
}
+// The child of `root` that contains `node`.
+function ancestorBelow(root: Element, node: Element) {
+ for (let current: Element | null = node; current; current = current.parentElement) {
+ if (current.parentElement === root) return current
+ }
+}
+
+// Whether a visible, positioned surface that takes input, `depth` levels into a portal at most, overlaps the box. A
+// wrapper that lets input through is transparent: a full-window portal container never counts, only what it holds.
+function floats(node: Element, rect: DOMRect, depth: number): boolean {
+ // Marked surfaces were measured with their dialog layer.
+ if (node.matches(overlay)) return false
+ const style = getComputedStyle(node)
+
+ if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0") return false
+
+ if ((style.position === "fixed" || style.position === "absolute") && style.pointerEvents !== "none") {
+ const box = node.getBoundingClientRect()
+
+ if (box.width > 1 && box.height > 1 && overlaps(rect, box)) return true
+ }
+
+ return depth > 0 && Array.from(node.children).some((child) => floats(child, rect, depth - 1))
+}
+
// The client box excludes the scrollbar track, including a left-side RTL scrollbar.
function scrollClip(port: HTMLElement, rect: DOMRect, zoom: number) {
const area = port.getBoundingClientRect()
diff --git a/packages/app/src/runtime/plugin/host-apis.tsx b/packages/app/src/runtime/plugin/host-apis.tsx
index bda8e4152bbf..784458fff477 100644
--- a/packages/app/src/runtime/plugin/host-apis.tsx
+++ b/packages/app/src/runtime/plugin/host-apis.tsx
@@ -36,7 +36,7 @@ import {
type StorageScope,
type Tabs,
} from "@opencode/plugin/gui"
-import { BuiltinPanel, type BuiltinStoreFrom, type BuiltinStoreOptions } from "@opencode/plugin/gui/builtin"
+import { BuiltinPanel, BuiltinPromptGate, type BuiltinStoreFrom, type BuiltinStoreOptions } from "@opencode/plugin/gui/builtin"
import { usePlatform } from "@/runtime/platform/platform"
import { same } from "@/runtime/persistence/equality"
import { Persist, persisted, removePersisted } from "@/runtime/persistence/storage"
@@ -53,6 +53,7 @@ import { useCurrentRoute, useLayout } from "@/shell/state/layout"
import { sessionPaneTab, sessionTabPane, type SessionPane } from "@/shell/state/session-tabs"
import { terminalFontFamily, useSettings } from "@/settings/model"
import { useSettingsSurface } from "@/settings/surface"
+import { fitsSidePane } from "@/session/session-panel-width"
import { formatKeybindParts, useCommand } from "@/shell/commands/command"
import { createMediaQuery } from "@solid-primitives/media"
import { useIsRouting, useLocation } from "@solidjs/router"
@@ -73,6 +74,7 @@ import {
createProjectRequestState,
createSideRegionState,
selectMobileView,
+ selectPanelState,
selectWaitingProjectServer,
transitionMobileView,
transitionProjectRequest,
@@ -83,6 +85,7 @@ import {
} from "./host-layout-machine"
import { usePluginHost, type HostApiFactories } from "./host"
import { createLocatedWrites } from "./located"
+import { settlePromptGates } from "./prompt-gate"
import { createSessionPanelMenu } from "./panel-menu"
import type { Region } from "./panels"
import {
@@ -312,9 +315,7 @@ export function createHostApis() {
return true
},
openExternal(url) {
- if (platform.openLocalFile && URL.canParse(url) && new URL(url).protocol === "file:")
- return platform.openLocalFile(url)
- platform.openExternal(url)
+ if (/^(?:https?:\/\/|mailto:)/i.test(url) && URL.canParse(url)) platform.openExternal(url)
},
}),
desktop: () =>
@@ -460,6 +461,7 @@ export function createHostApis() {
// Before the interface mounts, reads return what an empty layout holds and writes wait for it.
layout: (plugin) => ({
narrow,
+ fitsSide: () => fitsSidePane(document.querySelector("[data-pane-row]")?.getBoundingClientRect().width ?? 0),
ready: () => current()?.layout.ready() ?? false,
open: (key, session, options) => write((value) => value.layout.open(key, session, options)),
close: (key, session) => write((value) => value.layout.close(key, session)),
@@ -859,6 +861,13 @@ export function createPluginAttachment(apis: HostApis) {
})
}
+ // Opening the tab a pane already selects changes no selection, so a New tab view over it would stay. The region
+ // hears of the open before the write, while the pane's selection is still the one on screen, and replaces that view
+ // as a tab that becomes the selection does.
+ const uncover = (session: SessionRef, key: string) => {
+ if (mountedSession(session)) region()?.opening(key)
+ }
+
const place = (key: string, session: SessionRef, value: string, options: OpenOptions | undefined) => {
const item = provider(key)
const placement = options?.tab ?? "open"
@@ -869,6 +878,7 @@ export function createPluginAttachment(apis: HostApis) {
// A select keeps the narrow-screen view, as a background open does, and shows the tab's pane too.
if (placement === "select")
return batch(() => {
+ uncover(session, key)
layout.panel.append(value, key)
layout.panel.focus(value, key)
reveal(session, value, key)
@@ -885,6 +895,8 @@ export function createPluginAttachment(apis: HostApis) {
if (mountedSession(session) && !known.some((entry) => entry.key === key && !entry.tab.transient)) return
}
+ uncover(session, key)
+
// Pinned tabs are listed without being stored; opening one only selects it.
if (known.some((entry) => entry.key === key && entry.tab.pinned)) layout.panel.focus(value, key)
else if (placement === "preview") layout.panel.preview(value, key, transient)
@@ -945,9 +957,12 @@ export function createPluginAttachment(apis: HostApis) {
const pane = mounted ? mounted.paneOf(key) : sessionTabPane(panel, key)
const shown = mounted ? mounted.pane(pane).active() : sessionPaneTab(panel, pane)
- if (shown !== key) return panel.all.includes(key) ? "open" : "closed"
-
- return paneOpened(session, pane) ? "visible" : "active"
+ return selectPanelState({
+ stored: panel.all.includes(key),
+ selected: shown === key,
+ covered: !!mounted?.newTab(pane),
+ paneOpen: paneOpened(session, pane),
+ })
}
const hide = (key: string, session: SessionRef) =>
@@ -1224,6 +1239,17 @@ export function createPluginAttachment(apis: HostApis) {
attach: () => apis.attach(mounted),
/** The routed `MountedSession`. */
current,
+ /**
+ * What a send to a session waits for before its request goes out: the `BuiltinPromptGate` of every plugin that
+ * ships with the app, which prepares the session for its next step. A session no open tab owns has no gate.
+ */
+ ready(server: string, sessionID: string) {
+ const session = untrack(sessions).find((item) => item.key === `${server}\n${sessionID}`)
+
+ if (!session) return Promise.resolve()
+
+ return settlePromptGates(untrack(() => host.items(BuiltinPromptGate)), host.builtin, session)
+ },
closed,
/** Opens and selects a side tab by key, as a reopened closed tab comes back. */
openTab: (key: string, session: SessionRef) => open(key, session, { tab: "select" }),
diff --git a/packages/app/src/runtime/plugin/host-layout-machine.test.ts b/packages/app/src/runtime/plugin/host-layout-machine.test.ts
index 8073a1a4ae0f..d099d27b59a7 100644
--- a/packages/app/src/runtime/plugin/host-layout-machine.test.ts
+++ b/packages/app/src/runtime/plugin/host-layout-machine.test.ts
@@ -6,6 +6,7 @@ import {
MOBILE_VIEW_PENDING_TTL_MS,
PROJECT_REQUEST_TTL_MS,
selectMobileView,
+ selectPanelState,
selectSideRegionSession,
transitionMobileView,
transitionProjectRequest,
@@ -198,3 +199,16 @@ test("a request for a listed server opens the picker at once", () => {
run.dispatch({ type: "request", server: "local", title: "Open", listed: true })
expect(run.effects).toEqual([{ type: "open.picker", server: "local", title: "Open" }])
})
+
+// `Layout.state` tells a plugin whether the person sees its tab. The browser reads it to decide whether a page the
+// agent shows must be brought to the front: a tab under the "+" New tab view reported `visible` and stayed hidden.
+test.each([
+ ["the pane's tab, on screen", { stored: true, selected: true, covered: false, paneOpen: true }, "visible"],
+ ["the pane's tab, pane hidden", { stored: true, selected: true, covered: false, paneOpen: false }, "active"],
+ ["the pane's tab under a New tab view", { stored: true, selected: true, covered: true, paneOpen: true }, "open"],
+ ["under a New tab view, pane hidden", { stored: true, selected: true, covered: true, paneOpen: false }, "open"],
+ ["another tab of the strip", { stored: true, selected: false, covered: false, paneOpen: true }, "open"],
+ ["not in the strip", { stored: false, selected: false, covered: false, paneOpen: true }, "closed"],
+] as const)("a panel key's state: %s", (_label, input, expected) => {
+ expect(selectPanelState(input)).toBe(expected)
+})
diff --git a/packages/app/src/runtime/plugin/host-layout-machine.ts b/packages/app/src/runtime/plugin/host-layout-machine.ts
index 1eb19a7462da..09d7bfdd9d65 100644
--- a/packages/app/src/runtime/plugin/host-layout-machine.ts
+++ b/packages/app/src/runtime/plugin/host-layout-machine.ts
@@ -1,4 +1,23 @@
-import type { OpenOptions } from "@opencode/plugin/gui"
+import type { OpenOptions, PanelState } from "@opencode/plugin/gui"
+
+/**
+ * Where a panel key stands in a session, as `Layout.state` reports it. A New tab view shown in the key's pane covers
+ * the tab the pane selects: that tab is still in the strip, but it is not the one its pane shows.
+ */
+export function selectPanelState(input: {
+ /** The key is in the session's strip. */
+ readonly stored: boolean
+ /** The key is the tab its pane selects. */
+ readonly selected: boolean
+ /** A New tab view shows in the key's pane, over the tab the pane selects. */
+ readonly covered: boolean
+ /** The key's pane is on screen. */
+ readonly paneOpen: boolean
+}): PanelState {
+ if (!input.selected || input.covered) return input.stored ? "open" : "closed"
+
+ return input.paneOpen ? "visible" : "active"
+}
/** A narrow-screen view selected for a session that is not routed waits this long for the navigation that routes it. */
export const MOBILE_VIEW_PENDING_TTL_MS = 5_000
diff --git a/packages/app/src/runtime/plugin/host.tsx b/packages/app/src/runtime/plugin/host.tsx
index 195e68773157..cfcb862dc8ec 100644
--- a/packages/app/src/runtime/plugin/host.tsx
+++ b/packages/app/src/runtime/plugin/host.tsx
@@ -111,7 +111,7 @@ type Instance = {
export type PluginInput = { readonly options: PluginOptions; readonly client: () => OpenCodeClient | undefined }
/** The APIs a window context exposes as properties. */
-type HostApis = Omit
+type HostApis = Omit
/**
* Creates one HostApi for a plugin instance, on the instance's first read of it. `register` withdraws what it is
@@ -194,7 +194,7 @@ export function PluginHostProvider(props: ParentProps) {
function createHost(input: HostInput) {
const language = useLanguage()
const owner = getOwner()
- const provided = new Map & { readonly status: "active" } }>()
+ const provided = new Map Live>()
const generations = new Map()
// Entries are indexed by registry and contracts versioned by token, so a change wakes only its own readers.
@@ -274,10 +274,10 @@ function createHost(input: HostInput) {
return pending
}
- const contractLive = (token: Contract): Live => {
+ const contractLive = (token: Contract, consumer: string, signal: AbortSignal): Live => {
void state.contracts[token.id]
- return provided.get(token.id)?.live ?? absent(token.id, false)
+ return provided.get(token.id)?.(consumer, signal) ?? absent(token.id, false)
}
// Reuses each item object while its value is unchanged so keyed renders do not remount.
@@ -695,7 +695,7 @@ function createHost(input: HostInput) {
if (existing) return existing
- const read = liveAccessor(token.kind === "contract" ? () => contractLive(token) : () => ipcLive(token))
+ const read = liveAccessor(token.kind === "contract" ? () => contractLive(token, plugin, controller.signal) : () => ipcLive(token))
lives.set(token.id, read)
@@ -858,6 +858,9 @@ function createHost(input: HostInput) {
provide(token: Contract | Ipc, impl: T) {
if (token.kind === "ipc") throw new Error("Ipcs are provided by a plugin's main entry")
+ return context.provideFor(token, () => impl)
+ },
+ provideFor(token: Contract, bind: (consumer: string, signal: AbortSignal) => T) {
if (!owns(plugin, token.id)) throw new Error(`${plugin} provides only its own contracts, not "${token.id}"`)
if (late()) return () => {}
@@ -866,7 +869,17 @@ function createHost(input: HostInput) {
generations.set(token.id, generation)
- const entry = { live: { status: "active", value: impl, generation } as const }
+ const clients = new WeakMap>()
+
+ const entry = (consumer: string, signal: AbortSignal) => {
+ const previous = clients.get(signal)
+
+ if (previous) return previous
+ const live = { status: "active", value: untrack(() => bind(consumer, signal)), generation } as const
+ clients.set(signal, live)
+
+ return live
+ }
provided.set(token.id, entry)
setState("contracts", token.id, (version = 0) => version + 1)
@@ -1015,6 +1028,8 @@ function createHost(input: HostInput) {
serversReady: createMemo(() => selectServersReady(startup.state())),
/** The plugins main lists; empty on the web and until main answers. */
installed: createMemo(() => selectInstalled(startup.state())),
+ /** Whether the plugin ships with the app. What only built-ins may contribute is read through it. */
+ builtin: (id: string) => input.builtins?.has(id) ?? false,
/** A plugin's main entry cannot answer. Reactive. */
mainFailed: (id: string) => selectMainFailed(startup.state(), id),
/** Reports what the startup gate waits for. */
diff --git a/packages/app/src/runtime/plugin/new-tab-machine.test.ts b/packages/app/src/runtime/plugin/new-tab-machine.test.ts
index 8c7c00711a9b..f22a96d4cb37 100644
--- a/packages/app/src/runtime/plugin/new-tab-machine.test.ts
+++ b/packages/app/src/runtime/plugin/new-tab-machine.test.ts
@@ -114,6 +114,17 @@ describe("new tab machine", () => {
expect(result.state.panes.side).toEqual({ ids: ["new:1"], chosen: undefined })
})
+ test("opening the tab the pane already selects replaces the New tab shown over it", () => {
+ const region: Region = { regionActive: "a", side: { active: "a", keys: ["a", "b"] } }
+ const opened: NewTabsEvent[] = [sync(region), { type: "open", pane: "side" }, { type: "open", pane: "side" }]
+ const result = run([...opened, { type: "open.selected", pane: "side" }, sync(region)])
+
+ // Only the shown one goes, as when another tab selects itself; with none shown the event changes nothing.
+ expect(result.state.panes.side).toEqual({ ids: ["new:1"], chosen: undefined })
+ expect(shown(result.state, region, "side")).toBeUndefined()
+ expect(transitionNewTabs(result.state, { type: "open.selected", pane: "side" }).state).toBe(result.state)
+ })
+
test("a split pane that loses its last tab takes its New tabs and choice with it", () => {
const open: Region = { regionActive: "t", side: none, split: { active: "t", keys: ["t"] } }
const closed: Region = { side: { active: "a", keys: ["a"] } }
diff --git a/packages/app/src/runtime/plugin/new-tab-machine.ts b/packages/app/src/runtime/plugin/new-tab-machine.ts
index b6afa1026707..b5077e1d2fe3 100644
--- a/packages/app/src/runtime/plugin/new-tab-machine.ts
+++ b/packages/app/src/runtime/plugin/new-tab-machine.ts
@@ -46,6 +46,11 @@ export type NewTabsEvent =
| { readonly type: "select.new"; readonly pane: SessionPane; readonly id: string }
/** The user selects a tab of the pane, which shows over its New tabs. */
| { readonly type: "select.tab"; readonly pane: SessionPane }
+ /**
+ * A tab opens in the pane that already selects it. The open changes no selection for `sync` to see, so this replaces
+ * the New tab the pane shows over it, as a tab that selects itself does.
+ */
+ | { readonly type: "open.selected"; readonly pane: SessionPane }
/** `empty`: the strip holds no tab, so closing the last New tab empties the region. */
| { readonly type: "dismiss"; readonly id: string; readonly empty: boolean }
@@ -82,6 +87,18 @@ export function transitionNewTabs(state: NewTabsState, event: NewTabsEvent): New
return { state: withPane(state, event.pane, { ids: pane.ids, chosen: undefined }), effects: [] }
}
+ if (event.type === "open.selected") {
+ // The pane selects a tab, so the New tab it shows is the chosen one.
+ const pane = state.panes[event.pane]
+
+ if (pane.chosen === undefined) return { state, effects: [] }
+
+ return {
+ state: withPane(state, event.pane, { ids: pane.ids.filter((id) => id !== pane.chosen), chosen: undefined }),
+ effects: [],
+ }
+ }
+
const owner = SESSION_PANES.find((pane) => state.panes[pane].ids.includes(event.id))
if (!owner) return { state, effects: [] }
diff --git a/packages/app/src/runtime/plugin/pane-drag.tsx b/packages/app/src/runtime/plugin/pane-drag.tsx
index 3e870972f7ac..8cf7f7198a09 100644
--- a/packages/app/src/runtime/plugin/pane-drag.tsx
+++ b/packages/app/src/runtime/plugin/pane-drag.tsx
@@ -228,6 +228,7 @@ export function createPaneDrag(input: {
{(target) => (
{current().title}
diff --git a/packages/app/src/runtime/plugin/panels.tsx b/packages/app/src/runtime/plugin/panels.tsx
index a71ff059daa7..d7d2a45e21a2 100644
--- a/packages/app/src/runtime/plugin/panels.tsx
+++ b/packages/app/src/runtime/plugin/panels.tsx
@@ -413,6 +413,15 @@ export function createRegion(input: {
input.tabs().setActive(key)
})
},
+ /**
+ * A tab is about to open. When its pane already selects it, the open changes no selection, so the New tab the pane
+ * shows over it is replaced here; any other open replaces it by becoming the selection.
+ */
+ opening(key: string) {
+ const pane = paneOfKey(key)
+
+ if (untrack(panes[pane].active) === key) dispatchNewTabs({ type: "open.selected", pane })
+ },
/** The new tab views of a pane, by id in strip order. */
newTabs,
/** The id of the new tab view a pane shows: the chosen one, else the newest while the pane selects no tab. */
diff --git a/packages/app/src/runtime/plugin/prompt-gate.test.ts b/packages/app/src/runtime/plugin/prompt-gate.test.ts
new file mode 100644
index 000000000000..0b452e4fe9a9
--- /dev/null
+++ b/packages/app/src/runtime/plugin/prompt-gate.test.ts
@@ -0,0 +1,113 @@
+import { afterEach, beforeEach, expect, jest, test } from "bun:test"
+import { Registry, type SessionRef } from "@opencode/plugin/gui"
+import { BuiltinPromptGate } from "@opencode/plugin/gui/builtin"
+import { PROMPT_GATE_TIMEOUT_MS, settlePromptGates } from "./prompt-gate"
+
+// SAFETY: the gates under test receive the ref and never read it.
+const session = { key: "server\nses_alpha", id: "ses_alpha" } as SessionRef
+
+// The gates of one built-in, as the host lists a registry's items.
+const builtins = (...gates: BuiltinPromptGate[]) => gates.map((value) => ({ plugin: "browser", value }))
+
+const shipped = (plugin: string) => plugin === "browser"
+
+beforeEach(() => void jest.useFakeTimers())
+
+afterEach(() => void jest.useRealTimers())
+
+// Runs the promise jobs queued so far, which the fake clock does not.
+const settle = async (promise: Promise) => {
+ const state = { done: false }
+ void promise.then(() => (state.done = true))
+
+ // More turns than the longest chain here: a gate, allSettled, the race and its cleanup.
+ for (const _ of Array.from({ length: 16 })) await Promise.resolve()
+
+ return state.done
+}
+
+test("a send waits for every gate, and not for the timeout once they settled", async () => {
+ const slow = Promise.withResolvers()
+ const signals: AbortSignal[] = []
+
+ const waiting = settlePromptGates(
+ builtins(
+ { ready: (input) => void signals.push(input.signal) },
+ { ready: () => slow.promise },
+ // A gate that throws or rejects is another plugin's fault, never the prompt's.
+ { ready: () => Promise.reject(new Error("gate failed")) },
+ {
+ ready: () => {
+ throw new Error("gate threw")
+ },
+ },
+ ),
+ shipped,
+ session,
+ )
+
+ expect(await settle(waiting)).toBe(false)
+ slow.resolve()
+ expect(await settle(waiting)).toBe(true)
+ // The host stopped waiting.
+ expect(signals.map((signal) => signal.aborted)).toEqual([true])
+})
+
+test("a gate that never settles holds the send for one second and no longer", async () => {
+ const signals: AbortSignal[] = []
+
+ const waiting = settlePromptGates(
+ builtins({
+ ready: (input) => {
+ signals.push(input.signal)
+
+ return new Promise(() => undefined)
+ },
+ }),
+ shipped,
+ session,
+ )
+
+ expect(PROMPT_GATE_TIMEOUT_MS).toBe(1_000)
+ jest.advanceTimersByTime(PROMPT_GATE_TIMEOUT_MS - 1)
+ expect(await settle(waiting)).toBe(false)
+ expect(signals[0]?.aborted).toBe(false)
+ jest.advanceTimersByTime(1)
+ expect(await settle(waiting)).toBe(true)
+ expect(signals[0]?.aborted).toBe(true)
+})
+
+test("a send with no gate does not wait", async () => {
+ expect(await settle(settlePromptGates([], shipped, session))).toBe(true)
+})
+
+// The registry is in the workspace-only SDK, but a registry is its id: a plugin bundle can make the same token with
+// the public SDK and add an item under it.
+test("a plugin bundle that registers a prompt gate is never asked, and holds no send", async () => {
+ expect(Registry.define("prompt-gate").id).toBe(BuiltinPromptGate.id)
+ const asked: string[] = []
+
+ const waiting = settlePromptGates(
+ [
+ { plugin: "browser", value: { ready: () => void asked.push("browser") } },
+ {
+ plugin: "acme-bundle",
+ value: {
+ ready: (input) => {
+ asked.push(`acme-bundle ${input.session.id}`)
+
+ return new Promise(() => undefined)
+ },
+ },
+ },
+ ],
+ shipped,
+ session,
+ )
+
+ expect(await settle(waiting)).toBe(true)
+ expect(asked).toEqual(["browser"])
+ // With only a bundle's gate there is nothing to wait for, and no timer either.
+ const bundle = { plugin: "acme-bundle", value: { ready: () => new Promise(() => undefined) } }
+ expect(await settle(settlePromptGates([bundle], shipped, session))).toBe(true)
+})
diff --git a/packages/app/src/runtime/plugin/prompt-gate.ts b/packages/app/src/runtime/plugin/prompt-gate.ts
new file mode 100644
index 000000000000..9b9a23ed7fd8
--- /dev/null
+++ b/packages/app/src/runtime/plugin/prompt-gate.ts
@@ -0,0 +1,36 @@
+import type { SessionRef } from "@opencode/plugin/gui"
+import type { BuiltinPromptGate } from "@opencode/plugin/gui/builtin"
+
+/**
+ * How long a prompt waits for the plugins' gates before it is sent anyway. A gate that misses it costs the model one
+ * step without what the gate prepared; a second of dead time on Enter is the most that is worth.
+ */
+export const PROMPT_GATE_TIMEOUT_MS = 1_000
+
+/**
+ * Resolves once every gate settled or the timeout passed, whichever is first; it never rejects. Only the gates of
+ * plugins that ship with the app are asked (`builtin`): the registry is theirs alone, and a plugin bundle that adds
+ * an item under its id would otherwise hold every prompt and learn which session it goes to.
+ */
+export function settlePromptGates(
+ items: readonly { readonly plugin: string; readonly value: BuiltinPromptGate }[],
+ builtin: (plugin: string) => boolean,
+ session: SessionRef,
+) {
+ const gates = items.flatMap((item) => (builtin(item.plugin) ? [item.value] : []))
+
+ if (gates.length === 0) return Promise.resolve()
+ const controller = new AbortController()
+ const settled = Promise.withResolvers()
+ const timer = setTimeout(settled.resolve, PROMPT_GATE_TIMEOUT_MS)
+
+ // Promise.try keeps a gate that throws to itself, so the others still run.
+ void Promise.allSettled(
+ gates.map((gate) => Promise.try(() => gate.ready({ session, signal: controller.signal }))),
+ ).then(() => settled.resolve())
+
+ return settled.promise.finally(() => {
+ clearTimeout(timer)
+ controller.abort()
+ })
+}
diff --git a/packages/app/src/runtime/plugin/render.tsx b/packages/app/src/runtime/plugin/render.tsx
index 90be86625e8d..575bb1022518 100644
--- a/packages/app/src/runtime/plugin/render.tsx
+++ b/packages/app/src/runtime/plugin/render.tsx
@@ -14,6 +14,7 @@ import {
type ParentProps,
} from "solid-js"
import { Portal, render } from "solid-js/web"
+import { makeEventListener } from "@solid-primitives/event-listener"
import {
MarkdownProvider,
useMarkdown,
@@ -33,10 +34,15 @@ import {
type CodeBlockProps,
type MountedSession,
} from "@opencode/plugin/gui"
-import { BuiltinSlot, type BuiltinSlotMap } from "@opencode/plugin/gui/builtin"
+import { BuiltinAppLink, BuiltinSlot, type BuiltinSlotMap } from "@opencode/plugin/gui/builtin"
+import { usePlatform } from "@/runtime/platform/platform"
+import { useLanguage } from "@/runtime/i18n/language"
+import { showToast } from "@/shell/notifications/toast"
+import { appLinkRoute, createAppLinks } from "./app-links"
import { PluginContext } from "@opencode/plugin/gui/host"
import { usePluginHost, type Item } from "./host"
import { createLinkCheck } from "./link-check"
+import { webHref } from "./web-href"
/**
* Renders one plugin contribution with its context and error isolation: a contribution that throws records the
@@ -154,6 +160,7 @@ export function PluginThemes(props: { loaded: () => boolean }) {
export function PluginLinks(props: ParentProps<{ session: MountedSession; active?: boolean }>) {
const host = usePluginHost()
const markdown = useMarkdown()
+ const desktop = usePlatform().platform === "desktop"
// Checks untracked: markdown calls this inside its render effect, which must not follow the routed session.
const localFileExists = createLinkCheck(
@@ -163,6 +170,7 @@ export function PluginLinks(props: ParentProps<{ session: MountedSession; active
const Links = (inner: ParentProps<{ codeBlocks: MarkdownCodeBlocks | false }>) => (
void host.links.open({ href, session: props.session })}
localFileExists={localFileExists}
@@ -187,6 +195,48 @@ export function PluginLinks(props: ParentProps<{ session: MountedSession; active
)
}
+/**
+ * Offers a plain click on a web link in the session screen (its conversation and side panels) to the LinkHandler
+ * contributions first, as `Links.open({ href, session })`. A click with a modifier key, or one no handler takes, keeps
+ * the link's own behavior: the system browser.
+ */
+export function createWebLinks(session: () => MountedSession) {
+ const host = usePluginHost()
+ const language = useLanguage()
+ const platform = usePlatform()
+
+ if (platform.platform === "desktop") createAppLinks((href) => {
+ const handler = host.items(BuiltinAppLink)[0]
+ const route = appLinkRoute(href, !!handler)
+
+ if (route === "mail") return platform.openExternal(href)
+
+ if (route === "review") return handler?.value.review(href)
+ void navigator.clipboard.writeText(href).then(
+ () => showToast({ title: language.t("common.copied") }),
+ () => showToast({ title: language.t("common.requestFailed") }),
+ )
+ })
+
+ makeEventListener(document, "click", (event) => {
+ const href = webLink(event, session)
+
+ if (href && host.links.open({ href, session: session() })) event.preventDefault()
+ })
+}
+
+function webLink(event: MouseEvent, session: () => MountedSession) {
+ if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)
+ return
+ const anchor = event.target instanceof Element ? event.target.closest("a[href]") : null
+
+ // `data-pane-row` holds the conversation and the side panels; dialogs and menus render outside it.
+ if (!(anchor instanceof HTMLAnchorElement) || !anchor.closest("[data-pane-row]") || anchor.hasAttribute("download"))
+ return
+
+ return webHref(anchor.getAttribute("href") ?? "", session().server.url)
+}
+
/**
* The `CodeBlock` renderers and `CodeBlockAction` buttons for the session's Markdown, by language. Markdown asks only
* for complete blocks of a listed language. Content renders inside `Provider` with code block content off, under the
diff --git a/packages/app/src/runtime/plugin/side-region.tsx b/packages/app/src/runtime/plugin/side-region.tsx
index 3dcfb178bae8..fa999d98fe0e 100644
--- a/packages/app/src/runtime/plugin/side-region.tsx
+++ b/packages/app/src/runtime/plugin/side-region.tsx
@@ -102,6 +102,7 @@ export function SideRegion(props: {
bo
e.preventDefault()
}
+ // Kobalte moves focus between tabs without scrolling, so a tab reached from the keyboard (Home, End, the arrows) can
+ // stay under the fades or the sticky "+". This brings the whole tab, which carries the ring and the close button,
+ // into view; the strip's scroll-padding (tabs.css) keeps it clear of both. Clicks already land on a visible tab.
+ const onFocusIn = (e: FocusEvent) => {
+ if (!(e.target instanceof HTMLElement) || !e.target.matches('[role="tab"]:focus-visible')) return
+ const tab = e.target.closest('[data-slot="tabs-trigger-wrapper"]') ?? e.target
+
+ tab.scrollIntoView({ block: "nearest", inline: "nearest" })
+ }
+
input.el.addEventListener("wheel", onWheel, { passive: false })
input.el.addEventListener("scroll", fade, { passive: true })
+ input.el.addEventListener("focusin", onFocusIn)
// The strip and each tab, so a resized strip or a retitled tab updates the fades; opening and closing tabs updates
// them through `update`.
const resize = new ResizeObserver(fade)
@@ -110,6 +121,7 @@ export const createTabStripScroll = (input: { el: HTMLDivElement; lead: () => bo
return () => {
input.el.removeEventListener("wheel", onWheel)
input.el.removeEventListener("scroll", fade)
+ input.el.removeEventListener("focusin", onFocusIn)
observer.disconnect()
resize.disconnect()
diff --git a/packages/app/src/runtime/plugin/titlebar-items.tsx b/packages/app/src/runtime/plugin/titlebar-items.tsx
index b5225ca15a31..a4ebd3e0c375 100644
--- a/packages/app/src/runtime/plugin/titlebar-items.tsx
+++ b/packages/app/src/runtime/plugin/titlebar-items.tsx
@@ -60,7 +60,7 @@ function TitlebarItemButton(props: { item: TitlebarItem; vertical?: boolean }) {
>
props.item.run?.()}
disabled={!!props.item.busy}
diff --git a/packages/app/src/runtime/plugin/web-href.test.ts b/packages/app/src/runtime/plugin/web-href.test.ts
new file mode 100644
index 000000000000..593c328f1a50
--- /dev/null
+++ b/packages/app/src/runtime/plugin/web-href.test.ts
@@ -0,0 +1,11 @@
+import { expect, test } from "bun:test"
+import { webHref } from "./web-href"
+
+test("network-path and explicit web links enter the same session link policy", () => {
+ const base = "https://session.test/base/"
+ expect(webHref("//other.test/path", base)).toBe("https://other.test/path")
+ expect(webHref("http://other.test/path", base)).toBe("http://other.test/path")
+
+ for (const path of ["/api/file", "report.html", "#part", "///etc/x", "//\\host/file", "file:///x"])
+ expect(webHref(path, base)).toBeUndefined()
+})
diff --git a/packages/app/src/runtime/plugin/web-href.ts b/packages/app/src/runtime/plugin/web-href.ts
new file mode 100644
index 000000000000..03fddb6c2eae
--- /dev/null
+++ b/packages/app/src/runtime/plugin/web-href.ts
@@ -0,0 +1,10 @@
+/** A web address written in a session, never a relative file, fragment, or UNC path. Desktop renderer origins
+ * need not be HTTP, so use the session server's web scheme for a network-path reference. */
+export function webHref(written: string, server: string) {
+ const value = written.trim()
+
+ if (!/^(?:https?:\/\/|\/\/)(?![\/\\])/i.test(value) || !URL.canParse(value, server)) return
+ const url = new URL(value, server)
+
+ return /^https?:$/.test(url.protocol) ? url.href : undefined
+}
diff --git a/packages/app/src/runtime/server/client.tsx b/packages/app/src/runtime/server/client.tsx
index 5f79979a1c9b..c28e0417e204 100644
--- a/packages/app/src/runtime/server/client.tsx
+++ b/packages/app/src/runtime/server/client.tsx
@@ -229,7 +229,10 @@ export function createServerTransport(input: {
http: ServerConnection.HttpBase
fetch?: typeof globalThis.fetch
}): ServerTransport {
- const queue = createRequestQueue({ fetch: input.fetch ?? globalThis.fetch })
+ const queue = createRequestQueue({
+ fetch: input.fetch ?? globalThis.fetch,
+ prefix: () => serverPathPrefix(state.current.http.url),
+ })
// Keeps the endpoint as plain values: a plugin's endpoint can be a store proxy that already reads the next password,
// and the client built here keeps the one it started with.
@@ -290,3 +293,10 @@ function createDirSdkContext(directory: string, serverSDK: ServerSDKBase): Locat
event: serverSDK.event.location(directory),
}
}
+
+/** The path a server URL sits under, such as `/opencode` for `https://host/opencode/`; empty at the root. */
+function serverPathPrefix(url: string) {
+ if (!URL.canParse(url)) return ""
+
+ return new URL(url).pathname.replace(/\/+$/, "")
+}
diff --git a/packages/app/src/runtime/server/loopback.test.ts b/packages/app/src/runtime/server/loopback.test.ts
new file mode 100644
index 000000000000..94c53fd18e93
--- /dev/null
+++ b/packages/app/src/runtime/server/loopback.test.ts
@@ -0,0 +1,17 @@
+import { expect, test } from "bun:test"
+import { sameLoopbackServer } from "./loopback"
+
+// The window's "local server" and main's "pages share the browser profile" both read this, so they cannot disagree.
+test.each([
+ { url: "http://127.0.0.1:4096", own: "http://127.0.0.1:4096", expected: true },
+ { url: "http://localhost:4096", own: "http://127.0.0.1:4096", expected: true },
+ { url: "http://[::1]:4096/", own: "http://127.0.0.1:4096", expected: true },
+ // Another loopback port may be a WSL server, a tunnel or a container with its own disk.
+ { url: "http://localhost:4097", own: "http://127.0.0.1:4096", expected: false },
+ { url: "https://127.0.0.1:4096", own: "http://127.0.0.1:4096", expected: false },
+ { url: "http://192.168.1.2:4096", own: "http://127.0.0.1:4096", expected: false },
+ { url: "http://localhost:4096", own: undefined, expected: false },
+ { url: "not a url", own: "http://127.0.0.1:4096", expected: false },
+])("$url is the app's own server at $own: $expected", (row) => {
+ expect(sameLoopbackServer(row.url, row.own)).toBe(row.expected)
+})
diff --git a/packages/app/src/runtime/server/loopback.ts b/packages/app/src/runtime/server/loopback.ts
new file mode 100644
index 000000000000..87bc4104b08f
--- /dev/null
+++ b/packages/app/src/runtime/server/loopback.ts
@@ -0,0 +1,22 @@
+/**
+ * A loopback http(s) URL's origin with `localhost`, `127.0.0.1` and `[::1]` read as one host, so two names for the
+ * same port compare equal; undefined for any other URL.
+ */
+export function loopbackOrigin(url: string) {
+ if (!URL.canParse(url)) return
+ const parsed = new URL(url)
+
+ if (parsed.hostname !== "localhost" && parsed.hostname !== "127.0.0.1" && parsed.hostname !== "[::1]") return
+
+ return `${parsed.protocol}//127.0.0.1:${parsed.port || (parsed.protocol === "https:" ? "443" : "80")}`
+}
+
+/**
+ * Whether a server URL is the app's own server under any loopback name: the one rule the window (whether a server is
+ * local) and the desktop's main process (whether its pages share the browser profile) both use.
+ */
+export function sameLoopbackServer(url: string, own: string | undefined) {
+ const origin = loopbackOrigin(url)
+
+ return !!origin && !!own && origin === loopbackOrigin(own)
+}
diff --git a/packages/app/src/runtime/server/registry.tsx b/packages/app/src/runtime/server/registry.tsx
index 4efb1078c993..ea6907f18924 100644
--- a/packages/app/src/runtime/server/registry.tsx
+++ b/packages/app/src/runtime/server/registry.tsx
@@ -4,6 +4,7 @@ import { batch, createMemo } from "solid-js"
import { reconcile, type SetStoreFunction, type Store } from "solid-js/store"
import { Persist, persisted } from "@/runtime/persistence/storage"
import { ServerScope } from "@/runtime/server/scope"
+import { sameLoopbackServer } from "./loopback"
import type { PluginServerStatus } from "./plugin-machine"
import { ServerHttp, ServerHttpBase, ServerKey, ServerState } from "./persistence"
@@ -38,15 +39,6 @@ export function serverLabel(conn: ServerConnection.Any, current?: { hostname?: s
return serverName(conn)
}
-function loopbackOrigin(url: string) {
- if (!URL.canParse(url)) return
- const parsed = new URL(url)
-
- if (parsed.hostname !== "localhost" && parsed.hostname !== "127.0.0.1" && parsed.hostname !== "[::1]") return
-
- return `${parsed.protocol}//127.0.0.1:${parsed.port || (parsed.protocol === "https:" ? "443" : "80")}`
-}
-
// Project data comes from the server; this keeps which projects this client has used and the last one.
export function createServerProjects(input: {
scope: () => ServerScope
@@ -220,10 +212,7 @@ export namespace ServerConnection {
if (builtin(conn)) return true
- if (conn.type !== "http" || !ownUrl) return false
- const origin = loopbackOrigin(conn.http.url)
-
- return !!origin && origin === loopbackOrigin(ownUrl)
+ return conn.type === "http" && sameLoopbackServer(conn.http.url, ownUrl)
}
}
diff --git a/packages/app/src/runtime/server/request-queue-machine.test.ts b/packages/app/src/runtime/server/request-queue-machine.test.ts
index c6757c22952f..51e5002c41d2 100644
--- a/packages/app/src/runtime/server/request-queue-machine.test.ts
+++ b/packages/app/src/runtime/server/request-queue-machine.test.ts
@@ -1,5 +1,6 @@
import { describe, expect, test } from "bun:test"
import {
+ classifyRequest,
createRequestQueueState,
selectInflightCount,
selectQueuedCount,
@@ -125,3 +126,26 @@ describe("transitionRequestQueue", () => {
])
})
})
+
+describe("classifyRequest", () => {
+ test("classifies API paths under a server path prefix like those at the root", () => {
+ const paths = [
+ ["GET", "/api/event"],
+ ["GET", "/api/session"],
+ ["GET", "/api/session/ses_1/message"],
+ ["GET", "/api/vcs/diff"],
+ ["POST", "/api/worktree"],
+ ["GET", "/api/project"],
+ ] as const
+
+ for (const [method, path] of paths)
+ expect(classifyRequest(method, new URL(`http://server/opencode${path}`), "/opencode")).toEqual(
+ classifyRequest(method, new URL(`http://server${path}`)),
+ )
+ })
+
+ test("leaves paths outside the prefix alone", () => {
+ expect(classifyRequest("GET", new URL("http://server/api/event"), "/opencode").bypass).toBe(true)
+ expect(classifyRequest("GET", new URL("http://server/opencode-other/api/event"), "/opencode").bypass).toBe(false)
+ })
+})
diff --git a/packages/app/src/runtime/server/request-queue-machine.ts b/packages/app/src/runtime/server/request-queue-machine.ts
index 6a97096e8e60..6f70da99b0a3 100644
--- a/packages/app/src/runtime/server/request-queue-machine.ts
+++ b/packages/app/src/runtime/server/request-queue-machine.ts
@@ -149,9 +149,11 @@ export function isRequestInflight(state: RequestQueueState, id: number) {
/**
* The event stream bypasses the queue. Writes go first. Session lists and the first transcript page unblock
* navigation, so they go ahead of location reads. Older pages and filtered indexes keep background priority.
+ * `prefix` is the server URL's path, such as `/opencode`, when the server sits under one.
*/
-export function classifyRequest(method: string, url: URL): RequestClassification {
- const pathname = url.pathname
+export function classifyRequest(method: string, url: URL, prefix = ""): RequestClassification {
+ // A server behind a path prefix serves its API under it; classify the path the server sees.
+ const pathname = prefix && url.pathname.startsWith(`${prefix}/`) ? url.pathname.slice(prefix.length) : url.pathname
// The event stream is long-lived; never count it against the request budget.
if (pathname === "/api/event") return bypass
diff --git a/packages/app/src/runtime/server/request-queue.test.ts b/packages/app/src/runtime/server/request-queue.test.ts
index 797d9d30990a..1474ab14bb40 100644
--- a/packages/app/src/runtime/server/request-queue.test.ts
+++ b/packages/app/src/runtime/server/request-queue.test.ts
@@ -8,6 +8,7 @@ function setup(input?: {
stallMs?: number
headersTimeoutMs?: number
setupHeadersTimeoutMs?: number
+ prefix?: string
}) {
const pending: Array<{ url: string; signal: AbortSignal; resolve: () => void }> = []
const logs: Array<{ message: string; data: RequestStallSnapshot }> = []
@@ -19,6 +20,7 @@ function setup(input?: {
stallMs: input?.stallMs,
headersTimeoutMs: input?.headersTimeoutMs,
setupHeadersTimeoutMs: input?.setupHeadersTimeoutMs,
+ prefix: () => input?.prefix ?? "",
now: () => clock,
log: (message, data) => logs.push({ message, data }),
fetch: Object.assign(
@@ -159,6 +161,18 @@ describe("createRequestQueue", () => {
expect(input.queue.inflight()).toBe(1)
})
+ test("never counts the event stream of a server under a path prefix against the budget", async () => {
+ const input = setup({ limit: 1, prefix: "/opencode" })
+ void input.queue.fetch("http://server/opencode/api/session")
+ void input.queue.fetch("http://server/opencode/api/event")
+ await input.settle()
+ expect(input.pending.map((item) => new URL(item.url).pathname).toSorted()).toEqual([
+ "/opencode/api/event",
+ "/opencode/api/session",
+ ])
+ expect(input.queue.inflight()).toBe(1)
+ })
+
test("a queued request leaves without being sent as soon as its caller aborts, while every slot stays stuck", async () => {
const input = setup({ limit: 1, stallMs: 5 })
const controller = new AbortController()
diff --git a/packages/app/src/runtime/server/request-queue.ts b/packages/app/src/runtime/server/request-queue.ts
index 37d5c2aebb83..72666f62582f 100644
--- a/packages/app/src/runtime/server/request-queue.ts
+++ b/packages/app/src/runtime/server/request-queue.ts
@@ -26,6 +26,8 @@ const setupRequestHeadersTimeoutMs = 10 * 60_000
export function createRequestQueue(input: {
fetch: typeof globalThis.fetch
+ /** The server URL's path, such as `/opencode`, when the server sits under a prefix. */
+ prefix?: () => string
limit?: number
slowLimit?: number
stallMs?: number
@@ -106,7 +108,7 @@ export function createRequestQueue(input: {
const fetch: typeof globalThis.fetch = Object.assign(
async (resource: RequestInfo | URL, init?: RequestInit) => {
const request = new Request(resource, init)
- const kind = classifyRequest(request.method, new URL(request.url))
+ const kind = classifyRequest(request.method, new URL(request.url), input.prefix?.())
if (kind.bypass) return base(request)
diff --git a/packages/app/src/session/composer/activity-chips.tsx b/packages/app/src/session/composer/activity-chips.tsx
index 26e648ffcf63..354b950c77e2 100644
--- a/packages/app/src/session/composer/activity-chips.tsx
+++ b/packages/app/src/session/composer/activity-chips.tsx
@@ -6,6 +6,7 @@ import { MenuScroll } from "@opencode/ui/menu-scroll"
import { SessionProgressIndicatorV2 } from "@opencode/session-ui/v2/session-progress-indicator-v2"
import type { ShellOutputInput, ShellOutputOutput } from "@opencode/client/promise"
import { stripAnsi } from "@opencode/session-ui/tools/ansi"
+import { Match } from "effect"
import { createEffect, createMemo, createSignal, For, on, onCleanup, Show } from "solid-js"
import { useLanguage } from "@/runtime/i18n/language"
import { useSettings } from "@/settings/model"
@@ -21,7 +22,16 @@ export type SessionActivityItem = {
target: string
// When the work started running, from the server's record of it.
started: number
-} & ({ type: "subagent"; sessionID: string } | { type: "shell" })
+} & (
+ | {
+ type: "subagent"
+ sessionID: string
+ // Running jobs in its tree, which its Stop cancels.
+ jobs?: readonly string[]
+ }
+ | { type: "shell" }
+ | { type: "script" }
+)
type DurationKey =
| "ui.message.duration.seconds"
@@ -51,6 +61,7 @@ export function formatElapsed(ms: number, t: (key: DurationKey, params: Record Promise
@@ -72,6 +83,7 @@ export function SessionActivityChips(props: {
enabled: () => settings.general.backgroundActivity() !== "off",
subagents: () => props.subagents,
shells: () => props.shells,
+ scripts: () => props.scripts ?? [],
stop: props.onStop,
ended: props.shell.ended,
focus: {
@@ -105,9 +117,13 @@ export function SessionActivityChips(props: {
const alignment = useComposerLaneAlignment()
const row = (item: SessionActivityItem) => ({
- // A shell opens its own panel in place; a subagent opens where it runs.
- closeOnSelect: item.type !== "shell",
- onSelect: () => (item.type === "shell" ? panel.open(item) : props.onOpen(item)),
+ // A shell opens its own panel in place; a subagent opens where it runs; a script has nowhere to open.
+ closeOnSelect: item.type === "subagent",
+ onSelect: () => {
+ if (item.type === "shell") return panel.open(item)
+
+ if (item.type === "subagent") props.onOpen(item)
+ },
onKeyDown: (event: KeyboardEvent) => {
if (event.key !== "Delete" && event.key !== "Backspace") return
@@ -147,7 +163,13 @@ export function SessionActivityChips(props: {
tabIndex={-1}
data-slot="session-activity-stop"
icon={rowStopping(item) ? : }
- aria-label={language.t(item.type === "shell" ? "session.running.stop.shell" : "session.running.stop.subagent")}
+ aria-label={language.t(
+ Match.value(item.type).pipe(
+ Match.when("shell", () => "session.running.stop.shell" as const),
+ Match.when("script", () => "session.running.stop.script" as const),
+ Match.orElse(() => "session.running.stop.subagent" as const),
+ ),
+ )}
aria-disabled={rowStopping(item) || undefined}
aria-busy={rowStopping(item) || undefined}
onPointerDown={(event) => {
@@ -194,6 +216,7 @@ export function SessionActivityChips(props: {
)}
+
+ {(item) => (
+ rows.set(item.key, el)}>
+
+
+ {item.label}
+
+ {end(item)}
+
+ )}
+
{(item) => (
rows.set(item.key, el)}>
diff --git a/packages/app/src/session/composer/composer-lane.css b/packages/app/src/session/composer/composer-lane.css
index b2390fd37fbc..b0fad536e410 100644
--- a/packages/app/src/session/composer/composer-lane.css
+++ b/packages/app/src/session/composer/composer-lane.css
@@ -27,7 +27,7 @@
&:focus-visible {
outline: 2px solid var(--v2-border-border-focus);
- outline-offset: 2.5px;
+ outline-offset: 2px;
}
/* Overlays layer over the capsule's own surface. */
diff --git a/packages/app/src/session/composer/controller.ts b/packages/app/src/session/composer/controller.ts
index 85582106fe06..0d346afba2e3 100644
--- a/packages/app/src/session/composer/controller.ts
+++ b/packages/app/src/session/composer/controller.ts
@@ -1,5 +1,6 @@
import { createEffect, createMemo, createSignal, on, onMount, untrack, type Accessor } from "solid-js"
import { useDialog } from "@opencode/ui/context/dialog"
+import { focusField, handoffRing } from "@opencode/ui/context/field-focus"
import type { ComposerControls } from "@/composer/adapter"
import { setCursorPosition } from "@/composer/editor/dom"
import { promptLength } from "@/composer/prompt-parts"
@@ -47,8 +48,10 @@ export function createSessionComposerController(input: {
const target = editor()
if (!target) return
+ const visible = handoffRing(target)
requestAnimationFrame(() => {
- target.focus()
+ if (visible === undefined) target.focus()
+ else focusField(target, visible)
setCursorPosition(target, cursor)
})
},
diff --git a/packages/app/src/session/composer/focus.tsx b/packages/app/src/session/composer/focus.tsx
index 5bb1df580bec..3b01d600c72b 100644
--- a/packages/app/src/session/composer/focus.tsx
+++ b/packages/app/src/session/composer/focus.tsx
@@ -9,6 +9,7 @@ import {
type ParentProps,
} from "solid-js"
import { useDialog } from "@opencode/ui/context/dialog"
+import { focusField } from "@opencode/ui/context/field-focus"
import { setCursorPosition } from "@/composer/editor/dom"
import {
createComposerFocusState,
@@ -122,7 +123,7 @@ function createComposerFocus() {
// A control chosen while the session was loading owns focus now.
if (active && active !== document.body && active !== opener && !isTitlebarTabLink(active)) return "claimed"
- element.focus({ preventScroll: true })
+ focusField(element, false, { preventScroll: true })
setCursorPosition(element, effect.cursor)
return "focused"
diff --git a/packages/app/src/session/composer/plugin-pills.tsx b/packages/app/src/session/composer/plugin-pills.tsx
index a23d2f7626fe..b489acf14beb 100644
--- a/packages/app/src/session/composer/plugin-pills.tsx
+++ b/packages/app/src/session/composer/plugin-pills.tsx
@@ -1,6 +1,7 @@
import { Icon } from "@opencode/ui/icon"
import { Menu } from "@opencode/ui/menu"
import { Popover } from "@kobalte/core/popover"
+import { createOverlayFocus } from "@opencode/ui/context/overlay-focus"
import { createMemo, For, Match, Show, Switch, untrack, type Accessor, type JSX } from "solid-js"
import { createStore } from "solid-js/store"
import {
@@ -73,6 +74,10 @@ function PluginPill(props: { pill: ComposerPill; input: ComposerPillProps; align
const view = createMemo(() => props.pill.show(props.input))
const [state, setState] = createStore({ open: false })
+ const overlayFocus = createOverlayFocus()
+
+ let trigger: HTMLButtonElement | undefined
+
return (
{(current) => (
@@ -93,11 +98,15 @@ function PluginPill(props: { pill: ComposerPill; input: ComposerPillProps; align
{(menu) => (
setState("open", open)}
+ onOpenChange={(open) => {
+ overlayFocus.openChanged(open)
+ setState("open", open)
+ }}
placement={composerLanePlacement(alignment())}
gutter={8}
>
overlayFocus.restore(event, trigger)}
>
{/* Untracked: the content renders once per open; its own reactivity updates it in place. */}
{untrack(() =>
diff --git a/packages/app/src/session/composer/queue-panel.tsx b/packages/app/src/session/composer/queue-panel.tsx
index 900ffbd709e2..cb7d9bde4db5 100644
--- a/packages/app/src/session/composer/queue-panel.tsx
+++ b/packages/app/src/session/composer/queue-panel.tsx
@@ -129,6 +129,7 @@ export function SessionQueuePanel(props: { queue: SessionQueueView; hidden?: boo
4 }}
style={{
diff --git a/packages/app/src/session/composer/region.tsx b/packages/app/src/session/composer/region.tsx
index 40292d873daa..fb3b027ed2e4 100644
--- a/packages/app/src/session/composer/region.tsx
+++ b/packages/app/src/session/composer/region.tsx
@@ -2,9 +2,11 @@ import type { SessionUserActions } from "@opencode/session-ui/message"
import type { ShellOutputInput } from "@opencode/client/promise"
import { getFilename, sameDirectory } from "@opencode/util/path"
import { useDialog } from "@opencode/ui/context/dialog"
+import { focusField, handOffFocus } from "@opencode/ui/context/field-focus"
import { isScrollKeyTarget, scrollKey, scrollKeyOwner } from "@opencode/ui/scroll-view"
import { makeEventListener } from "@solid-primitives/event-listener"
import { useNavigate } from "@solidjs/router"
+import { Match } from "effect"
import { createEffect, createMemo, on, onCleanup, onMount, Show, type Accessor } from "solid-js"
import { Composer } from "@/composer/composer"
import { VoiceComposer } from "@/voice/composer"
@@ -142,10 +144,6 @@ export function createActiveSessionRegion(input: {
}, download)
}
- const focus = () => {
- if (!input.session.data.isChild()) promptRef?.focus()
- }
-
const openParent = () => {
const id = input.session.data.parentID()
@@ -319,7 +317,10 @@ export function createActiveSessionRegion(input: {
navigateMessageByOffset: input.timeline.actions.navigateMessage,
jumpToMessage: input.timeline.actions.jumpToMessage,
revert,
- focusInput: focus,
+ // A shortcut moved focus, so the ring shows.
+ focusInput: () => {
+ if (promptRef && !input.session.data.isChild()) focusField(promptRef, true)
+ },
model: () => {
const selection = controls().model.selection
const model = selection.current()
@@ -371,7 +372,7 @@ export function createActiveSessionRegion(input: {
const focusPrompt = () => {
if (!promptRef) return
- promptRef.focus()
+ handOffFocus(promptRef)
setCursorPosition(promptRef, prompt.cursor() ?? promptLength(prompt.current()))
}
@@ -467,6 +468,10 @@ export function ActiveSessionComposerRegion(props: {
.flatMap((task) => (task.type === "shell" ? [{ ...task, key: task.id, target: task.id }] : [])),
)
+ const scripts = createMemo
(() =>
+ props.model.region.state.background.scripts().map((task) => ({ ...task, key: task.id, target: task.id })),
+ )
+
const alignment = useComposerLaneAlignment()
const todos = createMemo(() => sessionTodos(props.session.history.messages(), props.session.data.revertMessageID()))
// Like the old dock: the plan shows while the turn runs and still has work left, so stale todos never linger.
@@ -483,13 +488,26 @@ export function ActiveSessionComposerRegion(props: {
.at(-1)?.todo === true
const stop = (item: SessionActivityItem) => {
- const request =
- item.type === "subagent"
- ? server.api.session.interrupt({ sessionID: item.sessionID })
- : server.api.shell.remove({
- id: item.target,
- location: { directory: data.shell.get(item.target)?.location.directory ?? location().directory },
- })
+ const background = props.model.region.state.background
+
+ // A subagent stops with everything its tree still runs.
+ const request: Promise = Match.value(item).pipe(
+ Match.when({ type: "subagent" }, (subagent) =>
+ Promise.all([
+ ...(data.session.status(subagent.sessionID) === "running"
+ ? [server.api.session.interrupt({ sessionID: subagent.sessionID })]
+ : []),
+ ...(subagent.jobs ?? []).map(background.cancelJob),
+ ]),
+ ),
+ Match.when({ type: "script" }, (script) => background.cancelJob(script.target)),
+ Match.orElse((shell) =>
+ server.api.shell.remove({
+ id: shell.target,
+ location: { directory: data.shell.get(shell.target)?.location.directory ?? location().directory },
+ }),
+ ),
+ )
return request.then(
() => true,
@@ -581,6 +599,7 @@ export function ActiveSessionComposerRegion(props: {
{
const current = props.session.identity.params.id
diff --git a/packages/app/src/session/composer/session-composer-region.tsx b/packages/app/src/session/composer/session-composer-region.tsx
index 90acc061d82b..dda1497e131c 100644
--- a/packages/app/src/session/composer/session-composer-region.tsx
+++ b/packages/app/src/session/composer/session-composer-region.tsx
@@ -47,6 +47,7 @@ export function SessionComposerRegion(props: {
{/* Only the docks and composer take the pointer; the gaps beside them belong to the timeline underneath. */}
diff --git a/packages/app/src/session/composer/shell-panel-machine.ts b/packages/app/src/session/composer/shell-panel-machine.ts
index cc39629fbec8..d4c85708e502 100644
--- a/packages/app/src/session/composer/shell-panel-machine.ts
+++ b/packages/app/src/session/composer/shell-panel-machine.ts
@@ -53,6 +53,7 @@ export type ShellPanelWork = {
readonly enabled: boolean
readonly subagents: readonly SessionActivityItem[]
readonly shells: readonly SessionActivityItem[]
+ readonly scripts?: readonly SessionActivityItem[]
}
export type ShellPanelEvent =
@@ -187,14 +188,20 @@ export function selectShellPanelView(state: ShellPanelState, work: ShellPanelWor
const shell = state.status === "shell" ? state : undefined
// A shell that ended while its panel is open still counts until the menu closes.
const held = shell && !running(work, shell.item) ? 1 : 0
- const counts = { subagents: work.subagents.length, shells: work.shells.length + held }
+
+ const counts = {
+ subagents: work.subagents.length,
+ scripts: work.scripts?.length ?? 0,
+ shells: work.shells.length + held,
+ }
+
const phase = shell?.phase.status
const stoppingKeys = state.status === "disposed" ? NO_STOPS : state.stopping
const stopping = !!shell && stoppingKeys[shell.item.key] !== undefined
return {
counts,
- active: work.enabled && (counts.subagents > 0 || counts.shells > 0),
+ active: work.enabled && (counts.subagents > 0 || counts.scripts > 0 || counts.shells > 0),
open: state.status === "list" || state.status === "shell",
enter: state.status !== "disposed" && state.enter,
shell: shell?.item,
@@ -313,11 +320,13 @@ function running(work: ShellPanelWork, item: SessionActivityItem) {
function stoppable(work: ShellPanelWork, item: SessionActivityItem) {
if (item.type === "shell") return running(work, item)
+ if (item.type === "script") return !!work.scripts?.some((script) => script.key === item.key)
+
return work.subagents.some((subagent) => subagent.key === item.key)
}
function count(work: ShellPanelWork) {
- return work.subagents.length + work.shells.length
+ return work.subagents.length + (work.scripts?.length ?? 0) + work.shells.length
}
function changed(state: ShellPanelState, effects: readonly ShellPanelEffect[] = NO_EFFECTS): ShellPanelTransition {
diff --git a/packages/app/src/session/composer/shell-panel.ts b/packages/app/src/session/composer/shell-panel.ts
index 0c32bddfdf2d..d69ce0f87276 100644
--- a/packages/app/src/session/composer/shell-panel.ts
+++ b/packages/app/src/session/composer/shell-panel.ts
@@ -18,6 +18,7 @@ export function createShellPanel(input: {
enabled: () => boolean
subagents: () => readonly SessionActivityItem[]
shells: () => readonly SessionActivityItem[]
+ scripts?: () => readonly SessionActivityItem[]
stop: (item: SessionActivityItem) => Promise
// How a shell that left the running list ended; undefined once the server no longer knows it.
ended: (id: string) => Promise
@@ -29,11 +30,19 @@ export function createShellPanel(input: {
ended: () => void
}
}) {
- const work = () => ({ enabled: input.enabled(), subagents: input.subagents(), shells: input.shells() })
+ const work = () => ({
+ enabled: input.enabled(),
+ subagents: input.subagents(),
+ shells: input.shells(),
+ scripts: input.scripts?.() ?? [],
+ })
+
const initial = untrack(work)
const [panelState, setPanelState] = createSignal(
- createShellPanelState({ active: initial.enabled && initial.subagents.length + initial.shells.length > 0 }),
+ createShellPanelState({
+ active: initial.enabled && initial.subagents.length + initial.scripts.length + initial.shells.length > 0,
+ }),
)
// One per Stop in flight, plus the shown shell's end lookup, keyed by attempt.
diff --git a/packages/app/src/session/composer/todo-pill.tsx b/packages/app/src/session/composer/todo-pill.tsx
index fca1ba39adec..b45d489a0e6c 100644
--- a/packages/app/src/session/composer/todo-pill.tsx
+++ b/packages/app/src/session/composer/todo-pill.tsx
@@ -1,6 +1,7 @@
import { Popover } from "@kobalte/core/popover"
import { Badge } from "@opencode/ui/badge"
import { MenuScroll } from "@opencode/ui/menu-scroll"
+import { createOverlayFocus } from "@opencode/ui/context/overlay-focus"
import { createEffect, createMemo, For, Match, on, Show, Switch } from "solid-js"
import { createStore } from "solid-js/store"
import { useLanguage } from "@/runtime/i18n/language"
@@ -15,6 +16,10 @@ export function SessionTodoPill(props: { todos: readonly Todo[]; defaultOpen?: b
const alignment = useComposerLaneAlignment()
const [state, setState] = createStore({ open: props.defaultOpen ?? false })
+ const overlayFocus = createOverlayFocus()
+
+ let trigger: HTMLButtonElement | undefined
+
const done = createMemo(() => props.todos.filter((todo) => todo.status === "completed").length)
const current = createMemo(() => currentTodo(props.todos))
// The pill names the first todo in progress and counts the others running beside it.
@@ -30,11 +35,15 @@ export function SessionTodoPill(props: { todos: readonly Todo[]; defaultOpen?: b
>
setState("open", open)}
+ onOpenChange={(open) => {
+ overlayFocus.openChanged(open)
+ setState("open", open)
+ }}
placement={composerLanePlacement(alignment())}
gutter={8}
>
-
+ overlayFocus.restore(event, trigger)}
+ >
diff --git a/packages/app/src/session/requests/background.ts b/packages/app/src/session/requests/background.ts
index c5af37f9f747..8105ac32dec3 100644
--- a/packages/app/src/session/requests/background.ts
+++ b/packages/app/src/session/requests/background.ts
@@ -1,4 +1,5 @@
import type {
+ JobInfo,
JsonValue,
SessionInfo,
SessionMessageAssistant,
@@ -17,12 +18,34 @@ type Subagent = {
label: string
agent?: string
started: number
+ // Running jobs in its tree, which its Stop cancels.
+ jobs?: string[]
}
type Task = Subagent | { id: string; type: "shell"; label: string; started: number }
+type Script = { id: string; type: "script"; label: string; started: number }
+
+// The turn's foreground work. A script blocks along with the shells it is running.
+export type BlockingTask = {
+ partID: string
+ id?: string
+ label?: string
+ agent?: undefined
+ started: number
+} & ({ type: "shell" } | { type: "execute"; commands: string[]; background: boolean })
+
const decodeString = Schema.decodeUnknownOption(Schema.String)
+// A script's calls stream through its execute call's metadata.
+const decodeCall = Schema.decodeUnknownOption(
+ Schema.Struct({
+ tool: Schema.String,
+ status: Schema.String,
+ input: Schema.Struct({ command: Schema.String }),
+ }),
+)
+
// Tool input and metadata are open JSON, so a field of the wrong type reads as absent.
const text = (value: JsonValue | undefined) => Option.getOrUndefined(decodeString(value))
@@ -32,15 +55,25 @@ export function createSessionBackground(input: {
sessions: () => SessionInfo[]
status: (id: string) => "idle" | "running"
shells: () => ShellInfo[]
+ // Running background jobs in the session's tree.
+ jobs?: () => readonly JobInfo[]
}) {
const history = createMemo(() => {
// The latest call for each child names it; calls never decide whether it still runs.
const calls = new Map()
+ // A script moved to the background ends its execute call with the job's id; its first line names it.
+ const scripts = new Map()
const id = input.sessionID()
const assistant = (id ? input.messages(id) : []).reduce((latest, message) => {
if (message.type !== "assistant") return latest
message.content.forEach((part) => {
+ if (part.type === "tool" && part.name === "execute" && part.state.status === "completed") {
+ const jobID = text(part.state.metadata?.jobID)
+
+ if (jobID) scripts.set(jobID, firstLine(text(part.state.input.code)))
+ }
+
if (part.type !== "tool" || part.name !== "subagent" || part.state.status === "streaming") return
const sessionID = text(part.state.metadata?.sessionID)
@@ -57,13 +90,32 @@ export function createSessionBackground(input: {
return {
calls,
+ scripts,
blocking:
- assistant?.content.flatMap((part) => {
- if (part.type !== "tool" || part.state.status !== "running" || part.name !== "shell") return []
+ assistant?.content.flatMap((part): BlockingTask[] => {
+ if (part.type !== "tool" || part.state.status !== "running") return []
+
+ // A script in the foreground blocks the turn, and so do the shells it is running.
+ if (part.name === "execute")
+ return [
+ {
+ type: "execute",
+ partID: part.id,
+ id: undefined,
+ label: firstLine(text(part.state.input.code)),
+ agent: undefined,
+ started: part.time.ran ?? part.time.created,
+ commands: executeShellCommands(part.state.metadata.toolCalls),
+ // Only a script running as a job can move to the background.
+ background: part.state.metadata.background === true,
+ },
+ ]
+
+ if (part.name !== "shell") return []
return [
{
- type: "shell" as const,
+ type: "shell",
partID: part.id,
id: text(part.state.metadata.shellID),
label: text(part.state.input.command),
@@ -75,10 +127,12 @@ export function createSessionBackground(input: {
}
})
- const blocking = createMemo(() => history().blocking)
+ // A script that can't move still covers its shells, but isn't offered to move.
+ const blocking = createMemo(() => history().blocking.filter((item) => item.type !== "execute" || item.background))
// Like the TUI, a subagent runs exactly while its session, or any session below it, is running. Subagents always run
- // in the background, so every running descendant is background work.
+ // in the background, so every running descendant is background work, and so is an idle one whose tree still runs a
+ // job. A subagent job belongs to the child it runs.
const subagents = createMemo(() => {
const id = input.sessionID()
@@ -87,12 +141,12 @@ export function createSessionBackground(input: {
const sessions = input.sessions()
const parents = new Map(sessions.map((info) => [info.id, info.parentID]))
- const descends = (sessionID: string) => {
+ const descends = (sessionID: string, ancestor: string) => {
const seen = new Set()
let parentID = parents.get(sessionID)
while (parentID && !seen.has(parentID)) {
- if (parentID === id) return true
+ if (parentID === ancestor) return true
seen.add(parentID)
parentID = parents.get(parentID)
}
@@ -100,21 +154,36 @@ export function createSessionBackground(input: {
return false
}
- // The latest call for a child names it; its own session decides whether it still runs.
+ const jobs = (input.jobs?.() ?? []).filter((job) => job.status === "running")
+
+ // The latest call for a child names it; its own session or its tree's jobs decide whether it still runs.
return sessions.flatMap((info): Subagent[] => {
- if (input.status(info.id) !== "running" || !descends(info.id)) return []
+ if (!descends(info.id, id)) return []
+
+ const owned = jobs.filter((job) => {
+ const owner = job.kind === "subagent" ? job.childSessionID : job.sessionID
+
+ return owner === info.id || descends(owner, info.id)
+ })
+
+ const running = input.status(info.id) === "running"
+
+ if (!running && owned.length === 0) return []
+
const latest = current.calls.get(info.id)
- return [
- {
- id: info.id,
- type: "subagent",
- sessionID: info.id,
- label: latest?.label ?? info.title ?? info.id,
- agent: latest?.agent,
- started: latest?.started ?? info.time.created,
- },
- ]
+ const item: Subagent = {
+ id: info.id,
+ type: "subagent",
+ sessionID: info.id,
+ label: latest?.label ?? info.title ?? info.id,
+ agent: latest?.agent,
+ started: latest?.started ?? info.time.created,
+ }
+
+ if (owned.length > 0) item.jobs = owned.map((job) => job.id)
+
+ return [item]
})
})
@@ -129,8 +198,10 @@ export function createSessionBackground(input: {
if (shell.status !== "running" || shell.metadata.sessionID !== id) return []
if (
- current.blocking.some(
- (item) => item.type === "shell" && (item.id === shell.id || (!!item.label && shell.command === item.label)),
+ current.blocking.some((item) =>
+ item.type === "shell"
+ ? item.id === shell.id || (!!item.label && shell.command === item.label)
+ : shell.time.started >= item.started && item.commands.includes(shell.command),
)
)
return []
@@ -141,5 +212,58 @@ export function createSessionBackground(input: {
return [...subagents(), ...shells]
})
- return { blocking, tasks }
+ // The session's own scripts moved to the background, while their job runs.
+ const scripts = createMemo((): Script[] => {
+ const id = input.sessionID()
+
+ if (!id) return []
+ const current = history()
+
+ return (input.jobs?.() ?? []).flatMap((job) => {
+ if (job.kind !== "codemode" || job.status !== "running" || job.sessionID !== id) return []
+
+ return [
+ {
+ id: job.id,
+ type: "script" as const,
+ label: current.scripts.get(job.id) ?? job.id,
+ started: job.time.started,
+ },
+ ]
+ })
+ })
+
+ return { blocking, tasks, scripts }
+}
+
+function firstLine(code: string | undefined) {
+ return code
+ ?.split("\n")
+ .map((line) => line.trim())
+ .find((line) => line.length > 0)
+}
+
+// The commands of the shells a running script has started and not finished.
+function executeShellCommands(calls: JsonValue | undefined) {
+ if (!Array.isArray(calls)) return []
+
+ return calls.flatMap((call) =>
+ Option.match(decodeCall(call), {
+ onNone: () => [],
+ onSome: (item) => (item.tool === "shell" && item.status === "running" ? [item.input.command] : []),
+ }),
+ )
+}
+
+// Applies the job.updated events that arrived while the list request was in flight on top of its response, which may
+// predate them.
+export function mergeJobList & { status: string }>(
+ listed: readonly T[],
+ updates: ReadonlyMap,
+) {
+ const jobs = new Map(listed.map((job) => [job.id, job]))
+
+ updates.forEach((info, id) => (info.status === "running" ? jobs.set(id, info) : jobs.delete(id)))
+
+ return jobs
}
diff --git a/packages/app/src/session/requests/job-list.test.ts b/packages/app/src/session/requests/job-list.test.ts
new file mode 100644
index 000000000000..d616ea8c2369
--- /dev/null
+++ b/packages/app/src/session/requests/job-list.test.ts
@@ -0,0 +1,18 @@
+import { describe, expect, test } from "bun:test"
+import { mergeJobList } from "./background"
+
+const job = (id: string, status: string) => ({ id, status })
+
+describe("mergeJobList", () => {
+ test("drops a listed job that settled while the list loaded", () => {
+ const jobs = mergeJobList([job("job_a", "running")], new Map([["job_a", job("job_a", "completed")]]))
+
+ expect([...jobs.keys()]).toEqual([])
+ })
+
+ test("keeps a job that started while the list loaded", () => {
+ const jobs = mergeJobList([job("job_a", "running")], new Map([["job_b", job("job_b", "running")]]))
+
+ expect([...jobs.keys()]).toEqual(["job_a", "job_b"])
+ })
+})
diff --git a/packages/app/src/session/requests/model.ts b/packages/app/src/session/requests/model.ts
index 765ef4476f83..b5ec7cfdd879 100644
--- a/packages/app/src/session/requests/model.ts
+++ b/packages/app/src/session/requests/model.ts
@@ -1,5 +1,10 @@
import { createEffect, createMemo, createSignal, onCleanup, untrack } from "solid-js"
-import { isPermissionNotFoundError, type FormInfo, type PermissionRequest } from "@opencode/client/promise"
+import {
+ isPermissionNotFoundError,
+ type FormInfo,
+ type JobInfo,
+ type PermissionRequest,
+} from "@opencode/client/promise"
import { abort } from "@opencode/util/abort"
import { useParams } from "@solidjs/router"
import { showToast } from "@/shell/notifications/toast"
@@ -9,7 +14,7 @@ import { projectSettingsKey, useSettings } from "@/settings/model"
import { useWorkspaceLocation } from "@/workspaces/location"
import { sessionPermissionRequest, sessionFormRequest, sessionTreeIDs } from "@/session/requests/session-request-tree"
import { createWebSearchRequest } from "./websearch"
-import { createSessionBackground } from "@/session/requests/background"
+import { createSessionBackground, mergeJobList } from "@/session/requests/background"
import { createSteerBackground } from "@/session/requests/steer-background"
import { useData, useServer } from "@/runtime/server/current"
import { needsUser } from "./auto-approve-machine"
@@ -158,17 +163,64 @@ export function createSessionRequestModel() {
return !!id && !data.session.get(id)?.parentID
}
+ // Running jobs in the session's tree: listed once when the session opens or the connection returns, then kept by
+ // job.updated events.
+ const [jobs, setJobs] = createSignal>(new Map())
+ const runningJobs = createMemo(() => [...jobs().values()])
+ // Events seen while the latest list request is in flight, applied over its response.
+ let jobUpdates: Map | undefined
+
+ const stopJobs = serverSDK.event.on("experimental.job.updated", (event) => {
+ const info = event.data.info
+
+ jobUpdates?.set(info.id, info)
+
+ setJobs((previous) => {
+ if (info.status === "running") return new Map(previous).set(info.id, info)
+
+ if (!previous.has(info.id)) return previous
+
+ const next = new Map(previous)
+ next.delete(info.id)
+
+ return next
+ })
+ })
+
+ onCleanup(stopJobs)
+
+ createEffect(() => {
+ const sessionID = params.id
+
+ if (!sessionID || serverSDK.connection.status() !== "connected") return
+ const updates = new Map()
+ jobUpdates = updates
+ void serverSDK.api.experimental.job
+ .list({ sessionID, descendants: true, status: "running" })
+ .then((list) => {
+ if (jobUpdates === updates && params.id === sessionID) setJobs(mergeJobList(list, updates))
+ })
+ .catch(() => undefined)
+ .finally(() => {
+ if (jobUpdates === updates) jobUpdates = undefined
+ })
+ })
+
const running = createSessionBackground({
sessionID: () => params.id,
messages: data.session.message.list,
sessions: data.session.list,
status: data.session.status,
shells: () => data.shell.list({ directory: sdk().directory }),
+ jobs: runningJobs,
})
// Moving to the background and the plugins' background list stay with the primary session's own work.
const blocking = createMemo(() => (primary() ? running.blocking() : []))
const tasks = createMemo(() => (primary() ? running.tasks() : []))
+ const scripts = createMemo(() => (primary() ? running.scripts() : []))
+
+ const cancelJob = (id: string) => serverSDK.api.experimental.job.cancel({ id })
const moveToBackground = async () => {
if (!primary()) return
@@ -268,6 +320,8 @@ export function createSessionRequestModel() {
background: {
blocking,
tasks,
+ scripts,
+ cancelJob,
move: moveToBackground,
steer,
},
diff --git a/packages/app/src/session/screen.tsx b/packages/app/src/session/screen.tsx
index 814ed52302fc..d595196c67d8 100644
--- a/packages/app/src/session/screen.tsx
+++ b/packages/app/src/session/screen.tsx
@@ -23,7 +23,7 @@ import type { SessionModel } from "@/session/model"
import { SESSION_PANEL_WIDTH_MIN } from "@/session/session-panel-width"
import { useLayout } from "@/shell/state/layout"
import { SessionPanelFrame } from "@/session/session-frame"
-import { PluginLinks } from "@/runtime/plugin/render"
+import { createWebLinks, PluginLinks } from "@/runtime/plugin/render"
import { createPanelSidebar, createRegion, MobilePanel } from "@/runtime/plugin/panels"
import { createMobileViews, MobileViewTabs } from "@/runtime/plugin/mobile"
import { usePluginAttachment } from "@/runtime/plugin/host-apis"
@@ -54,6 +54,7 @@ import { createPanelMotion, holdLandingWidth, panelOpacity, setPanelResizing } f
export function SessionScreenView(props: { session: SessionModel }) {
// Link handling for the rest of the screen; each cached timeline provides its own for its session.
const mounted = createMountedSession(props.session)
+ createWebLinks(mounted.view)
return (
@@ -301,6 +302,7 @@ function SessionScreenContent(props: {
actions={actions}
scroll={timeline.scroll}
onResumeScroll={timeline.actions.resume}
+ focusComposer={composer.quote.focus}
setScrollRef={timeline.view.setScrollRef}
onScheduleScrollState={timeline.view.scheduleScrollState}
follow={timeline.follow}
@@ -308,6 +310,24 @@ function SessionScreenContent(props: {
onHistoryScroll={timeline.view.onHistoryScroll}
centered={screen.centered()}
reserveReviewToggle={!sideVisible()}
+ reviewToggle={
+ {
+ event.stopPropagation()
+ hideTimelineScrollbar()
+ }}
+ onClick={hideTimelineScrollbar}
+ >
+ {
+ sideGlyph = fill
+ paintSideGlyph(sideMotion.closed())
+ }}
+ />
+
+ }
onContentResize={timeline.view.contentResized}
bottomInset={timeline.inset()}
setVisibleRef={timeline.view.setVisibleRef}
@@ -450,23 +470,6 @@ function SessionScreenContent(props: {
<>
- {/* Keep the control outside panel animations. */}
-
-
-
button {
+ display: block;
+ max-inline-size: 100%;
+ padding: 6px 4px;
+ border-radius: 6px;
+ text-align: start;
+}
+
+/* The toggle follows the header actions in DOM order, but stays at the pane row's end as review opens. */
+.session-header-actions > [data-slot="session-review-toggle"] {
+ position: fixed;
+ inset-inline-end: calc(var(--shell-inline-inset, 8px) + var(--session-header-inset-end, 12px));
+}
+
.session-header-title-measure {
position: absolute;
visibility: hidden;
diff --git a/packages/app/src/session/session-identity-header.tsx b/packages/app/src/session/session-identity-header.tsx
index 909b60e6c589..0a41ed6536ff 100644
--- a/packages/app/src/session/session-identity-header.tsx
+++ b/packages/app/src/session/session-identity-header.tsx
@@ -49,7 +49,7 @@ import "./session-identity-header.css"
const SessionHeaderCollapse = createContext<() => number>(() => 0)
-export function SessionTitleHeader(props: ParentProps) {
+export function SessionTitleHeader(props: ParentProps<{ separateFade?: boolean }>) {
return (
<>
{/* The bottom inset reserves room for the fade without covering rows stuck below the bar. */}
@@ -59,15 +59,23 @@ export function SessionTitleHeader(props: ParentProps) {
{props.children}
- {/* Stuck timeline headers stack above this fade, so it only fades content scrolling under the bar. */}
-
+
+
+
>
)
}
+export function SessionHeaderFade() {
+ // Stuck timeline headers stack above this fade, so it only fades content scrolling under the bar.
+ return (
+
+ )
+}
+
export function SessionHeaderLayout(
props: ParentProps<{
title: string | undefined
@@ -223,7 +231,7 @@ export function SessionLocation(props: {
open(props.sessionID, ancestor.id)}
>
{ancestor.title}
diff --git a/packages/app/src/session/session-panel-width.test.ts b/packages/app/src/session/session-panel-width.test.ts
index 938a9064651b..15af22204665 100644
--- a/packages/app/src/session/session-panel-width.test.ts
+++ b/packages/app/src/session/session-panel-width.test.ts
@@ -1,5 +1,11 @@
import { expect, test } from "bun:test"
-import { clampSessionPanelWidth } from "./session-panel-width"
+import { clampSessionPanelWidth, fitsSidePane } from "./session-panel-width"
+
+test("an automatic side pane needs room in the row, excluding the sidebar", () => {
+ expect(fitsSidePane(820 - 240)).toBe(false)
+ expect(fitsSidePane(777)).toBe(false)
+ expect(fitsSidePane(778)).toBe(true)
+})
test.each([
["keeps widths already within the limit", 800, 1700, false, false, 800],
diff --git a/packages/app/src/session/session-panel-width.ts b/packages/app/src/session/session-panel-width.ts
index 172cef4209cb..6ed74af4efea 100644
--- a/packages/app/src/session/session-panel-width.ts
+++ b/packages/app/src/session/session-panel-width.ts
@@ -12,6 +12,10 @@ export const SIDE_PANE_WIDTH_MIN = 320
const SESSION_PANEL_WIDTH_FIT = 450
+export function fitsSidePane(rowWidth: number) {
+ return rowWidth >= SESSION_PANEL_WIDTH_FIT + SIDE_PANE_WIDTH_MIN + 8
+}
+
const REVIEW_PANE_WIDTH_FIT = 480
const REVIEW_PANE_WIDTH_FIT_SPLIT = 800
diff --git a/packages/app/src/session/timeline/message-timeline.tsx b/packages/app/src/session/timeline/message-timeline.tsx
index 591a7b843b3f..3ff58a0cd847 100644
--- a/packages/app/src/session/timeline/message-timeline.tsx
+++ b/packages/app/src/session/timeline/message-timeline.tsx
@@ -35,13 +35,13 @@ import {
SessionAncestorTrail,
SessionHeaderLayout,
SessionLocation,
+ SessionHeaderFade,
SessionTitleHeader,
} from "../session-identity-header"
import { SessionHeaderSpacer } from "@/session/header/session-header"
import { SessionHeaderGap } from "@/session/header/drag-area"
import { SessionWorkingIndicator } from "@/session/header/session-working-indicator"
-
-type BlockingTask = { type: "shell"; partID: string; id?: string; label?: string; started: number }
+import type { BlockingTask } from "@/session/requests/background"
type SessionBackground = {
blocking: Accessor
@@ -83,6 +83,7 @@ type MessageTimelineProps = {
actions?: SessionUserActions
scroll: { overflow: boolean; jump: boolean }
onResumeScroll: (behavior?: ScrollBehavior) => void
+ focusComposer?: () => void
setScrollRef: (el: HTMLDivElement | undefined) => void
onScheduleScrollState: (el: HTMLDivElement) => void
follow: TimelineFollow
@@ -90,6 +91,7 @@ type MessageTimelineProps = {
onHistoryScroll: () => void
centered: boolean
reserveReviewToggle: boolean
+ reviewToggle?: JSX.Element
onContentResize: () => void
bottomInset?: number
setVisibleRef?: (el: HTMLDivElement | undefined) => void
@@ -156,6 +158,8 @@ function MessageTimelineView(
const sessionID = props.data.sessionID
const sessionStatus = props.data.status
const parentID = props.data.parentID
+
+ let titleButton: HTMLButtonElement | undefined
const parentTitle = props.data.parentTitle
const childTitle = props.data.childTitle
const projection = props.data.projection
@@ -194,6 +198,15 @@ function MessageTimelineView(
const showHeader = createMemo(() => !props.hideHeader && (props.data.showHeader() || workspaceSession()))
const messageByID = projection.messageByID
+ const laneSpacing = createMemo(() => {
+ if (!props.next) return
+ const active = projection.activeMessageID()
+
+ if (!active) return
+
+ return laneGap(projection.rows(), active, messageByID())
+ })
+
const virtualized = createTimelineVirtualizer({
active: () => props.active !== false,
sessionKey: () => `${server.key}/${props.data.sessionID()}`,
@@ -205,9 +218,12 @@ function MessageTimelineView(
follow: props.follow,
scroll: () => props.scroll,
onResumeScroll: props.onResumeScroll,
+ focusComposer: props.focusComposer,
setScrollRef: props.setScrollRef,
onContentResize: props.onContentResize,
bottomInset: () => props.bottomInset ?? 0,
+ // The status line's gap above it (--timeline-gap-* in timeline-next.css) past the old lane's 16px.
+ tailExtra: () => ({ s: 0, m: 4, l: 16 })[laneSpacing() ?? "s"],
setVisibleRef: props.setVisibleRef,
onScheduleScrollState: props.onScheduleScrollState,
onUserScroll: props.onUserScroll,
@@ -475,15 +491,6 @@ function MessageTimelineView(
return projection.rows().some((row) => Predicate.isTagged(row, "Thinking") && row.userMessageID === active)
})
- const laneSpacing = createMemo(() => {
- if (!props.next) return
- const active = projection.activeMessageID()
-
- if (!active) return
-
- return laneGap(projection.rows(), active, messageByID())
- })
-
const working = () => {
if (!props.next) return showWorking()
const status = nextStatus()
@@ -572,9 +579,15 @@ function MessageTimelineView(
}}
)}
+ headerInset={
+
+
+
+
+ }
header={
-
+
+ {props.reviewToggle}
>
)}
@@ -651,13 +665,17 @@ function MessageTimelineView(
- {childTitle()}
+
+
+ {childTitle()}
+
}
>
@@ -688,6 +706,7 @@ function MessageTimelineView(
if (event.key === "Escape") {
event.preventDefault()
props.title.cancel()
+ titleButton?.focus({ preventScroll: true })
}
}}
onBlur={props.title.submit}
diff --git a/packages/app/src/session/timeline/quote.tsx b/packages/app/src/session/timeline/quote.tsx
index 5e9d144c25ae..faf85fec5bd6 100644
--- a/packages/app/src/session/timeline/quote.tsx
+++ b/packages/app/src/session/timeline/quote.tsx
@@ -427,6 +427,7 @@ export function TimelineQuote(props: { controller: TimelineQuoteController }) {
onCleanup(() => quote.setElement(undefined))
}}
data-component="timeline-quote"
+ data-floating-overlay
data-prevent-autofocus
role="toolbar"
aria-label={language.t("session.quote.actions")}
diff --git a/packages/app/src/session/timeline/search-bar.tsx b/packages/app/src/session/timeline/search-bar.tsx
index 0d78393dc1b1..61def09a9a0e 100644
--- a/packages/app/src/session/timeline/search-bar.tsx
+++ b/packages/app/src/session/timeline/search-bar.tsx
@@ -1,6 +1,6 @@
import { Icon } from "@opencode/ui/icon"
import "@opencode/ui/text-input.css"
-import { Show } from "solid-js"
+import { For, Show } from "solid-js"
import type { TimelineSearchController } from "./search-controller"
import "./search-bar.css"
@@ -9,7 +9,7 @@ export function TimelineSearchBar(props: { controller: TimelineSearchController
return (
-
+
@@ -64,9 +64,23 @@ export function TimelineSearchBar(props: { controller: TimelineSearchController
{c.result.activeDisplay()}/{c.result.count()}
+
+ {(delta) => (
+ event.preventDefault()}
+ onClick={() => c.result.move(delta)}
+ >
+
+
+ )}
+
event.preventDefault()}
onClick={() => c.query.close()}
diff --git a/packages/app/src/session/timeline/search-controller.ts b/packages/app/src/session/timeline/search-controller.ts
index b3b440b736f6..e249efb8552c 100644
--- a/packages/app/src/session/timeline/search-controller.ts
+++ b/packages/app/src/session/timeline/search-controller.ts
@@ -352,6 +352,8 @@ export function createTranscriptSearch(
activeDisplay: () => view().activeDisplay,
count: () => view().count,
move: (delta: number) => dispatch({ type: "move", delta }),
+ previousLabel: () => language.t("ui.fileSearch.previousMatch"),
+ nextLabel: () => language.t("ui.fileSearch.nextMatch"),
},
element: {
setInput: (element: HTMLInputElement) => (inputEl = element),
diff --git a/packages/app/src/session/timeline/virtualizer.tsx b/packages/app/src/session/timeline/virtualizer.tsx
index dd77a41ecb08..0922e74c9cb7 100644
--- a/packages/app/src/session/timeline/virtualizer.tsx
+++ b/packages/app/src/session/timeline/virtualizer.tsx
@@ -111,11 +111,14 @@ type Input = {
follow: TimelineFollow
scroll: Accessor<{ overflow: boolean; jump: boolean }>
onResumeScroll: (behavior?: ScrollBehavior) => void
+ focusComposer?: () => void
setScrollRef: (element: HTMLDivElement | undefined) => void
/** The rows' content changed height. */
onContentResize: () => void
/** Height of the composer region floating over the timeline's bottom edge, where the timeline fades out. */
bottomInset?: Accessor
+ /** Room the status line needs past the 36px lane, so it keeps its gap to the activity pill. */
+ tailExtra?: Accessor
setVisibleRef?: (element: HTMLDivElement | undefined) => void
onScheduleScrollState: (element: HTMLDivElement) => void
onUserScroll: (target?: EventTarget | null) => void
@@ -139,6 +142,7 @@ export type TimelineRouteReveal = {
type ViewProps = {
header: JSX.Element
+ headerInset?: JSX.Element
bottomSpacer?: JSX.Element
deferred: (row: TimelineRow.TimelineRow) => boolean
renderRow: (row: Accessor, onSizeChange?: () => void) => JSX.Element
@@ -153,7 +157,7 @@ export function createTimelineVirtualizer(input: Input) {
// activity pill and its 10px composer gap. Without hover the pill grows from 32px to its 44px touch size
// (composer-lane.css), and the tail grows with it. Both come and go inside it, so neither moves the rows above.
const touch = createMediaQuery("(hover: none)")
- const tailSize = () => (touch() ? 104 : 92)
+ const tailSize = () => (touch() ? 104 : 92) + (input.tailExtra?.() ?? 0)
const ownerSessionKey = input.sessionKey()
const entry = cache.get(ownerSessionKey)
const cached = entry?.presentationKey === input.presentationKey?.() ? entry : undefined
@@ -1094,7 +1098,8 @@ export function createTimelineVirtualizer(input: Input) {
width: "100%",
height: `${item().size}px`,
overflow: "clip",
- "overflow-clip-margin": Predicate.isTagged(row(), "TurnGap") ? undefined : "0.5px",
+ // Room for paint rounding, card shadows and a focus ring (2px at a 2px offset) on a control at the row edge.
+ "overflow-clip-margin": Predicate.isTagged(row(), "TurnGap") ? undefined : "5px",
}}
>
input.onResumeScroll(prefersReducedMotion() ? "auto" : "smooth")}
+ onClick={(event) => {
+ input.onResumeScroll(prefersReducedMotion() ? "auto" : "smooth")
+
+ // From the keyboard, the button hides under its own focus; the prompt is where the session continues.
+ if (event.detail === 0) input.focusComposer?.()
+ }}
>
+
+ {/* The scroll viewport's fade masks anything outside the chat, including the review toggle when open. */}
+ {props.header}
+
}>
- {props.header}
+ {props.headerInset}
{
if (dialog.active) return
setChatGPTUsageLimit("lastSeenAt", Date.now())
- dialog.show(() =>
)
+ dialog.show(() => (
+
+ ))
})
}),
)
diff --git a/packages/app/src/settings/experimental/experimental.tsx b/packages/app/src/settings/experimental/experimental.tsx
index 1fbd7fb8c865..bb15108eb9e5 100644
--- a/packages/app/src/settings/experimental/experimental.tsx
+++ b/packages/app/src/settings/experimental/experimental.tsx
@@ -1,4 +1,4 @@
-import { Component } from "solid-js"
+import type { Component } from "solid-js"
import { Switch } from "@opencode/ui/switch"
import { Select } from "@opencode/ui/select"
import { useLanguage } from "@/runtime/i18n/language"
diff --git a/packages/app/src/settings/general/general.tsx b/packages/app/src/settings/general/general.tsx
index 6e4ff317a2e5..f78ceab4eed2 100644
--- a/packages/app/src/settings/general/general.tsx
+++ b/packages/app/src/settings/general/general.tsx
@@ -254,6 +254,17 @@ export const SettingsGeneral: Component = () => {
{language.t("settings.general.section.general")}
+
+
+ settings.general.setSharedSidePanel(checked)}
+ />
+
+
diff --git a/packages/app/src/settings/general/interface-mode.css b/packages/app/src/settings/general/interface-mode.css
index ceb7a8c901ba..b166e9031ff9 100644
--- a/packages/app/src/settings/general/interface-mode.css
+++ b/packages/app/src/settings/general/interface-mode.css
@@ -13,13 +13,12 @@
--preview-ink-strong: var(--v2-background-bg-layer-04);
position: relative;
display: flex;
- overflow: hidden;
/* A fixed size keeps the row from resizing when the chosen layout changes the panel width. */
width: 120px;
min-width: 0;
flex-direction: column;
box-sizing: border-box;
- border: 1px solid var(--v2-border-border-base);
+ border: 1px solid var(--v2-border-border-muted);
border-radius: 8px;
background-color: var(--v2-background-bg-layer-02);
cursor: pointer;
@@ -29,19 +28,13 @@
border-color: var(--v2-border-border-strong);
}
+ &:not([data-checked]) [data-slot="interface-mode-sketch"] {
+ opacity: 0.45;
+ }
+
&[data-checked] {
--preview-ink-strong: color-mix(in srgb, var(--v2-background-bg-accent) 70%, transparent);
- border-color: var(--v2-border-border-focus);
-
- /* An inset shadow on the card paints under the opaque name row, so the inner ring sits on top instead. */
- &::after {
- content: "";
- position: absolute;
- inset: 0;
- border-radius: 7px;
- box-shadow: inset 0 0 0 1px var(--v2-border-border-focus);
- pointer-events: none;
- }
+ border-color: var(--v2-border-border-strong);
}
&:has(input:focus-visible) {
@@ -187,6 +180,8 @@
text-overflow: ellipsis;
color: var(--v2-text-text-muted);
background-color: var(--v2-background-bg-base);
+ /* The card doesn't clip, so its check can sit outside the corner. */
+ border-radius: 0 0 7px 7px;
transition: color 120ms ease;
[data-slot="interface-mode-option"]:hover &,
@@ -211,7 +206,7 @@
width: 120px;
flex-direction: column;
box-sizing: border-box;
- border: 1px solid var(--v2-border-border-base);
+ border: 1px solid var(--v2-border-border-muted);
border-radius: 8px;
background-color: var(--v2-background-bg-base);
cursor: pointer;
@@ -221,9 +216,12 @@
border-color: var(--v2-border-border-strong);
}
+ &:not([data-checked]) [data-slot="navigation-mode-sketch"] {
+ opacity: 0.45;
+ }
+
&[data-checked] {
- border-color: var(--v2-border-border-focus);
- box-shadow: inset 0 0 0 1px var(--v2-border-border-focus);
+ border-color: var(--v2-border-border-strong);
}
&:has(input:focus-visible) {
@@ -346,3 +344,36 @@
color: var(--v2-text-text-base);
}
}
+
+/* Selection is a 2px neutral border and a check outside the corner, so it never reads as the blue keyboard ring. The
+ second pixel is an overlay, because an inset shadow would sit under the name's background. */
+:is([data-slot="interface-mode-option"], [data-slot="navigation-mode-option"])[data-checked]::after {
+ content: "";
+ position: absolute;
+ inset: 0;
+ border-radius: 7px;
+ box-shadow: inset 0 0 0 1px var(--v2-border-border-strong);
+ pointer-events: none;
+}
+
+:is([data-slot="interface-mode-option"], [data-slot="navigation-mode-option"]) > [data-slot="mode-option-check"] {
+ position: absolute;
+ z-index: 1;
+ top: -7px;
+ inset-inline-end: -7px;
+ display: flex;
+ width: 16px;
+ height: 16px;
+ align-items: center;
+ justify-content: center;
+ border-radius: 50%;
+ background-color: var(--v2-icon-icon-muted);
+ color: var(--v2-background-bg-base);
+ box-shadow: 0 0 0 2px var(--v2-background-bg-layer-01);
+}
+
+@media (forced-colors: active) {
+ :is([data-slot="interface-mode-option"], [data-slot="navigation-mode-option"]) > [data-slot="mode-option-check"] {
+ border: 1px solid CanvasText;
+ }
+}
diff --git a/packages/app/src/settings/general/interface-mode.tsx b/packages/app/src/settings/general/interface-mode.tsx
index 1374e0b2cf2a..4ac31937c8d1 100644
--- a/packages/app/src/settings/general/interface-mode.tsx
+++ b/packages/app/src/settings/general/interface-mode.tsx
@@ -1,4 +1,5 @@
import { For, Match, Show, Switch, createUniqueId } from "solid-js"
+import { Icon } from "@opencode/ui/icon"
import { Select } from "@opencode/ui/select"
import { useLanguage } from "@/runtime/i18n/language"
import { type TabLayout, useSettings } from "@/settings/model"
@@ -89,6 +90,9 @@ function NavigationSetting() {
{language.t(`settings.general.row.navigation.${mode}`)}
+
+
+
)}
@@ -158,6 +162,9 @@ function TabLayoutSetting() {
{language.t(`settings.general.row.interfaceMode.${mode.id}`)}
+
+
+
)}
@@ -166,5 +173,13 @@ function TabLayoutSetting() {
)
}
+function ModeCheck() {
+ return (
+
+
+
+ )
+}
+
// Mirrors the inbox: a session that needs you, then finished work, then sessions still running.
const inboxRows = ["approval", "done", "working", "working"] as const
diff --git a/packages/app/src/settings/list.tsx b/packages/app/src/settings/list.tsx
index b7c3251d9972..4e9babb33127 100644
--- a/packages/app/src/settings/list.tsx
+++ b/packages/app/src/settings/list.tsx
@@ -3,7 +3,7 @@ import "@/settings/settings.css"
export const SettingsList: Component<{ children: JSX.Element; variant?: "catalog" }> = (props) => {
return (
-
+
{props.children}
)
diff --git a/packages/app/src/settings/model.test.ts b/packages/app/src/settings/model.test.ts
index 20f7c6da1369..328d2cdaf68f 100644
--- a/packages/app/src/settings/model.test.ts
+++ b/packages/app/src/settings/model.test.ts
@@ -46,6 +46,7 @@ describe("settings schema", () => {
showSearch: true,
experimentalBrowser: false,
showProjectIcon: true,
+ focusRing: "muted",
releaseNotes: false,
mobileDiffWrap: false,
},
@@ -57,6 +58,7 @@ describe("settings schema", () => {
expect(settings.general).not.toHaveProperty("showStatus")
expect(settings.general).not.toHaveProperty("experimentalBrowser")
expect(settings.general).not.toHaveProperty("showProjectIcon")
+ expect(settings.general).not.toHaveProperty("focusRing")
expect(settings.appearance).not.toHaveProperty("showProjectName")
const copied = (value: typeof settings) => ({
diff --git a/packages/app/src/settings/model.tsx b/packages/app/src/settings/model.tsx
index 31a846f69662..b01f42311228 100644
--- a/packages/app/src/settings/model.tsx
+++ b/packages/app/src/settings/model.tsx
@@ -137,6 +137,8 @@ const generalSchema = Persistence.struct({
newTimeline: Persistence.optional(Schema.Boolean),
// Browser-style session tab grouping across vertical and horizontal tabs.
tabGroups: Persistence.optional(Schema.Boolean),
+ // One side panel open state for every session tab, instead of one per tab.
+ sharedSidePanel: Persistence.optional(Schema.Boolean),
// "projects" is retired; `resolveSidebarOrganize` moves it to its replacement.
sidebarOrganize: Schema.Literals(["projects", "list", "customize", "recent", "consolidated"]),
mobileTitlebarPosition: Schema.Literals(["top", "bottom"]),
@@ -462,6 +464,10 @@ export const { use: useSettings, provider: SettingsProvider } = createSimpleCont
setTabGroups(value: boolean) {
setStore("general", "tabGroups", value)
},
+ sharedSidePanel: withFallback(() => store.general?.sharedSidePanel, false),
+ setSharedSidePanel(value: boolean) {
+ setStore("general", "sharedSidePanel", value)
+ },
newQuestionUI: withFallback(() => store.general?.newQuestionUI, defaultSettings.general.newQuestionUI),
setNewQuestionUI(value: boolean) {
setStore("general", "newQuestionUI", value)
diff --git a/packages/app/src/settings/navigation.tsx b/packages/app/src/settings/navigation.tsx
index 05ce3fc0cd7a..92434bbb6e2f 100644
--- a/packages/app/src/settings/navigation.tsx
+++ b/packages/app/src/settings/navigation.tsx
@@ -2,12 +2,13 @@ import { Button } from "@opencode/ui/button"
import { Icon } from "@opencode/ui/icon"
import { Menu } from "@opencode/ui/menu"
import { Tabs } from "@opencode/ui/tabs"
-import { createEffect, ErrorBoundary, For, on, Show, type ComponentProps, type JSX } from "solid-js"
+import { createEffect, ErrorBoundary, For, on, onCleanup, Show, type ComponentProps, type JSX } from "solid-js"
import { useLanguage } from "@/runtime/i18n/language"
import { ErrorPage } from "@/shell/errors/error"
import { CollapsedSidebarToggleSpace } from "@/shell/sidebar-toggle"
import { useSettingsSurface } from "./surface"
import { SettingsSearch } from "./search"
+import { trackTabHeader } from "./tab-header"
import "./search.css"
type SettingsNavItem = {
@@ -64,6 +65,27 @@ export function SettingsNavigation(props: {
),
)
+ // Each page renders its own header, so it is found again once the selected page has mounted.
+ createEffect(
+ on(
+ () => props.value,
+ () => {
+ let release: (() => void) | undefined
+
+ const frame = requestAnimationFrame(() => {
+ const header = root?.querySelector
(".settings-content .settings-tab-header")
+
+ if (root && header) release = trackTabHeader(root, header)
+ })
+
+ onCleanup(() => {
+ cancelAnimationFrame(frame)
+ release?.()
+ })
+ },
+ ),
+ )
+
return (
diff --git a/packages/app/src/settings/search-catalog.ts b/packages/app/src/settings/search-catalog.ts
index b87153928c48..82a2b049065c 100644
--- a/packages/app/src/settings/search-catalog.ts
+++ b/packages/app/src/settings/search-catalog.ts
@@ -35,6 +35,14 @@ export const clientSettings: Entry
[] = [
target: "settings-tab-layout",
keywords: "top side tabs inbox sidebar mode layout vertical horizontal focus pro",
},
+ {
+ tab: "general",
+ label: "settings.general.row.sharedSidePanel.title",
+ description: "settings.general.row.sharedSidePanel.description",
+ target: "settings-shared-side-panel",
+ section: "settings.general.section.general",
+ keywords: "right side panel review sidebar persist keep open sessions switch",
+ },
{
tab: "general",
label: "settings.workspaces.default.title",
diff --git a/packages/app/src/settings/settings.css b/packages/app/src/settings/settings.css
index 385621c21fba..f73e7167e588 100644
--- a/packages/app/src/settings/settings.css
+++ b/packages/app/src/settings/settings.css
@@ -610,6 +610,11 @@
background: var(--v2-background-bg-base);
}
+/* Focus scrolled up stops below the sticky header and its 24px fade. tab-header.ts measures the header. */
+.settings-tab-body :is(a[href], button, input, select, textarea, [tabindex]) {
+ scroll-margin-block-start: calc(var(--settings-tab-header-height, 0px) + 24px);
+}
+
.settings-tab-header::before {
content: "";
position: absolute;
@@ -1321,9 +1326,11 @@
}
.settings-providers-view-all {
+ align-self: flex-start;
margin-top: 20px;
padding: 0;
border: 0;
+ border-radius: 4px;
background: transparent;
font-size: 13px;
font-weight: 530;
@@ -1460,6 +1467,13 @@
.settings-project-card[data-menu="true"] {
background: var(--v2-background-bg-layer-02);
}
+
+/* The row's button opens the project, so the ring goes on the whole row, inset like the other full-width rows. The
+ options button keeps its own ring. */
+.settings-project-card:has(> button:first-child:focus-visible) {
+ outline: 2px solid var(--v2-border-border-focus);
+ outline-offset: -2px;
+}
.settings-models {
gap: 12px;
}
@@ -1923,7 +1937,9 @@
min-height: 0;
flex-direction: column;
gap: 12px;
- overflow: hidden;
+ /* Clipped for the removal animation, with room for a focus ring on the row's edge controls. */
+ overflow: clip;
+ overflow-clip-margin: 5px;
transition:
padding-bottom 150ms ease-out,
margin-bottom 150ms ease-out,
@@ -2256,8 +2272,16 @@
padding-inline: 0 !important;
}
+/* The panel scrolls, so its sides are padded by 5px and taken back by the margin: room for the focus ring of a control
+ at its edge, such as Check for updates and How to add skills. The tabs root's overflow-clip-margin covers the rest. */
.settings-subtabs > [data-slot="tabs-v2-content"] {
padding-top: 24px;
+ padding-inline: 5px;
+ margin-inline: -5px;
+}
+
+.settings-subtabs > [data-slot="tabs-v2-content"]:focus-visible {
+ outline-offset: -2px;
}
.settings-extension-row {
diff --git a/packages/app/src/settings/shell.tsx b/packages/app/src/settings/shell.tsx
index 282c678e61df..790c316f99ce 100644
--- a/packages/app/src/settings/shell.tsx
+++ b/packages/app/src/settings/shell.tsx
@@ -140,6 +140,7 @@ export function SettingsScreen() {
{
diff --git a/packages/app/src/settings/tab-header.ts b/packages/app/src/settings/tab-header.ts
new file mode 100644
index 000000000000..41c370e272f3
--- /dev/null
+++ b/packages/app/src/settings/tab-header.ts
@@ -0,0 +1,12 @@
+// A settings page's header sticks over its body, and the browser does not count sticky elements when it scrolls focus
+// into view. settings.css offsets each focusable control by `--settings-tab-header-height`, which this keeps equal to
+// the header's height on `scope`. Returns the cleanup.
+export function trackTabHeader(scope: HTMLElement, header: HTMLElement) {
+ const observer = new ResizeObserver(() =>
+ scope.style.setProperty("--settings-tab-header-height", `${header.offsetHeight}px`),
+ )
+
+ observer.observe(header)
+
+ return () => observer.disconnect()
+}
diff --git a/packages/app/src/settings/workspaces/project-row.tsx b/packages/app/src/settings/workspaces/project-row.tsx
index 8a4f02ddc199..a69696380e9b 100644
--- a/packages/app/src/settings/workspaces/project-row.tsx
+++ b/packages/app/src/settings/workspaces/project-row.tsx
@@ -97,7 +97,7 @@ export function SettingsProjectRow(props: {
type="button"
aria-label={displayName(props.project)}
title={props.project.worktree}
- class="flex h-full min-w-0 flex-1 items-center gap-2 rounded-[4px] bg-transparent text-start focus-visible:outline-none focus-visible:[box-shadow:inset_0_0_0_1px_var(--v2-border-border-focus)]"
+ class="flex h-full min-w-0 flex-1 items-center gap-2 rounded-[4px] bg-transparent text-start focus-visible:outline-none"
onClick={() => props.onOpen(props.project)}
>
diff --git a/packages/app/src/settings/workspaces/project.css b/packages/app/src/settings/workspaces/project.css
index b8ada6daf6a7..139c6abb2f3f 100644
--- a/packages/app/src/settings/workspaces/project.css
+++ b/packages/app/src/settings/workspaces/project.css
@@ -325,11 +325,16 @@
transition: box-shadow 120ms ease;
}
-.project-settings-color:focus-visible,
+/* Selection is a neutral ring and focus the shared blue outline, so a focused swatch and the selected one stay distinct. */
.project-settings-color--selected {
box-shadow:
0 0 0 2px var(--v2-background-bg-layer-01),
- 0 0 0 4px var(--v2-border-border-focus);
+ 0 0 0 4px var(--v2-border-border-inverse);
+}
+
+.project-settings-color:focus-visible {
+ outline: 2px solid var(--v2-border-border-focus);
+ outline-offset: 2px;
}
@media (hover: hover) {
diff --git a/packages/app/src/shell/commands/keymap.test.ts b/packages/app/src/shell/commands/keymap.test.ts
index 15c3cc934e3b..fdf96464731e 100644
--- a/packages/app/src/shell/commands/keymap.test.ts
+++ b/packages/app/src/shell/commands/keymap.test.ts
@@ -143,6 +143,23 @@ test("keys are left alone while keybinds are blocked", () => {
expect(ran).toEqual(["palette"])
})
+// A page prompt in the browser pane is a modal alert dialog; the app's keys stay off inside it and work everywhere else.
+test("a modal alert dialog keeps command keys from running inside it", () => {
+ const ran: string[] = []
+ setup([command("palette", "mod+k", ran)])
+ const prompt = document.createElement("div")
+ prompt.setAttribute("role", "alertdialog")
+ prompt.setAttribute("aria-modal", "true")
+ const field = document.createElement("input")
+ prompt.append(field)
+ document.body.append(prompt)
+
+ press(field, { key: "k", ctrlKey: true })
+ press(document.body, { key: "k", ctrlKey: true })
+
+ expect(ran).toEqual(["palette"])
+})
+
test.each([
{ keybind: "mod+alt+.", init: { key: "≥", code: "Period", ctrlKey: true, altKey: true } },
{ keybind: "mod+shift+[", init: { key: "{", code: "BracketLeft", ctrlKey: true, shiftKey: true } },
diff --git a/packages/app/src/shell/commands/keymap.ts b/packages/app/src/shell/commands/keymap.ts
index c8efe7ec954d..55156fb03f9f 100644
--- a/packages/app/src/shell/commands/keymap.ts
+++ b/packages/app/src/shell/commands/keymap.ts
@@ -208,8 +208,8 @@ function physicalKey(event: Pick
) {
return event.key
}
-// The HTML host, except that it drops keys while an IME composes or while command keybinds are blocked, and that
-// its owner can destroy it, which disposes the keymap.
+// The HTML host, except that it drops keys while an IME composes, while command keybinds are blocked or while the
+// keyboard is inside a modal alert dialog, and that its owner can destroy it, which disposes the keymap.
function createAppKeymapHost(root: HTMLElement, blocked: () => boolean) {
const host = createHtmlKeymapHost(root)
const destroyed = new Set<() => void>()
@@ -238,6 +238,10 @@ function createAppKeymapHost(root: HTMLElement, blocked: () => boolean) {
if (blocked()) return
+ // A modal alert dialog the app's dialog stack does not track, such as a page's prompt in the browser pane, is
+ // modal for less than the window: its keys are its own.
+ if (original?.target instanceof Element && original.target.closest('[role="alertdialog"][aria-modal="true"]')) return
+
listener(event)
}),
onKeyRelease: (listener) => host.onKeyRelease(listener),
diff --git a/packages/app/src/shell/palette-menu.css b/packages/app/src/shell/palette-menu.css
index 8efd76a41d95..e48f7c0f8d56 100644
--- a/packages/app/src/shell/palette-menu.css
+++ b/packages/app/src/shell/palette-menu.css
@@ -82,6 +82,17 @@
white-space: nowrap;
}
+@media (forced-colors: active) {
+ :is(.palette-menu-row, [data-color-scheme="dark"] .palette-menu-row):is([data-active], :focus-visible) {
+ background: Highlight;
+ color: HighlightText;
+ }
+
+ .palette-menu-row:is([data-active], :focus-visible) * {
+ color: inherit;
+ }
+}
+
@media (prefers-reduced-motion: reduce) {
.palette-menu-search [data-component="text-input-v2"] {
transition: none;
diff --git a/packages/app/src/shell/panel-motion.ts b/packages/app/src/shell/panel-motion.ts
index fbf461dea9d4..86acdc8fed3b 100644
--- a/packages/app/src/shell/panel-motion.ts
+++ b/packages/app/src/shell/panel-motion.ts
@@ -16,14 +16,16 @@ import {
const [flights, setFlights] = createSignal(0)
// A resize handle being dragged. On Linux a native view's bounds land on screen frames before the DOM around it, so one
-// kept live through a drag would jump against its panel on every move. macOS puts both on the same frame, so its views
-// stay live and keep laying out through the drag. Windows is untested and keeps the still.
+// kept live through a drag would jump against its panel on every move. macOS and Windows put both on the same frame, or
+// one apart, so their views stay live and keep laying out through the drag. Hiding the view for a still instead blanks
+// the box on the first move, until the window paints the still, and leaves the box's background beside the still as the
+// panel grows.
const [resizing, setResizing] = createSignal(false)
export const panelsMoving = () => flights() > 0 || resizing()
/** Pass to a resize handle's `onDraggingChange` when its drag moves a panel that can hold a native view. */
-export const setPanelResizing = (dragging: boolean) => setResizing(dragging && !/Mac/.test(navigator.platform))
+export const setPanelResizing = (dragging: boolean) => setResizing(dragging && !/Mac|Win/.test(navigator.platform))
// The left sidebar and the side panel share one spring, so they move as one system. Each panel's flight takes its time
// scaled by the square root of how far it travels against a 480px panel, between 0.15s and 0.3s, so a narrow sidebar
diff --git a/packages/app/src/shell/search-list.css b/packages/app/src/shell/search-list.css
index 1992733eddbc..a211a60cf1ad 100644
--- a/packages/app/src/shell/search-list.css
+++ b/packages/app/src/shell/search-list.css
@@ -57,6 +57,17 @@
outline: none;
}
+@media (forced-colors: active) {
+ .search-list-row:is([data-active], :focus-visible) {
+ background: Highlight;
+ color: HighlightText;
+ }
+
+ .search-list-row:is([data-active], :focus-visible) * {
+ color: inherit;
+ }
+}
+
.search-list-row-text {
display: flex;
min-width: 0;
@@ -279,10 +290,8 @@
/* A list dialog with a compact header and a bare search, as in the integration and manage models dialogs. */
[data-component="dialog-v2"] [data-slot="dialog-container"] [data-slot="dialog-content"].search-dialog {
- /* Trailing controls sit 10px from both the top and the end edge. */
[data-slot="dialog-header"] {
- padding-block: 10px 6px;
- padding-inline: 14px 10px;
+ padding: 14px 16px 8px;
[data-slot="dialog-close-button"] {
margin-top: 0;
@@ -308,8 +317,9 @@
}
[data-slot="dialog-description"] {
- font-size: 12px;
+ font-size: 13px;
line-height: var(--line-height-base);
+ letter-spacing: -0.04px;
}
}
diff --git a/packages/app/src/shell/shell.tsx b/packages/app/src/shell/shell.tsx
index bc223771e5d6..fdad7ee44b89 100644
--- a/packages/app/src/shell/shell.tsx
+++ b/packages/app/src/shell/shell.tsx
@@ -246,6 +246,7 @@ export default function Layout(props: ParentProps) {