Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ThreadTerminalRouteScreen.tsx

1,328 lines45.3 KB

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