Repository navigation
linux(socket): add surface.report_tty (Sprint A #8) - #224
Conversation
Greptile SummaryImplements the Linux-side Confidence Score: 5/5Safe to merge; implementation is correct and all remaining findings are P2 style notes already captured in prior review threads. Core logic faithfully mirrors the established handleSurfaceSendText pattern. Allocation/update/response flow is correct, no new P0 or P1 issues found. The two substantive concerns (defer inconsistency, misleading error message) and the missing surface_id-only test were all raised in previous threads. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant C as Caller (CLI/Python)
participant S as socket.zig dispatcher
participant H as handleSurfaceReportTty
participant TM as TabManager
participant WS as Workspace
participant P as Panel
C->>S: surface.report_tty {workspace_id?, surface_id?, tty_name}
S->>H: dispatch(alloc, params)
alt workspace_id provided
H->>TM: findWorkspaceById(workspace_id)
TM-->>H: WorkspaceLookup
else surface_id only
H->>TM: findSurfaceGlobal(surface_id)
TM-->>H: {id, ws}
else neither
H->>TM: selectedWorkspace()
TM-->>H: *Workspace
end
alt surface_id provided + workspace known
H->>WS: findSurfaceInWorkspace(surface_id)
WS-->>H: target_id (u128)
else surface_id only (no workspace_id)
H->>TM: findSurfaceGlobal(surface_id) [2nd call]
TM-->>H: found.id
else no surface_id
H->>WS: focused_panel_id
WS-->>H: target_id (u128)
end
H->>H: trim(tty_name), reject if empty
H->>WS: panels.getPtr(target_id)
WS-->>H: **Panel
H->>WS: ws.alloc.dupe(tty_name) to new_tty
H->>P: free old tty_name, set tty_name = new_tty
H->>H: build JSON response
H-->>C: {workspace_id, surface_id, tty_name}
Reviews (2): Last reviewed commit: "linux(socket): add surface.report_tty re..." | Re-trigger Greptile |
Implements the v2 surface.report_tty RPC on Linux. Mirrors the
workspace_id/surface_id resolution pattern from handleSurfaceSendText so
callers may omit either or both ids. Trims surrounding whitespace and
rejects empty tty_name. The handler stores the TTY name onto
Panel.tty_name using the alloc-then-free pattern (avoids dangling on
allocation failure) and echoes {workspace_id, surface_id, tty_name}.
The Linux build does not yet have a PortScanner / remote workspace
plumbing equivalent to macOS, so this is metadata-only — the value is
recorded and visible to subsequent surface.list / pane.list responses
that may want to surface it, but no port scan is triggered.
Adds tests_v2/test_surface_report_tty.py covering: default surface
fallback, explicit surface_id targeting, whitespace trimming, missing /
empty / whitespace-only tty_name errors, and invalid workspace/surface
id errors.
Refs #220 (Sprint A item #8).
eb6c7a6 to
7105bbc
Compare
Summary
Implements the v2
surface.report_ttyRPC on Linux. Mirrors theworkspace_id/surface_idresolution pattern fromhandleSurfaceSendTextso callers may omit either or both ids. Trims surrounding whitespace and
rejects empty
tty_name. Stores the TTY name ontoPanel.tty_nameusingthe allocate-then-free pattern (avoids dangling on allocation failure)
and echoes
{workspace_id, surface_id, tty_name}.The Linux build does not yet have a PortScanner / remote workspace
plumbing equivalent to macOS, so this is metadata-only — the value is
recorded and visible to subsequent
surface.list/pane.listresponsesthat may want to surface it, but no port scan is triggered.
What's added
cmux-linux/src/socket.zig:.{ "surface.report_tty", handleSurfaceReportTty }dispatch entry +handleSurfaceReportTty(~50 LOC), placed next tohandleSurfaceClearHistory.tests_v2/test_surface_report_tty.py: round-trip test coveringsurface_id)surface_idtargetingtty_nameerrorsworkspace_id/surface_iderrorsLinux vs macOS shape
macOS returns
{workspace_id, workspace_ref, surface_id, surface_ref, tty_name, [pending]}.Linux returns the same
{workspace_id, surface_id, tty_name}core triplethat other Linux v2 surface handlers already return —
_refand thependingremote-workspace flag are intentionally omitted because theyhave no Linux equivalent yet. Tests assert the Linux shape.
Test plan
nix develop --command bash -c 'cd cmux-linux && zig build -Doptimize=ReleaseFast'Refs #220 (Sprint A item #8).