Files
archived-orca/mobile/src/tasks/workspace-ssh-gate.ts
OrcaWinandOrcaWin a99bc36593 feat(mobile): localize tasks, new workspaces and source control (#35646)
* feat(mobile): localize tasks, new workspaces and source control

Moves the last ~670 strings (task lists and boards, issue and PR sources, the
new-workspace flow, and source control) to the translation API, with all ten
translations. What remains in the coverage baseline is reviewed non-copy: key
names, schema errors and log lines.

- Source control section titles recompute on a language change

* fix(mobile): align catalog terminology across screens

A whole-catalog pass per language reconciled terms that differed between batches
(host/desktop, dictation, transcripts, address form) with the glossaries and the
desktop catalogs. The page bundle verifier now reports catalog bytes separately.

* fix(mobile): keep fetched history and source error slugs language-independent

History rows are derived from the fetched page at render so relative times follow a
language switch; quality-gate follow-ups for the tasks and source control migration.

* fix(mobile): name Android notification channels in the UI language

* chore(mobile): drop catalog entries for removed source-control copy

* fix(mobile): re-localize the composer source hook on current main

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-10-28 21:11:04 -07:00

76 lines
2.8 KiB
TypeScript

import type { SshConnectionState, SshConnectionStatus } from '../../../src/shared/ssh-types'
import { ORCAD_RECLAIM_STALE_LOCK_FLAG } from '../../../src/shared/orcad-stale-lock-reclaim'
import { translate } from '../i18n/mobile-i18n'
// Keep unread SSH fields optional so an omitted member cannot drop auth-failed state into connected fallback.
export type WorkspaceSshRecord = Omit<
SshConnectionState,
'error' | 'reconnectAttempt' | 'managedServer'
> & {
error?: string | null
reconnectAttempt?: number
managedServer?: { kind?: string; serving?: { state?: string; detail?: string } }
}
export type WorkspaceSshGate = {
status: SshConnectionStatus | null
requiresConnection: boolean
connectInProgress: boolean
error: string | null
needsDesktopServerRecovery: boolean
}
function isWorkspaceSshConnectInProgress(status: SshConnectionStatus | null): boolean {
return status === 'connecting' || status === 'deploying-relay' || status === 'reconnecting'
}
export function workspaceSshStatusLabel(status: SshConnectionStatus | null): string {
if (status === 'connected') {
return translate('tasks.workspaceSshGate.connected', 'Connected')
}
if (status === 'connecting') {
return translate('tasks.workspaceSshGate.connecting', 'Connecting')
}
if (status === 'deploying-relay') {
return translate('tasks.workspaceSshGate.deployingRelay', 'Deploying relay')
}
if (status === 'reconnecting') {
return translate('tasks.workspaceSshGate.reconnecting', 'Reconnecting')
}
if (status === 'auth-failed') {
return translate('tasks.workspaceSshGate.authenticationFailed', 'Authentication failed')
}
if (status === 'reconnection-failed') {
return translate('tasks.workspaceSshGate.reconnectFailed', 'Reconnect failed')
}
if (status === 'error') {
return translate('tasks.workspaceSshGate.connectionFailed', 'Connection failed')
}
return translate('tasks.workspaceSshGate.disconnected', 'Disconnected')
}
export function deriveWorkspaceSshGate(args: {
connectionId: string | null
state: WorkspaceSshRecord | null
connecting: boolean
}): WorkspaceSshGate {
const matchingState =
args.connectionId && args.state?.targetId === args.connectionId ? args.state : null
const status = matchingState?.status ?? null
return {
status,
requiresConnection: args.connectionId !== null && status !== 'connected',
connectInProgress: args.connecting || isWorkspaceSshConnectInProgress(status),
error: matchingState?.error ?? null,
needsDesktopServerRecovery: needsDesktopServerRecovery(matchingState?.managedServer)
}
}
function needsDesktopServerRecovery(server: WorkspaceSshRecord['managedServer']): boolean {
return (
server?.kind === 'managed' &&
server.serving?.state === 'unverifiable' &&
Boolean(server.serving.detail?.includes(ORCAD_RECLAIM_STALE_LOCK_FLAG))
)
}