Skip to content

Commit 279de76

Browse files
committed
fix(app,lib): satisfy cold-open CI lint checks
1 parent 5c65f4c commit 279de76

6 files changed

Lines changed: 40 additions & 24 deletions

File tree

packages/app/src/web/actions-projects.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,7 @@ const resolveProjectTerminalKey = (
7878
}
7979

8080
const createPendingTerminalSessionId = (): string => {
81-
const randomUuid = globalThis.crypto?.randomUUID
82-
return typeof randomUuid === "function"
83-
? randomUuid.call(globalThis.crypto)
84-
: `pending-${Date.now()}-${Math.random().toString(16).slice(2)}`
81+
return globalThis.crypto.randomUUID()
8582
}
8683

8784
export const connectProjectById = (

packages/app/src/web/app-ready-terminal-screen.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { TerminalPanel } from "./panel-terminal.js"
1010
import { type BrowserScreen, projectPickerScreen } from "./screen.js"
1111
import { shouldShowTerminalTabs } from "./terminal-mobile-layout.js"
1212
import { terminalSessionId } from "./terminal-state.js"
13-
import { isPendingActiveTerminalSession, type ActiveTerminalSession } from "./terminal.js"
13+
import { type ActiveTerminalSession, isPendingActiveTerminalSession } from "./terminal.js"
1414

1515
type TerminalWorkspaceView = "terminal" | "tasks"
1616

@@ -369,8 +369,9 @@ const TerminalPane = (
369369
const browserProjectKey = terminalSession.browserProjectKey
370370
const canOpenBrowser = canOpenProjectBrowser(projectBrowser, browserProjectId)
371371
const pendingSession = isPendingActiveTerminalSession(terminalSession)
372-
const bodyContent = taskManagerOpen && browserProjectId !== undefined
373-
? (
372+
let bodyContent: JSX.Element | undefined
373+
if (taskManagerOpen && browserProjectId !== undefined) {
374+
bodyContent = (
374375
<TerminalTaskManagerBody
375376
onClose={onCloseTaskManager}
376377
onLoadProjectTaskLogs={onLoadProjectTaskLogs}
@@ -384,9 +385,9 @@ const TerminalPane = (
384385
selectedProjectSummary={selectedProjectSummary}
385386
/>
386387
)
387-
: pendingSession
388-
? <PendingTerminalBody session={terminalSession} />
389-
: undefined
388+
} else if (pendingSession) {
389+
bodyContent = <PendingTerminalBody session={terminalSession} />
390+
}
390391
const detachTerminalSession = (): void => {
391392
onTerminalClose(sessionId)
392393
if (singleSession) {
@@ -404,15 +405,19 @@ const TerminalPane = (
404405
}}
405406
onDetach={() => {
406407
detachTerminalSession()
407-
onTerminalMessage(`${pendingSession ? "Closed pending" : "Detached"} SSH terminal: ${terminalSession.session.id}.`)
408+
onTerminalMessage(
409+
`${pendingSession ? "Closed pending" : "Detached"} SSH terminal: ${terminalSession.session.id}.`
410+
)
408411
}}
409412
onKill={() => {
410413
if (!pendingSession) {
411414
requestTerminalSessionClose(terminalSession.closePath)
412415
terminalSession.onExit?.()
413416
}
414417
detachTerminalSession()
415-
onTerminalMessage(`${pendingSession ? "Closed pending" : "Killed"} SSH terminal: ${terminalSession.session.id}.`)
418+
onTerminalMessage(
419+
`${pendingSession ? "Closed pending" : "Killed"} SSH terminal: ${terminalSession.session.id}.`
420+
)
416421
}}
417422
onOpenBrowser={browserProjectId === undefined || !canOpenBrowser
418423
? undefined

packages/app/src/web/panel-terminal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
type TerminalStatus,
1616
useTerminalSessionLifecycle
1717
} from "./terminal-panel-runtime.js"
18-
import { isPendingActiveTerminalSession, type ActiveTerminalSession } from "./terminal.js"
18+
import { type ActiveTerminalSession, isPendingActiveTerminalSession } from "./terminal.js"
1919

2020
type TerminalPanelProps = {
2121
readonly keyboardOpen: boolean

packages/app/src/web/terminal-panel-runtime.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,19 @@ const attachGlobalResizeListeners = (sendResize: () => void): void => {
6969
globalThis.visualViewport?.addEventListener("scroll", sendResize)
7070
}
7171

72-
const mountTerminalSession = (
73-
{ connectionRef, hostRef, notifyMessage, onAttachFailure, runtimeRef, session, setStatus }: TerminalLifecycleArgs
74-
): (() => void) | undefined => {
72+
const resolveMountHost = (
73+
{ hostRef, session }: Pick<TerminalLifecycleArgs, "hostRef" | "session">
74+
): HTMLDivElement | null => {
7575
if (isPendingActiveTerminalSession(session)) {
76-
return undefined
76+
return null
7777
}
78+
return hostRef.current
79+
}
7880

79-
const host = hostRef.current
81+
const mountTerminalSession = (
82+
{ connectionRef, hostRef, notifyMessage, onAttachFailure, runtimeRef, session, setStatus }: TerminalLifecycleArgs
83+
): (() => void) | undefined => {
84+
const host = resolveMountHost({ hostRef, session })
8085
if (host === null) {
8186
return undefined
8287
}

packages/app/src/web/terminal.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,19 @@ export const buildProjectActiveTerminalSession = (
8282
}
8383
}
8484

85+
const resolvePendingProjectMessage = (
86+
message: string | undefined,
87+
phase: PendingTerminalConnection["phase"]
88+
): string => {
89+
const trimmedMessage = message?.trim() ?? ""
90+
if (trimmedMessage.length > 0) {
91+
return trimmedMessage
92+
}
93+
return phase === "error"
94+
? "SSH session startup failed."
95+
: "Starting project and waiting for SSH..."
96+
}
97+
8598
export const buildPendingProjectActiveTerminalSession = (
8699
{
87100
createdAt,
@@ -96,11 +109,7 @@ export const buildPendingProjectActiveTerminalSession = (
96109
): ActiveTerminalSession => {
97110
const encodedProjectKey = encodeURIComponent(projectKey)
98111
const encodedSessionId = encodeURIComponent(pendingSessionId)
99-
const resolvedMessage = message?.trim().length
100-
? message.trim()
101-
: phase === "error"
102-
? "SSH session startup failed."
103-
: "Starting project and waiting for SSH..."
112+
const resolvedMessage = resolvePendingProjectMessage(message, phase)
104113
return {
105114
browserProjectId: projectId,
106115
browserProjectKey: projectKey,

packages/lib/src/usecases/projects-up.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ const runProjectComposeUp = (
177177
}
178178

179179
return runDockerComposeUp(projectDir, { buildMode: "reuse" }).pipe(
180-
Effect.catchAll(() =>
180+
Effect.catchTag("DockerCommandError", () =>
181181
Effect.logWarning(
182182
`docker compose up -d failed in ${projectDir}; falling back to docker compose up -d --build.`
183183
).pipe(

0 commit comments

Comments
 (0)