Skip to content

feat: CLI polish, static client assets, config system, and test infrastructure - #15

Merged
jesse23 merged 24 commits into
mainfrom
jesse_cli
Mar 25, 2026
Merged

feat: CLI polish, static client assets, config system, and test infrastructure#15
jesse23 merged 24 commits into
mainfrom
jesse_cli

Conversation

@jesse23

@jesse23 jesse23 commented Mar 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • CLI UX polishwebtty help as canonical entry, all-caps headings, frequency-ordered commands, at/ls/rm/mv with 2-char names and full aliases (attach, list, remove, rename), stop/start server lifecycle, webtty no-arg opens main session
  • Static client assets — browser TS extracted to src/client/index.ts, compiled by Bun.build, served as /dist/client-browser.js; zero inline scripts, script-src 'self' CSP-safe; GET /api/config endpoint replaces server-side template injection
  • Config system improvementscopyOnSelect, rightClickBehavior, logs config keys; $VISUAL$EDITORvi/notepad editor resolution; isServerRunning() validates JSON array to reject non-webtty processes; stop server when last session exits or is removed
  • Test infrastructure — isolated HOME dirs for all subprocess tests (no more config file clobbering); shared test utilities in src/utils.test.ts; pty/index.test.ts with real PTY integration tests; src/server/static.test.ts covering findGhosttyWeb/serveFile; 110 tests, 100% coverage on all unit-testable files
  • ADR 012 — documents static asset build architecture and CSP rationale
  • Docs — coverage scope documented in development.md; specs and ADRs updated throughout

ADRs

  • ADR 011 — amended: CLI UX polish, command renames, at/mv, stop-on-last-rm, copy config
  • ADR 012 — new: static asset build, GET /api/config, CSP rationale

jesse23 added 22 commits March 24, 2026 13:11
…tups, enhance mime type handling, and improve temporary directory management

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes webtty’s UX and architecture by moving the browser client to CSP-safe static assets, expanding the config surface (including clipboard/logging behavior), tightening server/CLI lifecycle behavior, and improving the test harness to be more isolated and integration-focused.

Changes:

  • Extract browser client into src/client/*, build it via scripts/build.ts, and serve it as static assets; add GET /api/config for runtime client config.
  • Polish CLI command surface and help output (at/ls/rm/mv, no-arg default behavior, config/help commands), plus server lifecycle tweaks (stop when last session exits / last rm in CLI).
  • Improve test infrastructure (isolated HOME dirs, shared helpers, new unit + integration tests for static serving and PTY).

Reviewed changes

Copilot reviewed 33 out of 34 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tsconfig.json Include scripts/ in TS project for typechecking/build tooling.
src/utils.ts Remove shared MIME/static helpers (moved server-side).
src/utils.test.ts Repurpose into shared test utilities (ports, temp HOME, server wait helpers).
src/server/websocket.ts Add “last session closed” hook to enable auto-shutdown on final PTY exit.
src/server/websocket.test.ts Use shared test helpers + add test for shutdown on last session exit.
src/server/static.ts Move MIME + ghostty-web path helpers into server static module.
src/server/static.test.ts Add unit tests for findGhosttyWeb, mimeType, serveFile.
src/server/routes.ts Add GET /api/config, serve static client.html, and serve /dist/* from webtty dist first.
src/server/routes.test.ts Update expectations for static HTML shell + add /api/config test.
src/server/index.ts Wire clientDistPath into routes and install last-session-closed shutdown handler.
src/server/client.ts Remove server-side HTML rendering template.
src/server/client.test.ts Remove tests for deleted server-side client renderer.
src/pty/index.test.ts Add PTY integration tests.
src/config.ts Add copyOnSelect/rightClickBehavior/logs, and allow HOME override for config path.
src/config.test.ts Switch to HOME override (no os.homedir spying) + add tests for new config keys.
src/client/index.ts New browser TS entry: fetch config, init terminal, WS reconnect, copy behaviors.
src/client/index.html New static HTML shell referencing built JS/CSS.
src/client/index.css New extracted client CSS styles.
src/cli/index.ts Custom help formatting and no-arg default behavior.
src/cli/http.ts Harden isServerRunning + implement optional server logging to file.
src/cli/http.test.ts Add coverage for logging + refactor platform stubbing.
src/cli/commands.ts Rename/polish commands, add config/help, stop-on-last-rm behavior.
src/cli/commands.test.ts Update CLI tests for new commands, add no-arg/help/config coverage.
scripts/build.ts Build server + browser bundles, copy static HTML/CSS into dist/.
docs/specs/webtty.md Update spec text and API details (notably delete header semantics).
docs/specs/config.md Document new config keys and reload behavior.
docs/specs/client.md Document static asset architecture and /api/config endpoint.
docs/specs/cli.md Update CLI spec for new command surface and UX changes.
docs/adrs/012.client.static-assets.md New ADR documenting static client build + CSP rationale.
docs/adrs/011.cli.default-and-help.md Remove superseded ADR.
docs/adrs/011.cli.config-and-help.md New ADR for CLI polish, config/help, command changes.
docs/adrs/002.cli.start-stop.md Clarify rationale for HTTP lifecycle approach.
docs/adrs/001.webtty.bootstrap.md Add single-port and ws rationale notes.
README.md Update quickstart commands to match new CLI behavior.
Comments suppressed due to low confidence (1)

src/cli/index.ts:85

  • program.parseAsync(process.argv) is called without being awaited/returned. Since unresolved Promises don’t keep the event loop alive, the process can exit before async command actions complete (depending on timing), and any rejection becomes unhandled. Prefer top-level await program.parseAsync(process.argv) (ESM supports it) or return the promise from the entrypoint.
program.action(async () => {
  await program.parseAsync(['at', 'main'], { from: 'user' });
});

program.parseAsync(process.argv);


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cli/index.ts
Comment thread docs/specs/cli.md Outdated
Comment thread docs/specs/cli.md Outdated
Comment thread src/server/index.ts Outdated
Comment thread src/cli/http.ts Outdated
Comment thread src/cli/http.ts
Comment thread src/cli/commands.ts Outdated
jesse23 and others added 2 commits March 24, 2026 23:55
…test failure

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
- Re-enable --help by removing helpOption(false); custom formatHelp already omits Options section
- Fix cli.md: start/stop lifecycle wording, remove stale 'down' alias mention
- Export configDir() from config.ts for consistent HOME-aware path resolution
- Fix logPath() to use configDir() instead of os.homedir()
- Fix fd leak: close log fd in parent process after spawn
- Fix config cmd: use configDir(), ensure config dir/file exists before opening editor
- Improve clientDistPath derivation: use __dirname-relative path instead of ghostty-web location

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>

@jesse23 jesse23 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All 7 Copilot comments addressed in e200a52:

  • #1 helpOption(false) removed — --help works again; custom formatHelp already omits the Options section so help output is unchanged
  • #2/#3 cli.md updated: start/stop lifecycle wording, stale down alias mention removed
  • #4 clientDistPath now derived from __dirname (server entry location) — robust regardless of node_modules layout; also falls back to src/client/ when dist/ not built
  • #5 logPath() now uses exported configDir() from config.ts which respects process.env.HOME
  • #6 Log fd closed in parent process immediately after child.unref()
  • #7 webtty config uses configDir(), creates dir and empty config file if missing before opening editor

@jesse23
jesse23 merged commit 17af98c into main Mar 25, 2026
3 checks passed
@jesse23
jesse23 deleted the jesse_cli branch March 25, 2026 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants