Extension UI in daemon/RPC mode: setWidget component factories silently dropped, worker theme uninitialized, no terminal width available #2065
denkhaus
started this conversation in
Bug reports
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Extension UI degradation in daemon/RPC mode is under-documented; three remaining gaps
Context
Extensions in daemon-attached sessions run in worker processes. The RPC
extension UI bridge (
rpc-extension-ui-context.js) can only forward what isserializable. This was already acknowledged in #690, #697, #885, and #1806
(thanks for those fixes). However, the current docs (extensions.md, main
branch) still say only: "Some TUI-specific methods are no-ops or return
defaults" - without naming which ones. Three gaps remain that cost hours of
debugging and are not documented anywhere:
1. setWidget silently drops component factories (analogous to #885)
ctx.ui.setWidget(key, (tui, theme) => component)is a documented form andworks in interactive mode. Under daemon/RPC it is silently dropped:
#885 fixed exactly this pattern for
ctx.ui.custom()by rejecting loudly.The same treatment (throw, or at least warn) would apply here. Alternatively,
document prominently: "In daemon-attached sessions, only the string-array
form of setWidget is forwarded."
Repro: run any TUI daemon-attached, register a factory-widget extension,
/reload- no widget, no error, no log line.2. ctx.ui.theme is imported but uninitialized in workers
ctx.ui.themeexists in RPC mode (getter returns the shared theme module),but the worker never calls
initTheme(). Everytheme.fg(...)call throws:Extensions that colorize widget strings per the docs will fail in every
daemon-attached session. Either initialize the theme in workers, or export a
worker-safe API (e.g.
ctx.ui.themeOr(null)), or document that color callsmust guard with try/catch and fall back to raw ANSI codes.
3. No terminal width available to extensions in daemon mode
There is no way for an extension to learn the client terminal width:
DAEMON_CLIENT_ENV_KEYS) carries onlyHERDR_*COLUMNSin their environmentprocess.stdout.columnsundefined)new Text(line, 1, 0), alwaysleft-aligned), so right-aligning a widget line - e.g. to line up with the
built-in heartbeat tray label - is impossible through the public API
We ended up detecting the session's TUI via /proc (match
comm=prime-agentprocesses whose cwd equals the session cwd, rank by utime) and reading the
winsize via TIOCGWINSZ with a python3 helper. That works but is obviously
not the intended path. Suggestions:
(e.g.
ctx.ui.terminalColumns, refreshed on resize), oralign: "left" | "right"option toExtensionWidgetOptionsandlet the TUI align string-widget lines
Suggested documentation fix (minimum)
In extensions.md, extend the RPC paragraph of
ctx.hasUIwith a table ofwhich UI methods degrade in daemon/RPC mode:
Environment: prime-agent 0.8.1, daemon-attached TUI, extensions auto-loaded
from ~/.prime/agent/extensions/.
All reactions