Skip to content

feat(app): enable workspace panes before the first message - #58225

Open
nixoid wants to merge 4 commits into
anomalyco:devfrom
nixoid:draft-panes
Open

nixoid wants to merge 4 commits into
anomalyco:devfrom
nixoid:draft-panes

Conversation

@nixoid

@nixoid nixoid commented Oct 22, 2026

Copy link
Copy Markdown

Issue for this PR

No existing GitHub issue. This came from trying to inspect a workspace before sending the first message.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

File Browser, Review and Browser are workspace tools, but they currently require a saved Session. That makes users send a message just to inspect files or preview a page. Review also appears automatically beside unrelated panes, and its toggle controls the whole sidebar rather than Review itself.

This lets the New Session screen use the same pane components and context as saved Sessions. A draft reserves an ID locally; no backend Session is created until the first message. That message reuses the ID, keeping the draft's workspace, open panes and browser state through the handoff. Extensions must opt into drafts, so existing session-only extensions keep their current behavior. Browser drafts use the workspace's network connection, but agent permissions are granted only after the Session is saved.

  • Cmd/Ctrl+E toggles File Browser, including when its filter has focus.
  • Review becomes a normal, closable tab, opened through + or Cmd/Ctrl+Shift+R instead of appearing automatically.
  • Cmd/Ctrl+Shift+B opens Browser on a draft too.
  • Cmd/Ctrl+P, existing diffs and the mobile Changes view stay intact.

How did you verify your code works?

  • Reran all 25 Review e2e cases; the draft/promotion/close-button keeper also passed 10 repetitions without retries.
  • Earlier branch validation passed 39 related e2e cases, browser component/connection tests and core browser lifecycle tests, including no Session creation before submission and delayed permission grants. Also exercised a local desktop release build.
  • Changed-file lint and formatting pass. Full bun run check is blocked by four existing TUI type errors; the e2e typecheck still has its four existing timeline/performance errors.
  • A follow-up desktop report that the X button does nothing did not reproduce in the harness. Added checks for closing File Browser and Review before submission, closing a background Review tab after submission, and closing the last pane. No unverified runtime fix is claimed for that report.

Screenshots / recordings

Unsent prompt with an explicitly opened Review tab and file preview. The test confirms no backend Session exists at this point.

Workspace panes before the first message

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Problem and inconsistencies
---------------------------
File Browser, Review and Browser operate on a workspace, but their UI was
available only through a saved Session screen. Before the first message,
the draft route exposed neither the mounted extension context nor the side
region, so the same shortcuts behaved differently depending on whether the
user had already chatted. Creating an empty backend Session to unlock these
features would break the existing admit-on-first-message behavior.

The file launcher was also presented as Open file and associated with quick
open rather than a separate File Browser toggle. Review was unconditionally
pinned whenever any side pane opened, while Toggle review actually toggled
the entire region. Its expanded state therefore described unrelated file
and browser panes instead of Review itself.

Browser attachments had a further saved-Session dependency: registration
looked up the Session and immediately granted agent access. Allocating a new
Session id on submission would also replace the identity owning draft tabs,
file-view state and native browser bindings.

Solution
--------
- Reserve the eventual Session id locally on the existing draft tab and
  reuse it on first submission. Keep backend Session creation where it was;
  opening or looking up a draft pane does not create a Session record.
- Mount the shared SessionScreen, extension context, region and sizing on
  drafts instead of introducing parallel pane implementations. Add an
  explicit draft indicator and opt-in lookups/Panel.drafts so session-only
  extensions retain their saved-Session-only defaults.
- Resolve existing workspace selections to their actual directory. Keep
  file-view keys stable and transfer region preferences during promotion,
  pending worktree creation and rollback, retaining the composer handoff.
- Register file.browse with mod+e and matching menu copy. Repeating it closes
  the selected File Browser even while its filter owns focus. Leave mod+p
  and the existing Changes/diff functionality intact.
- Make Review an ordinary, explicitly opened tab with a + menu entry and
  mod+shift+r. Let its extension own the toggle and accessibility state via
  a generic slot; distinguish the host's Toggle side panel command. Close
  empty regions and derive width requirements from the selected panel.
- Carry draft location metadata through browser IPC and use the existing
  Location network tunnel without a saved Session or agent grant. Drafts
  negotiate RPC version 5 while saved attachments retain version 4. Subscribe
  to session.created before the initial lookup, then grant access only once
  the reserved Session exists in the matching Location, revoking it when
  the attachment ends. Keep the binding on same-directory promotion and
  restore its tab inventory when a workspace change requires retargeting.
  An unsupported draft handshake does not disable saved-Session browsing.
- Exclude unsaved drafts from Session refreshes and snapshot-diff modes,
  make visit-scoped state recognize draft visits, and defer initial blank
  browser address focus until its input ref exists.

Verification
------------
Update the existing Review/tab/mobile keepers and shared harness for opt-in
Review and the multi-entry + menu. Add coverage for zero Session creation
before submission, first-message pane retention, native browser binding
retention, workspace retargeting and delayed browser permission grants.

Passed: 25 Review and 39 related e2e cases; 20 native macOS shortcut/draft
repetitions; 5 component cases and 10 draft-browser repetitions; 15 browser
connection unit cases; and 20 core browser lifecycle executions. Also passed
affected-package typechecks, changed-file lint, formatting, SDK documentation
checks, and desktop release packaging/runtime/signature verification.

Full bun run check remains blocked by four existing TUI type errors; the
e2e typecheck retains its four existing timeline/performance errors. The
unrelated worktree composer cursor failure also reproduces in the original
checkout. Local three-sample cold-entry medians were 420.6 ms before and
379.9 ms after. Build outputs and installation artifacts are not committed.
Exercise the X buttons in the existing draft-pane keeper, not only the keyboard shortcuts. Verify File Browser and Review can each close the last draft pane without saving a Session or losing the prompt, and can be reopened normally.

After first-message promotion, close the background Review tab without changing the selected file, then close the final file tab and check that the side panel disappears. Keep the original draft shortcut-toggle assertions.

The reported desktop close-button failure did not reproduce in this harness; this commit adds regression coverage rather than claiming an unverified runtime fix. All 25 Review cases passed, and the expanded keeper passed 10 repetitions without retries.

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed by reading the code and running type checks (gui-extensions, app and plugin-browser all pass) plus the browser connection and core browser-idle tests (all pass). I could not run the new e2e cases here because Chromium is missing a system library, so the draft panes behaviour is not verified. Could you attach before/after screenshots or a short recording of the New Session screen with File Browser, Review and Browser open, and of a saved Session where Review no longer appears automatically?

Public API: these changes affect the extension SDK and the browser RPC. All are optional additions, so existing extensions and callers keep working:

  • Sessions.list(options?), Sessions.current(options?) and Screen.current(options?) gain an optional { drafts?: boolean } argument. The default excludes drafts, so current behaviour is kept.
  • SessionRef.draft?: boolean and Panel.drafts?: boolean are added.
  • Layout.toggle(key, session, options?) gains an optional OpenOptions.
  • A new slot session.panel.toggle is added.
  • The experimental.browser attach input accepts version: 4 | 5 plus an optional draft, and the attached control event now echoes the version it was given.
  • The persisted draft tab gains an optional sessionId.

Behaviour changes:

  • The app command review.toggle (mod+shift+r) is replaced by a Review extension command with the same binding, plus a new unbound panel.toggle.
  • The File Browser gets a mod+e binding.

Scope: beyond draft panes, this bundles several UX changes:

  • Review is no longer listed unless it was explicitly opened, so existing sessions lose the Review tab they had.
  • "Open file" is renamed "File Browser" and gets mod+e.
  • Closing the last tab now collapses the side region.
  • wide now follows only the active tab.
  • The Review toggle moves into a slot.

Each of these is reasonable alone, but together they change the default side panel for every user. I'd suggest confirming them with maintainers or splitting them from the draft panes work. Also, SessionReviewToggle in session/header/session-header-actions.tsx is now unused, and artifact-view.tsx contains formatting-only changes unrelated to this PR.

.pipe(Effect.mapError(() => call.error("unavailable", "Session not found.", {})))
if (session.location.directory !== ctx.location.directory)
const committed = yield* Deferred.make<void>()
if (input.draft)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A draft attach now starts a browser on this Location's network for any ses… ID that has no Session yet. Access is granted later, when a matching session.created event arrives. That seems fine, but please check compatibility: a desktop build that sends version: 5 to an older server, which only accepts Schema.Literal(4), gets a schema decode error rather than browser.pane.unsupported. Does the pane then mark drafts unsupported for that server (the new supportKey), or keep retrying with backoff? A test for draft attach against a v4-only server would make this clear.

@@ -151,7 +158,7 @@ const setup: Setup<typeof Review> = (ctx) => {
order: 10,
kind: "tab",
},
list: (input) => (!layout.narrow() && input.session.project ? [tab] : []),
list: (input) => (!layout.narrow() && input.session.project && input.open.includes(TAB) ? [tab] : []),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review used to be pinned and transient, so every saved session showed it. With input.open.includes(TAB), existing sessions lose the Review tab until the user opens it via + or mod+shift+r, and features that relied on Review being present now need that explicit step. This is a product decision separate from draft panes; it would be good to get maintainer sign-off or move it to its own PR.

const tabs = useTabs()
const servers = useSettingsServers()
const settingsSurface = useSettingsSurface()
tabs.reserveDraft(props.draftId)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reserved ID survives a failed first send: the draft is restored with the same sessionId, and composer-adapter reuses it via reserveDraft. If the first session.create actually reached the server, for example a timeout after creation, the retry sends an ID that already exists. How is that handled? It may be worth issuing a fresh ID when the create fails with a conflict.

return key ? byKey().get(key) : undefined
}),
wide: createMemo(() => providers().some((item) => item.value.wide)),
wide: createMemo(() => !!byKey().get(active() ?? "")?.provider.wide),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wide now depends only on the active tab, not on whether any provider in the region is wide. Switching between a split-diff Review tab and a file tab will now change the session's minimum width on every switch, which can make the layout jump. Was that intended?

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only new commit merges dev into the branch. The PR's own changes are identical to the version I reviewed earlier. Type checks for gui-extensions, app and plugin-browser and the browser connection tests still pass on the merged head.

None of the earlier points are addressed yet; their threads stay open:

  • draft attach against an older (v4-only) server
  • Review no longer listed by default
  • a retry after a failed first send reusing the reserved ID
  • wide following only the active tab

The public API impact is unchanged from my earlier review. Before/after screenshots or a short recording of the draft panes would still help.

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only new commit merges dev again; it changes none of the PR's files, and its own changes are identical to the version I reviewed before.

None of the earlier points are addressed yet; their threads stay open:

  • draft attach against an older (v4-only) server
  • Review no longer listed by default
  • a retry after a failed first send reusing the reserved ID
  • wide following only the active tab

The public API impact is unchanged from my earlier review. Before/after screenshots or a short recording of the draft panes would still help.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant