Terminal UI
Purpose
The Terminal UI (virtufin-tui) is a Textual-based Python operator dashboard for the Virtufin control plane, the terminal one of the two operator clients (the other is the web app, web-app). It is a pure consumer of the existing virtufin-api gRPC surface: it runs no service-side code, adds no proto messages, and requires no service changes. It fills the operator role that kubectl plays for Kubernetes: workers, connections and feeds, state, events, scenarios and strategies over a remote virtufin-api endpoint, with live CloudEvent streaming, multi-context switching, scripts and an AI assistant.
What both clients do is specified once, client-neutrally, in Operator Clients; this spec is the TUI's binding of it (keys, panes, files) plus what only the terminal has.
Related specs:
- Operator Clients: the views, operations and rules both clients implement; each binding requirement here names the one it implements.
- Operations: the operation catalog scripts and the AI assistant call, and the shared script-form format.
- Feed Definitions: the shared feed definitions the Feeds pane connects and disconnects.
- Cross-cutting: API-mediated pub/sub (the TUI talks only to virtufin-api, never to Dapr directly).
- Pub/Sub Topics: the CloudEvent envelope and topic taxonomy the Events pane renders.
- Worker Management: worker lifecycle, tags and creation-time config the TUI drives.
- WebSocket Feed: the WebSocketFeed worker (one connection per worker), its commands and status, behind connections and feeds.
Requirements
Requirement: Multi-Context Configuration
The TUI SHALL implement the operator-clients Contexts. It SHALL read the catalog of contexts from contexts.toml under the XDG config directory (~/.config/virtufin/api/contexts.toml on Linux/macOS, %APPDATA%\virtufin\api\contexts.toml on Windows). Every tab SHALL show the active context's name and its connection dot in a row under the tab bar; the Trading tab adds the scenario the TUI works in, highlighted when it is LIVE.
Scenario: The file's entries
- WHEN the TUI reads
contexts.toml - THEN it SHALL read a
[[contexts]]array whose entries MUST havename,api_hostandapi_portand MAY havetls(bool),api_key,default_worker_topic,worker_api_host,worker_api_port,description,event_topics(default["sys.api.state.saved", "sys.api.state.deleted"]) andprotected(bool)
Scenario: A broken entry
- WHEN an entry lacks a required field, or the file does not parse
- THEN the TUI SHALL still start, skip the entry and show the problem at startup
Scenario: The active context is state
- WHEN the user picks a context
- THEN the TUI SHALL persist it at
~/.local/state/virtufin/api/state.toml(mode0600), not in the catalog - AND SHALL keep the same catalog-vs-active split for every user setting it persists (contexts, LLM providers, themes, event topics)
Scenario: Resolving the active context
- WHEN the TUI starts
- THEN the active context SHALL be the CLI
--contextflag, else$VIRTUFIN_TUI_CONTEXT, else the persisted state file, else the first entry in the file
Scenario: Host and port overrides
- WHEN
VIRTUFIN_TUI_API_HOSTorVIRTUFIN_TUI_API_PORTis set - THEN it SHALL override the active context's host or port in memory, however that context was resolved (the
--contextflag and$VIRTUFIN_TUI_CONTEXTincluded)
Scenario: LIVE is bootstrapped
- WHEN the TUI starts or switches context and the scenario registry has no
LIVE - THEN it SHALL bootstrap
LIVEin the registry, a failure not stopping the TUI
Scenario: First-run with no config file
- WHEN the user runs
virtufin-tuiand nocontexts.tomlexists - THEN the TUI SHALL seed shipped default configs into
~/.config/virtufin/ - AND SHALL NOT overwrite existing files (seeded files are mode
0600)
Scenario: Env var override
- WHEN
VIRTUFIN_TUI_API_HOST=staging.virtufin.comandVIRTUFIN_TUI_API_PORT=5002are exported - THEN the TUI SHALL use those values for the active context, regardless of what is in
contexts.toml
Scenario: Switch context mid-session
- WHEN the user selects a different context from the config page
- THEN the TUI SHALL tear down the existing gRPC channel, DataPump tasks, and event subscription
- AND SHALL rebuild the client and restart its subscriptions against the new context
- AND SHALL prepare it as at startup: bootstrap
LIVEwhen missing, then run theinit_scripts
Scenario: The config page's tables
- WHEN the user presses
Enteron the config page - THEN it SHALL switch context only in the contexts table; on an available pane it SHALL add the pane, in the tabs-and-panes table it SHALL do nothing
- AND a context going up or down SHALL NOT move the highlight off the context the user picked
- AND the page SHALL scroll as a whole, so its footer stays on screen
Scenario: A protected context
- WHEN the active context has
protected = true - THEN its context row SHALL be red on every tab and say so
- AND the confirmation for each write (operator-clients, Contexts) SHALL be a dialog naming the context, asked from pages, dialogs and the AI tab alike
Scenario: A setting changed in the TUI
- WHEN the user changes the active Scenario, the theme, the event topics, the LLM provider or a display toggle (Events' wall/message time) in the TUI
- THEN the TUI SHALL save it to the state file and SHALL NOT rewrite the user's config file
- AND for the theme and the display toggles, the config file's value SHALL be the default and the state's the current value
Scenario: A context entry without a port
- WHEN a
contexts.tomlentry has noapi_port - THEN the TUI SHALL start with the other contexts and show at startup that the entry was skipped and why
Scenario: No active context
- WHEN no context resolves (no
contexts.toml, or the persisted name is not among its contexts) - THEN the TUI SHALL start on the config page with every context shown not connected, and watch no endpoint
- AND every pane that needs a context (all but Home and Config; a custom pane opts out with
WORKS_UNBOUND = True) SHALL say so instead of opening, and no pane SHALL stop the TUI - AND once a context is picked, the pane shown SHALL open for it
- AND leaving the config page while its switch still connects SHALL NOT fail the switch
Requirement: Client Access via gRPC Reflection
This is the TUI's binding of operator-clients Backend Access through the Gateway: the descriptor path.
The TUI SHALL invoke control-plane RPCs without vendored proto stubs, using
the API gateway's reflection RPCs (get_file_descriptor_protos_async) to load
descriptors at runtime, and SHALL invoke them via the raw reflection path (invoke_raw_async) with typed protobuf messages
built from the loaded descriptors.
Scenario: List workers via reflection
- WHEN the TUI reads the workers table
- THEN it SHALL call
WorkManager.ListWorkersthrough the reflection pipeline (invoke_raw_async), decoding the response from the dynamically-loaded message class
Requirement: Descriptor Pool per Backend
Each backend service SHALL get its own DescriptorPool. Pools SHALL NOT be
shared: backend protos all declare package virtufin and MAY declare
identically-named messages.
Scenario: One descriptor pool per service
- WHEN the TUI loads descriptors for more than one backend service
- THEN it SHALL build a separate
DescriptorPoolper service - AND SHALL NOT share pools between services with colliding
package virtufinsymbols
Requirement: State and Service Browser
The TUI SHALL provide a service browser that enumerates registered services
and methods via the gateway reflection RPCs (ListServices, ListMethods),
renders a JSON input form, and dispatches invocation through the gateway's
dynamic method dispatch. The browser SHALL expose raw JSON invocation only —
it SHALL NOT attempt schema-driven form generation for arbitrary methods.
Scenario: Browse services and methods
- WHEN the user opens the service browser
- THEN the TUI SHALL list services, then list a selected service's methods, and invoke a method by JSON payload
Requirement: AI Assistant
The TUI SHALL ship an AI chat tab that translates natural-language requests
into control-plane operations via OpenAI-compatible tool calling. The agent
logic SHALL be Textual-free (unit-testable) and SHALL have no privileged
path: every tool SHALL map 1:1 to an existing TuiClient/DataPump call.
A write tool SHALL run only after the user confirms it in a dialog naming the
operation and its input; a declined call SHALL be returned to the model as not
confirmed.
Scenario: The tools are the operation catalog
- WHEN the agent offers its tools
- THEN they SHALL be the operation catalog (operations, Operation Catalog: the catalog document domain-devkit ships), each operation one tool named
<group>__<action>with the document's input schema, without the people-only operations and, for a context the user may only read, without the write operations - AND each call SHALL be validated against its schema and run as the TUI's implementation of that operation
Scenario: A bounded loop
- WHEN the model keeps calling tools
- THEN the agent SHALL stop after 5 iterations
Scenario: A destructive tool asks first
- WHEN the model calls
workers__stopwith{"id": "w1"} - THEN the TUI SHALL ask before running
workers.stopand SHALL callStopWorkeronly on yes
Scenario: The same tools as the web app
- WHEN domain-devkit's catalog document lists an operation
- THEN the TUI's AI tab SHALL offer it as a tool with the same input schema, or the TUI's tests SHALL fail
Scenario: Provider resolution
- WHEN the AI tab resolves a provider
- THEN it SHALL check
VIRTUFIN_TUI_AI_PROVIDERenv → persisted default → first ready provider → none - AND SHALL show a configure state (disabled input) when no provider resolves
Scenario: Tool execution never raises
- WHEN a tool call fails
- THEN the TUI SHALL surface the error to the model as a structured result rather than raising
Requirement: Custom Pane Extension
The TUI SHALL support user-defined panes dropped into
~/.config/virtufin/tui/panes/. Two kinds SHALL be supported: a script +
form pair (<name>.py + sibling <name>.form.json in the shared script-form format, run as a subprocess on
submit) and a live widget pane (<name>.py defining a module-level Pane
class with a (stores, client, **kwargs) constructor, mounted as a persistent
page). Files matching neither pattern SHALL be skipped with a warning.
Scenario: Discover panes
- WHEN the TUI resolves pane tabs
- THEN it SHALL scan
~/.config/virtufin/tui/panes/and map script+form pairs and live-widget classes to pages
Requirement: Kill Switch
The TUI SHALL implement the operator-clients Kill Switch; this requirement is its terminal binding. K SHALL open it on every tab, and the context row SHALL say on every tab while any scenario is halted. The Scenario pane SHALL halt or resume one scenario with h, after a confirmation, and show each scenario's halt. The AI tab SHALL have no kill switch tool (the operation is people-only).
Scenario: What the kill switch reports
- WHEN the kill switch has run
- THEN the TUI SHALL report per scenario and per executor what was done and what failed
Scenario: Nothing resumes by itself
- WHEN scenarios are halted
- THEN none SHALL resume by itself: the Scenario page halts or resumes one scenario (
h, with a confirmation) and shows each scenario's halt - AND while any scenario is halted the context row SHALL say so on every tab
Scenario: Not for the AI
- WHEN the AI tab offers its tools
- THEN there SHALL be no kill switch tool
Scenario: Kill switch
- WHEN the user presses
Kand confirms twice - THEN every active or paused scenario SHALL be halted before any executor is asked to cancel, and the report SHALL list the halted scenarios and each executor's canceled orders and failures
- AND a no at either question SHALL change nothing
Requirement: Alerts Pane
The TUI SHALL collect alerts as the Alerts spec says and show them in an alerts pane (Infra, before events; it works without an active context): one row per alert with when it last came, its severity (an error red, a warning yellow), context, source, subject, text, count and when it first came. d SHALL dismiss the selected alert and c clear the list.
Scenario: Dismiss and clear
- WHEN the user presses
don an alert and thenc - THEN the alert SHALL be gone, and then the list SHALL be empty
Requirement: Unread Alerts
The context row SHALL say on every tab how many alerts are unread; showing the Alerts pane SHALL read them, and an alert that comes in while it is shown is read. Failed actions SHALL still show their error notice too.
Scenario: A breach while on another tab
- WHEN the P&L worker publishes a limit breach while the user is on the Trading tab
- THEN the context row SHALL count one new alert, and the Alerts pane SHALL list it at the top
Requirement: Change Log
The TUI SHALL record every write it sends to a context (a worker created, started, stopped, deleted or tagged, a worker command other than status, a state entry saved or deleted, a trigger scheduled or deleted, an operation a script calls through vf) with its time, context and outcome: done, failed with the reason, or declined (a no on a protected context). A script's writes through its own client (_rpc, run_operation) do not pass the TUI and are not recorded.
Scenario: A write on a protected context declined
- WHEN the user says no to a write on a protected context
- THEN nothing SHALL be sent, and the change log SHALL list the write as
declined
Scenario: A script's write through vf
- WHEN a script calls the reflected write
workmanager.UpdateWorkerTagsthroughvfon a protected context and the user confirms - THEN the change log SHALL list
UpdateWorkerTagsasdone
Requirement: Changes Pane
The change log SHALL outlive a restart: appended to changes.jsonl in the TUI's state directory, one JSON object per line, bounded in size with one previous file kept. A changes pane (Infra, after alerts; it works without an active context) SHALL list it newest first, a failed write in red.
Scenario: After a restart
- WHEN the TUI starts again
- THEN the Changes pane SHALL list the writes of earlier sessions
Requirement: Command Palette
ctrl+p SHALL open a command palette that finds, as the user types, every command of where it was opened: each key of the current page it implements (named with that key), going to any pane of the layout, the kill switch, the keys overview, and switching to any other configured context (the same switch as the Config page's, only once the context's api answers), next to Textual's own commands.
Scenario: Run a page action from the palette
- WHEN the user is on the Workers page, opens the palette and picks
Mark all (b) - THEN the TUI SHALL do what
bdoes there, and the palette SHALL NOT offer keys the page does not implement
Requirement: Keyboard Dispatch
The TUI SHALL expose per-page actions via a single dashboard binding table,
with first-match-wins dispatch and footer visibility gated on whether the
current page implements the action. Every page's keys SHALL go through the
dashboard table, so the footer shows them. ? SHALL show the help overlay,
in a dialog too; q SHALL quit after asking.
Scenario: Moving between tabs
- WHEN the user presses
rightorleft - THEN the TUI SHALL cycle the top-level tabs (priority bindings; a press while a switch runs SHALL count)
- AND
1–9and0(the tenth) SHALL switch sub-tabs, and</>step through them, so a pane past the tenth is reachable
Scenario: One meaning per key
- WHEN a page offers to add, delete, act on or open its rows
- THEN
aSHALL add,dSHALL delete,mSHALL open the row's actions, andEnterSHALL open the row (labeled Open) or make it the one in use (labeled Use: a scenario or context), on every page - AND no key SHALL be labeled with two of these meanings on different pages
Scenario: Live changes ask first
- WHEN a single key would stop something live: disconnecting a feed definition, pausing a scenario, quitting
- THEN the TUI SHALL ask before doing it; resuming or starting SHALL NOT ask
- AND
qpressed again in the quit question SHALL quit
Scenario: Undo a tag change
- WHEN the user sets or clears a tag
- THEN
Ctrl+ZSHALL undo it for 10 seconds, as long as the toast saying so is shown
Scenario: Page-conditional bindings
- WHEN the user presses a bound key on a page that does not implement the action
- THEN the key SHALL be hidden from the footer help for that page
- AND SHALL dispatch to the first matching action when present
Scenario: No refresh key
- WHEN anything a page shows changes on the platform
- THEN the page SHALL update by itself from events, so the TUI SHALL have no refresh key (
rruns a script on Scripts only)
Scenario: An empty list
- WHEN a page's list is empty
- THEN its status line SHALL say how to add the first entry (the key, or the page where it is added)
Scenario: Focus on a page's table
- WHEN a page is opened that has a table
- THEN the table SHALL have focus, not a filter or selector above it, so
Enterandspacereach the page's actions - AND a page without a table SHALL focus its first shown widget, never a hidden one (the closed filter line)
Requirement: Filtering
This is the TUI's binding of the filtering of operator-clients Tables.
The States and Events panes SHALL share one filter on /, evaluating the value-presentation Filter Expressions on their Values. The kinds are the composed presentation fragments (value-presentation, Presentation Fragments) with the user's ~/.config/virtufin/tui/representations.json over them when it exists.
Scenario: The Order Book
- WHEN the user presses
/on the Order Book, a price ladder - THEN no filter SHALL open
Scenario: The Workers filter
- WHEN the user presses
/on the Workers or Connections pane - THEN the filter line SHALL evaluate the value-presentation Worker Filter, the status line showing the expression and the shown and listed counts
Scenario: The table panes' filter
- WHEN the user presses
/on any other table pane - THEN the filter line SHALL evaluate the Filter Expressions over its rows: a word SHALL match any cell, a field SHALL name a column (its header lower-cased, other characters as
_) and match that column's cell,-termSHALL exclude - AND the pane's status line or header SHALL show the expression and the shown and total counts
Scenario: Open, type, keep, clear
- WHEN the user presses
/on the States or Events pane - THEN a filter line SHALL open with the current expression and take the focus, and the list SHALL re-filter on each keystroke
- AND
EnterSHALL keep the expression and give the focus back to the list, andEscSHALL clear it and give the focus back to the list - AND the expression SHALL be kept per pane for the session, not saved
Scenario: Events already received
- WHEN the filter changes on the Events pane
- THEN the buffered events received since the last clear (
c) SHALL be shown again through it, not only the events that arrive afterwards - AND the status line SHALL show the expression and the shown and received counts
Scenario: A bad expression
- WHEN the expression does not parse
- THEN the filter line SHALL mark it as an error, the status line SHALL say why, and the list SHALL stay unfiltered until it parses
Scenario: Workers by tag
- WHEN the user presses
/on the Workers pane and typestag:world=act - THEN only the workers whose
worldtag containsactSHALL be listed, andEscSHALL list all again with the focus on the table
Scenario: Two tables, one filter
- WHEN the filter on the Portfolio pane names a field
- THEN each table SHALL be filtered by its own columns, and a table without that column SHALL show no rows
Scenario: Keys while typing
- WHEN the filter line has the focus
- THEN
leftandrightSHALL move the cursor in it, not switch the view, and digits SHALL be typed, not pick a sub-tab
Scenario: Selection kept
- WHEN the filter changes on the States pane and the selected key still passes
- THEN it SHALL stay selected
Scenario: Table rows by column
- WHEN the user presses
/on the Instruments pane and typespair:ETH* - THEN only the rows whose Pair starts with
ETHSHALL be shown, the header SHALL show the expression andshown/total, andEscSHALL show all rows again
Scenario: Selection by key
- WHEN the filter changes on a registry pane or the Triggers pane and the selected row still passes
- THEN it SHALL stay selected
Requirement: Flat or Tree
The States and Events panes SHALL show their keys or topics flat or as the value-presentation Name Tree, switched with T and kept per pane for the session.
Scenario: States as a tree
- WHEN the user presses
Ton the States pane - THEN the table SHALL give way to the tree of the shown keys, each leaf with its value's preview, and
Tagain SHALL bring the table back with the same filter
Scenario: Events by topic
- WHEN the user presses
Ton the Events pane - THEN the tree of the topics of the buffered events SHALL appear beside the log, growing as events arrive, and picking a node SHALL show only that node's events in the log (a topic, a leaf, opens its stream: Value Representations in the TUI)
Requirement: Value Representations in the TUI
The TUI SHALL implement the value-presentation spec (Values, Value Streams, Kinds by Instance, Representation Mapping, Representations, Presentation Fragments, Conformance) for the States, Events and Indicators panes. Its kinds and representations SHALL be the fragments of the installed devkits, composed (virtufin.presentation entry point), with the user's mapping ~/.config/virtufin/tui/representations.json over them, and its CI SHALL run the fragments' vectors.
Scenario: Drawing the representations
- WHEN the TUI draws a representation
- THEN it SHALL use Textual widgets, and draw the stream representation
plot.linewithtextual-plotext
Scenario: Cycle representations
- WHEN a Value or stream is shown and has more than one representation the TUI implements
- THEN
vSHALL show the next one in mapping order, wrapping around
Scenario: A state key in its representations
- WHEN the user presses
Enteron a key in the States pane (table row or tree leaf) - THEN the key's value SHALL open in its first representation in place of the list, following the key's newest value,
hSHALL switch between the value and the key's stream (the values read while the pane was shown), andEscSHALL return to the list - AND each key's preview in the table and the tree SHALL be its value's first representation on one line
Scenario: A topic in its representations
- WHEN the user picks a topic (a leaf) in the Events pane's topic tree (Flat or Tree)
- THEN that topic's stream SHALL be shown in its first stream representation in place of the log,
hSHALL switch to its newest event as a Value and back, andEscSHALL return to the log - AND the log of all subscribed topics SHALL stay as it is; picking a node that is not a leaf SHALL narrow it as before
Scenario: An indicator in its representations
- WHEN the user presses
Enteron a pair's row in the Indicators pane - THEN that pair's indicator stream (the saved value, then each
changedevent while the pane shows the indicator) SHALL open in its first stream representation in place of the table,vSHALL show the next one,hSHALL switch between the stream and its newest Value, andEscSHALL return to the table
Requirement: Distribution as a Single Python Package
The TUI SHALL be distributed as a single pip-installable Python package built
with hatchling, exposing a virtufin-tui console script entry point that calls
virtufin_tui.app:main. It SHALL be runnable without installation via
uvx --from virtufin-tui virtufin-tui. The package SHALL depend on
textual[syntax], textual-plotext, virtufin-api, grpcio, openai,
pydantic, and tomlkit. The version SHALL be pinned in versions.env as LIBRARY_VERSION.
Scenario: uvx run
- WHEN the user runs
uvx --from virtufin-tui virtufin-tui - THEN the TUI SHALL launch against the active context (or the config page if none is configured)
Scenario: Pinned version
- WHEN CI builds the package
- THEN it SHALL inject
LIBRARY_VERSIONfromversions.envintopyproject.tomlbefore building
Requirement: Bounded Table Cells
This is the TUI's binding of the bounded cells of operator-clients Tables.
Every table in the TUI SHALL bound its cells by table_max_column_width (W, default 60) and table_max_row_height (H, default 5) from ~/.config/virtufin/tui/config.toml: a cell wider than W SHALL wrap inside its column, and a row SHALL be at most H lines high.
Scenario: A wide cell
- WHEN a cell's text is wider than W
- THEN it SHALL wrap at W (a word longer than W folded), and its column SHALL be no wider than W plus the scrollbar
Scenario: A tall cell
- WHEN a cell's content is taller than H lines
- THEN its row SHALL be H lines high and the cell SHALL show H lines and a scrollbar at its right edge whose thumb shows the position
Scenario: Scrolling a row
- WHEN the user presses
shift+downorshift+upon a selected row with a scrollbar - THEN its cells SHALL scroll by one line, the mouse wheel SHALL keep scrolling the table, and a refresh of the table SHALL keep the row's position
Scenario: Settings
- WHEN the user sets
table_max_row_height = 3andtable_max_column_width = 40 - THEN every table SHALL use them from the next start
Requirement: Resizable Columns
This is the TUI's binding of the resizable columns of operator-clients Tables.
The user SHALL be able to set the width of any column of any table in the TUI, by keyboard and by mouse; a width the user set SHALL replace the column's automatic width (Bounded Table Cells) and SHALL be remembered.
Scenario: Sideways
- WHEN a table is wider than the screen
- THEN
shift+leftandshift+rightSHALL scroll it sideways (left/rightswitch tabs), and a column picked with[or]SHALL be scrolled into view
Scenario: Resize by keyboard
- WHEN the user presses
[or]in a table - THEN the previous or next column SHALL be picked and its header highlighted,
-and+SHALL make it one character narrower or wider, and its cells SHALL wrap at the new width
Scenario: Back to automatic
- WHEN the user presses
=on a picked column - THEN the column SHALL take its automatic width again and the set width SHALL be forgotten
Scenario: Resize by mouse
- WHEN the user drags a column boundary, in the header or in any row, from within two cells of it
- THEN the column SHALL follow the pointer, at least one character wide
Scenario: Handles
- WHEN a table is shown
- THEN each column boundary SHALL be marked in the header, and the mark SHALL be highlighted while the pointer is within two cells of that boundary
Scenario: Remembered
- WHEN the user set a column's width and restarts the TUI
- THEN the same table's column with the same header SHALL have that width, kept in
~/.local/state/virtufin/tui/state.json
Requirement: Navigation Binding
The TUI SHALL be a client of navigation-specs: it SHALL use the user's structure (~/.config/virtufin/tui/navigation.json) if it validates, else the context's shared one (cfg.navigation, followed through the state-change events), else the built-in default domain-devkit ships, show which is in use and why another was skipped, and resolve it again on a context switch.
Scenario: A shared structure arrives
- WHEN an admin shares a structure on the context the TUI follows and the user has none of their own
- THEN the TUI SHALL redraw its tabs from the shared structure without a restart
Scenario: A broken user structure
- WHEN
navigation.jsondoes not validate - THEN the TUI SHALL use the shared or built-in structure and say that the user's is invalid, with its first error
Requirement: TUI Representation Profile
The TUI's profile SHALL draw the first level as top tabs and the second as sub-tabs; a top-level leaf SHALL be a tab without sub-tabs, and a node deeper than the second level SHALL be a sub-tab labeled with its group's label and its own (Group › Leaf). A view naming a custom pane SHALL open it; a view the TUI lacks SHALL show a placeholder naming it. A page SHALL be built on its first visit and kept, still following its data, until a context switch.
Scenario: A third level
- WHEN Trading holds a group Analytics with P&L and Risk
- THEN the Trading tab SHALL show the sub-tabs
Analytics › P&LandAnalytics › Riskin their order
Requirement: The User's Structure in the TUI
The navigation view (the Config pane) SHALL edit the user's own structure, starting from the one in use: move, insert and remove entries and add top-level groups, never removing a protected entry; saving SHALL write navigation.json after validating it, and SHALL never write the shared structure. A saved pane_order that differs from the TUI's former default SHALL be migrated once into navigation.json; an unchanged one SHALL be dropped.
Scenario: A customized pane order
- WHEN a TUI from before this change starts with a reordered
pane_orderinconfig.toml - THEN the TUI SHALL write the same tabs and panes as
navigation.jsononce and use it
Requirement: Pages in the TUI
A node opening a page SHALL render the context's shared page of that name, validated by the page-specs rules; its sources SHALL come from the TUI's stores and subscriptions, pushed, not polled. The TUI SHALL draw Stack, Heading, Text, WorkerTable and ValueStream, open the matching pane for a component that is a whole view (WorkerBrowser the Workers pane), and show a placeholder naming any other component.
Scenario: A shared page with a view component
- WHEN a shared page holds a heading and a
ConnectionBrowser - THEN the TUI SHALL show the heading above its Connections pane
Requirement: Feeds Pane
The TUI's feeds pane SHALL be its binding of feed-definitions: it SHALL list the context's shared definitions (cfg.feed.*) with their preset, world, topics and state (Feed Status, from the members of the definition's feed group), validated by the feed-definitions rules, and SHALL pass that spec's conformance vectors.
Scenario: Same feeds as the web app
- WHEN a definition is connected in the web app
- THEN the TUI's Feeds pane SHALL show it connected, and disconnecting it in the TUI SHALL delete the feeds the web app created
Scenario: An invalid shared definition
- WHEN
cfg.feed.<NAME>holds a document the validator refuses - THEN the pane SHALL list it with its first error and SHALL refuse to connect it
Requirement: Feeds Pane Actions
On the Feeds pane C SHALL connect and X disconnect the selected definition (feed-definitions, Connect and Disconnect), a SHALL add one from a preset's template, Enter SHALL open its JSON for editing with the errors at their paths, and d SHALL delete it (refused while connected). Each SHALL be a write for admins only; disconnecting SHALL ask first.
Scenario: Delete a connected definition
- WHEN the user presses
don a connected definition - THEN the TUI SHALL refuse, saying to disconnect it first
Requirement: Page Picker in the TUI
A pagePicker node (navigation-specs, Page Picker Entries) SHALL be a sub-tab showing the chosen page under a line naming it; p SHALL open a picker modal with a filter over the names the node allows, and choosing one SHALL render it. The choice SHALL be kept per node route in the TUI's state file (page_picks, like the active scenario). The navigation editor SHALL be able to insert a picker.
Scenario: Pick a page
- WHEN the user presses
pon a picker sub-tab, typesfiland choosesfills - THEN the sub-tab SHALL render
fills, and the TUI SHALL renderfillsthere after a restart
Requirement: Marking on Every Table
Every page whose table takes bulk actions (operator-clients Bulk Actions per View) SHALL mark rows like Workers: space marks the cursor row (and moves down), b marks every row the filter shows (again: unmarks them), m opens the action menu titled with the count, a mark shows as ✓ before the row's first cell, and the status line says how many are marked. While several rows are marked, a one-row key (Enter, detail, tag) SHALL refuse and say to unmark the others.
Scenario: Space marks on the Scenario page
- WHEN the user presses
spaceon the Scenario page - THEN the cursor scenario SHALL be marked; Pause or Resume SHALL be
P
Scenario: Marked feeds, then Connect
- WHEN the user marks two feed definitions, presses
mand picks Connect - THEN the TUI SHALL connect both as one bulk run (operator-clients Bulk Row Actions) and report each
Scenario: Enter with several marked
- WHEN two triggers are marked and the user presses
Enter - THEN the TUI SHALL open nothing and say the key acts on one row: unmark the others
Requirement: Config Entries in the TUI
The TUI SHALL keep personal variables in ~/.config/virtufin/tui/env.toml and personal secrets in ~/.config/virtufin/tui/secrets.toml (owner read and write only), and the secret patterns in config.toml ([secrets] patterns). Its Environment variables and Secrets pages SHALL offer a add, e edit, d delete (marked rows in bulk), i import a .env file, and a switch between Personal and Platform.
Scenario: Import on the Secrets page
- WHEN the user presses
ion the Secrets page and picks a.envfile - THEN the import preview SHALL list the matching names, and confirming SHALL write
secrets.toml
Requirement: Contexts Import in the TUI
The TUI's Contexts page SHALL list the contexts of ~/.config/virtufin/api/contexts.toml, switch on Enter, and import a TOML file with i into that file, keeping its comments and layout, owner read and write only.
Scenario: A new context
- WHEN an imported file adds
staging - THEN
contexts.tomlSHALL holdstagingafter the existing entries, its comments unchanged
Requirement: Script Forms in the TUI
The TUI SHALL read a script's <name>.form.json as the shared script-form format (operations, Script Form Format), converted to textual_jsonforms' FormConfig with its checks, and SHALL pass the values, typed as the schema says, as JSON in VIRTUFIN_TUI_FORM_DATA. n SHALL start a new script from the template; e SHALL switch between the form and the code.
Scenario: The shared format
- WHEN a script's
.form.jsonis a form the web app accepts - THEN the TUI SHALL draw the same fields with the same checks and pass the same values
Requirement: Infra Panes
The TUI's Infra panes SHALL implement the operator-clients requirements (this spec says only how the terminal binds them): workers Worker Operations and Worker Registry, connections Connection Operations, triggers Trigger Operations, states State Browser, events Live Events and eventstores EventStore Status. Where the shared requirement and a binding here disagree, the shared one SHALL win (Clients and Bindings).
Scenario: A shared rule changes
- WHEN operator-clients changes what a view does (a new column, another confirmation)
- THEN the TUI SHALL follow it without a change to this spec, unless a key, a dialog or a file of the TUI changes
Requirement: Trading Panes
The TUI's Trading panes SHALL implement the shared requirements: feeds feed-definitions; scenario Scenario Operations; strategy Strategy Operations; instruments, orderbook and indicators Topic Catalog, Instruments, Order Book and Indicators; portfolio, pnl and risk Portfolio, and P&L and Risk; compare Scenario Comparison. Every pane SHALL follow Kill Switch, Tables and Kept Subscriptions.
Scenario: A composite with a cycle
- WHEN the user composes strategy
BofAon the Strategy pane whileAis composed ofB - THEN the TUI SHALL refuse it, naming the cycle, as Strategy Operations says, and write nothing
Requirement: Workers Pane
The Workers pane is the TUI's binding of operator-clients Worker Operations. It SHALL offer every worker operation by keyboard: the detail as a popover, deletion behind a confirmation modal, the tag undo as Ctrl+Z, and actions on the marked workers (b marks every worker the filter shows) or else the selected one. The Connections pane SHALL do the same for stopping publishing and disconnecting.
Scenario: Upgrade dialog
- WHEN the user upgrades a worker of a registry package
- THEN the dialog SHALL preselect the newest version and say what an upgrade keeps and restarts (a running worker restarts with the new code)
- AND the pane SHALL say how many workers have a newer version, and
uon marked workers SHALL upgrade each to the latest
Scenario: Stop everything a filter shows
- WHEN the user filters the workers by
tag:world=act, pressesbto mark every worker shown, opens the action menu and picks Stop - THEN the TUI SHALL stop every marked worker and report each one's result, as Worker Operations says for many workers
Scenario: Workers sorted and filtered
- WHEN the user presses
oon the Workers or Connections table, or clicks a column header - THEN the rows SHALL be sorted by the picked column (
[/], else the first), again reversed, as operator-clients Tables says - AND
/SHALL filter the Connections pane too, with the value-presentation Worker Filter over each feed (sourceits URL,topicits publish topic)
Requirement: Connections Pane
The TUI SHALL implement the operator-clients Connection Operations; this requirement is its terminal binding. The Connections pane SHALL draw each feed's recent p50 latency as a sparkline next to the latest p50/p90, and give the clock-skew reason in the connection's detail. Beyond the shared operations the TUI SHALL send a raw message to a feed (InvokeWorkerCommand(worker_id, "send", payload)).
Scenario: The state column
- WHEN the Connections pane lists a connection
- THEN its state column SHALL show the table's single-width glyph in the color of its tone, the connection's detail SHALL name the state, and the pane's help SHALL list every glyph with its state
Scenario: Send a raw message
- WHEN the user sends a message to a connection
- THEN the TUI SHALL call
InvokeWorkerCommand(worker_id, "send", payload)with the message as the payload
Scenario: A feed of a definition
- WHEN a connection is a member of a feed definition's feed group
- THEN it SHALL be disconnected from the Feeds pane, which deletes the definition's feed group
Requirement: Pushed Data in the TUI
The TUI SHALL implement the operator-clients Pushed Data, Not Polling and Kept Subscriptions; this requirement is its terminal binding. Its subscriptions SHALL be gRPC server streams (Pubsub.Subscribe, grpc.health.v1.Health/Watch), and it SHALL have no refresh key.
Scenario: Context liveness
- WHEN contexts are configured and one is active
- THEN each context's reachability SHALL come from one
grpc.health.v1.Health/Watchstream on its own channel with HTTP/2 keepalive - AND the API key check SHALL be one keyed call each time a context comes up (health checks need none)
Scenario: Registries
- WHEN the TUI saves or deletes a
cfg.feed,cfg.scenarioorcfg.strategyentry - THEN it SHALL announce the change (
publish_change), and the Feeds, Scenario and Strategy panes SHALL reload on those state-change events instead of on a timer
Requirement: Error Notices in the TUI
The TUI SHALL implement the operator-clients Error Reporting; this requirement is its terminal binding: the error notice is a Textual notification, the details go to the TUI's log file, and a pane's stale note is in its status line.
Scenario: A failed compose
- WHEN composing a strategy fails
- THEN the TUI SHALL show one notification
Compose failed: <reason>and keep the Strategy pane's rows
Requirement: Events Pane
The TUI SHALL implement the operator-clients Live Events in its Events pane; this requirement is its terminal binding. The subscribed topics SHALL be the context's event_topics from contexts.toml, changed on the Events pane and kept in the TUI's state; an event SHALL be pretty-printed in the log (type, source, id, topic, time and the decoded payload).
Scenario: Change subscribed topics
- WHEN the user adds or removes topics via the events page
- THEN the TUI SHALL restart the subscription immediately with the new topic set
- AND SHALL persist the new topic set to TUI state
Scenario: Reconnect
- WHEN the subscription drops
- THEN the Events pane SHALL show the backoff status (Kept Subscriptions) and keep its log
Requirement: Worker Registry in the TUI
This is the TUI's binding of operator-clients Worker Registry. The registry SHALL be the shipped copy with the user's ~/.config/virtufin/tui/workers.toml merged over it. A personal credential SHALL resolve from ~/.config/virtufin/tui/credentials.toml as a SourceCredential (basic/bearer). The new-worker flow SHALL also take inline code and a relative file.
Scenario: A personal credential
- WHEN an entry's
authenticationisgithubandcredentials.tomlhas agithubentry - THEN the TUI SHALL send the code source with that credential, and without the entry SHALL say it is missing and create nothing
Scenario: Inline code
- WHEN the user creates a worker from inline code
- THEN the TUI SHALL send it base64-encoded in
code_source
Requirement: Portfolio, P&L and Risk in the TUI
The portfolio, pnl and risk panes SHALL implement operator-clients Portfolio and P&L and Risk; this requirement is their terminal binding. Zero balances SHALL be shown with a toggle, a breached Risk row SHALL be red, and l on the Risk pane SHALL set the scenario's limits; editing the scenario SHALL keep them.
Scenario: Set a limit
- WHEN the user presses
lon the Risk pane and clears the gross limit - THEN the TUI SHALL save the scenario's registry entry without that limit, through the write gate
Requirement: Order Book in the TUI
The orderbook pane SHALL implement operator-clients Order Book; this requirement is its terminal binding. It SHALL show the chosen book as orderbook.ladder, drawn as the States and Events views draw it: the TUI SHALL draw the bars with block characters (eighths of a cell), asks red and bids green.
Scenario: The pane and the views draw one ladder
- WHEN the same book is shown in the Order book pane and as
orderbook.ladderin the Events pane - THEN both SHALL show the same levels with the same bars
Requirement: Script Operations in the TUI
Scripts SHALL call operations (Reflected Operations included) through vf: await vf.<name>(input) SHALL run the catalog operation of that name, else the reflected <service>.<Method>, in the TUI with its own client, so a write passes its write gate and change log, and a declined write SHALL raise vf.OperationFailed. A stream SHALL be iterated with async for, cancelled when the loop is left.
Scenario: A read
- WHEN a script awaits
vf.workmanager.ListWorkers({}) - THEN the TUI SHALL run it through
Gateway.InvokeJsonwithout asking, and the script SHALL get the workers
Scenario: A declined write
- WHEN a script calls a reflected write on a protected context and the user says no
- THEN nothing SHALL be sent and the script SHALL get
vf.OperationFailed
Requirement: Reflected Operations on the Scripts Pane
Below the script list, the Scripts pane SHALL list the catalog operations and, collapsed under "From reflection", the reflected methods by service, each marked read, write or stream; the methods SHALL be read when the group is first opened and again after a context switch, and opening one SHALL read its input fields once.
Scenario: Open the group
- WHEN the user opens "From reflection" on a context whose gateway lists
workmanager - THEN the pane SHALL list
workmanager's methods,ListWorkersmarked read
Requirement: Compare in the TUI
The compare pane SHALL implement operator-clients Scenario Comparison, P&L and Positions Compared, Market Compared and Decisions Compared; this requirement is its terminal binding. Two pickers at the top SHALL choose the first and the second scenario, s SHALL swap them, and the pair SHALL be kept in the TUI's state file.
Scenario: Swap the pair
- WHEN the pane compares
LIVEwithPAPERand the user pressess - THEN it SHALL compare
PAPERwithLIVE, every difference with the opposite sign, and keep that pair
Requirement: Compare Sections in the TUI
The compare pane SHALL show its three sections, P&L, Market and Decisions, one at a time; tab and shift+tab SHALL switch between them, and the shown section SHALL be kept with the pair. A positive difference SHALL be green, a negative one red, and a divergence yellow. In Market, a SHALL add a symbol to compare and d remove one added. The match window SHALL be the compare_match_window_seconds setting of the TUI's config.toml.
Scenario: Switch section
- WHEN the P&L section is shown and the user presses
tab - THEN the pane SHALL show the Market section and keep it for the next start
Requirement: Users View in the TUI
Until the TUI signs its users in (access-control), it cannot tell whether a user is an admin. It SHALL therefore not show a navigation node naming users, and SHALL show no placeholder for it.
Scenario: The default structure
- WHEN the TUI shows the built-in default navigation
- THEN Config SHALL list no Users entry
Requirement: Topology Pane
The TUI SHALL implement the Topology view as a tree pane under Infra; this requirement is its terminal binding. - Rows: groups by parent, members marked shared where they belong to several groups, a worker expanding to its input and output topic families. - Health: each row shows its health level and, for a group, its counts per level.
Scenario: Expand a group
- WHEN the user expands group
momentum-btc - THEN the pane SHALL list its child groups, then its workers and triggers, each with its health level
Requirement: Item Tables in the TUI
The TUI SHALL implement operator-clients Table Columns and Row Detail in its panes:
- each item pane SHALL order its columns as Table Columns says;
- the Status column SHALL show the status symbol table's single-width glyph in its tone's color;
- the row's detail SHALL name the status, and the pane's help SHALL list the glyphs it shows;
- Enter on the cursor row SHALL open the row's detail where the pane has one.
Scenario: The Workers pane
- WHEN the Workers pane lists workers
- THEN its columns SHALL start with Name and the status glyph, and end with Groups, Tags and ID
Scenario: Enter on a trigger
- WHEN the user presses
Enteron a trigger's row - THEN the trigger's detail SHALL open