feat(ui): add runtime logger and replace console usage

This commit is contained in:
Shantur Rathore
2025-12-05 15:07:49 +00:00
parent 49143bd049
commit 971abe24d7
44 changed files with 406 additions and 138 deletions

View File

@@ -26,8 +26,30 @@ This starts the Vite dev server at `http://localhost:3000`.
To build the production assets:
```bash
```
npm run build
```
The output will be generated in the `dist` directory, which is then consumed by the Server or Electron app.
## Debug Logging
The UI now routes all logging through a lightweight wrapper around [`debug`](https://github.com/debug-js/debug). The logger exposes four namespaces that can be toggled at runtime:
- `sse` Server-sent event transport and handlers
- `api` HTTP/API calls and workspace lifecycle
- `session` Session/model state, prompt handling, tool calls
- `actions` User-driven interactions in UI components
You can enable or disable namespaces inside DevTools by importing the helpers:
```ts
import { listLoggerNamespaces, enableLogger, disableLogger } from "./src/lib/logger"
listLoggerNamespaces() // => [{ name: "sse", enabled: false }, ...]
enableLogger("sse") // turn on SSE logs
disableLogger("sse") // turn them off again
```
Enabled namespaces are persisted in `localStorage` under `opencode:logger:namespaces`, so your preference survives reloads.