Commit Graph

197 Commits

Author SHA1 Message Date
Yaojia Wang
524f2073a0 style: modern dark UI refresh
- design-token palette (:root vars): deeper #0e0f13 base, indigo #7c8cff accent,
  layered surfaces, softer borders, shadow + radius scale
- tabs as floating rounded chips (active = elevated surface); refined dots
- key bar as rounded chips with gaps; Esc gets the accent tint
- toolbar icon buttons with rounded hover
- overlays (history/dashboard/qr/search/settings) get backdrop-blur + card +
  shadow; indigo primary buttons; consistent inputs with accent focus ring
- chrome uses a system UI font (terminal stays monospace)
- xterm dark theme + meta theme-color + manifest + app icon synced to the
  palette (indigo-gradient icon, accent cursor)
216 tests green; tsc + build clean.
2026-06-18 09:08:02 +02:00
Yaojia Wang
e1a9439cce merge: O2 resume-past-sessions + tech-debt cleanup + cleaner terminal
- O2: /sessions reads ~/.claude/projects JSONL; 🕘 panel resumes a past session
  in a new tab (claude --resume <id>) in its project dir
- chore: *.css module decl removes the last @ts-ignore
- ui: drop in-terminal Connecting/Connected lines (tab dot shows it)
216 tests green.
2026-06-18 08:10:33 +02:00
Yaojia Wang
c5a70a2f36 docs: log O2 done + tech-debt cleared; only O1 + F4/F7(device) remain 2026-06-18 08:10:33 +02:00
Yaojia Wang
99bae333f3 chore: clear tech-debt — *.css module decl removes the @ts-ignore; tick F-table
- public/css.d.ts: declare module '*.css' so tsc resolves CSS side-effect
  imports; removed the @ts-ignore in main.ts
- PROGRESS_LOG F1-F9 table ticked to match what's actually verified (F4/F7 still
  need a physical device)
2026-06-18 08:06:03 +02:00
Yaojia Wang
e36ca272ed feat(v0.3): O2 — resume past Claude sessions
- src/http/history.ts: listSessions() reads ~/.claude/projects/*/*.jsonl
  (mtime-sorted, top 50), parseSessionMeta() extracts cwd + first user prompt
  (pure, 4 unit tests); GET /sessions
- terminal-session: opts.initialInput (typed ~700ms after the shell is ready)
- tabs.newTabForResume(cwd,id): new tab in the project dir running
  'claude --resume <id>'
- public/history.ts: 🕘 panel listing sessions (project · time · preview) with
  Resume buttons
- Verified: /sessions returns 44 real sessions; panel lists project/time/preview.
  216 tests green.
2026-06-18 08:04:04 +02:00
Yaojia Wang
25269cad3f fix(ui): drop in-terminal Connecting/Connected/reconnecting lines
The tab connection dot (green/amber/red) already shows connection state, so the
'[terminal] Connecting…/Connected' and 'Disconnected — reconnecting' lines just
cluttered the scrollback. Rely on the dot; keep only the actionable exit message.
2026-06-18 07:39:29 +02:00
Yaojia Wang
5df3f9158c merge: v0.3 cockpit — Claude Code status/approve/notify + tmux keepalive + FE polish
High value: H2/H4 hooks→live status + browser notifications; H3 remote
approve/reject (held PermissionRequest); H1 tmux keepalive (survive restart).
Medium: keybar Claude shortcuts, scrollback search, clickable links, QR connect,
PWA, themes, session dashboard, new-tab-in-cwd.
Also fixed: tab-switch flakiness; idle keep-alive sockets hanging close().
212 tests green.
2026-06-18 07:29:08 +02:00
Yaojia Wang
5b357e67df docs: mark v0.3 cockpit complete; only optional O1/O2 remain 2026-06-18 07:28:55 +02:00
Yaojia Wang
eb28a5593f docs: README + CLAUDE.md updated for v0.2/v0.3 (cockpit, tmux, hooks, toolbar) 2026-06-18 07:28:21 +02:00
Yaojia Wang
915a51e4bb docs: log v0.3 medium batch M3/M6/M7 2026-06-18 07:15:35 +02:00
Yaojia Wang
87e11734d8 feat(v0.3): M6 — new tab opens in the active tab's directory
- title-util.cwdFromOsc7: parse cwd from OSC 7 (file:// URL); 4 unit tests
- terminal-session: register OSC 7 handler → cwd getter; opts.cwd → sent in the
  attach frame on a fresh session
- protocol/types: ClientMessage attach.cwd (absolute path); validated
- session/manager/server: thread cwd → createSession spawn cwd (defaults homeDir)
- tabs: '+' (newTab) opens in the active tab's reported cwd, falls back to home
- Verified: server attach.cwd spawns there; cd /private/tmp → + → new tab pwd is
  /private/tmp. 212 tests green.
2026-06-18 07:14:52 +02:00
Yaojia Wang
f79f14b89d feat(v0.3): M3 themes/font settings + M7 session dashboard
- M3: settings.ts (⚙ panel: dark/light/solarized theme + font size A-/A+),
  persisted to localStorage; terminal-session.applyTheme; TabApp.applySettings
  applies to all + new tabs
- M7: dashboard.ts (▦ overlay listing every tab with connection dot + folder +
  Claude status; click a row to focus; live re-render while open);
  TabApp.snapshot()/focusTab()
- Browser-verified: light theme renders + persists; dashboard lists tabs and
  focuses on click. 208 tests green, typechecks + build ok.
2026-06-18 05:40:35 +02:00
Yaojia Wang
dcb1bf4845 docs: log v0.3 H1 tmux keepalive 2026-06-17 19:49:30 +02:00
Yaojia Wang
9099f73534 feat(v0.3): H1 — tmux keepalive (sessions survive a server restart)
- src/session/tmux.ts: sync tmux CLI wrappers (available/has/kill), best-effort
- config: useTmux from USE_TMUX env (1/0/auto→detect tmux on PATH)
- session: when useTmux, spawn 'tmux new-session -A -s web_<id> <shell>' (the
  node-pty proc is a tmux CLIENT); createSession takes an optional id for
  re-attach; Session.tmuxName; kill() runs tmux kill-session
- manager: handleAttach re-attaches to a surviving 'web_<id>' tmux session after
  a restart (Case 3.5); shutdown kills only the client pty for tmux sessions so
  the shell keeps running
- tests: USE_TMUX:0 in shared integration cfg (no tmux leakage); unit CFGs
  useTmux:false; integration 'H1' (real tmux): set var → restart server →
  re-attach → var survived. 208 tests green.
2026-06-17 19:48:39 +02:00
Yaojia Wang
af2a0879e3 docs: log v0.3 H3 remote approve/reject 2026-06-17 19:13:38 +02:00
Yaojia Wang
9a6150c355 feat(v0.3): H3 — remote approve/reject (no typing)
- types/protocol: ClientMessage approve/reject; ServerMessage status.pending
- server: POST /hook/permission HELD until the client decides; approve/reject
  ws messages resolve it with {hookSpecificOutput.decision.behavior allow|deny};
  5-min timeout + release-on-disconnect fall back to Claude's own prompt
- manager.handleHookEvent threads pending flag
- setup-hooks: PermissionRequest uses the held curl (writes decision to stdout);
  status events stay fire-and-forget
- FE: terminal-session approve()/reject() + pending state; tabs approval banner
  (Approve/Reject) for the active tab's held request
- Tests: protocol approve/reject; integration ⑧ held→approve→allow. 207 green.
- Browser-verified: banner 'Claude wants to use Bash' → Approve → resolves allow.
2026-06-17 19:13:07 +02:00
Yaojia Wang
04355f05e9 docs: log v0.3 H2/H4 Claude status feature 2026-06-17 19:01:10 +02:00
Yaojia Wang
c81cebdc47 feat(v0.3): H4 — live Claude status badge + notifications + setup-hooks
- terminal-session: handle 'status' frame → claudeStatus + onClaudeStatus
- tabs: per-tab Claude glyph (⚙ working /  waiting / ✓ idle); inactive
  'waiting' tab gets an amber highlight + a browser notification (permission
  requested on first tab switch)
- scripts/setup-hooks.mjs + 'npm run setup-hooks': idempotently install/remove
  command hooks in ~/.claude/settings.json (inline curl to $WEBTERM_HOOK_URL with
  $WEBTERM_SESSION; no-op outside web-terminal); backs up settings.json
- Browser-verified end-to-end: PermissionRequest→, PreToolUse→⚙, Stop→✓;
  inactive waiting tab shows amber + glyph. 205 tests green.
2026-06-17 19:00:34 +02:00
Yaojia Wang
a411c89ee9 feat(v0.3): H2 server — Claude Code hooks → live status side-channel
- types: ClaudeStatus + ServerMessage 'status'; Session.claudeStatus;
  SessionManager.handleHookEvent
- session: inject WEBTERM_SESSION + WEBTERM_HOOK_URL into the spawned shell env
  so hooks know which tab they belong to
- http/hook.ts: pure event→status mapper (PreToolUse→working, PermissionRequest/
  Notification:permission_prompt→waiting, Stop/idle_prompt→idle); 6 unit tests
- server: POST /hook (loopback-only, express.json 64kb) → manager pushes 'status'
- fix: closeIdleConnections() on shutdown so an idle hook keep-alive socket
  doesn't hang close()/SIGTERM
- integration ⑦ (real PTY): attach → POST /hook → ws receives status. 205 tests green.
2026-06-17 18:44:07 +02:00
Yaojia Wang
8c2a6825cc docs: log v0.3 step 1 (FE quick wins) 2026-06-17 18:33:31 +02:00
Yaojia Wang
fbc218c57f feat(v0.3): QR connect (M5) + PWA installable (M4)
- M5: 📱 toolbar button → modal with a client-side QR of location.origin
  (shareable when opened via the LAN IP) + localhost tip
- M4: manifest.webmanifest + icon.svg + sw.js (network-first, never intercepts
  /term or /hook) + registration in main.ts; apple-touch + theme-color meta
- Browser-verified: QR canvas renders, SW 'controlled', manifest linked,
  no console errors. 199 tests green, build ok.
2026-06-17 18:32:57 +02:00
Yaojia Wang
eaeacf3a78 feat(v0.3): keybar Claude shortcuts + scrollback search + clickable links
- keybar: add Esc·Esc / ^O / ^T / ^B + per-button tooltips (KEY_MAP 14 keys)
- M1 search: @xterm/addon-search per terminal; 🔍 toolbar button + search box
  (Enter=next, Shift+Enter=prev, Esc=close)
- M2 links: @xterm/addon-web-links per terminal (tap URLs Claude prints)
- tab bar split into #tabs (scrollable) + #toolbar (utility cluster) for future
  utilities (QR/settings/dashboard)
- Browser-verified: 14 keybar buttons, search highlights matches, no console errors.
  199 tests green, typechecks + build ok.
2026-06-17 18:28:40 +02:00
Yaojia Wang
110c1752d4 docs: log tab-switching fix 2026-06-17 15:46:17 +02:00
Yaojia Wang
e058751962 fix(v0.2): tab switching needed multiple clicks
Root cause: whole tab was draggable=true, so a click with any micro-movement
became a (no-op) drag instead of a click → switch failed. Plus every event
(activity/title/status) rebuilt the entire tab bar via replaceChildren, which
could destroy the element mid-click.

Fix:
- switch on pointerdown (fires before drag arms; also works on touch)
- build tab DOM once; update classes/dot/label IN PLACE (refreshTab); full
  rebuild only on structural change (add/close/reorder/rename)
- close/rename-input stopPropagation on pointerdown so they don't re-activate

Verified: single pointerdown/click switches reliably across tabs; rename + drag
still work. 198 tests green.
2026-06-17 15:45:18 +02:00
Yaojia Wang
bf21ac0ab7 docs: log folder-name tab titles 2026-06-17 15:38:09 +02:00
Yaojia Wang
4091283773 feat(v0.2): tab title = current folder (from OSC title)
- title-util.ts: folderFromTitle() parses 'user@host:~/path' → last folder
  segment (home stays ~); pure, dependency-free, 7 unit tests
- terminal-session.ts: onTitleChange → folderFromTitle so the tab auto-names
  to the cwd folder and updates live on cd
- Browser-verified: ~ → cd project → 'web-terminal' → cd docs → 'docs' → cd ~ → '~'.
  198 tests green, typecheck + build ok.
2026-06-17 15:27:01 +02:00
Yaojia Wang
459a27eda8 docs: log status dot + activity + drag-reorder 2026-06-17 14:55:48 +02:00
Yaojia Wang
b5f21e5fdd feat(v0.2): tab status dot, activity (unread) indicator, drag-reorder
- terminal-session.ts: track SessionStatus (connecting/connected/reconnecting/
  exited) + onStatus callback; FIX: wire onTitleChange (onTitle was in opts but
  never bound — auto-title was dead)
- tabs.ts: per-tab status dot (color = connection state), unread flag set on
  background output + cleared on activate, HTML5 drag-to-reorder (preserves
  active tab, persisted)
- style.css: .tab-dot colors, .unread ring, .dragging/.drag-over feedback
- Browser-verified: green dot connected, unread ring after bg output, reorder
  AAA|BBB→BBB|AAA persists across reload. 191 tests green, typechecks + build ok.
2026-06-17 14:55:19 +02:00
Yaojia Wang
064330f8d9 docs: log v0.2 multi-tab + titles + keybar feature 2026-06-17 12:13:17 +02:00
Yaojia Wang
4f66016f02 feat(v0.2): multi-tab terminal + titles + Claude Code shortcut bar
Frontend feature (backend unchanged — manager was already multi-session):
- Multi-tab: each tab = independent WS + Terminal + session (terminal-session.ts,
  tabs.ts); tab bar with +, ×, middle-click close; persisted to localStorage
  (migrates v0.1 single-session key)
- Tab titles: auto from xterm onTitleChange (OSC 0/2), double-click to rename
  inline (manual wins over auto); ellipsis + tooltip
- Shortcut key bar now shown on ALL devices (clickable buttons trigger shortcuts),
  reordered for Claude Code (Esc prominent, ⇧Tab, ↑↓, ⏎, ^C, Tab, ←→, /);
  responsive sizing via @media (pointer:coarse) for touch
- Verified in browser: rename, two independent sessions, keybar on desktop +
  narrow viewport. 191 tests green; both typechecks + esbuild build pass.
2026-06-17 12:11:18 +02:00
Yaojia Wang
f3b6ad5a68 docs: W5 acceptance — browser smoke (F1/F2/F3/F8) + log v0.1 status
7/9 acceptance criteria auto-verified: F1/F2/F3/F8 via headless browser
(xterm renders, echo round-trips, exit prompt, resize survives), F5/F6/F9 via
integration tests. F4 (LAN) + F7 (phone keybar) need physical devices -> user.
gitignore .gstack/.
2026-06-17 11:18:13 +02:00
Yaojia Wang
81585ad35f docs: T21 README (install/run/config/security) + security self-review
- No hardcoded secrets; Origin+path+maxPayload checks verified wired in server.ts
- No eval/exec; input is verbatim to PTY by design (byte-shuttle)
- npm run build -> dist/server.js verified
2026-06-17 11:02:16 +02:00
Yaojia Wang
86c7e3de02 docs: log W2-W4 (T12-T15 done, 187 tests, real-PTY E2E verified) 2026-06-17 10:37:01 +02:00
Yaojia Wang
cdec19a256 test: T15 integration/E2E (real WS, M2/M4/L3/L5, F5/F6)
6 cases against real startServer via ws client:
①bad-origin 401 ②wrong-path destroy ③oversized-frame 1009 ④spawn-fail exit(-1)
— all pass in sandbox; ⑤attach->output ⑥reconnect-replay gated by PTY_AVAILABLE
(auto-skip where posix_spawn is blocked). Orchestrator verified ⑤⑥ sandbox-off:
6/6 pass with real shell — F5/F6 confirmed (replay incl CJK/ANSI intact).
2026-06-17 10:16:14 +02:00
Yaojia Wang
0dac54b4f4 feat: T14 server.ts — wiring (noServer/handleUpgrade, M4/M5/L3/L5)
Express static (public/+build/); WebSocketServer noServer + maxPayload (L5);
upgrade gate: path!=wsPath->destroy, bad origin->401, else handleUpgrade (L3);
connection waits attach, handleAttach in try/catch -> exit(-1)+close on spawn
fail (M4); message routes input/resize; close->detach (never kill); SIGINT/TERM
->shutdown; reapIdle timer; safeSend guards readyState (M5). tsc clean.
2026-06-16 20:09:33 +02:00
Yaojia Wang
a2897b2e12 feat: T13 session/manager.ts — session table (M3/L1/L2)
handleAttach 4 paths (new/alive/exited-L1/not-found); reapIdle uses
now-max(detachedAt,lastOutputAt)>idleTtl (M3); shutdown kills all; injected
onExit removes from table when attached, keeps for L1 replay when detached (L2);
createSession errors propagate (M4). 21 tests; full suite 181 green.
2026-06-16 18:58:14 +02:00
Yaojia Wang
20212dd7f6 feat: T12 session/session.ts — PTY lifecycle (M4/M5/L1/L4)
createSession/attachWs/detachWs/writeInput/resize/kill; node-pty spawn (throws
on failure/M4), onData->buffer+forward, onExit->exitedAt+exit+injected onExit;
sendIfOpen guards readyState (M5); detach never kills PTY; write/resize no-op
after exit (L4); detach-then-exit keeps session (L1).
Tests vi.mock node-pty -> mock IPty (no real spawn): 19 tests. Full suite green.
2026-06-16 18:54:15 +02:00
Yaojia Wang
c27aaa1ac2 docs: log W1 frontend batch (T8-T11 done, 141 tests) 2026-06-16 18:49:01 +02:00
Yaojia Wang
326d3472dd feat: W1 frontend — index.html, style.css, keybar, main.ts (esbuild entry)
- T8 public/index.html      — #term/#keybar, loads ./build/main.js (type=module)
- T9 public/style.css       — fullscreen term, keybar fixed bottom, hidden >768px
- T10 public/keybar.ts      — key→byte map + mountKeybar (13 tests)
- T11 public/main.ts        — xterm+fit, WS client (wss on https/M6), reconnect
                              backoff, resize debounce, mountKeybar wiring

Verified by orchestrator: backend+frontend tsc clean; full suite 141 tests;
npm run build:web bundles main.ts -> public/build/main.js (430kb).
Note: main.ts uses one @ts-ignore for the CSS import (minor; future: *.css d.ts).
2026-06-16 18:36:32 +02:00
Yaojia Wang
de8c366ab2 docs: log W1 backend batch (T3-T7 done, 128 tests) 2026-06-16 08:10:38 +02:00
Yaojia Wang
0fa0b69ce9 feat: W1 batch — config, protocol, ring-buffer, origin, mock-pty (TDD)
Parallel module-builder subagents, disjoint file ownership, shared tree:
- T4 src/config.ts        — loadConfig+M1 origins (32 tests)
- T5 src/protocol.ts      — parse/serialize+SESSION_ID_RE+M7 (60 tests)
- T6 src/session/ring-buffer.ts — byte-accurate, no UTF-8/ANSI split+M2 (15 tests)
- T7 src/http/origin.ts   — host+port match, undefined rejected (12 tests)
- T3 test/helpers/mock-pty.ts — IPty double w/ emitData/emitExit (9 tests)

Verified by orchestrator: tsc --noEmit clean; full suite 128 tests pass.
2026-06-16 08:09:40 +02:00
Yaojia Wang
0e10dc21c3 feat: T2 freeze src/types.ts (shared contracts)
- All ARCHITECTURE §3 interfaces as pure types; dependency-free (no ws/node/DOM)
  so both backend and frontend can import it
- Refinements vs §3 (documented): EnvLike (not NodeJS.ProcessEnv), WebSocketLike +
  WS_OPEN (not ws.WebSocket), added Config.wsPath (invariant 8)
- ARCHITECTURE §3.1/§3.4 reconciled to match (anti-drift)
- tsc --noEmit passes

T2 of docs/PLAN.md
2026-06-16 07:58:52 +02:00
Yaojia Wang
409b208928 build: adopt esbuild for frontend bundling (build:web → public/build/)
- esbuild dev dep; build:web/dev:web bundle public/main.ts → public/build/main.js
- gitignore public/build/; tsconfig.web.json now typecheck-only
- frontend build convention documented in PLAN §1, DISPATCH, ARCHITECTURE §5
- resolves the T1 deferred decision
2026-06-16 07:36:01 +02:00
Yaojia Wang
987cab8eb7 docs: log T1 done; flag frontend-bundling decision for T11/T14 2026-06-16 07:22:33 +02:00
Yaojia Wang
b126cf0e42 feat: T1 scaffold — package.json, tsconfig (backend+web), vitest, dirs
- All deps declared once (express5, ws, node-pty, @xterm/xterm6, addon-fit;
  dev: typescript6, tsx, vitest4, @types/node|ws|express)
- postinstall chmod +x node-pty spawn-helper (prebuild ships it non-exec → posix_spawnp fails)
- node-pty verified: require + real PTY spawn (exitCode 0)
- npm test passes with no tests (passWithNoTests)
- tsconfig.web.json type-checks frontend; browser bundling strategy still TBD (see log)

T1 of docs/PLAN.md
2026-06-16 07:21:42 +02:00
Yaojia Wang
91d0a7189f docs: add subagent dispatch kit (per-task prompts + templates) 2026-06-16 07:08:54 +02:00
Yaojia Wang
dda09ef2c6 docs: web-terminal v0.1 spec, plan, and multi-agent dev config
- TECH_DOC + ARCHITECTURE (cross-validated, 12 fixes M1-M7/L1-L5)
- PLAN: waves W0-W5, tasks T1-T21 for multi-agent parallel dev
- PROGRESS_LOG: orchestrator-owned cross-session memory
- CLAUDE.md: required-reading + orchestrator-worker workflow
- .claude/agents: module-builder, module-reviewer
2026-06-16 06:54:57 +02:00