Conversation
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.
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
going out of the tui to see the processes and their contests is a hassle, so I added a sidebar widget for it.