Skip to content

New session: draft first, pick project and worktree, create on send - #1005

Merged
ivanfenenko merged 12 commits into
mainfrom
feature/1004-new-session-draft
Nov 9, 2026
Merged

ivanfenenko merged 12 commits into
mainfrom
feature/1004-new-session-draft

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • New session opens Session Chat at once as a draft: header "New session · Draft · created when you send", and nothing is created on the server until the first send. Both apps already opened chat with a placeholder session; the eager create on bind is now done on the first send instead.
  • A centred Run session in card (prototype version 1: two-line rows with icon tiles) picks where it runs: Project and Worktree rows each open their own sheet, plus Starts from for a new worktree on v2. A folder that is not a Git repo shows a greyed "None · not a Git repo" row; with the Worktrees setting off there is no Worktree row. The card keeps phone width on wide screens and tightens with the keyboard up.
  • Project sheet: search, Home order, Add project… (a project added from there becomes the draft's project). Worktree sheet: Local, New worktree, then the project's worktrees with running counts. Starts from lists v2 base branches.
  • First send creates the worktree (server-named, no name field; v2 from the chosen base, v1 from the current checkout), then the session in it, then sends the prompt. A failure keeps the draft with Retry and does not create duplicates.
  • The draft (text, attachments, model/agent/variant, project, place) is kept in memory per Connection Profile: Back and backgrounding keep it, New session restores it, Discard draft (⋯) and app restart drop it. Back with no text drops it.
  • Home's hold gesture and New session / Run in sheet are gone; the dock, ⌘N / Ctrl+N, Worktrees "New session here" and /new all open the draft.
  • New design-system card component on both platforms (RunSessionInCard on iOS, OpenCodePickerCard on Android) with gallery entries. String keys shared across platforms.

Checks

  • Android: ./gradlew :app:assembleDebug :app:assembleDebugAndroidTest :app:testDebugUnitTest pass.
  • iOS: xcodebuild test -only-testing:"OpenCode MobileTests" pass (3378 Swift Testing + 124 XCTest).
  • node scripts/check-string-keys.mjs passes; gitleaks finds nothing.
  • Real apps against the scenario harness (opencode v1 1.19.5 and v2 dev, scripted model): draft and card, both sheets, New worktree with and without Starts from, base branch honoured on v2 (worktree HEAD at the chosen branch), request order worktree → session → prompt on both protocols, non-Git project via Add project…, Worktrees off, keep / restore / discard, failed first send keeps the draft and a resend creates one session.

Evidence

Screenshots in the evidence comment.

Issue

Fixes #1004

Risks / Follow-ups

  • Not checked on a device: tablets, foldables / iPhone Duo, light mode on Android, Android with the keyboard up (the emulator would not show its soft keyboard; iOS was checked), and the iOS failure/Retry path (covered by unit tests).
  • The Local tile uses a stand-in icon (terminal on Android, folder-check on iOS): there is no monitor icon in the shared icon set yet.
  • v1 accepts a worktree create without a name (checked on 1.19.5); older v1 servers were not tried.
  • The header title is not muted while drafting (the top bar has no muted style). The Android retry snackbar times out after a few seconds; Send retries the same way.
  • After a send the in-memory draft is cleared once the session exists; a prompt failure after that uses the normal send error in the real session.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

ivanfenenko and others added 11 commits November 9, 2026 10:28
A caption, one rounded card of label-over-value rows with icon tiles
that open pickers, and a middle-truncated path footnote. Keeps one
phone width on wide windows; compact rows while the keyboard is up.
Gallery entry included.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Binding the placeholder session no longer creates anything on the
server. Session Chat shows the draft: a "New session" header, the Run
session in card (Project, Worktree, Starts from for a new v2 worktree)
with its project, worktree and base-branch sheets, and a live composer.

The first send creates the new worktree (v2 from the chosen base, v1
from the checkout; the server names it), then the session in that
checkout, seeds its model, promotes the screen to it and sends the
prompt through the normal path. A failure keeps the draft and shows the
error with Retry; a retry reuses what was already created.

NewSessionDraftStore keeps one draft per Connection Profile in memory:
text, attachments, model/agent/variant, project and place. Leaving an
empty draft drops it; Discard draft (overflow menu) clears it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Home's New session (dock tap and Ctrl+N), the Worktrees screen's New
session here, Ctrl+N and /new in Session Chat all open the draft. The
profile's draft wins; a fresh one starts in the Home filter's project
or worktree, or where the most recent session runs in All. New session
here keeps the draft's text and runs in that worktree.

The hold gesture, Home's New session / Run in sheet and its eager New
worktree create are gone. The draft's Add project… opens Home's Add
project flow, and the project it adds becomes the draft's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A New session draft creates its worktree on the first send and lets the
server pick the name, so the create request's name is optional and the
v1 and v2 bodies omit it when nil.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
NewSessionDraft holds what a New session has before it exists on the
server: text, attachments, model pick, project and place (Local, an
existing worktree, or a New worktree with its base). NewSessionDraftStore
keeps one per Connection Profile in memory only; a draft with text or
attachments wins when New session opens again, a place alone is not
kept. NewSessionDraftStart holds the starting-place rule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A caption over one rounded card of two-line rows (icon or letter tile,
small label, bold value, chevron) with inset dividers and a muted
middle-truncated path under it. Keeps a 340 pt width on wide screens and
tightens with the keyboard up. Gallery entry and previews included.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
New session now opens Session Chat at once as a draft: nothing is created
on the server until the first send. The draft shows a centred "Run
session in" card (Project, Worktree, Starts from on v2) whose rows open
their own bottom sheets, a "New session / Draft · created when you send"
header, and only Discard draft in the overflow menu.

The first send creates the worktree (New worktree, server-named, v2 from
the chosen base), then the session in that checkout, seeds its model,
promotes the screen in place and sends the prompt through the normal
path. A failure keeps the draft and offers Retry; a worktree that was
already created is reused.

The draft lives in memory per Connection Profile: Back or backgrounding
keeps it, New session restores it, a successful send or Discard draft
clears it. Home's dock tap, Cmd-N, /new and Worktrees "New session
here" open it; the New session hold gesture, the Home New session / Run
in sheet and its eager New worktree path are gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Android takes the iOS key names, keeps the three strings iOS still uses,
and iOS drops the Home keys and helpers nothing uses any more.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…v2 (iOS)

The draft area already sits above the keyboard, so adding the overlap
again pushed the card under the header. The draft also read the stored
protocol, which is unset until probed, so v2 lost Starts from and the
chosen base branch; it now probes once when the draft opens.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

iOS 27.2 simulator and Android 17 emulator (Pixel 9a), opencode v1 1.19.5 and v2 dev via the scenario harness (scripted model, throwaway projects).

Step iOS Android
Draft with the Run session in card
Worktree sheet
New worktree + Starts from (v2)
New worktree on v1 (no Starts from)
Keyboard up not shown (emulator kept its soft keyboard hidden)
Project sheet with search
Not a Git repo
Worktrees setting off
After the first send
Draft restored after Back
First send fails: draft kept, Retry

@ivanfenenko
ivanfenenko marked this pull request as ready for review November 9, 2026 14:09

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review: no finding that 2+ of 2 passes agreed on.

6 finding(s) from a single pass, not posted
  • android/app/src/main/java/dev/opencode/mobile/ui/sessionchat/SessionChatViewModel.kt:2024 medium: Add project… from a content-less draft is swallowed: the popped draft screen's onCleared drops the pending add-project request (glm-5.3-flash)
  • ios/OpenCode Mobile/OpenCode Mobile/UI/SessionChat/NewSessionDraftPresentation.swift:203 medium: Worktrees setting off still shows and uses a stored draft's worktree / New worktree place (deepseek-v4.1-flash)
  • ios/OpenCode Mobile/OpenCode Mobile/UI/SessionChat/SessionChatViewModel.swift:2213 medium: Every draft screen writes the shared per-profile draft with no ownership, so a stale screen overwrites newer edits (deepseek-v4.1-flash)
  • android/app/src/main/java/dev/opencode/mobile/ui/sessionchat/SessionChatViewModel.kt:2013 low: discardNewSessionDraft leaves newSessionDraft set, so publishUiState re-renders the discarded draft card (glm-5.3-flash)
  • ios/OpenCode Mobile/OpenCode Mobile/UI/SessionChat/Region/SessionChatComposer.swift:205 low: composer.promoteDraft switches to the created worktree without reloading its commands, agents or selection context (glm-5.3-flash)
  • android/app/src/main/java/dev/opencode/mobile/ui/sessionchat/SessionChatViewModel.kt:2118 low: v2 base branch silently ignored when the stored protocol hint is unset (deepseek-v4.1-flash)

opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.177 · 1 pass(es) stopped early · 1 pass(es) failed

Keep both sides in Session Chat: the draft's Retry action (#1004) and the
"Still sending…" stall Retry from #1003 share the snackbar.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko
ivanfenenko merged commit 14e221c into main Nov 9, 2026
@ivanfenenko
ivanfenenko deleted the feature/1004-new-session-draft branch November 9, 2026 15:39
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.

New session: draft first, pick project and worktree, create on send

1 participant