Skip to content

Surface resolution: unknown ids are not_found; explicit workspace beats env surface id (#148) - #163

Merged
arzafran merged 3 commits into
mainfrom
fix/148-surface-not-found
Jul 21, 2026
Merged

Surface resolution: unknown ids are not_found; explicit workspace beats env surface id (#148)#163
arzafran merged 3 commits into
mainfrom
fix/148-surface-not-found

Conversation

@arzafran

Copy link
Copy Markdown
Member

What this does

programa send with a stale surface id from another app instance now fails with a truthful not_found instead of the misleading "Surface is not a terminal" — and when a workspace is explicitly targeted, a stale env PROGRAMA_SURFACE_ID no longer hijacks the target at all.

Closes #148. Follow-up for notify's differently-shaped copy of the bug: #162.

Summary

  • Review order: Sources/TerminalController+Surface.swift (4 handlers split existence-check from type-check, mirroring v2SurfaceFocus/v2SurfaceClose), then CLI/programa.swift (env surface fallback in send/send-key/read-screen suppressed when any workspace target resolved; explicit --surface still wins)
  • Two-commit red/green structure: commit 1 is the failing test, commit 2 the fix — verified locally against a tagged build (red: invalid_params, green: pass); commit 3 adds the test to the new tests_v2 CI subset from CI: run curated tests_v2 socket subset on PRs (#145) #161

Test Plan

  • Tagged-build run: test fails without fix, passes with it
  • Full app scheme builds
  • tests-v2-subset job green on this PR

arzafran added 3 commits July 21, 2026 15:06
Red half of the two-commit structure for #148: surface.send_text with a
surface UUID unknown to this instance (alone, or alongside a valid
workspace_id) currently mis-resolves to 'invalid_params: Surface is not
a terminal'. Verified failing against a tagged build without the fix.
…ts env surface id

App side: v2SurfaceSendText/SendKey/ClearHistory/ReadText now check
ws.panels membership before the TerminalPanel type-cast, mirroring
v2SurfaceFocus/v2SurfaceClose — an unknown UUID gets not_found instead
of the misleading 'Surface is not a terminal'.

CLI side: the PROGRAMA_SURFACE_ID env fallback in send, send-key, and
read-screen is suppressed whenever a workspace target resolved (flag or
PROGRAMA_WORKSPACE_ID env), so a stale surface id inherited from another
app instance can no longer override an explicit workspace. An explicit
--surface flag still always wins.

Closes #148
@arzafran
arzafran merged commit b5daaa8 into main Jul 21, 2026
@arzafran
arzafran deleted the fix/148-surface-not-found branch July 21, 2026 18:07
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.

Unknown PROGRAMA_SURFACE_ID resolves to 'Surface is not a terminal' instead of not_found

1 participant