Skip to content

feat(mobile): native composer bar — UIKit keyboard tracking, quick keys, glass input - #6356

Closed
saddlepaddle wants to merge 1 commit into
mobile-terminal-screenfrom
native-composer
Closed

saddlepaddle wants to merge 1 commit into
mobile-terminal-screenfrom
native-composer

Conversation

@saddlepaddle

@saddlepaddle saddlepaddle commented Aug 11, 2026 •

Copy link
Copy Markdown
Member

Stacked on #6342. First step of the fully-native input direction: a modules/composer Expo module that owns the input surface, replacing KeyboardAvoidingView + the RN quick-keys row on the terminal screen.

Why native

The Slack/Cursor input feel lives entirely on the native side of the RN boundary: keyboardLayoutGuide rides the keyboard's real animation curve (RN's KeyboardAvoidingView approximates it with a timing animation — the visible jank), and first-responder control means the keyboard actually appears (the WKWebView xterm textarea never reliably focused, #6342's known gap).

Design

  • ComposerView (UIKit ExpoView) mounts as a full-screen overlay; every touch outside the bar passes through via hitTest. The bar pins to self.keyboardLayoutGuide.topAnchor, so UIKit owns tracking end to end.
  • Props in, events out — no RN children. placeholder, autoFocus, quickKeys: [{id, label|symbol}] (SF Symbols); onSubmitText, onChangeText, onFocusChange, onQuickKey, onBarMetrics (occluded height, used by RN to inset content). The draft lives natively; RN only mirrors it.
  • Growing UITextView (1→~5 lines), send button appears with text, clears on submit.
  • Glass: UIGlassEffect on iOS 26, systemThickMaterialDark before — the pre-26 no-op gap the home widget has is designed out here.
  • Terminal screen: quick-key byte map + bracketed-paste framing for multiline submits stay in RN.

Verified on iOS 26.5 simulator (Maestro, full local stack, live claude PTY)

  • Bar renders (glass pill, placeholder, SF-symbol quick keys) in the bottom safe area.
  • Tap focuses the native field → keyboard appears with the bar riding it; terminal content resizes above via onBarMetrics.
  • Typed "hi there" via the soft keyboard, tapped send → claude received it (\r confirmed its trust prompt), field auto-cleared, session booted, and the OSC title updated the nav header live. Full native-input → PTY → render round trip.
  • Repo typecheck + lint clean.

Follow-ups

  • Keyboard dismiss affordance (the WebView isn't a scrollview, so no drag-to-dismiss surface yet).
  • Home NewChatWidget migration onto this module (chips row, voice dictation moving to native SFSpeechRecognizer) — next PR of the native-composer track.
  • Ref view-functions (focusInput/blurInput/clearText) are wired but have no call sites yet; exercise when the home widget migrates.

Summary by cubic

Introduces a native UIKit composer bar for iOS that replaces the RN input and quick-keys row on the Terminal screen. Smooth keyboard tracking, reliable focus, glass UI, and built-in quick keys.

  • New Features

    • Added @superset/composer Expo module with a native ComposerBar (keyboardLayoutGuide tracking, glass background, quick keys).
    • Terminal screen uses ComposerBar; removed KeyboardAvoidingView and the RN quick-keys row.
    • Emits occluded height to inset content; submit clears input; focus is first-responder native.
    • Props/events: placeholder, autoFocus, quickKeys; submit/change/focus/metrics. Methods: focus, blur, clear.
    • Multiline input is framed as bracketed paste before sending to the PTY.
  • Dependencies

    • Added iOS module with Composer.podspec; registered ComposerModule.
    • Wired module path in Metro and tsconfig (@superset/composer).

Written for commit 6a9896d. Summary will update on new commits.

Review in cubic

…ys, glass input

modules/composer: an ExpoView overlay whose bar pins to keyboardLayoutGuide,
so input rides the keyboard's real animation curve. Owns the growing
UITextView, send button, quick-keys row (data-driven), and glass background
(UIGlassEffect on iOS 26, thick material fallback before). The terminal
screen drops KeyboardAvoidingView + the RN quick-keys row for it.
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c5b8d9d0-e516-4667-b766-8ee5dce98617

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai 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.

6 issues found across 13 files

You’re at about 90% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/mobile/modules/composer/src/ComposerBar.tsx">

<violation number="1" location="apps/mobile/modules/composer/src/ComposerBar.tsx:33">
P1: The terminal screen cannot render on Android when the composer is shown because this wrapper unconditionally requires a view that the module config registers only on Apple platforms. A platform-specific implementation or Android-safe fallback would keep the existing terminal flow working on Android.</violation>
</file>

<file name="apps/mobile/screens/(authenticated)/workspace/[id]/terminal/[terminalId]/TerminalScreen.tsx">

<violation number="1" location="apps/mobile/screens/(authenticated)/workspace/[id]/terminal/[terminalId]/TerminalScreen.tsx:79">
P1: Multiline submissions are corrupted for shells or programs that have not enabled bracketed-paste mode because this client unconditionally sends bracketed-paste delimiters. Framing should depend on the terminal’s tracked mode, or the submission should use the server-side framing path.</violation>

<violation number="2" location="apps/mobile/screens/(authenticated)/workspace/[id]/terminal/[terminalId]/TerminalScreen.tsx:86">
P1: Text entered while the terminal is connecting or reconnecting can disappear without reaching the PTY: the composer is available before the WebSocket is open, and native submission clears the draft even when `sendInput` drops it. Showing the composer only when `connectionState === "open"` would prevent this loss until a reliable draft-preserving path exists.</violation>

<violation number="3" location="apps/mobile/screens/(authenticated)/workspace/[id]/terminal/[terminalId]/TerminalScreen.tsx:108">
P2: After the session ends, the composer is removed but its last occlusion height remains applied, so the terminal/end-state content can retain a large blank bottom inset, especially if the keyboard was visible. Applying the inset only while the composer is shown avoids retaining stale layout state.</violation>
</file>

<file name="apps/mobile/modules/composer/ios/ComposerView.swift">

<violation number="1" location="apps/mobile/modules/composer/ios/ComposerView.swift:100">
P2: Using the composer without quick keys leaves a blank 44-point strip under the text field. Initializing the scroll view hidden (and letting `rebuildQuickKeys()` reveal it when keys arrive) keeps the optional prop from changing the bar height unexpectedly.</violation>

<violation number="2" location="apps/mobile/modules/composer/ios/ComposerView.swift:128">
P2: On devices with a home indicator, the composer can sit underneath the system gesture area whenever the keyboard is hidden. The keyboard-following constraint also needs a safe-area-aware lower position, while retaining the keyboard guide position when the keyboard is visible.</violation>
</file>
Architecture diagram
sequenceDiagram
    participant RN as RN TerminalScreen
    participant CB as ComposerBar (RN wrapper)
    participant NV as Native ComposerView (ExpoView)
    participant KB as UIKit keyboardLayoutGuide
    participant TV as UITextView
    participant PTY as xterm/PTY
    
    Note over RN,PTY: Native Composer - Runtime Flow
    
    RN->>CB: Mount ComposerBar (absolute inset-0 overlay)
    CB->>NV: Pass props (placeholder, quickKeys, autoFocus)
    NV->>NV: Build glass bar (UIGlassEffect / dark blur)
    NV->>TV: Auto-focus (becomeFirstResponder)
    TV->>KB: Present keyboard
    KB-->>NV: Pin bar to keyboardLayoutGuide.topAnchor
    
    Note over NV,RN: Keyboard Tracking & Metrics
    
    NV->>NV: layoutSubviews() computes occludedHeight
    NV-->>CB: NEW: onBarMetrics (occludedHeight)
    CB-->>RN: setOccludedHeight
    RN->>RN: Pad terminal content (paddingBottom)
    
    Note over RN,PTY: Text Input Path
    
    TV->>NV: textViewDidChange
    NV->>NV: Update placeholder/send button visibility
    NV->>NV: Grow UITextView (38-120px), clamp & scroll
    NV-->>CB: NEW: onChangeText (mirror draft to RN)
    
    Note over RN,PTY: Send / Submit Flow
    
    User->>TV: Tap send button
    TV->>NV: submit() (guard non-empty)
    NV-->>CB: onSubmitText (raw text)
    CB-->>RN: handleSubmit(text)
    RN->>RN: Check for newline
    alt Single-line input
        RN->>PTY: sendInput(text + "\r")
    else Multi-line input
        RN->>PTY: sendInput("[200~" + text + "[201~\r")
    end
    
    Note over RN,PTY: Quick Keys Flow
    
    User->>NV: Tap quick key (SF symbol / label)
    NV-->>CB: NEW: onQuickKey (id)
    CB-->>RN: Map id to byte sequence
    RN->>PTY: sendInput(bytes)
    
    Note over TV,NV: Ref Methods (wired, not yet used)
    
    RN->>CB: Imperative handle (focusInput/blurInput/clearText)
    CB->>NV: AsyncFunction call (main queue)
    NV->>TV: becomeFirstResponder / resignFirstResponder / clearText
    
    Note over NV,RN: Touch Pass-Through
    
    User->>NV: Tap outside bar
    NV->>NV: hitTest returns nil (view === self)
    NV-->>RN: Touch falls through to RN content
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

};

const NativeView = withUniwind(
requireNativeView("Composer") as React.ComponentType<

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.

P1: The terminal screen cannot render on Android when the composer is shown because this wrapper unconditionally requires a view that the module config registers only on Apple platforms. A platform-specific implementation or Android-safe fallback would keep the existing terminal flow working on Android.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/mobile/modules/composer/src/ComposerBar.tsx, line 33:

<comment>The terminal screen cannot render on Android when the composer is shown because this wrapper unconditionally requires a view that the module config registers only on Apple platforms. A platform-specific implementation or Android-safe fallback would keep the existing terminal flow working on Android.</comment>

<file context>
@@ -0,0 +1,79 @@
+};
+
+const NativeView = withUniwind(
+	requireNativeView("Composer") as React.ComponentType<
+		NativeComposerProps & { className?: string }
+	>,
</file context>

}, []);

const banner = STATE_BANNERS[connectionState];
const showComposer = routingKey !== null && exitCode === null;

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.

P1: Text entered while the terminal is connecting or reconnecting can disappear without reaching the PTY: the composer is available before the WebSocket is open, and native submission clears the draft even when sendInput drops it. Showing the composer only when connectionState === "open" would prevent this loss until a reliable draft-preserving path exists.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/mobile/screens/(authenticated)/workspace/[id]/terminal/[terminalId]/TerminalScreen.tsx, line 86:

<comment>Text entered while the terminal is connecting or reconnecting can disappear without reaching the PTY: the composer is available before the WebSocket is open, and native submission clears the draft even when `sendInput` drops it. Showing the composer only when `connectionState === "open"` would prevent this loss until a reliable draft-preserving path exists.</comment>

<file context>
@@ -55,13 +73,20 @@ export function TerminalScreen() {
+	}, []);
+
 	const banner = STATE_BANNERS[connectionState];
+	const showComposer = routingKey !== null && exitCode === null;
 
 	return (
</file context>
Suggested change
const showComposer = routingKey !== null && exitCode === null;
const showComposer =
routingKey !== null && exitCode === null && connectionState === "open";

const handleSubmit = useCallback((text: string) => {
// Multi-line input rides a bracketed paste so TUIs treat it as one
// prompt (same framing the host applies in terminal.send).
const framed = text.includes("\n")

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.

P1: Multiline submissions are corrupted for shells or programs that have not enabled bracketed-paste mode because this client unconditionally sends bracketed-paste delimiters. Framing should depend on the terminal’s tracked mode, or the submission should use the server-side framing path.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/mobile/screens/(authenticated)/workspace/[id]/terminal/[terminalId]/TerminalScreen.tsx, line 79:

<comment>Multiline submissions are corrupted for shells or programs that have not enabled bracketed-paste mode because this client unconditionally sends bracketed-paste delimiters. Framing should depend on the terminal’s tracked mode, or the submission should use the server-side framing path.</comment>

<file context>
@@ -55,13 +73,20 @@ export function TerminalScreen() {
+	const handleSubmit = useCallback((text: string) => {
+		// Multi-line input rides a bracketed paste so TUIs treat it as one
+		// prompt (same framing the host applies in terminal.send).
+		const framed = text.includes("\n")
+			? `\u001b[200~${text}\u001b[201~\r`
+			: `${text}\r`;
</file context>

</View>
) : null}
<View className="flex-1">
<View className="flex-1" style={{ paddingBottom: occludedHeight }}>

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.

P2: After the session ends, the composer is removed but its last occlusion height remains applied, so the terminal/end-state content can retain a large blank bottom inset, especially if the keyboard was visible. Applying the inset only while the composer is shown avoids retaining stale layout state.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/mobile/screens/(authenticated)/workspace/[id]/terminal/[terminalId]/TerminalScreen.tsx, line 108:

<comment>After the session ends, the composer is removed but its last occlusion height remains applied, so the terminal/end-state content can retain a large blank bottom inset, especially if the keyboard was visible. Applying the inset only while the composer is shown avoids retaining stale layout state.</comment>

<file context>
@@ -80,7 +105,7 @@ export function TerminalScreen() {
 				</View>
 			) : null}
-			<View className="flex-1">
+			<View className="flex-1" style={{ paddingBottom: occludedHeight }}>
 				{!workspaceId || !terminalId ? (
 					<Centered>
</file context>
Suggested change
<View className="flex-1" style={{ paddingBottom: occludedHeight }}>
<View
className="flex-1"
style={{ paddingBottom: showComposer ? occludedHeight : 0 }}
>

sendButton.addTarget(self, action: #selector(submit), for: .touchUpInside)
sendButton.translatesAutoresizingMaskIntoConstraints = false

quickKeysScroll.showsHorizontalScrollIndicator = false

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.

P2: Using the composer without quick keys leaves a blank 44-point strip under the text field. Initializing the scroll view hidden (and letting rebuildQuickKeys() reveal it when keys arrive) keeps the optional prop from changing the bar height unexpectedly.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/mobile/modules/composer/ios/ComposerView.swift, line 100:

<comment>Using the composer without quick keys leaves a blank 44-point strip under the text field. Initializing the scroll view hidden (and letting `rebuildQuickKeys()` reveal it when keys arrive) keeps the optional prop from changing the bar height unexpectedly.</comment>

<file context>
@@ -0,0 +1,261 @@
+    sendButton.addTarget(self, action: #selector(submit), for: .touchUpInside)
+    sendButton.translatesAutoresizingMaskIntoConstraints = false
+
+    quickKeysScroll.showsHorizontalScrollIndicator = false
+    quickKeysScroll.translatesAutoresizingMaskIntoConstraints = false
+    quickKeysStack.axis = .horizontal
</file context>

// The whole point of the module: UIKit pins the bar to the keyboard's
// top edge and animates it on the keyboard's own curve.
barBackground.bottomAnchor.constraint(
equalTo: keyboardLayoutGuide.topAnchor, constant: -8),

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.

P2: On devices with a home indicator, the composer can sit underneath the system gesture area whenever the keyboard is hidden. The keyboard-following constraint also needs a safe-area-aware lower position, while retaining the keyboard guide position when the keyboard is visible.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/mobile/modules/composer/ios/ComposerView.swift, line 128:

<comment>On devices with a home indicator, the composer can sit underneath the system gesture area whenever the keyboard is hidden. The keyboard-following constraint also needs a safe-area-aware lower position, while retaining the keyboard guide position when the keyboard is visible.</comment>

<file context>
@@ -0,0 +1,261 @@
+      // The whole point of the module: UIKit pins the bar to the keyboard's
+      // top edge and animates it on the keyboard's own curve.
+      barBackground.bottomAnchor.constraint(
+        equalTo: keyboardLayoutGuide.topAnchor, constant: -8),
+
+      bar.topAnchor.constraint(equalTo: barBackground.contentView.topAnchor),
</file context>

@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

@saddlepaddle

Copy link
Copy Markdown
Member Author

Superseded: the UIKit composer module built here was replaced by TerminalComposer (ported from the home glass composer) on #6366, which deletes modules/composer entirely. Closing in favor of one squash-merge of #6366.

This branch was previously deployed

1 inactive deployment
preview — 6a9896d0 Deployed Aug 11, 2026 by saddlepaddle via Deploy API #7469
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