This repository has been archived on 2026-07-17. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
codespace/web
tao.chen 3df9f42626 fix(web): stabilize useMutation results so TerminalPanel stops flooding /shell/resize
The mutationFn / onSuccess closures inside every useMutation in
process.ts were created fresh on every render, which made the
mutation result object unstable across renders. TerminalPanel's
terminal-init useEffect has [resize, workspaceId] as deps; with
"resize" changing on every render, the effect re-ran on every
render, which:
  - disposed and recreated the xterm Terminal
  - re-attached onResize (which fires fit() → onResize → mutate)
  - 100ms debounce kept getting reset
  - but the effect re-creating itself with new closures every
    ~16ms kept fit()'s pre-resize state oscillating, eventually
    letting the debounce expire and firing the API
Result: /api/workspaces/:id/shell/resize was being spammed.

Fix: wrap every useMutation's mutationFn (and onSuccess where
present) in useCallback with explicit deps. useMutation now sees a
stable config and returns a stable result object. The terminal
effect's dep [resize, workspaceId] no longer changes per render
unless workspaceId actually changes.

Affects: useProcessStart/Stop/Restart, useShellStart/Stop/
Restart/Resize. All same pattern, all same risk.
2026-07-06 18:19:57 +08:00
..
2026-07-02 16:57:37 +08:00
2026-07-02 16:48:19 +08:00
2026-07-02 16:48:19 +08:00
2026-07-02 16:48:19 +08:00
2026-07-02 16:48:19 +08:00
2026-07-02 16:48:19 +08:00

codespace-web

Frontend IDE shell for the codespace Go backend.

Scope

This package is the codespace web IDE. It connects to the Go backend: the file explorer and editor call the file APIs, the toolbar drives the process start/stop/restart endpoints, and the terminal streams the running OpenCode process over the WebSocket endpoint /api/workspaces/:id/process/ws.

Commands

Command Purpose
pnpm install Install dependencies
pnpm dev Start the Vite dev server (proxies /api and /healthz to http://localhost:8080)
pnpm lint Run ESLint
pnpm build Type-check and build for production

Stack

  • Vite + React 19 + TypeScript
  • Tailwind CSS v4
  • react-router v7
  • Zustand for local UI state
  • TanStack Query for API state
  • @monaco-editor/react editor wrapper
  • @xterm/xterm + @xterm/addon-fit terminal wrapper
  • react-resizable-panels for layout splits
  • lucide-react for icons

Non-goals

  • Authentication
  • i18n
  • Tests (no test framework until business logic is added)