fix(cmux CLI): a list that lacks the window's workspace reads the window again with the barrier (#32201 follow-up)

Merged
LA
4d ago
+100-13

Summary

Follow-up to #32201 (CLI-1: workspace list reads the app window without the app's read barrier). #32201 merged at its first reviewed head (8185ff03), before this fix for that review's Medium finding (https://github.com/manaflow-ai/cmux/pull/32201#issuecomment-6576122764) reached it.

The gap: cmux workspace close <the workspace the window shows>; cmux workspace list. The app's last published snapshot, which #32201 reads with after: 0, can still show the closed workspace. The overlay then marks every row unfocused until the app publishes again.

Fix: when a workspace list of the app's session lacks the workspace the app's window shows, the snapshot is older than the daemon's answer, so the overlay reads the window once more with after: "sync". Every other list keeps the single fast read. app_workspaces takes the barrier; the with_read_barrier doc names a caller-chosen after.

Owner: the cmux CLI (cmux-tui/crates/cmux-tui).

Changelog

none

Testing

Regression test: a_list_without_the_window_s_workspace_reads_the_window_again_with_the_barrier (cmux-tui, cli/app_focus/tests.rs): a fake app answers after: 0 with the pre-close window and after: "sync" with the post-close window; the list must read twice and take focused from the second read.

Observed / Not run

Observed: the red and green steps above. Not run: an app round with a close then a list under load.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Fixes the workspace close <shown> then workspace list case where the overlay marked every row unfocused because the app's last published snapshot still showed the closed workspace. When a list of the app's session lacks the workspace the window shows, the overlay now reads the window once more with after: "sync"; every other list keeps the single fast read, and the read barrier's doc now notes the caller-chosen after.