Commit Graph
27 Commits
Author SHA1 Message Date
Dr. ZedandBohdan Triapitsyn 636dcd5314 fix: improve Windows managed OpenCode shutdown and launch behavior (#844)
* fix: windows shutdown and restart orphaned cleanup

* fix: launch managed OpenCode directly on Windows
Unwrap OpenCode wrappers to launch directly on Windows, improving shutdown reliability and avoid orphans.

* fix: restore desktopNotifyEnabled in health snapshot

---------

Signed-off-by: Dr. Zed <142888684+DocterZed@users.noreply.github.com>
Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
2026-04-11 22:29:09 +03:00
Bohdan Triapitsyn aef7b206ed fix: respect host when checking port availability 2026-04-02 14:11:32 +03:00
Colin Mollenhour 8dfe833faf feat(cli): add --foreground flag for systemd and process manager deployments (#695)
* feat(cli): add --foreground flag for systemd and process manager deployments

Adds --foreground / --no-daemon to `openchamber serve` which runs the
server inline in the CLI process instead of spawning a detached daemon child.
Required for systemd Type=simple (and other process managers) that track the
direct child — the always-daemon behavior introduced in #640 broke this use case.

Also documents OPENCHAMBER_HOST (bind address) in --help, which was
implemented but never exposed to users.

* docs: add systemd service guide for VPN/LAN deployments

Documents how to run OpenCode and OpenChamber as separate systemd
user services for persistent access over Tailscale or LAN, using
the new --foreground flag and OPENCODE_HOST to wire them together.

* fix(cli): address foreground mode parity issues from PR review

- Fix Ctrl+C handling: CLI SIGINT handler now defers to server in
  foreground mode; dedicated signal handlers perform graceful shutdown
  and clean exit
- Restore lifecycle parity: foreground instances write PID/instance
  files so status, stop, and restart can discover them
- Add deterministic --foreground --json output: emits stable startup
  JSON with port, pid, url, and foreground flag before blocking

* fix(cli): tighten inline foreground behavior for restart UX and JSON-only output

* fix(cli): pass --host to foreground server, reject --json, add --quiet output

- Pass options.host through to startWebUiServer() in foreground mode so
  the bind address is respected (fixes localhost-only regression from #750)
- Reject --foreground --json with a clear usage error; --json is only
  supported in background (daemon) mode
- Emit resolved port on stdout in --quiet foreground mode, matching
  daemon parity
- Update systemd docs to include --host 0.0.0.0 for LAN/VPN access
  now that the default bind is 127.0.0.1

* fix(cli): remove duplicate OPENCHAMBER_HOST entry from help text

* fix(cli): emit restart summary before foreground serve() blocks

restart --json (and --quiet / human) with a foreground instance would
hang forever without output because serve() blocks and the post-loop
summary was unreachable.  Emit the final output after stop succeeds
but before the blocking serve call — foreground is always sorted last
so all daemon results are already collected.

* fix(cli): restart stops foreground instances without re-attaching

Foreground instances are managed by a process manager (systemd, Docker,
etc.) that will restart them automatically.  The restart command now
just stops the foreground instance, records the result, and exits —
no serve() call, no blocking.  This makes restart --json and all
other output modes work correctly for foreground instances.
2026-03-24 00:36:28 +02:00
yslee ea6d4c4d43 feat(server): support configurable hostname for managed OpenCode server spawn (#599)
* feat(server): support configurable hostname for managed OpenCode server spawn

Allow the managed OpenCode server bind hostname to be configured via
OPENCHAMBER_OPENCODE_HOSTNAME environment variable (default: 127.0.0.1).

This enables LAN/Tailscale access without a reverse proxy by setting
the hostname to 0.0.0.0.

Closes #597

* fix: address review feedback — input validation, port probe hostname, security docs

- Add defensive parsing for OPENCHAMBER_OPENCODE_HOSTNAME with trim/empty
  check and warning log, matching OPENCODE_HOST validation pattern
- Pass configured hostname to resolveManagedOpenCodePort() so port
  availability is probed on the actual bind address, avoiding EADDRINUSE
- Add security note in README docs warning about 0.0.0.0 exposure on
  untrusted networks
2026-03-23 15:48:04 +02:00
Iuliia Ivashko dc100ed0da fix: bind web server to 127.0.0.1 by default and add --host CLI flag (#750)
## Summary

Fixes #736 — OpenChamber listens on `0.0.0.0` (all interfaces) by default, exposing the server to the network without warning. The log output shows `visit: http://127.0.0.1:...` which is misleading.

## Changes

- **Default bind address changed to `127.0.0.1`** — server is only accessible locally unless explicitly configured otherwise
- **New `--host` CLI flag** — `openchamber --host 0.0.0.0 -p 8080` to listen on all interfaces
- **`OPENCHAMBER_HOST` env var** — documented in help text and docker-compose.yml as an alternative to `--host`
- **Docker entrypoint** defaults to `OPENCHAMBER_HOST=0.0.0.0` so container port mapping continues to work
- **Startup logs** show the actual bind address instead of hardcoded `localhost`

### Resolution priority

```
--host flag  >  OPENCHAMBER_HOST env var  >  127.0.0.1 (default)
```

### What doesn't break

- **Desktop app** — already forces `OPENCHAMBER_HOST=127.0.0.1` via Tauri
- **VS Code extension** — doesn't use the web server
- **Docker** — entrypoint sets `OPENCHAMBER_HOST=0.0.0.0`, preserving current behavior
- **Tunnels** — cloudflared connects to `127.0.0.1` origin internally, works regardless of bind address

## Testing

Automated:
- `bun run type-check` / `bun run lint` — pass

Manual (CLI, direct `node` execution):
- Default bind → `127.0.0.1` (verified via `lsof`/netstat)
- `--host 0.0.0.0` → binds all interfaces
- `--host=0.0.0.0` (inline) → works
- `--host` without value → error exit 2
- `OPENCHAMBER_HOST` env var → respected
- `--host` flag overrides env var
- IPv6 `::1` → correct bracketed URL, health check 200
- CLI daemon start/stop → works
- `visit:` URL → correct
- Help text → `--host` in OPTIONS, `OPENCHAMBER_HOST` in ENVIRONMENT
- Browser UI → loads and works
- Tunnel via UI → works
- Desktop app → no regression

Docker (tested on Ubuntu with native Docker):
- SSH key generated successfully
- `OpenChamber server listening on 0.0.0.0:3000`
- Health check 200
- `uid=1000(openchamber)` confirmed
2026-03-23 15:07:16 +02:00
Bohdan Triapitsyn 3123de5f43 fix: improve Windows UX and stabilize chat/session behavior across runtimes (#693)
* fix: preserve unsent prompt when adding editor context in VS Code

* fix: append Add to chat selections as markdown blocks with stable spacing

Convert selected assistant content to markdown before appending
Wrap each Add to chat selection in an `md` fenced block
Preserve multiline composer formatting across repeated appends

* fix: normalize persisted Windows paths to prevent identity mismatches

* fix: hide Windows subprocess console popups across server tasks

Hide OpenCode startup and shell command child windows in the web server
Apply windowsHide to cloudflared and skills-catalog git subprocesses
Cover remaining git service exec paths that could surface console windows

* fix: restore chat auto re-pin when reaching bottom

Re-pin now triggers when scrolling back into the bottom zone, not only via the button.
Upward user scroll intent still unpins immediately and is not overridden by re-pin.
Unified bottom/re-pin threshold logic to reduce sensitivity mismatches.

* fix: restore chat scroll release on mobile during streaming

Restores pinned-scroll release on touch scroll up so mobile users can leave auto-follow while streaming.
Improves re-pin behavior near bottom to avoid sticky or inconsistent pin states.
Includes related chat UI and dependency updates in the same change set.

* fix: hide daemon startup probe consoles on Windows

* fix: prevent pinned scroll tug-of-war during streaming

* fix: prefer git.exe to avoid Windows diff popup flashes

* fix: prefer git.exe discovery in Windows git flows

* fix: avoid where probes in Windows git resolution

* fix: avoid update-check subprocess flashes on Windows

* fix: normalize read file path labels

* feat: add OpenChamber defaults and improve theme ports

Add new OpenChamber light and dark themes
Regenerate imported themes with stronger surface mapping
Set OpenChamber themes as the default top options

* fix: stabilize chat pin and unpin behavior during streaming

Restores reliable unpin on upward wheel and touch gestures while auto-follow is active.
Prevents immediate re-pin while the user is actively scrolling upward near the bottom.
Keeps smooth follow-to-bottom behavior while reducing scroll tug-of-war.

* fix: suppress Windows command popups in VSCode runtime processes

Hide spawned git and server process windows in VS Code runtime
Extend hidden-window handling to server port cleanup and reveal commands
Keep behavior unchanged on non-Windows platforms
2026-03-17 13:18:54 +02:00
Bohdan Triapitsyn d160263f4f fix(cli): restore openchamber startup under npm/bun global shims 2026-03-13 11:33:23 +02:00
Sergio 875491c438 fix(web): hide daemon/git console windows on Windows (#653) 2026-03-13 11:13:36 +02:00
shekohex 9fb7c90dbd fix(cli): detect symlinked entrypoints (#652) 2026-03-13 09:49:25 +02:00
Iuliia Ivashko 63f1698cdd Epic: grand tunnel restructuring and CLI UX (#640)
* feat: restructure tunnel handling around provider-based service model" -m "Introduce tunnel service/registry/provider architecture and move Cloudflare handling behind provider adapter." -m "Add canonical tunnel modes (quick, managed-remote, managed-local) with legacy named/try-cf-tunnel compatibility mapping." -m "Add managed-local config-path support, normalized API response fields, tunnel-focused tests, and shell aliases for tunnel test workflows.

* feat(tunnels): harden managed startup and decouple runtime APIs

Improve managed Cloudflare startup reliability with explicit config validation, YAML diagnostics, and readiness detection based on process output instead of fixed delay assumptions.

Refactor server tunnel lifecycle around provider-aware runtime state and API responses while keeping legacy Cloudflare token endpoint compatibility, and add coverage for unsupported mode validation plus managed-local startup cases.

* feat: remove named tunnel mode and standardize managed modes

Replace named tunnel terminology with managed-remote and managed-local across API, server state, and UI settings without legacy aliases.

Add provider capability discovery endpoint and descriptor-based mode validation, including explicit mode_unsupported errors for removed mode values.

* feat(tunnels): finalize provider-aware tunnel UX and managed-local safety

Restructure tunnel settings with provider selection, mode chips, persisted managed-local config path, and clearer session badges while preserving existing tunnel flows.

Add legacy named-data migration, provider discovery CLI, and user-friendly managed-local config validation/error messaging with updated API/CLI/server tests.

* Add provider icon to tunnel settings

* Add control+C to stop tunnel

* feat(cli): add tunnel lifecycle profiles and preserve preset naming

Replace legacy tunnel flags with explicit tunnel lifecycle commands, daemon-by-default startup, and file-backed log tailing so tunnel operations are predictable and provider-agnostic.

Add managed-remote profile storage/migration for start-by-name workflows and propagate preset summaries to settings so user-defined profile names are preserved instead of falling back to Default.

* feat: improve tunnel CLI safety and startup UX

Add interactive TTL support and per-start TTL overrides for tunnel start
Strengthen port safety and instance validation with clearer startup and error guidance
Refine tunnel doctor and CLI output formatting for clearer, less noisy diagnostics

* feat: add TTL support, safety gates, and polished tunnel CLI output

* fix: harden tunnel doctor checks and CLI port handling

* fix: improve tunnel CLI diagnostics and profile output

* fix: streamline tunnel profile UX and doctor diagnostics

* fix: clarify tunnel replacement behavior across CLI and UI

* Upd docs

* docs: add mandatory clack CLI skill guidance. cleanup

* fix: standardize tunnel CLI mode parity and prompt UX

* fix: align CLI quiet and JSON output behavior

* feat/web-serve: in-progress animation

* fix: tunnel doctor managed remote validation

* Fix: security tightening

* fix: instance restart ux

* fix: tighten tunnel doctor input handling and CLI port/prompt validation

* chore: remove tunnel test suites per owner request

---------

Signed-off-by: Iuliia Ivashko <yulia.ivashko@gmail.com>
2026-03-12 19:40:22 +02:00
plfavreau 0b3d0378d4 fix(cli): surface tunnel bootstrap connect URL for --try-cf-tunnel (#561)
The CLI tunnel startup generated a bootstrap token but discarded it,
then built a URL with ?token=<uiPassword> which the tunnel auth system
ignores. Remote users always saw 'Tunnel access required' with no way
to authenticate.

Capture the bootstrap token, build the /connect?t=... URL, and pass it
through onTunnelReady so the CLI prints the correct one-time connect
link (and QR code).
2026-03-04 14:54:29 +02:00
Bohdan Triapitsyn 8bfbed0e68 fix: harden self-update flow and improve chat message readability (#562)
* fix: resolve Windows CLI module loading on absolute paths

* fix: improve chat tool rows layout and timestamp readability

* fix: make web update restart more reliable

* fix: make web self-update detect package manager correctly
2026-03-01 01:21:01 +02:00
plfavreau 7b5fd9e70c fix(cli): use pathToFileURL for dynamic imports on Windows (#560)
Node's ESM loader rejects bare Windows paths (e.g. C:\...) passed to
dynamic import(), interpreting the drive letter as a URL protocol.
Convert the package-manager.js path through pathToFileURL() to produce
a valid file:// URL, matching the fix already applied to the server
import on line 628.
2026-03-01 01:15:34 +02:00
Bohdan Triapitsyn 6eb5d1afa9 Fix Windows path/spawn regressions and session visibility (#552)
* Update OpenCode CLI detection

* fix(windows): handle cli file-url import and cmd shim spawn

Fixes #533 and #521.

* fix(windows): stabilize api path rewrite and session merge

Fixes #548.
2026-02-28 16:00:10 +02:00
Colin MollenhourandCopilot e02002bc9f feat(server): add OPENCODE_HOST env var for external OpenCode connections (#499)
* feat(server): add OPENCODE_HOST env var for external OpenCode connections

Allows specifying a full base URL (e.g. https://hostname:4096) for external
OpenCode connections, supporting custom hostnames and HTTPS. When set,
OPENCODE_HOST overrides OPENCODE_PORT. Malformed values are fatal at startup.

* docs: document OPENCODE_HOST env var in README and AGENTS

* Fatal error when OPENCODE_HOST has path, search or hash

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Colin Mollenhour <colin@mollenhour.com>

* fix(server): use external origin when re-probing OpenCode

---------

Signed-off-by: Colin Mollenhour <colin@mollenhour.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-25 19:42:32 +02:00
Iuliia Ivashko 138772e66e fix(managed-runtime): secure auth and lifecycle control across runtimes (#437)
* feat: add OpenCode server authentication with auto-generated passwords

* fix(auth): separate user env and managed OpenCode password state

* fix(auth): enforce env precedence and managed password rotation across runtimes

* fix(vscode): rotate managed auth on startup and harden webview proxy

* build: add dev icons and config for Tauri desktop development

* fix(runtime): start managed OpenCode via CLI and expose active API port

* fix(managed-runtime): control OpenCode lifecycle and surface secure diagnostics

* docs: remove VS Code plugin test runbook
2026-02-17 18:01:57 +02:00
Taylor Beeston 5fabc88f9e Fix subagent crash and add external OpenCode server support (#188)
* 🐛 Fix UI crash when subagent is active

Remove sessions dependency from hooks to prevent cascading re-renders.
Use getState() instead and switch to getGlobalSessionStatus().

*  Add support for connecting to external OpenCode server

Add OPENCODE_SKIP_START env var to skip starting embedded server.
Use OPENCODE_PORT to connect to existing OpenCode instance.
Update help text to document the new environment variables.

* 📝 Document external OpenCode server support

Add OPENCODE_PORT and OPENCODE_SKIP_START to READMEs.
Update AGENTS.md with external server integration notes.

*  Add URL-based routing for shareable session links

- Add react-router-dom dependency
- Create URL store for bi-directional sync with Zustand
- Add WebRouter/DesktopRouter context for runtime-aware routing
- Add useURLSync hook to sync URL with session/tab state
- Add useNavigation hook with copySessionLink utility
- Add share button in Header for copying session links
- Update App.tsx to use router wrappers

URL structure:
  /session/:sessionId?tab={chat|git|diff|terminal|files}&directory=/path
  /settings

This enables shareable links and deep-linking to specific sessions.

* Revert " Add URL-based routing for shareable session links"

This reverts commit b53ee304950a789538fa3d4a236d6361e634ea61.
2026-01-22 18:32:04 +02:00
Bohdan Triapitsyn 1f23b63c0b feat: add Web Push API support and PWA integration (#189)
* feat: add Web Push API support and PWA integration

Add web Push API with subscribe/unsubscribe and visibility endpoints
Introduce usePushVisibilityBeacon and useSessionDeepLink hooks
Integrate PWA with service worker, registerSW, and VAPID key persistence

* feat: add heartbeat visibility beacon for web runtime

Add a 10s heartbeat to ping visibility while visible
Subscribe to visibilitychange, focus, blur, pageshow, and pagehide events to report state
Clear heartbeat interval on unmount to avoid leaks
2026-01-22 01:19:24 +02:00
Bohdan Triapitsyn 3df362b220 feat(web): enable automatic port assignment if default is in use (#175) 2026-01-18 18:18:42 +02:00
Bohdan Triapitsyn 1ca08cf2d8 Revert "feat: add --remote-url CLI option to connect to remote OpenCode instances (#161)"
This reverts commit 53f8e1324e.
2026-01-17 22:20:26 +02:00
刘奕聪 53f8e1324e feat: add --remote-url CLI option to connect to remote OpenCode instances (#161)
* feat: add --remote-url CLI option to connect to remote OpenCode instances

* fix: pass remoteUrl to main function when running as CLI
2026-01-16 15:58:55 +02:00
Bohdan Triapitsyn be6aba3605 feat(web): auto-resolve available port for serve 2026-01-15 00:52:08 +02:00
Martin DONADIEU 11fb61a883 feat: add QR code and password URL for Cloudflare tunnel (#112)
* feat: add QR code and password URL parameter for Cloudflare tunnel

Add --tunnel-qr flag to generate scannable QR code for tunnel URL in terminal.
Add --tunnel-password-url flag to include password as URL parameter for auto-login.
Frontend now automatically detects and submits password token from URL.

* docs: update README with tunnel QR and password URL features

Add dev script for concurrent server, web, and UI watch mode.
2026-01-07 21:51:45 +02:00
Bohdan Triapitsyn 110b0e5d8f feat(terminal) refactoring and stability improvements (#98)
* feat(terminal): replace xterm with ghostty-web

Replace xterm.js terminal with ghostty-web implementation
Add terminal serialization support for state restoration
Apply custom patches to ghostty-web for enhancements

* feat(terminal): add bun-pty backend support

Switch terminal to ghostty-web with bun-pty backend for better performance
Auto-detect and prefer Bun runtime when available for terminal sessions
Update terminal viewport write queue handling for improved reliability

* fix(terminal): prevent unnecessary resize events

Only report terminal resize when dimensions actually change
Simplify chunk processing state tracking
Disable terminal transparency for consistent rendering

* feat(terminal): increase scrollback and buffer limits

Increase terminal scrollback buffer from 10k to 50k lines
Increase terminal buffer limit from 256k to 1M bytes
Add rate limiting and improve output handling for terminal streams
2026-01-02 21:57:53 +02:00
Alexis Okuwaandaptdnfapt 6c30245134 feat(web): add Cloudflare Quick Tunnel support for remote access (#85)
* feat(web): add Cloudflare Quick Tunnel support for remote access

Implement --try-cf-tunnel flag that creates a temporary public URL
routing to the locally running server via cloudflared.

Features:
- Auto-detect and spawn cloudflared subprocess
- Extract and display *.trycloudflare.com URL
- Proper cleanup on server shutdown
- Dynamic port handling (tunnel routes to actual listening port)
- Isolated HOME dir to avoid config conflicts
- Installation help and limitations warning

* docs: add Cloudflare tunnel feature to README

- Document --try-cf-tunnel flag in CLI examples
- Add Cloudflare Quick Tunnel to Web/PWA features

* docs: add cloudflared as prerequisite for --try-cf-tunnel

* feat(web): auto-generate password for Cloudflare tunnel

When using --try-cf-tunnel without --ui-password, automatically generate
a secure random password to protect the publicly exposed service.

Features:
- 16-character random password (easy to read, no ambiguous characters)
- Password is displayed after tunnel is established
- Warning to save the password (not shown again)
- Works in both foreground and daemon modes
- Uses same password for subsequent restarts (stored in instance file)

* fix(web): improve Cloudflare tunnel UX and fix spawn ENAMETOOLONG

- Generate and display password before tunnel starts (green colored)
- Display tunnel URL in cyan via onTunnelReady callback
- Fix ENAMETOOLONG by using env:undefined instead of copying process.env
- Pass tryCfTunnel flag from CLI to main function
- Remove duplicate tunnel URL output
- Update warning message to reflect password protection
- Change start script to use CLI wrapper for proper initialization

---------

Co-authored-by: aptdnfapt <197602950+aptdnfapt@users.noreply.github.com>
2025-12-31 15:43:18 +02:00
Bohdan Triapitsyn 6323050461 feat: add web update check and installation functionality 2025-12-19 19:57:18 +02:00
Bohdan Triapitsyn 4b2edf7318 Initial public release 2025-12-07 19:32:53 +02:00