Repository navigation
feat(mobile): native composer bar — UIKit keyboard tracking, quick keys, glass input - #6356
saddlepaddle wants to merge 1 commit into
Conversation
…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.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
There was a problem hiding this comment.
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
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| }; | ||
|
|
||
| const NativeView = withUniwind( | ||
| requireNativeView("Composer") as React.ComponentType< |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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>
| 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") |
There was a problem hiding this comment.
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 }}> |
There was a problem hiding this comment.
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>
| <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 |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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>
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Stacked on #6342. First step of the fully-native input direction: a
modules/composerExpo module that owns the input surface, replacingKeyboardAvoidingView+ 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:
keyboardLayoutGuiderides the keyboard's real animation curve (RN'sKeyboardAvoidingViewapproximates 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(UIKitExpoView) mounts as a full-screen overlay; every touch outside the bar passes through viahitTest. The bar pins toself.keyboardLayoutGuide.topAnchor, so UIKit owns tracking end to end.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.UITextView(1→~5 lines), send button appears with text, clears on submit.UIGlassEffecton iOS 26,systemThickMaterialDarkbefore — the pre-26 no-op gap the home widget has is designed out here.Verified on iOS 26.5 simulator (Maestro, full local stack, live claude PTY)
onBarMetrics.\rconfirmed its trust prompt), field auto-cleared, session booted, and the OSC title updated the nav header live. Full native-input → PTY → render round trip.Follow-ups
NewChatWidgetmigration onto this module (chips row, voice dictation moving to nativeSFSpeechRecognizer) — next PR of the native-composer track.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
@superset/composerExpo module with a nativeComposerBar(keyboardLayoutGuide tracking, glass background, quick keys).ComposerBar; removedKeyboardAvoidingViewand the RN quick-keys row.Dependencies
Composer.podspec; registeredComposerModule.@superset/composer).Written for commit 6a9896d. Summary will update on new commits.