Skip to content

shellterm: a line-oriented terminal, extracted from the dashboard - #1

Merged
tannevaled merged 1 commit into
mainfrom
initial
Nov 9, 2026
Merged

tannevaled merged 1 commit into
mainfrom
initial

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Item 2 of go-widgets/toolkit#548: the line-oriented terminal shared by the go-wasmcontainers dashboard and wasmdesk.

API:

  • Shell: Run(ctx, line, out) (code int, clear bool).
  • New(Options{Post, Greeting, OnDone, HistorySize}) *Session; Post is required.
  • Session methods: SetShell(Shell, lineedit.Completer), Attach(out, clear), Input, Resize, Note, History; the Running field is an mvvm.Observable[bool].
  • Bind(*toolkit.Terminal, *Session, invalidate): typing goes to the session, output to the terminal, and a clear empties the screen and the scrollback.

What moved, from go-wasmcontainers/dashboard v0.8.0:

  • vm/terminal.go's Terminal, keeping the key goroutine, the input queue, pending writes, Ctrl-C, exit status, clear, notes and completion.
  • ui/scene.go:400-408's wiring, which became Bind.

Changed in the move:

  • app.post became Options.Post, and app.Refresh became Options.OnDone.
  • The wctr greeting became Options.Greeting.
  • note became Note: the "# dashboard:" prefix, Clean and ShowActions stay with the caller.
  • WctrShell, Builtins and WctrCompleter stay in go-wasmcontainers.

Tests:

  • The dashboard's TestTerminal, on a real vt.Screen with a serialised stand-in for the UI goroutine, plus Bind tests on a toolkit.Terminal and a compiled Example.
  • -race -count=10 passes, and coverage is 100.0 % for every function.
  • Break check: dropping the history in SetShell fails TestSession (history = []).
  • GOOS=js GOARCH=wasm, linux/386 and windows all vet clean.

Dependencies: lineedit v0.1.1, mvvm v0.15.0, and toolkit v0.362.0, which carries Terminal.SetFont/SetCellSize (item 3, #549).

CI is lineedit's, without its fuzz job. Untrusted keys and terminal bytes are parsed by lineedit, which fuzzes them in its own CI.

Refs go-widgets/toolkit#548

🤖 Generated with Claude Code

Session is go-wasmcontainers/dashboard v0.8.0's vm.Terminal on
go-widgets/lineedit v0.1.1, with the dashboard-specific parts turned into
options: Post (was app.post), OnDone (was app.Refresh), Greeting (was the
wctr greeting), and Note (was note, minus the "# dashboard:" prefix, Clean
and ShowActions, which stay with the caller). Bind wires a
toolkit.Terminal as the dashboard's ui/scene.go did. The tests are the
dashboard's TestTerminal on a vt.Screen, under -race, at 100 % coverage.

Refs go-widgets/toolkit#548

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 7c3027b into main Nov 9, 2026
6 checks passed
@tannevaled
tannevaled deleted the initial branch November 9, 2026 12:14
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.

1 participant