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
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { appendTerminalContexts, extractTerminalContexts, normalizeTerminalContext, terminalContextKey } from './terminalContext';
|
||||
|
||||
const context = {
|
||||
terminalId: 'term-1', terminalLabel: 'Terminal 1', startLine: 12, endLine: 13, text: 'one\r\ntwo',
|
||||
};
|
||||
|
||||
describe('terminal context serialization', () => {
|
||||
test('normalizes immutable selection snapshots and line ranges', () => {
|
||||
expect(normalizeTerminalContext(context)).toEqual({ ...context, text: 'one\ntwo' });
|
||||
expect(normalizeTerminalContext({ ...context, text: '\n\n' })).toBeNull();
|
||||
expect(normalizeTerminalContext({ ...context, startLine: -2, endLine: 0 })?.startLine).toBe(1);
|
||||
});
|
||||
|
||||
test('serializes multiple contexts without exposing the block in visible text', () => {
|
||||
const serialized = appendTerminalContexts('fix this', [context, { ...context, terminalId: 'term-2', terminalLabel: 'Build', startLine: 2, endLine: 2, text: 'failed' }]);
|
||||
const parsed = extractTerminalContexts(serialized);
|
||||
expect(parsed.visibleText).toBe('fix this');
|
||||
expect(parsed.contexts).toEqual([
|
||||
{ terminalLabel: 'Terminal 1', startLine: 12, endLine: 13, text: 'one\ntwo' },
|
||||
{ terminalLabel: 'Build', startLine: 2, endLine: 2, text: 'failed' },
|
||||
]);
|
||||
});
|
||||
|
||||
test('ignores expired contexts and provides deterministic deduplication keys', () => {
|
||||
expect(appendTerminalContexts('hello', [{ ...context, text: '' }])).toBe('hello');
|
||||
expect(terminalContextKey(context)).toBe(terminalContextKey({ ...context }));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user