feat(terminal): refactor runtime and add mobile workspace (#2280)
Replace the legacy terminal flow with a shared authenticated WebSocket runtime used across web, desktop, relay, and mobile surfaces. - introduce the v3 terminal protocol with scoped attachments, snapshots, ordered output, bounded replay history, reconnects, and explicit lifecycle - harden PTY creation, restart, resize, close, force-kill, idle cleanup, shell selection, login mode, environment sanitization, and appearance sync - add runtime-aware terminal APIs with relay authentication and Electron parity - add a fullscreen mobile terminal workspace with touch scrolling, long-press selection, safe-area controls, quick keys, and Ctrl/Alt input - add terminal selection attachments, preview detection, project actions, shell settings, and localized UI - harden Ghostty rendering, resize recovery, Unicode handling, block characters, line height, and stale-row behavior - remove the obsolete terminal SSE path and update reverse-proxy guidance - expand terminal runtime, transport, input, selection, and store coverage - avoid duplicate web builds when preparing mobile assets in root CI builds
This commit is contained in:
committed by
GitHub
parent
f5b4a267c0
commit
d4a8c4d2e1
@@ -2,42 +2,36 @@ import {
|
||||
connectTerminalStream,
|
||||
createTerminalSession,
|
||||
resizeTerminal,
|
||||
updateTerminalAppearance,
|
||||
sendTerminalInput,
|
||||
closeTerminal,
|
||||
restartTerminalSession,
|
||||
forceKillTerminal,
|
||||
listTerminalShells,
|
||||
} from '@openchamber/ui/lib/terminalApi';
|
||||
import type {
|
||||
TerminalAPI,
|
||||
TerminalHandlers,
|
||||
TerminalStreamOptions,
|
||||
CreateTerminalOptions,
|
||||
ResizeTerminalPayload,
|
||||
TerminalSession,
|
||||
ForceKillOptions,
|
||||
} from '@openchamber/ui/lib/api/types';
|
||||
|
||||
const getRetryPolicy = (options?: TerminalStreamOptions) => {
|
||||
const retry = options?.retry;
|
||||
return {
|
||||
maxRetries: retry?.maxRetries ?? 3,
|
||||
initialRetryDelay: retry?.initialDelayMs ?? 1000,
|
||||
maxRetryDelay: retry?.maxDelayMs ?? 8000,
|
||||
connectionTimeout: options?.connectionTimeoutMs ?? 10000,
|
||||
};
|
||||
};
|
||||
|
||||
export const createWebTerminalAPI = (): TerminalAPI => ({
|
||||
async listShells() {
|
||||
return listTerminalShells();
|
||||
},
|
||||
|
||||
async createSession(options: CreateTerminalOptions): Promise<TerminalSession> {
|
||||
return createTerminalSession(options);
|
||||
},
|
||||
|
||||
connect(sessionId: string, handlers: TerminalHandlers, options?: TerminalStreamOptions) {
|
||||
connect(sessionId: string, handlers: TerminalHandlers) {
|
||||
const unsubscribe = connectTerminalStream(
|
||||
sessionId,
|
||||
handlers.onEvent,
|
||||
handlers.onError,
|
||||
getRetryPolicy(options)
|
||||
handlers.onError
|
||||
);
|
||||
|
||||
return {
|
||||
@@ -53,6 +47,10 @@ export const createWebTerminalAPI = (): TerminalAPI => ({
|
||||
await resizeTerminal(payload.sessionId, payload.cols, payload.rows);
|
||||
},
|
||||
|
||||
async updateAppearance(sessionId, appearance): Promise<void> {
|
||||
await updateTerminalAppearance(sessionId, appearance);
|
||||
},
|
||||
|
||||
async close(sessionId: string): Promise<void> {
|
||||
await closeTerminal(sessionId);
|
||||
},
|
||||
@@ -65,6 +63,11 @@ export const createWebTerminalAPI = (): TerminalAPI => ({
|
||||
cwd: options.cwd ?? '',
|
||||
cols: options.cols,
|
||||
rows: options.rows,
|
||||
themeMode: options.themeMode,
|
||||
terminalBackground: options.terminalBackground,
|
||||
terminalForeground: options.terminalForeground,
|
||||
shell: options.shell,
|
||||
loginShell: options.loginShell,
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user