Skip to content

Session Commands

Control a running VisiGrid GUI from the terminal. Inspect cells, apply changes, and watch state evolve — all from scripts or the command line.

The session server runs on TCP localhost with token auth. Protocol v1 is frozen — wire format locked by golden vectors.

List running VisiGrid sessions.

Terminal window
vgrid sessions [options]
OptionDescription
--jsonOutput as JSON array
Terminal window
# List all sessions
vgrid sessions
# Get session ID for scripting
SESSION=$(vgrid sessions --json | jq -r '.[0].session_id')

Attach to a session (interactive mode). Useful for debugging and exploration.

Terminal window
vgrid attach [options]
OptionDescription
--sessionSession ID (auto-discovers if only one)

Inspect cells, ranges, or workbook metadata from a running session.

Terminal window
vgrid inspect <target> [options]
OptionDescription
--sessionSession ID
--sheetSheet index, 0-based (default: 0)
--jsonOutput as JSON

Targets:

  • A1 — single cell (value, formula, format)
  • A1:D10 — range (values only)
  • workbook — revision, sheet count, dirty state
Terminal window
# Inspect a cell
vgrid inspect A1
# -> A1 = 1234.56 (number)
# Inspect a range on sheet 1
vgrid inspect A1:B10 --sheet 1
# Get workbook revision for conditional apply
REV=$(vgrid inspect workbook --json | jq '.revision')

Apply operations to a running session. Reads JSON Lines from stdin or file.

Terminal window
vgrid apply <file> [options]
OptionDescription
--sessionSession ID
--atomicAll-or-nothing apply (rollback on any failure)
--expected-revisionFail if current revision doesn’t match
--waitRetry on conflict (requires --atomic or --expected-revision)
--wait-timeoutMax wait time in seconds (default: 30)

Safety: --wait requires either --atomic or --expected-revision to prevent unbounded retries without idempotency protection.

Terminal window
# Apply operations atomically
cat ops.jsonl | vgrid apply -
# Conditional apply with revision check
vgrid apply ops.jsonl --atomic --expected-revision $REV --wait
# Custom timeout
vgrid apply ops.jsonl --atomic --wait --wait-timeout 60
# Operation format (JSON Lines)
{"op": "set", "cell": "A1", "value": "Hello"}
{"op": "set", "cell": "B1", "formula": "=A1 & \" World\""}

The --wait flag enables adaptive retry with exponential backoff and jitter. The server may return retry_after_ms hints which the client respects.

Query server health and metrics.

Terminal window
vgrid stats [options]
OptionDescription
--sessionSession ID
--jsonOutput as JSON
Terminal window
vgrid stats
# -> uptime: 3h 42m | connections: 2 | ops: 1,247 | revision: 89

View a read-only snapshot of the grid from a running session.

Terminal window
vgrid view [options]
OptionDescription
--sessionSession ID
--rangeRange to display (default: A1:J20)
--sheetSheet index, 0-based (default: 0)
--widthColumn width for display (default: 12)
--followFollow mode: refresh on changes (poll every 500ms)
Terminal window
# View current grid state
vgrid view
# View specific range
vgrid view --range A1:D10
# View a different sheet with wider columns
vgrid view --sheet 1 --width 20
# Watch for changes in real time
vgrid view --follow

Output is an ASCII table with column headers and row numbers. Wide values are truncated with ...

CodeMeaning
20Cannot connect (no server, connection refused)
21Protocol error (version mismatch, malformed message)
22Authentication failed
23Write conflict or revision mismatch
24Partial apply (non-atomic had rejections)
25Invalid input (bad op schema)
26Operation timed out
Terminal window
# Get session
SESSION=$(vgrid sessions --json | jq -r '.[0].session_id')
# Inspect current state
REV=$(vgrid inspect workbook --json | jq '.revision')
# Apply changes with revision check
vgrid apply ops.jsonl --atomic --expected-revision $REV --wait
# Verify new state
vgrid view --range A1:D10