Skip to content

#419 Fork from Session Chat overflow and from a message - #658

Merged
ivanfenenko merged 2 commits into
mainfrom
feature/ope-81-session-fork-from-session-chat
Oct 14, 2026
Merged

ivanfenenko merged 2 commits into
mainfrom
feature/ope-81-session-fork-from-session-chat

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Overflow → Fork session (iOS + Android): new entry after "Review changes". It forks the whole session at the tip and is allowed while busy or with a permission pending.
  • Message actions → Fork from here: shown on outgoing (user) messages only, between "Revert message" and "Copy message". It forks before that message (v1 messageID, v2 before).
  • One fork flow: the Commands sheet [fork], the overflow entry and the message action all use the existing dialog and Open / Stay here prompt. A message ID is optional all the way through to forkSession.
  • Title prefill: Fork of {title} from every entry point, or Forked session when the title is blank. Android shares this with Home through SessionForkTitle.
  • Rename failure no longer double-forks: fork and rename are separate steps. If the fork succeeds and the rename fails, the dialog closes, Open / Stay here still shows (with the server's title for the fork), and a non-blocking snackbar says "Fork created, but it couldn't be renamed." A failed fork keeps the dialog open with the error, as before. confirmFork does nothing once the dialog has closed.
  • Composer prefill (the issue's open question): the server copies history strictly before the message, so the tapped message isn't in the fork. Following the opencode TUI (dialog-fork.tsx prefills the fork's prompt with that message), a message fork saves the message text as the fork's composer draft through ComposerDraftStore. It appears when you tap Open, or later from the session list.
  • Analytics: chat_overflow_fork and message_actions_fork on both platforms.

Evidence (iOS, real app against a local opencode 1.18.35 server)

Message actions Fork dialog Result prompt Fork opened, composer prefilled Overflow

Checked on the server afterwards: exactly one fork, containing the 2 messages before the tapped one. Cancel from the overflow dialog created no session.

Checks

  • Android: ./gradlew --offline :app:assembleDebug passes. :app:testDebugUnitTest --tests '*SessionChat*' --tests '*MainScreenViewModelTest*': 384 tests, 0 failures. ktlint shows no new violations; the touched files already had some.
  • iOS: xcodebuild build passes. xcodebuild test -only-testing:"OpenCode MobileTests/SessionChatViewModelTests": 164/164 pass.
  • New Screen Model tests on both platforms cover:
    • a tip fork and the prefill fallback
    • a message fork: the message ID is passed and the composer draft is saved for the fork
    • rename failure: one fork, the prompt still shows, the snackbar shows
    • fork failure keeps the dialog open
    • Cancel or a blank title makes no API call
  • iOS real-app run as shown above.

Issue

Risks / Follow-ups

  • Android was not run in a real app on an emulator; it is covered by unit tests only. The UI change is two menu and sheet entries wired to the Screen Model.
  • The live run used one local server. The v1/v2 forkSession mapping was already in the repositories and is unchanged.
  • The "Session forked" prompt copy is unchanged from OPE-58.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith with what you need.

Add "Fork session" to the Session Chat overflow menu and "Fork from here"
to the outgoing-message actions sheet on iOS and Android. All entry points
share the existing fork dialog, now with an optional message ID passed to
forkSession and a "Fork of {title}" prefill ("Forked session" when blank).

Fork and rename are now separate steps: a failed rename after a successful
fork closes the dialog, still offers Open / Stay here, and shows a
non-blocking error, so one confirm never creates two forks. A fork from a
message saves that message's text as the fork's composer draft, matching
the opencode TUI.

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

linear-code Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
OPE-81 Session fork from Session Chat

What to build

From Session Chat, fork the open session via overflow (Fork session, whole session) or an outgoing message action (Fork from here). Show a shared name dialog with suggested title Fork of {currentTitle} (fallback Forked session), let the user edit it, create the fork, then prompt Open forked session / Stay here.

Synced Feature Slice: iOS + Android.

Relationship to OPE-58

OPE-58 implements this whole-session fork dialog flow first as the Commands-sheet [fork] action. This ticket wires the overflow and message entry points to that same shared path (and adds message-scoped fork with messageID). Prefer reusing OPE-58’s dialog/navigation rather than a second fork implementation.

Behavior

  • Overflow → Fork session — forks the whole open session (messageID omitted)
  • Outgoing message action → Fork from here — forks at that message (messageID set)
  • Shared name dialog (OpenCodeDialog + OpenCodeTextInput): suggested title prefilled and editable; trim whitespace; empty disables Fork
  • On confirm: fork with Session Chat worktree directory, then update the new session title; then show the switch prompt
  • If title update fails after a successful fork: still offer the switch prompt; surface a non-blocking error
  • Disable Fork while in flight; on error keep the name dialog open with an error
  • Allow while busy or permission pending; disable only while submit is in flight
  • Child sessions: same behavior as parents

Out of scope

  • Home/list fork
  • Fork from assistant / tool / unknown rows
  • Auto-navigate without the switch prompt
  • Share / archive / delete changes

Acceptance criteria

  • ☐ Overflow fork creates a new session at the tip, with the chosen title (or best-effort title + non-blocking error)
  • ☐ Message fork creates a new session at that outgoing message
  • ☐ User can open the fork or stay; stay leaves them on the source; open navigates to the fork’s Session Chat
  • ☐ Cancel / empty title does not call the API
  • ☐ Reuses the OPE-58 fork dialog flow when present
  • ☐ Parity on iOS and Android

Blocked by

Prefer after OPE-58 if that ticket lands the shared fork flow first; otherwise can start independently and OPE-58 should reuse this path.

Related

  • OPE-58 — Commands sheet [fork] entry

Review in Linear

@ivanfenenko
ivanfenenko marked this pull request as ready for review October 13, 2026 21:48

@ivanfenenko ivanfenenko left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Looks good. Single-flight on confirm and the rename-failure handling are solid on both platforms. One small iOS thing below.

The overflow entry and "Fork from here" close their menu before opening
the dialog, so the silent offline guard made Fork a no-op. Open the dialog
whenever the session exists; its Fork button already follows canMutate and
confirmFork still refuses to fork until the connection is live.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko
ivanfenenko merged commit a750af1 into main Oct 14, 2026
@ivanfenenko
ivanfenenko deleted the feature/ope-81-session-fork-from-session-chat branch October 14, 2026 07:46
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.

OPE-81: Session fork from Session Chat

1 participant