Skip to content

feat(api): accept short ID refs in socket commands#174

Merged
Jesssullivan merged 3 commits intomainfrom
sid/m7-short-id-refs
Apr 4, 2026
Merged

feat(api): accept short ID refs in socket commands#174
Jesssullivan merged 3 commits intomainfrom
sid/m7-short-id-refs

Conversation

@Jesssullivan
Copy link
Copy Markdown
Owner

Summary

P0 refactoring: adds kind:N short ID ref support to all socket commands.

  • parseRef() parses workspace:0, surface:1, pane:2, window:0 syntax
  • 22 handler call sites updated to accept both UUID hex and short refs
  • findSurfaceGlobal, findSurfaceInWorkspace, findWindowByRef — new ref-aware lookup functions
  • List responses now include short_id field (e.g., "short_id":"surface:0")
  • Surfaces/panes resolve by ordinal within selected workspace's ordered_panels

Examples

cmux workspace.select '{"workspace_id":"workspace:0"}'
cmux surface.focus '{"surface_id":"surface:1"}'
cmux pane.focus '{"pane_id":"pane:0"}'

Closes #158, closes #159

Test plan

  • Linux CI builds pass (Zig compilation + Nix checks)
  • Socket test suite passes on honey runner
  • workspace.list returns short_id field
  • surface.focus accepts surface:N syntax

Add parseRef() for 'kind:N' syntax (workspace:0, surface:1, pane:2,
window:0). Update all 22 handler call sites to accept both UUID hex
strings and short refs. Surfaces/panes resolve against ordered_panels
of the selected workspace.

List responses (workspace.list, surface.list, pane.list, window.list)
now include a short_id field for round-trip usage.

Closes #158, closes #159
@Jesssullivan Jesssullivan added this to the M7: API Modernization milestone Apr 4, 2026
@Jesssullivan Jesssullivan added enhancement New feature or request zig-lib refactoring P0 API modernization labels Apr 4, 2026
Replace client-side index→UUID resolution in _resolve_workspace_id,
_resolve_surface_id, _resolve_pane_id with direct short ref
construction (e.g., int 0 → 'workspace:0'). Backend now handles
resolution server-side via parseRef().

Closes #161
Use resolved_id: ?u128 instead of anonymous struct to avoid
type mismatch with findSurfaceGlobal return type.
@Jesssullivan Jesssullivan merged commit 4b029e6 into main Apr 4, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request refactoring P0 API modernization zig-lib

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include short_id field in list response payloads Accept short ID refs (surface:N, pane:N) in socket commands

1 participant