Skip to content

Feat/tui sidebar process list - #68

Open
hgraca wants to merge 3 commits into
shekohex:mainfrom
hgraca:feat/tui-sidebar
Open

hgraca wants to merge 3 commits into
shekohex:mainfrom
hgraca:feat/tui-sidebar

Conversation

@hgraca

@hgraca hgraca commented Sep 27, 2026 •

Copy link
Copy Markdown

going out of the tui to see the processes and their contests is a hassle, so I added a sidebar widget for it.

Screenshot from 2026-09-26 21-52-04 Screenshot from 2026-09-26 21-52-33

The sidebar found the server by scanning /proc/self/net/tcp{,6} and, where that
failed (non-Linux), by scraping the URL a throwaway session posted. /proc is
Linux-only, and the scrape spends a session just to learn a port.

The server now publishes its bound address to a per-user runtime record
($XDG_RUNTIME_DIR, or os.tmpdir(); PTY_RUNTIME_DIR overrides), keyed by the
project path so a reader can attribute it to an instance, and removes it on
dispose. Writes are atomic (temp + rename), and a reader never deletes a record:
PID liveness is namespace-sensitive and a partial read looks like corruption, so
only the owner can safely remove one — a candidate is validated by /health
instead.

The project path reaches the server from whichever host API has it: V1 PluginInput
directory/worktree, and V2 ctx.location.directory (V2 ctx.worktree is a domain
object, not a path).
A session carried only `createdAt`, so a reader could say how long a process had been
going but never how long it ran. The exit handler now stamps `exitAt` alongside
`exitCode`/`exitSignal`, and the info shape exposes it as an ISO string, so a
reader can show a fixed duration for a finished process instead of one that keeps
counting.
Ship a TUI plugin via exports["./tui"], so installing opencode-pty also puts a live
PTY panel in OpenCode sidebar. One plugin, two surfaces: the TUI entry is a
separate file only because opencode rejects a module that default-exports both
`server` and `tui`.

- a session row list on sidebar_content — bullet tinted by state, line count or
  exit code, collapsible and remembered in kv — that reads the origins the server
  publishes, and falls back to the instance-scoped scrape only when several
  records match one project (only the own server can say which is theirs)
- clicking a row opens its live output in a dialog, whose header carries the run
  time in its bottom-right corner: counted from the session start, frozen at its
  exitAt, ticking once a second while it runs
- the row control removes one session (a running one is confirmed first);
  (clear finished) drops every stopped session and never a live one
- the server starts only on request — expanding the panel is the trigger — and
  every probe is bounded
- a missing or inverted timestamp renders nothing rather than a wrong number

@opentui/solid and solid-js are runtime-injected by opencode, so they are optional
peers; the dev deps carry the types typecheck needs.
@shekohex

shekohex commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

This very cool!

Does it allow for actually sending commands in these ptys or say, typing in there to confirm a command or something?

Overall good idea for opencode v2.

Note: CI needs fixing

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