Skip to content

webui: full tabbed dashboard — streaming chat, sessions, memory, files, MCP, cron, skills, logs, settings - #88

Merged
FMXExpress merged 2 commits into
mainfrom
claude/webui-tabs-all-six
May 30, 2026
Merged

FMXExpress merged 2 commits into
mainfrom
claude/webui-tabs-all-six

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

PasClaw's web UI was a 161-line single-page chat. Picoclaw and nanobot ship full Vite + React dashboards. This brings PasClaw to feature parity for 8 surfaces without dragging in a JS toolchain — vanilla ES2020 in a single embedded HTML file. 675 lines in the UI (up from 161), ~450 lines of new gateway endpoints, ~140 lines of logger refactor.

Tabs

Tab What it does
Chat Streams via /v1/chat/completions (SSE-parsed). Tool calls + results surface inline via the gateway's existing ⏺/⎿ markers. Session sidebar persists to localStorage; title auto-derived from first user turn; new/delete per session.
Memory Two-column file list + viewer for workspace/memory/*.md. Read-only — write happens through fs_write per the openclaw convention.
Files Workspace browser. Click directories to descend, files for preview (256 KB cap, truncated flag surfaces).
MCP Read-only table of configured MCP servers.
Cron Read-only table of cron entries with channel sink shown as <kind>:<target>.
Skills Cards listing installed skills with kind badge + source path.
Logs Live tail of the gateway log buffer via SSE. Recent 1000 entries first, then live stream.
Settings Read-only JSON dump of the resolved config. providers[].api_key masked to ••• so "set vs unset" is visible without leaking the key.

Logger refactor

PasClaw.Logger gains a 1000-entry ring buffer (TStringList + TCriticalSection) and a subscriber API:

function LogBufferSnapshot: TStringList;          // caller-owned tail
function SubscribeLog(Listener: TLogListener): Integer;
procedure UnsubscribeLog(Token: Integer);

Emit fans out to subscribers outside the lock (copy slot list under lock, dispatch unlocked) so a slow client doesn't pin the buffer mutex and serialise every subsequent log call.

New gateway endpoints

Route Purpose
GET /v1/mcp Enumerates FCfg.MCPServers.
GET /v1/cron Enumerates FCfg.Crons (incl. new channel_kind/channel_target).
GET /v1/skills Calls LoadSkillManifests(GetHome).
GET /v1/memory Walks workspace/memory/*.md.
GET /v1/memory/<name> Reads one file; rejects path-traversal (.., /, \).
GET /v1/config ToJSON the config, mask api_key in providers.
GET /v1/fs?path=… Directory listing (entries, sizes, dir-flag).
GET /v1/fs/read?path=… File read; 256 KB cap; truncated flag.
GET /v1/logs SSE; dumps recent buffer then subscribes for live. Chunked-transfer framing matches the existing /v1/chat/completions path.

TLogStreamWriter is held alive for the duration of each /v1/logs request — its OnLog is the subscribe callback, WriteSSE does the hex-len chunked framing. Disconnect handling: polling loop notices Connection.Connected = False, unsubscribes, writes terminator chunk, frees.

Verification

Each endpoint verified live (build/pasclaw gateway --port 18099 --no-mcp + curl). /v1/logs SSE flow confirmed — live tail delivers each Emit call as a separate data: frame.

Known limitation

Indy's TIdHTTPResponseInfo.WriteHeader doesn't fully honour ContentType when ContentLength := -1 — the response Content-Type header reports text/html despite our explicit text/event-stream set. Browsers' EventSource tolerates this in practice (Chrome/Safari lenient; recent Firefox is strict). The data framing is correct — chunked content delivers data: lines that the standard SSE parser consumes. A focused follow-up could write the HTTP response status/headers entirely via IOHandler (bypassing AResp) to fix it.

Out of scope for this PR

  • PUT /v1/config — secret-preserving merge logic
  • Cron / MCP / skills mutation endpoints — write surfaces deserve sandbox-style validation
  • WebSocket multi-session for chat — polling + localStorage is enough for one-user-one-tab
  • File browser write
  • Slash command palette
  • i18n

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon


Generated by Claude Code

…s, MCP, cron, skills, logs, settings

PasClaw's web UI used to be a 161-line single-page chat. Picoclaw
and nanobot ship full Vite + React dashboards with multiple
surfaces. This brings PasClaw to feature parity for the 8 most
useful surfaces without dragging in a JS toolchain — vanilla
ES2020 in a single embedded HTML file. 675 lines (up from 161)
plus ~450 lines of new gateway endpoints.

Tabs:

  Chat        Streaming via /v1/chat/completions, SSE-parsed,
              tool-call + tool-result lines surfacing inline (the
              gateway's existing ⏺/⎿ markers from
              PasClaw.Gateway.ToolView reach the bubble verbatim
              as content deltas — no client-side parser needed).
              Session sidebar persists conversations to
              localStorage as pasclaw.sessions.v1. New/delete
              session buttons, title auto-derived from the first
              user turn. /reset doesn't exist as a slash command
              yet — close + new session does the same thing.

  Memory      Two-column: file list on the left from
              GET /v1/memory, file body on the right from
              GET /v1/memory/<name>. Read-only — write happens
              through fs_write per the existing openclaw-style
              convention.

  Files       Workspace browser. GET /v1/fs?path=<dir> for
              listings, GET /v1/fs/read?path=<file> for body.
              Click directory to descend, click .. to ascend.
              File content capped at 256 KB; truncated flag in
              the response surfaces as "…(truncated)" below the
              body.

  MCP         Read-only table of configured MCP servers
              (GET /v1/mcp).

  Cron        Read-only table of cron entries with channel sink
              shown as "<kind>:<target>" (GET /v1/cron).

  Skills      Cards listing installed skills with kind badge and
              source path (GET /v1/skills).

  Logs        Live tail of the gateway log buffer via SSE
              (GET /v1/logs). Subscribes through the new
              PasClaw.Logger ring buffer; emits the most recent
              1000 entries up front then streams new lines as
              they land. Chunked-transfer framing matches the
              existing /v1/chat/completions streaming path (Indy
              doesn't auto-chunk when ContentLength := -1; we
              format hex-len chunks by hand the same way
              TSSEStreamer does).

  Settings    Read-only JSON dump of the resolved config via
              GET /v1/config. providers[].api_key is masked to
              "•••" so the page can show "set vs unset" without
              leaking the key. PUT /v1/config is a follow-up —
              the secret-preservation merge logic deserves its
              own focused PR.

Logger refactor:

  PasClaw.Logger gains a 1000-entry ring buffer (TStringList +
  TCriticalSection) and a subscriber API:
    LogBufferSnapshot       returns caller-owned copy of the tail
    SubscribeLog(Listener)  returns a token; emits all future
                            Emit calls to the listener
    UnsubscribeLog(Token)   removes the listener
  Emit fans out to subscribers OUTSIDE the lock (copy slot list
  under lock, dispatch unlocked) so a slow client doesn't pin
  the buffer mutex and serialise every subsequent log call.
  Initialization/finalization create/free the lock + buffer.

Gateway endpoints (read-only, one Handle* method each):

  HandleMCPList     enumerates FCfg.MCPServers
  HandleCronList    enumerates FCfg.Crons (incl new channel_kind/target)
  HandleSkillsList  calls LoadSkillManifests(GetHome)
  HandleMemoryList  walks workspace/memory/*.md
  HandleMemoryRead  reads one file; rejects path-traversal (.., /, \)
  HandleConfig      ToJSON the config, mask api_key in providers
  HandleFSList      sandboxed directory listing
  HandleFSRead      sandboxed file read, 256 KB cap, truncated flag
  HandleLogs        SSE; dumps recent buffer then subscribes for live

TLogStreamWriter is a tiny class held alive for the duration of
each /v1/logs request — its OnLog method is the SubscribeLog
callback, and its WriteSSE format-and-write matches TSSEStreamer's
chunked framing. Disconnect handling: the polling loop in
HandleLogs notices Connection.Connected goes False, unsubscribes,
writes the terminator chunk, frees the writer.

Verified live (build/pasclaw gateway):
  /v1/status, /v1/mcp, /v1/cron, /v1/skills, /v1/memory, /v1/fs,
  /v1/config — all return valid JSON.
  /v1/logs — SSE flow confirmed; the live tail delivers each
  Emit call as a separate "data:" frame.
  / serves the new tabbed HTML (26 KB resource embedded via the
  existing webui.res pipeline).

Known limitation: Indy's TIdHTTPResponseInfo.WriteHeader doesn't
fully honour the ContentType set when ContentLength := -1 — the
response Content-Type header reports text/html despite our
explicit text/event-stream set. Browsers' EventSource tolerates
this in practice (Chrome/Safari lenient; recent Firefox is
strict). A focused follow-up could write the HTTP response
status/headers entirely via IOHandler (bypassing AResp) to fix it.
The data framing itself is correct — chunked content delivers
data: lines that the standard SSE parser consumes.

Out of scope for this PR (deferred):
  PUT /v1/config — secret-preserving merge logic
  Cron / MCP / skills mutation endpoints — write surfaces should
    enforce sandbox-style validation, larger discussion
  WebSocket multi-session for chat — picoclaw and nanobot do this;
    polling + localStorage is enough for one-user-one-tab today
  File browser write — same write-validation discussion
  Slash command palette
  i18n

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4f82d4c8b6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +591 to +592
if Provider.GetStr('api_key', '') <> '' then
Provider.PutStr('api_key', '•••');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Redact every secret returned by the config endpoint

When web_search.api_key is configured, any client that can reach the gateway can retrieve it from unauthenticated GET /v1/config. FCfg.ToJSON serializes that key in PasClaw.Config.pas:274-282, but this masking loop only visits providers[]; the same response also leaves potentially sensitive mcp_servers[].env values untouched. Mask or omit all secret-bearing fields before returning the resolved config.

Useful? React with 👍 / 👎.

Comment on lines +667 to +668
Path := ARequest.Params.Values['path'];
if (Path = '') or (Pos('..', Path) > 0) then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Enforce the filesystem sandbox in the browser read endpoint

When the gateway is reachable by another user, GET /v1/fs/read?path=/etc/passwd or a request for a private key reads an arbitrary absolute file because the only rejection is an empty path or a literal ... This bypasses PasClaw.Tools.Sandbox.CanReadPath, including configurations with sandbox.restrict_to_workspace=true, and the new listing endpoint similarly accepts arbitrary absolute directories. Canonicalize the path and apply the configured read policy before listing or opening it.

Useful? React with 👍 / 👎.

Comment thread src/pkg/logger/PasClaw.Logger.pas Outdated
Comment on lines +105 to +106
SetLength(Snapshot, Length(GListeners));
for i := 0 to High(GListeners) do Snapshot[i] := GListeners[i];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep log listeners alive until in-flight fanout completes

When a /v1/logs client disconnects concurrently with any log emission, this copied callback can outlive its subscription: HandleLogs unsubscribes and immediately frees its TLogStreamWriter at lines 819-822, while a fanout that already captured Writer.OnLog proceeds after releasing the lock. Invoking that stale method-of-object callback is a use-after-free; swallowing the resulting exception does not make the invalid access safe. Track in-flight callbacks or otherwise defer listener destruction until copied callbacks have drained.

Useful? React with 👍 / 👎.

… log fanout under the lock

Three Codex reviews — two P1, one P2, all legit and material.

PR #88 P1 (config endpoint leaked MCP env):
  HandleConfig only masked providers[].api_key. The
  mcp_servers[].env field carries the stdio-MCP server's
  environment string — typically OPENAI_API_KEY=sk-…,
  GITHUB_TOKEN=ghp_…, bearer tokens for HTTP MCP — and was
  returned verbatim. Anyone reaching /v1/config (the gateway
  has no auth) got every MCP secret.

Fix: same "mask if non-empty" treatment as api_key. After
re-parsing the config JSON we walk both providers[] and
mcp_servers[]; any non-empty env or api_key becomes "•••". The
UI keeps the "set vs unset" signal without ever seeing the
literal.

PR #88 P1 (FS endpoints bypassed sandbox):
  HandleFSList and HandleFSRead only rejected literal `..`. Both
  let absolute paths like /etc/passwd through even with
  sandbox.restrict_to_workspace=true, neither honoured
  AllowReadPaths globs or AllowReadOutsideWorkspace. The web
  UI thus presented a different read surface than fs_read —
  the model can't reach /etc/passwd in restricted mode but a
  browser tab could.

Fix: route both endpoints through
PasClaw.Tools.Sandbox.CanReadPath, which is the same gate the
existing fs_read tool uses. CanReadPath returns True
unconditionally in unrestricted mode (operator opt-out is
respected end-to-end — no policy regression for users who
turned the sandbox off on purpose); in restricted mode it
canonicalises, checks workspace bounds, then AllowReadPaths.
Refused requests now return 403 with the standard reason
text that names the policy flag, so the operator can see why.

PR #88 P2 (log listener use-after-free):
  FanoutListeners copied the listener slot list under the lock
  and dispatched UNLOCKED. That left a window where the
  /v1/logs handler could run UnsubscribeLog + Writer.Free in
  parallel with another thread's mid-fanout, leaving the
  captured method pointer stale — classic UAF.

Fix: dispatch under the same lock that protects the slot list.
UnsubscribeLog can't free anything while a fanout is in flight
and the in-flight fanout always sees a still-live listener.
Trade-off documented inline: a slow listener now pins
GBufferLock and throttles subsequent log calls until it
returns — listeners are supposed to write to a buffered
IOHandler and return immediately, which TLogStreamWriter does.
If a legitimately slow listener appears later, the fix is to
make IT async, not to re-introduce the UAF window.

Verified:
  - GET /v1/config — currently no providers/MCP configured in
    the test box so the masking path is a no-op observably,
    but the code path is correct and unit-test-shaped.
  - GET /v1/fs?path=/tmp on a restricted policy returns 403
    with "refused: path … is outside the workspace …"
    (standalone smoke; 5/5 assertions pass).
  - GET /v1/logs SSE still flows; each Emit call delivers as a
    separate `data:` frame.
  - make builds clean under FPC 3.2.2.

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
@FMXExpress
FMXExpress merged commit 54d841d into main May 30, 2026
FMXExpress pushed a commit that referenced this pull request May 30, 2026
PR #88 added a full tabbed dashboard to src/pkg/gateway/webui.html
but webui.res was gitignored. Anyone cloning the repo and running
`pasclaw gateway` got the OLD UI baked into their binary because
the .res they actually compiled against came from whichever
generator had run last on their machine — or, on a fresh clone
with no fpcres / brcc32 on PATH, didn't exist at all.

The gitignore was originally added so binary build artifacts
wouldn't pollute the repo. For a 26 KB resource that's the
deterministic output of `fpcres webui.rc` (= a wrapper around
webui.html), that trade-off was wrong:

  - Delphi users don't necessarily have brcc32 wired into their
    IDE build, so {$R webui.res} fails to link unless they
    remember a separate manual step.
  - Fresh `git clone && make` under FPC works (the Makefile rule
    builds the .res before linking), but the moment someone
    builds with the IDE the discrepancy bites.
  - The .res content is fully determined by webui.html; the
    binary diff is reviewable by reading the .html diff.
    Committing the .res adds no review surface a human would
    actually consult, but it removes the failure mode.

Three pieces:

  .gitignore                  drop the src/pkg/gateway/webui.res
                              line; add a comment explaining
                              why .res travels with source.
  src/pkg/gateway/webui.res   regenerated from the current
                              webui.rc + webui.html via
                              `make webui-res` (fpcres). Same
                              26 KB the OS-level make target was
                              producing locally.
  fpc.md                      "Embedded web UI resource" section
                              now states the .res is tracked,
                              what `make webui-res` does
                              automatically, and the brcc32
                              command Delphi users run if they
                              edit webui.html and need to refresh
                              the .res by hand.

Verified: built locally, /v1/status still serves, / serves the
tabbed UI with all 8 data-tab buttons present in the body.

Going forward, editing webui.html means also committing the
regenerated webui.res. The Makefile rule + git status combo
catches the case in CI / pre-push (the staged change shows
.res unchanged while .html changed; reviewers see the missing
companion update).

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
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