Open History to see the last commit
1import { DEFAULT_TERMINAL_ID, EnvironmentId, ThreadId } from "@t3tools/contracts";
2import { type KnownTerminalSession } from "@t3tools/client-runtime/state/terminal";
3import type { MenuAction } from "@react-native-menu/menu";
4import { SymbolView } from "../../components/AppSymbol";
5import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
6import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
7import { useCallback, useEffect, useMemo, useRef, useState } from "react";
8import { Platform, Pressable, View, useColorScheme } from "react-native";
9import {
10 KeyboardController,
11 KeyboardEvents,
12 KeyboardStickyView,
13 useKeyboardState,
14} from "react-native-keyboard-controller";
15
16import { AndroidHeaderIconButton, AndroidScreenHeader } from "../../components/AndroidScreenHeader";
17import {
18 ComposerToolbarButton,
19 ComposerToolbarRow,
20 ComposerToolbarScroller,
21} from "../../components/ComposerToolbarTrigger";
22import { ControlPillMenu } from "../../components/ControlPill";
23import { EmptyState } from "../../components/EmptyState";
24import { GlassSurface } from "../../components/GlassSurface";
25import { LoadingScreen } from "../../components/LoadingScreen";
26import { environmentCatalog } from "../../connection/catalog";
27import { useEnvironmentPresentation } from "../../state/presentation";
28import { terminalEnvironment } from "../../state/terminal";
29import { useAtomCommand } from "../../state/use-atom-command";
30import { useWorkspaceState } from "../../state/workspace";
31import {
32 MAX_TERMINAL_FONT_SIZE,
33 MIN_TERMINAL_FONT_SIZE,
34 TERMINAL_FONT_SIZE_STEP,
35 stepTerminalFontSize,
36} from "../../lib/appearancePreferences";
37import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
38import {
39 useAttachedTerminalSession,
40 useKnownTerminalSessions,
41} from "../../state/use-terminal-session";
42import { useThreadSelection } from "../../state/use-thread-selection";
43import { useSelectedThreadProjection } from "../../state/use-thread-detail";
44import { EnvironmentConnectionNotice } from "../connection/EnvironmentConnectionNotice";
45import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
46import { TerminalSurface } from "./NativeTerminalSurface";
47import { getPierreTerminalTheme } from "./terminalTheme";
48import { terminalDebugLog } from "./terminalDebugLog";
49import {
50 getTerminalBufferReplayKey,
51 getTerminalSurfaceReplayBuffer,
52 TERMINAL_BUFFER_REPLAY_STABILITY_DELAY_MS,
53} from "./terminalBufferReplay";
54import {
55 resolveTerminalOpenLocation,
56 takePendingTerminalLaunch,
57 type PendingTerminalLaunch,
58} from "./terminalLaunchContext";
59import {
60 basename,
61 buildTerminalMenuSessions,
62 getTerminalStatusLabel,
63 nextOpenTerminalId,
64 previousLiveTerminalId,
65 resolveTerminalSessionLabel,
66 type TerminalMenuSession,
67} from "./terminalMenu";
68import { cacheTerminalGridSize, getCachedTerminalGridSize } from "./terminalUiState";
69
70const DEFAULT_TERMINAL_COLS = 80;
71const DEFAULT_TERMINAL_ROWS = 24;
72const TERMINAL_ACCESSORY_HEIGHT = 52;
73const SHOWCASE_ENABLED = process.env.EXPO_PUBLIC_SHOWCASE === "1";
74
75type PendingModifier = "ctrl" | "meta";
76type HostPlatform = "mac" | "linux" | "windows" | "unknown";
77
78type TerminalToolbarAction =
79 | { readonly kind: "send"; readonly key: string; readonly label: string; readonly data: string }
80 | { readonly kind: "clear"; readonly key: string; readonly label: string }
81 | {
82 readonly kind: "modifier";
83 readonly key: string;
84 readonly label: string;
85 readonly modifier: PendingModifier;
86 };
87
88function firstRouteParam(value: string | string[] | undefined): string | null {
89 if (Array.isArray(value)) {
90 return value[0] ?? null;
91 }
92
93 return value ?? null;
94}
95
96function inferHostPlatform(environmentLabel: string | null): HostPlatform {
97 const value = environmentLabel?.toLowerCase() ?? "";
98 if (
99 value.includes("mac") ||
100 value.includes("macbook") ||
101 value.includes("mac mini") ||
102 value.includes("imac") ||
103 value.includes("darwin")
104 ) {
105 return "mac";
106 }
107 if (value.includes("windows") || value.includes("win")) {
108 return "windows";
109 }
110 if (value.includes("linux") || value.includes("ubuntu") || value.includes("debian")) {
111 return "linux";
112 }
113
114 return "unknown";
115}
116
117function applyCtrlModifier(input: string): string {
118 const firstCharacter = input[0];
119 if (!firstCharacter) {
120 return input;
121 }
122
123 const lowerCharacter = firstCharacter.toLowerCase();
124 if (lowerCharacter >= "a" && lowerCharacter <= "z") {
125 return String.fromCharCode(lowerCharacter.charCodeAt(0) - 96);
126 }
127
128 if (firstCharacter === "@") return "\u0000";
129 if (firstCharacter === "[") return "\u001b";
130 if (firstCharacter === "\\") return "\u001c";
131 if (firstCharacter === "]") return "\u001d";
132 if (firstCharacter === "^") return "\u001e";
133 if (firstCharacter === "_") return "\u001f";
134 if (firstCharacter === "?") return "\u007f";
135
136 return input;
137}
138
139function pickRunningTerminalSessionForBootstrap(
140 sessions: ReadonlyArray<KnownTerminalSession>,
141): KnownTerminalSession | null {
142 const running = sessions.filter(
143 (session) => session.state.status === "running" || session.state.status === "starting",
144 );
145 if (running.length === 0) {
146 return null;
147 }
148 return (
149 running.find((session) => session.target.terminalId === DEFAULT_TERMINAL_ID) ??
150 running[0] ??
151 null
152 );
153}
154
155type ThreadTerminalRouteScreenProps = StaticScreenProps<{
156 readonly environmentId: string;
157 readonly threadId: string;
158 readonly terminalId?: string;
159}>;
160
161export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps) {
162 const navigation = useNavigation();
163 const writeTerminal = useAtomCommand(terminalEnvironment.write, "terminal write");
164 const resizeTerminal = useAtomCommand(terminalEnvironment.resize, "terminal resize");
165 const clearTerminal = useAtomCommand(terminalEnvironment.clear, "terminal clear");
166 const closeTerminal = useAtomCommand(terminalEnvironment.close, "terminal close");
167 const openTerminal = useAtomCommand(terminalEnvironment.open, "terminal open");
168 const retryEnvironment = useAtomCommand(environmentCatalog.retryNow, "environment retry");
169 const appearanceScheme = useColorScheme() === "light" ? "light" : "dark";
170 const { state: workspaceState } = useWorkspaceState();
171 const { layout, panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
172 const params = props.route.params;
173 const { selectedThread, selectedThreadProject, selectedEnvironmentConnection } =
174 useThreadSelection();
175 const selectedThreadDetail = useSelectedThreadProjection();
176 const selectedThreadDetailWorktreePath =
177 selectedThreadDetail?.projection.thread.worktreePath ?? null;
178 const routeEnvironmentIdRaw = firstRouteParam(params.environmentId);
179 const routeThreadIdRaw = firstRouteParam(params.threadId);
180 const routeEnvironmentId = routeEnvironmentIdRaw
181 ? EnvironmentId.make(routeEnvironmentIdRaw)
182 : null;
183 const routeThreadId = routeThreadIdRaw ? ThreadId.make(routeThreadIdRaw) : null;
184 const environment = useEnvironmentPresentation(routeEnvironmentId);
185 const isEnvironmentReady = environment.presentation?.connection.phase === "connected";
186 const requestedTerminalId = firstRouteParam(params.terminalId);
187 const terminalId = requestedTerminalId ?? DEFAULT_TERMINAL_ID;
188 const {
189 isReady: hasResolvedFontPreference,
190 appearance,
191 setTerminalFontSize,
192 } = useAppearancePreferences();
193 const fontSize = appearance.terminalFontSize;
194 const cachedRouteGridSize =
195 routeEnvironmentId && routeThreadId
196 ? getCachedTerminalGridSize({
197 environmentId: routeEnvironmentId,
198 threadId: routeThreadId,
199 terminalId,
200 })
201 : null;
202 const knownSessions = useKnownTerminalSessions({
203 environmentId: selectedThread?.environmentId ?? null,
204 threadId: selectedThread?.id ?? null,
205 });
206 const runningSession = useMemo(
207 () => pickRunningTerminalSessionForBootstrap(knownSessions),
208 [knownSessions],
209 );
210 const activeKnownSession = useMemo(
211 () => knownSessions.find((session) => session.target.terminalId === terminalId) ?? null,
212 [knownSessions, terminalId],
213 );
214 const launchTarget = useMemo(
215 () =>
216 selectedThread
217 ? {
218 environmentId: selectedThread.environmentId,
219 threadId: selectedThread.id,
220 terminalId,
221 }
222 : null,
223 [selectedThread, terminalId],
224 );
225 const launchTargetKey = launchTarget
226 ? `${launchTarget.environmentId}:${launchTarget.threadId}:${launchTarget.terminalId}`
227 : null;
228 const [pendingLaunchEntry, setPendingLaunchEntry] = useState<{
229 readonly key: string | null;
230 readonly launch: PendingTerminalLaunch | null;
231 }>(() => ({
232 key: launchTargetKey,
233 launch: launchTarget === null ? null : takePendingTerminalLaunch(launchTarget),
234 }));
235 const pendingLaunch =
236 pendingLaunchEntry.key === launchTargetKey ? pendingLaunchEntry.launch : null;
237 const hasResolvedPendingLaunch = pendingLaunchEntry.key === launchTargetKey;
238 const [initialAttachGridEntry, setInitialAttachGridEntry] = useState(() => ({
239 key: launchTargetKey,
240 size: cachedRouteGridSize ?? {
241 cols: DEFAULT_TERMINAL_COLS,
242 rows: DEFAULT_TERMINAL_ROWS,
243 },
244 }));
245 const initialAttachGridSize =
246 initialAttachGridEntry.key === launchTargetKey ? initialAttachGridEntry.size : null;
247 const [lastGridSize, setLastGridSize] = useState(
248 cachedRouteGridSize ?? {
249 cols: DEFAULT_TERMINAL_COLS,
250 rows: DEFAULT_TERMINAL_ROWS,
251 },
252 );
253 const [keyboardFocusRequest, setKeyboardFocusRequest] = useState(0);
254 const [isAccessoryDismissed, setIsAccessoryDismissed] = useState(false);
255 const bufferReplayTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
256 const firstNonEmptyBufferLoggedRef = useRef(false);
257 const lastBufferReplayKeyRef = useRef<string | null>(null);
258 const sentInitialInputKeyRef = useRef<string | null>(null);
259 const [readyBufferReplayKey, setReadyBufferReplayKey] = useState<string | null>(null);
260 /** Default grid is always valid for attach; onResize refines cols/rows. Requiring a cached size blocked bootstrap for new terminal routes. */
261 const [hasMeasuredSurface, setHasMeasuredSurface] = useState(true);
262 const [pendingModifierState, setPendingModifierState] = useState<{
263 readonly terminalId: string;
264 readonly value: PendingModifier | null;
265 }>({
266 terminalId,
267 value: null,
268 });
269 const shouldRedirectToRunningTerminal =
270 requestedTerminalId === null &&
271 runningSession !== null &&
272 runningSession.target.terminalId !== terminalId;
273 const launchLocationCandidate = useMemo(() => {
274 if (!selectedThread || !selectedThreadProject?.workspaceRoot) {
275 return null;
276 }
277 if (pendingLaunch) {
278 return {
279 cwd: pendingLaunch.cwd,
280 worktreePath: pendingLaunch.worktreePath,
281 };
282 }
283 return resolveTerminalOpenLocation({
284 terminalLocation: activeKnownSession?.state.summary ?? null,
285 activeSessionLocation: activeKnownSession?.state.summary ?? null,
286 workspaceRoot: selectedThreadProject.workspaceRoot,
287 threadShellWorktreePath: selectedThread.worktreePath ?? null,
288 threadDetailWorktreePath: selectedThreadDetailWorktreePath,
289 });
290 }, [
291 activeKnownSession?.state.summary,
292 pendingLaunch,
293 selectedThread,
294 selectedThreadDetailWorktreePath,
295 selectedThreadProject?.workspaceRoot,
296 ]);
297 const [initialLaunchLocationEntry, setInitialLaunchLocationEntry] = useState(() => ({
298 key: launchTargetKey,
299 location: launchLocationCandidate,
300 }));
301 const launchLocation =
302 initialLaunchLocationEntry.key === launchTargetKey ? initialLaunchLocationEntry.location : null;
303 const terminalAttachInput = useMemo(
304 () =>
305 selectedThread !== null &&
306 launchLocation !== null &&
307 hasResolvedPendingLaunch &&
308 initialAttachGridSize !== null &&
309 hasResolvedFontPreference &&
310 hasMeasuredSurface &&
311 isEnvironmentReady &&
312 !shouldRedirectToRunningTerminal
313 ? {
314 threadId: selectedThread.id,
315 terminalId,
316 cwd: launchLocation.cwd,
317 worktreePath: launchLocation.worktreePath,
318 cols: initialAttachGridSize.cols,
319 rows: initialAttachGridSize.rows,
320 ...(pendingLaunch?.env ? { env: pendingLaunch.env } : {}),
321 ...(pendingLaunch ? { restartIfNotRunning: true } : {}),
322 }
323 : null,
324 [
325 hasMeasuredSurface,
326 hasResolvedFontPreference,
327 hasResolvedPendingLaunch,
328 initialAttachGridSize,
329 isEnvironmentReady,
330 launchLocation,
331 pendingLaunch,
332 selectedThread,
333 shouldRedirectToRunningTerminal,
334 terminalId,
335 ],
336 );
337 const terminal = useAttachedTerminalSession({
338 environmentId: selectedThread?.environmentId ?? null,
339 terminal: terminalAttachInput,
340 });
341 const terminalKey = selectedThread
342 ? `${selectedThread.environmentId}:${selectedThread.id}:${terminalId}`
343 : terminalId;
344 const bufferReplayKey = useMemo(
345 () => getTerminalBufferReplayKey({ terminalKey, fontSize }),
346 [fontSize, terminalKey],
347 );
348 if (lastBufferReplayKeyRef.current === null) {
349 lastBufferReplayKeyRef.current = bufferReplayKey;
350 }
351 const terminalSurfaceBuffer = getTerminalSurfaceReplayBuffer({
352 buffer: terminal.buffer,
353 replayKey: bufferReplayKey,
354 readyReplayKey: readyBufferReplayKey,
355 });
356 const isRunning = terminal.status === "running" || terminal.status === "starting";
357
358 // When the process ends while this screen is attached (e.g. typing `exit`),
359 // close the session and leave the screen, mirroring the web drawer's
360 // onSessionExited flow. Only react to a running -> exited transition
361 // observed on this screen so already-exited sessions can still be opened
362 // (they restart on attach).
363 const runningTerminalKeyRef = useRef<string | null>(null);
364 const reopenedStaleTerminalKeyRef = useRef<string | null>(null);
365 const pendingExitNavigationRef = useRef<string | null>(null);
366
367 // Attach subscriptions are cached with an idle TTL, so revisiting a
368 // terminal whose session ended while unobserved reuses the stale stream
369 // without a new attach RPC — the server never respawns anything. Detect
370 // that (dead status with processed events, never seen running here) and
371 // issue an explicit open; its snapshot flows into the live subscription.
372 useEffect(() => {
373 if (isRunning) {
374 reopenedStaleTerminalKeyRef.current = null;
375 return;
376 }
377 if (
378 terminalAttachInput === null ||
379 !selectedThread ||
380 (terminal.status !== "closed" && terminal.status !== "exited") ||
381 terminal.version === 0 ||
382 runningTerminalKeyRef.current === terminalKey ||
383 reopenedStaleTerminalKeyRef.current === terminalKey
384 ) {
385 return;
386 }
387 reopenedStaleTerminalKeyRef.current = terminalKey;
388 void openTerminal({
389 environmentId: selectedThread.environmentId,
390 input: {
391 threadId: selectedThread.id,
392 terminalId,
393 cwd: terminalAttachInput.cwd,
394 worktreePath: terminalAttachInput.worktreePath,
395 cols: terminalAttachInput.cols,
396 rows: terminalAttachInput.rows,
397 ...(terminalAttachInput.env ? { env: terminalAttachInput.env } : {}),
398 },
399 }).then((result) => {
400 // Release the guard on failure so a later render can retry the respawn.
401 if (result._tag === "Failure" && reopenedStaleTerminalKeyRef.current === terminalKey) {
402 reopenedStaleTerminalKeyRef.current = null;
403 }
404 });
405 }, [
406 isRunning,
407 openTerminal,
408 selectedThread,
409 terminal.status,
410 terminal.version,
411 terminalAttachInput,
412 terminalId,
413 terminalKey,
414 ]);
415
416 useEffect(() => {
417 terminalDebugLog("surface:props", {
418 terminalKey,
419 atomBufferLen: terminal.buffer.length,
420 surfaceBufferLen: terminalSurfaceBuffer.length,
421 replayKey: bufferReplayKey,
422 readyReplayKey: readyBufferReplayKey,
423 status: terminal.status,
424 version: terminal.version,
425 });
426 }, [
427 bufferReplayKey,
428 readyBufferReplayKey,
429 terminal.buffer.length,
430 terminal.status,
431 terminal.version,
432 terminalKey,
433 terminalSurfaceBuffer.length,
434 ]);
435
436 useEffect(() => {
437 terminalDebugLog("session:status", {
438 terminalKey,
439 status: terminal.status,
440 error: terminal.error,
441 summary: terminal.summary?.cwd ?? null,
442 bufferLen: terminal.buffer.length,
443 version: terminal.version,
444 });
445 }, [
446 terminal.buffer.length,
447 terminal.error,
448 terminal.status,
449 terminal.summary?.cwd,
450 terminal.version,
451 terminalKey,
452 ]);
453
454 useEffect(() => {
455 if (terminal.buffer.length === 0 || firstNonEmptyBufferLoggedRef.current) {
456 return;
457 }
458 firstNonEmptyBufferLoggedRef.current = true;
459 terminalDebugLog("session:first-nonempty-buffer", {
460 terminalKey,
461 length: terminal.buffer.length,
462 preview: terminal.buffer.slice(0, 160),
463 });
464 }, [terminal.buffer, terminal.buffer.length, terminalKey]);
465 const cwd = terminal.summary?.cwd ?? selectedThreadProject?.workspaceRoot ?? null;
466 const hostPlatform = useMemo(
467 () => inferHostPlatform(selectedEnvironmentConnection?.environmentLabel ?? null),
468 [selectedEnvironmentConnection?.environmentLabel],
469 );
470
471 const terminalTheme = getPierreTerminalTheme(appearanceScheme);
472 const usesNativeHeaderGlass = Platform.OS === "ios";
473 const pendingModifier =
474 pendingModifierState.terminalId === terminalId ? pendingModifierState.value : null;
475 const headerSubtitle = selectedThreadProject?.title ?? "";
476 const terminalToolbarActions = useMemo<ReadonlyArray<TerminalToolbarAction>>(() => {
477 const modifierActions: ReadonlyArray<TerminalToolbarAction> =
478 hostPlatform === "mac"
479 ? [
480 { kind: "modifier", key: "cmd", label: "cmd", modifier: "meta" },
481 { kind: "modifier", key: "ctrl", label: "ctrl", modifier: "ctrl" },
482 ]
483 : [
484 { kind: "modifier", key: "ctrl", label: "ctrl", modifier: "ctrl" },
485 { kind: "modifier", key: "alt", label: "alt", modifier: "meta" },
486 ];
487
488 return [
489 { kind: "send", key: "esc", label: "esc", data: "\u001b" },
490 ...modifierActions,
491 { kind: "send", key: "tab", label: "tab", data: "\t" },
492 { kind: "clear", key: "clear", label: "clear" },
493 { kind: "send", key: "up", label: "↑", data: "\u001b[A" },
494 { kind: "send", key: "down", label: "↓", data: "\u001b[B" },
495 { kind: "send", key: "left", label: "←", data: "\u001b[D" },
496 { kind: "send", key: "right", label: "→", data: "\u001b[C" },
497 { kind: "send", key: "tilde", label: "~", data: "~" },
498 { kind: "send", key: "pipe", label: "|", data: "|" },
499 { kind: "send", key: "slash", label: "/", data: "/" },
500 { kind: "send", key: "dash", label: "-", data: "-" },
501 ];
502 }, [hostPlatform]);
503 const keyboardState = useKeyboardState((state) => ({
504 height: state.height,
505 isVisible: state.isVisible,
506 }));
507 const isAccessoryVisible = keyboardState.isVisible && !isAccessoryDismissed;
508 const terminalBottomInset =
509 (keyboardState.isVisible ? keyboardState.height : 0) +
510 (isAccessoryVisible ? TERMINAL_ACCESSORY_HEIGHT : 0);
511
512 useEffect(() => {
513 const keyboardWillShow = KeyboardEvents.addListener("keyboardWillShow", () => {
514 setIsAccessoryDismissed(false);
515 });
516 const keyboardWillHide = KeyboardEvents.addListener("keyboardWillHide", () => {
517 setIsAccessoryDismissed(true);
518 });
519
520 return () => {
521 keyboardWillShow.remove();
522 keyboardWillHide.remove();
523 };
524 }, []);
525
526 const terminalMenuSessions = useMemo<ReadonlyArray<TerminalMenuSession>>(
527 () =>
528 buildTerminalMenuSessions({
529 knownSessions,
530 workspaceRoot: selectedThreadProject?.workspaceRoot ?? null,
531 currentSession: {
532 terminalId,
533 cwd: cwd ?? null,
534 status: terminal.status,
535 hasRunningSubprocess: terminal.hasRunningSubprocess,
536 displayLabel: resolveTerminalSessionLabel(terminalId, terminal.summary),
537 updatedAt: terminal.updatedAt,
538 },
539 }),
540 [
541 cwd,
542 knownSessions,
543 selectedThreadProject?.workspaceRoot,
544 terminal.hasRunningSubprocess,
545 terminal.summary,
546 terminal.status,
547 terminal.updatedAt,
548 terminalId,
549 ],
550 );
551
552 useEffect(() => {
553 if (pendingLaunchEntry.key === launchTargetKey) {
554 return;
555 }
556 setPendingLaunchEntry({
557 key: launchTargetKey,
558 launch: launchTarget === null ? null : takePendingTerminalLaunch(launchTarget),
559 });
560 }, [launchTarget, launchTargetKey, pendingLaunchEntry.key]);
561
562 useEffect(() => {
563 if (initialAttachGridEntry.key === launchTargetKey) {
564 return;
565 }
566 setInitialAttachGridEntry({
567 key: launchTargetKey,
568 size: cachedRouteGridSize ?? {
569 cols: DEFAULT_TERMINAL_COLS,
570 rows: DEFAULT_TERMINAL_ROWS,
571 },
572 });
573 }, [cachedRouteGridSize, initialAttachGridEntry.key, launchTargetKey]);
574
575 useEffect(() => {
576 if (
577 initialLaunchLocationEntry.key === launchTargetKey &&
578 initialLaunchLocationEntry.location !== null
579 ) {
580 return;
581 }
582 if (initialLaunchLocationEntry.key === launchTargetKey && launchLocationCandidate === null) {
583 return;
584 }
585 setInitialLaunchLocationEntry({
586 key: launchTargetKey,
587 location: launchLocationCandidate,
588 });
589 }, [
590 initialLaunchLocationEntry.key,
591 initialLaunchLocationEntry.location,
592 launchLocationCandidate,
593 launchTargetKey,
594 ]);
595
596 useEffect(() => {
597 if (!shouldRedirectToRunningTerminal || !selectedThread || !runningSession) {
598 return;
599 }
600 navigation.dispatch(
601 StackActions.replace("ThreadTerminal", {
602 environmentId: String(selectedThread.environmentId),
603 threadId: String(selectedThread.id),
604 terminalId: runningSession.target.terminalId,
605 }),
606 );
607 }, [navigation, runningSession, selectedThread, shouldRedirectToRunningTerminal]);
608
609 useEffect(() => {
610 const initialInput = pendingLaunch?.initialInput;
611 if (
612 !initialInput ||
613 !selectedThread ||
614 terminal.version === 0 ||
615 sentInitialInputKeyRef.current === launchTargetKey
616 ) {
617 return;
618 }
619 sentInitialInputKeyRef.current = launchTargetKey;
620 void writeTerminal({
621 environmentId: selectedThread.environmentId,
622 input: {
623 threadId: selectedThread.id,
624 terminalId,
625 data: initialInput,
626 },
627 });
628 }, [
629 launchTargetKey,
630 pendingLaunch?.initialInput,
631 selectedThread,
632 terminal.version,
633 terminalId,
634 writeTerminal,
635 ]);
636
637 useEffect(() => {
638 firstNonEmptyBufferLoggedRef.current = false;
639 sentInitialInputKeyRef.current = null;
640 }, [terminalKey]);
641
642 const clearBufferReplayTimer = useCallback(() => {
643 if (bufferReplayTimerRef.current !== null) {
644 clearTimeout(bufferReplayTimerRef.current);
645 bufferReplayTimerRef.current = null;
646 }
647 }, []);
648
649 const scheduleBufferReplayReady = useCallback(() => {
650 clearBufferReplayTimer();
651 const replayKey = bufferReplayKey;
652 terminalDebugLog("replay:schedule-ready", {
653 replayKey,
654 delayMs: TERMINAL_BUFFER_REPLAY_STABILITY_DELAY_MS,
655 });
656 bufferReplayTimerRef.current = setTimeout(() => {
657 bufferReplayTimerRef.current = null;
658 setReadyBufferReplayKey(replayKey);
659 terminalDebugLog("replay:ready", { replayKey });
660 }, TERMINAL_BUFFER_REPLAY_STABILITY_DELAY_MS);
661 }, [bufferReplayKey, clearBufferReplayTimer]);
662
663 useEffect(() => {
664 if (lastBufferReplayKeyRef.current === bufferReplayKey) {
665 return;
666 }
667
668 lastBufferReplayKeyRef.current = bufferReplayKey;
669 clearBufferReplayTimer();
670 setReadyBufferReplayKey(null);
671 }, [bufferReplayKey, clearBufferReplayTimer]);
672
673 useEffect(() => clearBufferReplayTimer, [clearBufferReplayTimer]);
674
675 useEffect(() => {
676 if (!routeEnvironmentId || !routeThreadId) {
677 setLastGridSize({
678 cols: DEFAULT_TERMINAL_COLS,
679 rows: DEFAULT_TERMINAL_ROWS,
680 });
681 return;
682 }
683
684 setLastGridSize(
685 getCachedTerminalGridSize({
686 environmentId: routeEnvironmentId,
687 threadId: routeThreadId,
688 terminalId,
689 }) ?? {
690 cols: DEFAULT_TERMINAL_COLS,
691 rows: DEFAULT_TERMINAL_ROWS,
692 },
693 );
694 setHasMeasuredSurface(true);
695 }, [routeEnvironmentId, routeThreadId, terminalId]);
696
697 const writeInput = useCallback(
698 (data: string) => {
699 if (!selectedThread || !isRunning) {
700 return;
701 }
702
703 void writeTerminal({
704 environmentId: selectedThread.environmentId,
705 input: {
706 threadId: selectedThread.id,
707 terminalId,
708 data,
709 },
710 });
711 },
712 [isRunning, selectedThread, terminalId, writeTerminal],
713 );
714
715 const handleInput = useCallback(
716 (data: string) => {
717 if (data.length === 0) {
718 return;
719 }
720
721 if (pendingModifier === "ctrl") {
722 setPendingModifierState({ terminalId, value: null });
723 writeInput(applyCtrlModifier(data));
724 } else if (pendingModifier === "meta") {
725 setPendingModifierState({ terminalId, value: null });
726 writeInput(`\u001b${data}`);
727 } else {
728 writeInput(data);
729 }
730 },
731 [pendingModifier, terminalId, writeInput],
732 );
733
734 const handleResize = useCallback(
735 (size: { readonly cols: number; readonly rows: number }) => {
736 terminalDebugLog("native:onResize", {
737 cols: size.cols,
738 rows: size.rows,
739 terminalKey,
740 });
741 setHasMeasuredSurface(true);
742 if (readyBufferReplayKey !== bufferReplayKey) {
743 scheduleBufferReplayReady();
744 }
745 if (routeEnvironmentId && routeThreadId) {
746 cacheTerminalGridSize(
747 {
748 environmentId: routeEnvironmentId,
749 threadId: routeThreadId,
750 terminalId,
751 },
752 size,
753 );
754 }
755 if (size.cols === lastGridSize.cols && size.rows === lastGridSize.rows) {
756 return;
757 }
758
759 setLastGridSize(size);
760 if (!selectedThread || !isRunning) {
761 return;
762 }
763
764 void resizeTerminal({
765 environmentId: selectedThread.environmentId,
766 input: {
767 threadId: selectedThread.id,
768 terminalId,
769 cols: size.cols,
770 rows: size.rows,
771 },
772 });
773 },
774 [
775 isRunning,
776 lastGridSize.cols,
777 lastGridSize.rows,
778 bufferReplayKey,
779 readyBufferReplayKey,
780 routeEnvironmentId,
781 routeThreadId,
782 resizeTerminal,
783 scheduleBufferReplayReady,
784 selectedThread,
785 terminalId,
786 terminalKey,
787 ],
788 );
789
790 const handleSelectTerminal = useCallback(
791 (nextTerminalId: string) => {
792 if (!selectedThread || nextTerminalId === terminalId) {
793 return;
794 }
795
796 navigation.dispatch(
797 StackActions.replace("ThreadTerminal", {
798 environmentId: String(selectedThread.environmentId),
799 threadId: String(selectedThread.id),
800 terminalId: nextTerminalId,
801 }),
802 );
803 },
804 [navigation, selectedThread, terminalId],
805 );
806
807 const navigateAwayAfterExit = useCallback(() => {
808 // With other shells still live, fall through to the previous one instead
809 // of dropping the user back on the thread.
810 const fallbackTerminalId = previousLiveTerminalId({
811 sessions: terminalMenuSessions,
812 exitedTerminalId: terminalId,
813 });
814 if (fallbackTerminalId !== null && selectedThread) {
815 navigation.dispatch(
816 StackActions.replace("ThreadTerminal", {
817 environmentId: String(selectedThread.environmentId),
818 threadId: String(selectedThread.id),
819 terminalId: fallbackTerminalId,
820 }),
821 );
822 return;
823 }
824 if (navigation.canGoBack()) {
825 navigation.goBack();
826 return;
827 }
828 // Deep-linked/root mounts have nothing to pop; land on the thread
829 // instead of stranding the user on a dead terminal.
830 if (selectedThread) {
831 navigation.dispatch(
832 StackActions.replace("Thread", {
833 environmentId: String(selectedThread.environmentId),
834 threadId: String(selectedThread.id),
835 }),
836 );
837 }
838 }, [navigation, selectedThread, terminalId, terminalMenuSessions]);
839
840 useEffect(() => {
841 // Detached (hidden surface or environment drop): forget the running
842 // marker so a reattach takes the stale-reopen path instead of misreading
843 // the dead snapshot as an exit observed on this screen. A pending exit
844 // navigation stays armed — it only clears once the session runs again —
845 // so refocusing a dead screen still leaves it.
846 if (terminalAttachInput === null) {
847 runningTerminalKeyRef.current = null;
848 return;
849 }
850 if (isRunning) {
851 runningTerminalKeyRef.current = terminalKey;
852 // The session came back (e.g. respawned elsewhere) before the user
853 // returned; a stale pending exit must not eject a live terminal.
854 pendingExitNavigationRef.current = null;
855 return;
856 }
857 // The web drawer treats both exited and closed as session end.
858 const sessionEnded = terminal.status === "exited" || terminal.status === "closed";
859 if (!sessionEnded || runningTerminalKeyRef.current !== terminalKey) {
860 return;
861 }
862 runningTerminalKeyRef.current = null;
863 // Mark this key handled so the stale-attach effect doesn't respawn the
864 // session the user just ended.
865 reopenedStaleTerminalKeyRef.current = terminalKey;
866 if (selectedThread) {
867 void closeTerminal({
868 environmentId: selectedThread.environmentId,
869 input: {
870 threadId: selectedThread.id,
871 terminalId,
872 },
873 });
874 }
875 if (navigation.isFocused()) {
876 navigateAwayAfterExit();
877 return;
878 }
879 // An unfocused screen can't navigate; leave when the user returns so
880 // they never land on the dead session.
881 pendingExitNavigationRef.current = terminalKey;
882 }, [
883 closeTerminal,
884 isRunning,
885 navigateAwayAfterExit,
886 navigation,
887 selectedThread,
888 terminal.status,
889 terminalAttachInput,
890 terminalId,
891 terminalKey,
892 ]);
893
894 useEffect(
895 () =>
896 navigation.addListener("focus", () => {
897 if (pendingExitNavigationRef.current !== terminalKey) {
898 return;
899 }
900 pendingExitNavigationRef.current = null;
901 navigateAwayAfterExit();
902 }),
903 [navigateAwayAfterExit, navigation, terminalKey],
904 );
905
906 const handleOpenNewTerminal = useCallback(() => {
907 if (!selectedThread) {
908 return;
909 }
910
911 navigation.dispatch(
912 StackActions.replace("ThreadTerminal", {
913 environmentId: String(selectedThread.environmentId),
914 threadId: String(selectedThread.id),
915 terminalId: nextOpenTerminalId({
916 listedTerminalIds: terminalMenuSessions.map((session) => session.terminalId),
917 activeRouteTerminalId: terminalId,
918 }),
919 }),
920 );
921 }, [navigation, selectedThread, terminalId, terminalMenuSessions]);
922
923 const handleDecreaseFontSize = useCallback(() => {
924 setTerminalFontSize(stepTerminalFontSize(fontSize, -1));
925 }, [fontSize, setTerminalFontSize]);
926
927 const handleIncreaseFontSize = useCallback(() => {
928 setTerminalFontSize(stepTerminalFontSize(fontSize, 1));
929 }, [fontSize, setTerminalFontSize]);
930
931 // Android mirror of the iOS NativeHeaderToolbar terminal menu below: text
932 // size, session switching, and "Open new terminal", rendered through the
933 // token-styled anchored menu (the native header items are iOS-only).
934 const androidTerminalMenuActions = useMemo<MenuAction[]>(
935 () => [
936 {
937 id: "text-size",
938 title: "Text size",
939 subactions: [
940 {
941 id: "font-decrease",
942 title: `A- ${Math.max(MIN_TERMINAL_FONT_SIZE, fontSize - TERMINAL_FONT_SIZE_STEP).toFixed(1)} pt`,
943 attributes: fontSize <= MIN_TERMINAL_FONT_SIZE ? { disabled: true } : undefined,
944 },
945 {
946 id: "font-increase",
947 title: `A+ ${Math.min(MAX_TERMINAL_FONT_SIZE, fontSize + TERMINAL_FONT_SIZE_STEP).toFixed(1)} pt`,
948 attributes: fontSize >= MAX_TERMINAL_FONT_SIZE ? { disabled: true } : undefined,
949 },
950 ],
951 },
952 ...terminalMenuSessions.map(
953 (session): MenuAction => ({
954 id: `terminal-session:${session.terminalId}`,
955 title: session.displayLabel,
956 subtitle: [getTerminalStatusLabel({ status: session.status }), basename(session.cwd)]
957 .filter(Boolean)
958 .join(" · "),
959 state: session.terminalId === terminalId ? ("on" as const) : undefined,
960 }),
961 ),
962 {
963 id: "terminal-new",
964 title: "Open new terminal",
965 image: "plus",
966 subtitle: `Start another shell in ${basename(selectedThreadProject?.workspaceRoot ?? null) ?? "this workspace"}`,
967 },
968 ],
969 [fontSize, selectedThreadProject?.workspaceRoot, terminalId, terminalMenuSessions],
970 );
971
972 const handleAndroidTerminalMenuAction = useCallback(
973 (event: { nativeEvent: { event: string } }) => {
974 const id = event.nativeEvent.event;
975 if (id === "font-decrease") {
976 handleDecreaseFontSize();
977 return;
978 }
979 if (id === "font-increase") {
980 handleIncreaseFontSize();
981 return;
982 }
983 if (id === "terminal-new") {
984 handleOpenNewTerminal();
985 return;
986 }
987 if (id.startsWith("terminal-session:")) {
988 handleSelectTerminal(id.slice("terminal-session:".length));
989 }
990 },
991 [handleDecreaseFontSize, handleIncreaseFontSize, handleOpenNewTerminal, handleSelectTerminal],
992 );
993
994 const handleClearTerminal = useCallback(() => {
995 if (!selectedThread) {
996 return;
997 }
998
999 setPendingModifierState({ terminalId, value: null });
1000 void clearTerminal({
1001 environmentId: selectedThread.environmentId,
1002 input: {
1003 threadId: selectedThread.id,
1004 terminalId,
1005 },
1006 });
1007 }, [clearTerminal, selectedThread, terminalId]);
1008
1009 const handleToolbarActionPress = useCallback(
1010 (action: TerminalToolbarAction) => {
1011 if (action.kind === "modifier") {
1012 setPendingModifierState((current) => ({
1013 terminalId,
1014 value:
1015 (current.terminalId === terminalId ? current.value : null) === action.modifier
1016 ? null
1017 : action.modifier,
1018 }));
1019 return;
1020 }
1021
1022 if (action.kind === "clear") {
1023 handleClearTerminal();
1024 return;
1025 }
1026
1027 setPendingModifierState({ terminalId, value: null });
1028 if (pendingModifier === "ctrl") {
1029 writeInput(applyCtrlModifier(action.data));
1030 } else if (pendingModifier === "meta") {
1031 writeInput(`\u001b${action.data}`);
1032 } else {
1033 writeInput(action.data);
1034 }
1035 },
1036 [handleClearTerminal, pendingModifier, terminalId, writeInput],
1037 );
1038
1039 const handleDismissKeyboard = useCallback(() => {
1040 setIsAccessoryDismissed(true);
1041 void KeyboardController.dismiss();
1042 }, []);
1043
1044 const handleShowKeyboard = useCallback(() => {
1045 setKeyboardFocusRequest((current) => current + 1);
1046 }, []);
1047 const handleRetryEnvironment = useCallback(() => {
1048 if (routeEnvironmentId !== null) {
1049 void retryEnvironment(routeEnvironmentId);
1050 }
1051 }, [retryEnvironment, routeEnvironmentId]);
1052
1053 if (!selectedThread) {
1054 if (workspaceState.isLoadingConnections) {
1055 return <LoadingScreen message="Opening terminal…" />;
1056 }
1057
1058 return (
1059 <View className="flex-1 bg-screen">
1060 <EmptyState
1061 title="Thread unavailable"
1062 detail="This terminal route needs an active thread and workspace."
1063 />
1064 </View>
1065 );
1066 }
1067
1068 if (!selectedThreadProject?.workspaceRoot) {
1069 return (
1070 <View className="flex-1 bg-screen">
1071 <EmptyState
1072 title="Terminal unavailable"
1073 detail="This thread does not have a workspace root yet, so there is nowhere to open a shell."
1074 />
1075 </View>
1076 );
1077 }
1078
1079 if (!environment.isReady && environment.presentation === null) {
1080 return <LoadingScreen message="Opening terminal…" />;
1081 }
1082
1083 return (
1084 <>
1085 <NativeStackScreenOptions
1086 options={{
1087 // Static header config lives in Stack.tsx (SOLID_HEADER_OPTIONS — the pty
1088 // scrolls internally, nothing for glass to sample). Default title/subtitle
1089 // styling, like every other page.
1090 // Android draws its own in-flow header (AndroidScreenHeader below);
1091 // the native stack header stays iOS-only.
1092 headerShown: Platform.OS !== "android",
1093 title: "Terminal",
1094 unstable_headerSubtitle:
1095 usesNativeHeaderGlass && headerSubtitle.length > 0 ? headerSubtitle : undefined,
1096 }}
1097 />
1098
1099 {Platform.OS === "android" ? (
1100 <AndroidScreenHeader
1101 title="Terminal"
1102 subtitle={headerSubtitle}
1103 onBack={navigation.canGoBack() ? () => navigation.goBack() : undefined}
1104 trailing={
1105 <>
1106 {layout.usesSplitView ? (
1107 <AndroidHeaderIconButton
1108 accessibilityLabel={
1109 panes.primarySidebarVisible ? "Maximize terminal" : "Show threads"
1110 }
1111 icon={
1112 panes.primarySidebarVisible
1113 ? "arrow.up.left.and.arrow.down.right"
1114 : "sidebar.left"
1115 }
1116 onPress={togglePrimarySidebar}
1117 />
1118 ) : null}
1119 {isEnvironmentReady ? (
1120 <ControlPillMenu
1121 actions={androidTerminalMenuActions}
1122 isAnchoredToRight
1123 title={getTerminalStatusLabel({
1124 status: terminal.status,
1125 hasRunningSubprocess: terminal.hasRunningSubprocess,
1126 })}
1127 onPressAction={handleAndroidTerminalMenuAction}
1128 >
1129 <AndroidHeaderIconButton accessibilityLabel="Terminal options" icon="terminal" />
1130 </ControlPillMenu>
1131 ) : null}
1132 </>
1133 }
1134 />
1135 ) : null}
1136
1137 {layout.usesSplitView ? (
1138 <NativeHeaderToolbar placement="left">
1139 <NativeHeaderToolbar.Button
1140 accessibilityLabel={panes.primarySidebarVisible ? "Maximize terminal" : "Show threads"}
1141 icon={
1142 panes.primarySidebarVisible ? "arrow.up.left.and.arrow.down.right" : "sidebar.left"
1143 }
1144 onPress={togglePrimarySidebar}
1145 separateBackground
1146 />
1147 </NativeHeaderToolbar>
1148 ) : null}
1149
1150 {isEnvironmentReady ? (
1151 <NativeHeaderToolbar placement="right">
1152 <NativeHeaderToolbar.Menu icon="terminal" title="Terminal options" separateBackground>
1153 <NativeHeaderToolbar.Label>
1154 {getTerminalStatusLabel({
1155 status: terminal.status,
1156 hasRunningSubprocess: terminal.hasRunningSubprocess,
1157 })}
1158 </NativeHeaderToolbar.Label>
1159 <NativeHeaderToolbar.Menu icon="textformat.size" inline title="Text size">
1160 <NativeHeaderToolbar.Label>Text size</NativeHeaderToolbar.Label>
1161 <NativeHeaderToolbar.MenuAction
1162 disabled={fontSize <= MIN_TERMINAL_FONT_SIZE}
1163 discoverabilityLabel="Decrease terminal text size"
1164 onPress={handleDecreaseFontSize}
1165 >
1166 <NativeHeaderToolbar.Label>{`A- ${Math.max(MIN_TERMINAL_FONT_SIZE, fontSize - TERMINAL_FONT_SIZE_STEP).toFixed(1)} pt`}</NativeHeaderToolbar.Label>
1167 </NativeHeaderToolbar.MenuAction>
1168 <NativeHeaderToolbar.MenuAction
1169 disabled={fontSize >= MAX_TERMINAL_FONT_SIZE}
1170 discoverabilityLabel="Increase terminal text size"
1171 onPress={handleIncreaseFontSize}
1172 >
1173 <NativeHeaderToolbar.Label>{`A+ ${Math.min(MAX_TERMINAL_FONT_SIZE, fontSize + TERMINAL_FONT_SIZE_STEP).toFixed(1)} pt`}</NativeHeaderToolbar.Label>
1174 </NativeHeaderToolbar.MenuAction>
1175 </NativeHeaderToolbar.Menu>
1176 {terminalMenuSessions.map((session) => (
1177 <NativeHeaderToolbar.MenuAction
1178 key={session.terminalId}
1179 icon={session.terminalId === terminalId ? "checkmark" : "terminal"}
1180 onPress={() => handleSelectTerminal(session.terminalId)}
1181 subtitle={[
1182 getTerminalStatusLabel({ status: session.status }),
1183 basename(session.cwd),
1184 ]
1185 .filter(Boolean)
1186 .join(" · ")}
1187 >
1188 <NativeHeaderToolbar.Label>{session.displayLabel}</NativeHeaderToolbar.Label>
1189 </NativeHeaderToolbar.MenuAction>
1190 ))}
1191 <NativeHeaderToolbar.MenuAction
1192 icon="plus"
1193 onPress={handleOpenNewTerminal}
1194 subtitle={`Start another shell in ${basename(selectedThreadProject.workspaceRoot) ?? "this workspace"}`}
1195 >
1196 <NativeHeaderToolbar.Label>Open new terminal</NativeHeaderToolbar.Label>
1197 </NativeHeaderToolbar.MenuAction>
1198 </NativeHeaderToolbar.Menu>
1199 </NativeHeaderToolbar>
1200 ) : null}
1201
1202 <View className="flex-1" style={{ backgroundColor: terminalTheme.background }}>
1203 {!isEnvironmentReady ? (
1204 <EnvironmentConnectionNotice
1205 environmentLabel={
1206 environment.presentation?.entry.target.label ??
1207 selectedEnvironmentConnection?.environmentLabel ??
1208 "Environment"
1209 }
1210 connection={
1211 environment.presentation?.connection ?? {
1212 phase: "available",
1213 error: null,
1214 traceId: null,
1215 }
1216 }
1217 resourceName="terminal"
1218 onRetry={handleRetryEnvironment}
1219 />
1220 ) : (
1221 <>
1222 <View className="flex-1" style={{ paddingBottom: terminalBottomInset }}>
1223 <TerminalSurface
1224 autoFocus={!SHOWCASE_ENABLED}
1225 buffer={terminalSurfaceBuffer}
1226 fontSize={fontSize}
1227 isRunning={isRunning}
1228 keyboardFocusRequest={keyboardFocusRequest}
1229 onInput={handleInput}
1230 onResize={handleResize}
1231 style={{ flex: 1 }}
1232 terminalKey={terminalKey}
1233 />
1234 </View>
1235
1236 {isAccessoryVisible ? (
1237 <KeyboardStickyView
1238 style={{ position: "absolute", bottom: 0, left: 0, right: 0 }}
1239 offset={{ closed: 0, opened: 0 }}
1240 >
1241 <View
1242 className="border-t"
1243 style={{
1244 backgroundColor: terminalTheme.background,
1245 borderTopColor: terminalTheme.border,
1246 minHeight: TERMINAL_ACCESSORY_HEIGHT,
1247 }}
1248 >
1249 <ComposerToolbarRow paddingBottom={4} paddingHorizontal={8} paddingTop={4}>
1250 <ComposerToolbarScroller
1251 contentPaddingRight={2}
1252 fadeOpaque={terminalTheme.background}
1253 fadeTransparent={`${terminalTheme.background}00`}
1254 >
1255 {terminalToolbarActions.map((action) => {
1256 const active =
1257 action.kind === "modifier" && pendingModifier === action.modifier;
1258
1259 return (
1260 <ComposerToolbarButton
1261 key={action.key}
1262 active={active}
1263 label={action.label}
1264 maxWidth={120}
1265 minWidth={action.label.length > 1 ? 56 : 44}
1266 onPress={() => handleToolbarActionPress(action)}
1267 showChevron={false}
1268 textTransform={
1269 action.kind === "modifier" || action.kind === "clear"
1270 ? "uppercase"
1271 : "none"
1272 }
1273 />
1274 );
1275 })}
1276 </ComposerToolbarScroller>
1277 <ComposerToolbarButton
1278 accessibilityLabel="Dismiss keyboard"
1279 icon={{ ios: "keyboard.chevron.compact.down", android: "keyboard_hide" }}
1280 onPress={handleDismissKeyboard}
1281 showChevron={false}
1282 />
1283 </ComposerToolbarRow>
1284 </View>
1285 </KeyboardStickyView>
1286 ) : !keyboardState.isVisible ? (
1287 <Pressable
1288 accessibilityLabel="Show keyboard"
1289 accessibilityRole="button"
1290 onPress={handleShowKeyboard}
1291 style={({ pressed }) => ({
1292 bottom: 16,
1293 borderRadius: 28,
1294 opacity: pressed ? 0.72 : 1,
1295 position: "absolute",
1296 right: 16,
1297 })}
1298 >
1299 <GlassSurface
1300 chrome="none"
1301 glassEffectStyle="regular"
1302 tintColor="transparent"
1303 style={{
1304 alignItems: "center",
1305 borderRadius: 24,
1306 height: 48,
1307 justifyContent: "center",
1308 width: 48,
1309 }}
1310 pointerEvents="none"
1311 >
1312 <SymbolView
1313 name={{ ios: "keyboard", android: "keyboard" }}
1314 size={20}
1315 tintColor={terminalTheme.foreground}
1316 type="monochrome"
1317 />
1318 </GlassSurface>
1319 </Pressable>
1320 ) : null}
1321 </>
1322 )}
1323 </View>
1324 </>
1325 );
1326}