Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7030c4c
iOS composer: dock reducer, per-terminal in-memory drafts, paste RPC,…
lawrencecchen Jun 9, 2026
c27e0f4
Mac host: terminal.paste RPC (bracketed paste + single submit)
lawrencecchen Jun 9, 2026
eea92e8
iOS composer: one-surface bottom dock, always-visible toolbar, pinned…
lawrencecchen Jun 9, 2026
dd1d9cf
iOS composer: dock-coherence UI tests (open/close cycles, draft survi…
lawrencecchen Jun 9, 2026
8707b0b
iOS composer: harden post-send draft clearing and deferred close unmount
lawrencecchen Jun 10, 2026
b7d42ac
iOS composer: FIFO draft pipeline so store effects apply in issue order
lawrencecchen Jun 10, 2026
6c5e5c1
iOS composer: failing tests for draft loss on fast terminal switches
lawrencecchen Jun 10, 2026
8a9ebb3
iOS composer: field-ownership marker fixes fast-switch draft erasure
lawrencecchen Jun 10, 2026
c17c7dd
iOS composer: open by default per terminal + iMessage inline send button
lawrencecchen Jun 10, 2026
8d1e3fa
Rebase fallout: route paste errors through applyOperationalError
lawrencecchen Jun 11, 2026
1c47e94
Review: import Foundation explicitly in InMemoryTerminalDraftStore
lawrencecchen Jun 11, 2026
a6cabb6
Review: terminal.paste partial-success contract + full grid reclaim u…
lawrencecchen Jun 11, 2026
9f0a8cf
Review: resign the actual keyboard owner, not the composerActive subtree
lawrencecchen Jun 11, 2026
8e41e81
Review: route terminal.paste through TerminalPanel explicit-input wra…
lawrencecchen Jun 11, 2026
c46cca5
Policy: DocC on new public symbols, one type per file, file-scope res…
lawrencecchen Jun 11, 2026
bf734f5
Review: key the composer focus handshake to its target terminal
lawrencecchen Jun 11, 2026
c0fb8be
Review: coalesce keystroke draft saves to one latest-value flush per …
lawrencecchen Jun 11, 2026
688d257
CI: refresh Swift file-length budget; injectable struct for responder…
lawrencecchen Jun 11, 2026
90435a1
Review bots: sign-out composer reset, seeded composerActive, doc + DE…
lawrencecchen Jun 11, 2026
c0c22b5
Review bots: throws + try #require in tests, dock-order docs, switch …
lawrencecchen Jun 11, 2026
dd711a3
CI: refresh Swift file-length budget after review doc additions
lawrencecchen Jun 11, 2026
7c7f090
Review bots round 2: compose-tap mirror race, paste ack on superseded…
lawrencecchen Jun 11, 2026
71928ab
Fix CI composer focus: key the handshake to the requesting surface's …
lawrencecchen Jun 11, 2026
fd06472
Composer reveal focus: deterministic UIKit assist for the mounted band
lawrencecchen Jun 11, 2026
a2d7d0e
CI: retrigger workflows (no pull_request runs fired for fd064720a)
lawrencecchen Jun 11, 2026
2b2c4d9
UI tests: account for the always-visible dock in ColorBands; longer s…
lawrencecchen Jun 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/swift-file-length-budget.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Format: max_lines<TAB>relative path
# Reduce counts as files shrink. CI fails if tracked files exceed this budget.
32955 CLI/cmux.swift
22444 Sources/TerminalController.swift
22576 Sources/TerminalController.swift
19955 Sources/Workspace.swift
19245 Sources/ContentView.swift
18056 Sources/AppDelegate.swift
Expand All @@ -23,16 +23,16 @@
5448 Sources/cmuxApp.swift
4460 Sources/Panels/FilePreviewPanel.swift
4400 cmuxTests/BrowserPanelTests.swift
4274 Packages/CmuxMobileShell/Sources/CmuxMobileShell/MobileShellComposite.swift
4227 Sources/BrowserWindowPortal.swift
4009 cmuxTests/WindowAndDragTests.swift
3937 Sources/Feed/FeedPanelView.swift
3760 cmuxTests/TabManagerUnitTests.swift
3699 cmuxTests/CLIGenericHookPersistenceTests.swift
3685 Packages/CmuxMobileShell/Sources/CmuxMobileShell/MobileShellComposite.swift
3670 Packages/CmuxMobileTerminal/Sources/CmuxMobileTerminal/GhosttySurfaceView.swift
3396 Sources/CmuxConfig.swift
3316 cmuxTests/TabManagerSessionSnapshotTests.swift
3202 Sources/Update/UpdateTitlebarAccessory.swift
2953 Packages/CmuxMobileTerminal/Sources/CmuxMobileTerminal/GhosttySurfaceView.swift
2877 Sources/SessionIndexView.swift
2871 cmuxTests/CMUXOpenCommandTests.swift
2654 Sources/Panels/CmuxWebView.swift
Expand All @@ -43,7 +43,7 @@
2327 cmuxTests/CJKIMEInputTests.swift
2290 Sources/FileExplorerView.swift
2260 Sources/TerminalWindowPortal.swift
2208 Sources/Mobile/MobileHostService.swift
2209 Sources/Mobile/MobileHostService.swift
2138 Sources/SessionPersistence.swift
2123 cmuxTests/ShortcutAndCommandPaletteTests.swift
2117 cmuxTests/CmuxConfigTests.swift
Expand Down Expand Up @@ -71,19 +71,19 @@
1313 cmuxTests/MobileHostAuthorizationTests.swift
1285 cmuxUITests/SidebarHelpMenuUITests.swift
1239 Sources/Feed/FeedCoordinator.swift
1205 Packages/CmuxMobileTerminal/Sources/CmuxMobileTerminal/TerminalInputTextView.swift
1197 cmuxTests/CodexAppServerSessionTests.swift
1156 cmuxTests/SidebarOrderingTests.swift
1144 Sources/VaultAgentProcessScanner.swift
1139 cmuxTests/PiVaultAgentPersistenceTests.swift
1107 Sources/AppDelegate+CmuxSSHURL.swift
1096 Sources/GhosttyConfig.swift
1084 cmuxTests/AgentHibernationTests.swift
1068 cmuxTests/FileExplorerStoreTests.swift
1058 cmuxUITests/BonsplitTabDragUITests.swift
1096 Sources/GhosttyConfig.swift
1021 cmuxUITests/TerminalCmdClickUITests.swift
1006 cmuxTests/CmuxSSHURLRequestTests.swift
1000 cmuxTests/CmuxTopSnapshotScopeTests.swift
949 Packages/CmuxMobileTerminal/Sources/CmuxMobileTerminal/TerminalInputTextView.swift
947 Sources/TerminalNotificationPolicy.swift
945 Sources/SessionIndexRegisteredAgents.swift
944 Sources/App/ShortcutRoutingSupport.swift
Expand Down Expand Up @@ -167,8 +167,8 @@
539 CLI/CodexTeamsApprovalBridge.swift
538 CLI/CMUXCLI+Themes.swift
536 cmuxTests/CmuxConfigContextMenuTests.swift
530 cmuxUITests/AutomationSocketUITests.swift
528 cmuxTests/CLINotifyProcessTestSupport.swift
528 cmuxUITests/AutomationSocketUITests.swift
527 CLI/CLISocketPathResolver.swift
523 Packages/CmuxSettingsUI/Sources/CmuxSettingsUI/Scene/SettingsWindowScene.swift
522 Packages/CmuxMobileTerminal/Sources/CmuxMobileTerminal/GhosttyRuntime.swift
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// The single coherent step the surface should take in response to a compose-button
/// tap, computed by ``ComposerDockState/intentForComposeButtonTap()``.
public enum ComposerDockIntent: Sendable, Equatable {
/// No composer is presented; present it and focus the field (the plain open).
case openComposer
/// A composer is presented but suppressed or unfocused; reveal the chrome (if
/// hidden), keep it presented, and focus the field. The draft is preserved.
case revealAndFocusComposer
/// A genuinely visible, focused composer; dismiss it (the only path that closes
/// the composer from the button).
case closeComposer
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/// The four booleans that describe the iOS terminal's bottom dock at the instant
/// the user acts on the composer, plus the pure decision that maps an action onto
/// the one coherent next step.
///
/// The bottom dock is a tangle of four independent flags — chrome hidden vs shown,
/// composer logically presented vs not, the composer field holding first responder
/// vs not, and the software keyboard up vs down. A blind `isComposerPresented.toggle()`
/// on the compose button ignored all of them, so the cycle compose → hide → reveal →
/// compose closed a still-presented (but visually suppressed, or revealed-yet-unfocused)
/// composer and the user saw their draft vanish. This type is the single source of
/// truth for that decision so it can be unit-tested off-device and the UIKit surface
/// only has to translate the resulting ``ComposerDockIntent`` into calls.
public struct ComposerDockState: Sendable, Equatable {
/// Whether the HIDE button has visually suppressed the whole bottom chrome
/// (toolbar + composer band). The composer can be *presented* yet hidden:
/// HIDE leaves ``composerPresented`` untouched and only drops the chrome, so
/// the draft survives.
public var chromeHidden: Bool
/// Whether the composer is logically presented (the store's `isComposerPresented`,
/// mirrored onto the surface). True from the moment the composer opens until it
/// is genuinely dismissed; a HIDE does not flip it.
public var composerPresented: Bool
/// Whether the composer's text field currently holds first responder. After a
/// reveal-from-hide the chrome is back and the composer is presented, but the
/// terminal proxy (not the field) took first responder, so this is false — the
/// exact state that made the next compose tap destructive.
public var fieldFocused: Bool
/// Whether the software keyboard is currently up.
///
/// Part of the dock's complete description, recorded so a captured trace and the
/// tests model the real state. It does NOT gate
/// ``intentForComposeButtonTap()`` today (the open/reveal/close decision turns
/// only on presented + suppressed/unfocused); it is retained for the dock's
/// faithful shape and any future keyboard-aware step.
public var keyboardUp: Bool

/// Creates a dock state from its four flags.
/// - Parameters:
/// - chromeHidden: Whether the HIDE button has suppressed the chrome.
/// - composerPresented: Whether the composer is logically presented.
/// - fieldFocused: Whether the composer field holds first responder.
/// - keyboardUp: Whether the software keyboard is up.
public init(
chromeHidden: Bool,
composerPresented: Bool,
fieldFocused: Bool,
keyboardUp: Bool
) {
self.chromeHidden = chromeHidden
self.composerPresented = composerPresented
self.fieldFocused = fieldFocused
self.keyboardUp = keyboardUp
}

/// Resolve what tapping the compose accessory button should do, given this dock
/// state.
///
/// The compose button has three jobs folded into one control, told apart by the
/// dock state:
///
/// - **Open** when no composer is presented: present it and focus the field.
/// - **Reveal** when a composer is presented but suppressed (``chromeHidden``)
/// or visible-yet-unfocused (presented, chrome shown, field not first
/// responder — the reveal-after-hide state): bring the chrome back, keep the
/// composer presented, and focus the field. The draft is never dismissed.
/// - **Close** only when the composer is genuinely visible and focused: a real
/// "I'm done composing" tap.
///
/// - Returns: the ``ComposerDockIntent`` the surface should carry out.
public func intentForComposeButtonTap() -> ComposerDockIntent {
guard composerPresented else {
// Nothing presented: a plain open.
return .openComposer
}
if chromeHidden || !fieldFocused {
// Presented but suppressed, or presented-and-visible yet the field lost
// first responder on a reveal. Either way the user wants the composer
// back and focused, NOT dismissed — reveal the chrome if needed and
// re-focus the field, leaving the draft intact.
return .revealAndFocusComposer
}
// Genuinely visible and focused: a real close.
return .closeComposer
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,61 @@ public enum DiagnosticEventCode: UInt16, Sendable, Codable, CaseIterable {
/// A pairing attempt was short-circuited because the device had no network
/// path (the reachability preflight failed before any connect).
case pairUnreachable = 10

// MARK: iOS composer instrumentation (draft-disappears-on-keyboard-dismiss hunt)
//
// These five codes discriminate WHY the iMessage-style composer's draft
// vanishes after the keyboard opens then closes. The draft text itself lives
// in the store (`terminalInputText`), so the symptom must be one of: the
// `isComposerPresented` flag toggled off, the composer view torn down + rebuilt
// while the flag stayed true, the draft cleared at the store, or (the residual)
// a `TextField`/`@FocusState` render blank. Logging the flag, the draft length,
// and the composer view's appear/disappear *independently* of the flag lets a
// single captured trace name which one happened. Raw values 11-17 are reserved
// for the in-flight keyboard-input instrumentation branch.

/// The store's `isComposerPresented` flag changed (store `didSet`). `a` = 1 if
/// the composer is now presented, else 0. An unexpected `a == 0` during a bare
/// keyboard dismiss is the "flag toggled off" cause.
case composerPresentedChanged = 18
/// The store's `terminalInputText` draft changed (store `didSet`). `a` = new
/// UTF-8 byte length; `b` = 1 if it just went to empty (a clear), else 0. A
/// clear (`b == 1`) with no submit/sign-out nearby is the "draft cleared at the
/// store" cause.
case composerInputTextChanged = 19
/// ``TerminalComposerView`` appeared (`.onAppear`). Logged independently of
/// ``composerPresentedChanged`` so a disappear/appear pair with no flag change
/// reveals a view-recreation bug (the flag stayed true but SwiftUI rebuilt the
/// view).
case composerViewAppear = 20
/// ``TerminalComposerView`` disappeared (`.onDisappear`). A disappear without a
/// matching ``composerPresentedChanged`` `a == 0` is a view-recreation bug, not
/// an intentional dismiss.
case composerViewDisappear = 21
/// The composer's text field focus changed (`@FocusState`). `a` = 1 focused,
/// else 0. A focus-lost (`a == 0`) while the flag stayed presented and the view
/// stayed mounted, yet the field reads empty, isolates the residual
/// `TextField`/`@FocusState` render-blank case.
case composerFieldFocusChanged = 22

// COMPOSER keyboard-toggle edge case (composer shown while the
// textbox/keyboard is hidden). These pin which transition desyncs the
// composer-presented flag from the keyboard/first-responder state, and they
// land in the same `store.diagnosticLog` sink the composer events above use.

/// `GhosttySurfaceView.setComposerActive` ran. `a` = 1 if the composer just
/// became active, else 0. `b` = the resolved first-responder owner
/// (``InputResponderIdentity`` raw value: which view holds first responder at
/// the transition). `c` = 1 if the terminal input proxy is first responder,
/// else 0. `ms` = the surface's `keyboardHeight` (points) at the transition. A
/// trace where `a == 1` but `ms == 0` and no terminal/composer responder owns
/// FR is the composer-up/keyboard-down desync.
case composerActiveTransition = 23

/// The docked bar's keyboard toggle button was tapped while the composer is
/// presented. `a` = 1 if the terminal input proxy was first responder when
/// tapped (so the tap would hide the keyboard), else 0. Purely diagnostic:
/// the keyboard toggle no longer dismisses the composer (the composer
/// survives a keyboard-down), so this records the tap for trace completeness.
case composerKeyboardToggleWhilePresented = 24
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/// A compact integer identity for the view that owns the keyboard's first
/// responder on the iOS terminal input path.
///
/// ``DiagnosticEvent`` carries only integer payloads (no allocated strings), so
/// the first-responder *class* is encoded as one of these small raw values and
/// decoded back to a human-readable name by `scripts/decode-ios-diagnostic.py`.
/// The composer-dock instrumentation stamps this into the payload slots of the
/// ``DiagnosticEventCode/composerActiveTransition`` and
/// ``DiagnosticEventCode/composerKeyboardToggleWhilePresented`` events so a
/// captured trace shows *which* view actually holds first responder when the
/// composer opens, closes, or survives a keyboard toggle.
public enum InputResponderIdentity: Int, Sendable, Codable, CaseIterable {
/// No first responder, or it could not be resolved.
case none = 0
/// The expected terminal keyboard proxy (`TerminalInputTextView`). The
/// keyboard is driving the view we instrument.
case terminalInputProxy = 1
/// The Metal/IOSurface terminal surface itself (`GhosttySurfaceView`).
case ghosttySurface = 2
/// A `UITextField` (e.g. an unexpected SwiftUI/text field stealing focus).
case uiTextField = 3
/// A `UITextView`.
case uiTextView = 4
/// Some other `UIResponder` subclass not in this list. The decoder pairs this
/// with the human-readable class name carried in the companion string log
/// (`anchormux`) for the same event.
case other = 9
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import Testing
@testable import CMUXMobileCore

/// Verifies the pure compose-button decision that keeps the iOS terminal composer
/// coherent across the compose → hide → reveal → compose cycle a user hit on device:
/// the draft must never be dismissed by the compose button while the composer is
/// still logically presented but visually suppressed or unfocused.
@Suite struct ComposerDockReducerTests {
/// A fresh open: nothing presented, so the button opens the composer.
@Test func composeButtonOpensWhenNothingPresented() {
let state = ComposerDockState(
chromeHidden: false,
composerPresented: false,
fieldFocused: false,
keyboardUp: false
)
#expect(state.intentForComposeButtonTap() == .openComposer)
}

/// A genuinely visible, focused composer: the button closes it. This is the ONLY
/// path that dismisses the composer from the button.
@Test func composeButtonClosesWhenVisibleAndFocused() {
let state = ComposerDockState(
chromeHidden: false,
composerPresented: true,
fieldFocused: true,
keyboardUp: true
)
#expect(state.intentForComposeButtonTap() == .closeComposer)
}

/// Composer presented but the HIDE button suppressed the chrome: the button must
/// REVEAL + focus, not close (closing here is what lost the draft on device).
@Test func composeButtonRevealsWhenPresentedButChromeHidden() {
let state = ComposerDockState(
chromeHidden: true,
composerPresented: true,
fieldFocused: false,
keyboardUp: false
)
#expect(state.intentForComposeButtonTap() == .revealAndFocusComposer)
}

/// The exact device-trace state: after a reveal-from-hide the chrome is back and
/// the composer is presented, but the terminal proxy (not the field) holds first
/// responder. The button must REVEAL + focus the field, not toggle the composer
/// closed.
@Test func composeButtonRefocusesWhenPresentedAndVisibleButFieldUnfocused() {
let state = ComposerDockState(
chromeHidden: false,
composerPresented: true,
fieldFocused: false,
keyboardUp: false
)
#expect(state.intentForComposeButtonTap() == .revealAndFocusComposer)
}

/// End-to-end: replay the reported compose → hide → reveal → compose sequence as
/// pure state transitions and assert the final compose tap ends in a presented,
/// focused composer (draft preserved), never a close.
@Test func composeHideRevealComposeKeepsComposerPresentedAndFocused() {
// 1. Compose: open from nothing. Intent = open.
var state = ComposerDockState(
chromeHidden: false,
composerPresented: false,
fieldFocused: false,
keyboardUp: false
)
#expect(state.intentForComposeButtonTap() == .openComposer)

// After open: composer presented, field focused, keyboard up.
state.composerPresented = true
state.fieldFocused = true
state.keyboardUp = true

// 2. Hide: chrome suppressed, keyboard dropped, field loses first responder.
// `composerPresented` stays true (HIDE never dismisses), so the draft lives.
state.chromeHidden = true
state.fieldFocused = false
state.keyboardUp = false
#expect(state.composerPresented)

// 3. Reveal (terminal tap): chrome returns but the terminal proxy takes first
// responder, so the composer field is NOT focused yet.
state.chromeHidden = false
state.fieldFocused = false
#expect(state.composerPresented)

// 4. Compose again: presented + visible + field-unfocused → reveal/refocus,
// NOT close. The composer (and its draft) stays.
#expect(state.intentForComposeButtonTap() == .revealAndFocusComposer)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ public final class MobileCoreRPCClient: MobileSyncing, Sendable {
case "mobile.terminal.create", "terminal.create":
return false
case "mobile.terminal.input", "terminal.input",
"mobile.terminal.paste", "terminal.paste",
"mobile.terminal.paste_image", "terminal.paste_image",
"mobile.terminal.replay", "terminal.replay",
"mobile.terminal.viewport", "terminal.viewport":
Expand Down
Loading
Loading