Skip to content

feat(cli): add coder exp sync graph command#27162

Draft
SasSwart wants to merge 1 commit into
sas/script-order-deps-on-timelinefrom
sas/sync-graph
Draft

feat(cli): add coder exp sync graph command#27162
SasSwart wants to merge 1 commit into
sas/script-order-deps-on-timelinefrom
sas/sync-graph

Conversation

@SasSwart

Copy link
Copy Markdown
Contributor

Summary

Adds a coder exp sync graph command that renders the unit dependency graph: vertices are units and edges are declared dependencies. The graph is folded client-side from the existing SyncTimeline event log, so no proto or agent changes are required, it is one RPC.

This is the new tip of the sync stack, based on #27160.

Output formats

Four formats via the shared cliui output formatter (--output, default text):

Format Description
text (default) Colorized ASCII summary of units and dependencies. Status markers are colored by state (completed green, started yellow, pending gray); satisfied/unsatisfied edges are marked with /.
json Raw graph model (nodes + edges).
table Flat per-unit listing with dependencies collapsed into a column.
dot Graphviz DOT with status-colored fill, pipeable to dot.

Color is applied only in the ASCII renderer and resolves to a colorless profile in tests and on non-TTY output, so golden files stay stable with no gating.

Example (text)

Units:
  ● app      pending
  ● db       completed
  ● migrate  started
  ● cache    pending (ready)

Dependencies:
  app → db  (requires completed) ✓
  app → migrate  (requires completed) ✗
  cache → db  (requires completed) ✓

Tests

  • cli/sync_graph_internal_test.go: unit tests for graph folding (node ordering, edge satisfaction, readiness) and each renderer.
  • Golden subtests in cli/sync_test.go covering empty, ascii, json, table, and dot, driven through the agent socket.
  • Regenerated command-help goldens.
Design notes
  • The model is built by folding client.SyncTimeline(ctx) events: status_change sets a unit's status and creates its node in first-seen order; dependency_added creates an edge and ensures both endpoints exist. After folding, an edge is satisfied when the target's current status equals the required status, and a node is ready when it is pending and all of its edges are satisfied (mirrors the Manager's readiness semantics).
  • The dot format is a small custom cliui.OutputFormat implementation rather than a ChangeFormatterData(TextFormat(), ...) wrapper, because DataChangeFormat.ID() delegates to the wrapped format and would collide with the text format ID.
  • Older agents that predate the SyncTimeline RPC return a clear "agent does not support graph" error, matching the timeline command's behavior.

Generated by Coder Agents on behalf of @SasSwart.

Add a `coder exp sync graph` command that renders the unit dependency
graph. Vertices are units and edges are declared dependencies. The graph
is folded client-side from the existing SyncTimeline event log, so no
proto or agent changes are required.

Four output formats are supported via the shared output formatter:

- text (default): a colorized ASCII summary of units and dependencies.
  Unit status markers are colored by state (completed green, started
  yellow, pending gray) and satisfied edges are marked distinctly.
- json: the raw graph model (nodes and edges).
- table: a flat per-unit listing with dependencies collapsed into a
  column.
- dot: Graphviz DOT with status-colored fill, pipeable to `dot`.

Color is applied only in the ASCII renderer and resolves to a colorless
profile in tests and on non-TTY output, keeping golden files stable.

Generated by Coder Agents on behalf of @SasSwart.
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