cmux NEXT: the app pushes an MDM-forced sessions.allowFullAccess, and the mode menu says Managed by your organization (#23322 a2)

Merged
TE
1mo ago
+711-20

What (part a2 of #23322)

This is part a2 of #23322 (sessions.allowFullAccess under MDM), split out from that PR's restructure. It covers the app's push and the mode menu. #23322 (a1, landed) is the daemon's bound. #25538 (a3, approve-all), #25539 (b, agents already running in full access) and #25549 (a4, probes and the pool) follow a1. Each part lands on its own: this one only adds fields that an older daemon ignores, and reads a field an older daemon never sends.

It builds the decision on #23322, quoted word for word:

"#23322 (sessions.allowFullAccess under MDM), decided: an MDM-managed value is an upper bound the user can't override. If MDM sets allowFullAccess=false, Full access is unavailable and the mode menu says "Managed by your organization". If MDM is unset, nothing changes. This only narrows access, so it needs no call from Leo."

The app tells acpmux what MDM forces (CmuxNextSettings/ChatSettings.swift). The _acpmux/chat_settings push adds two fields:

  • allowFullAccessManaged: whether MDM or the team policy forces the key.
  • allowFullAccess: the forced value. Anything but true counts as false, and the field is null when nothing forces it.

settings-schema.sources.sha256 is regenerated for the changed source.

The pane (webviews/.../startMode.ts, ComposerPickers.tsx, direct.ts):

  • It keeps one pane-wide flag from every _acpmux/start_mode answer: "fullAccess": "managed", which a1's daemon sends. An answer without the field (MDM unset, an older daemon) clears the flag.
  • While the flag is set, each full-access row in the mode menu is disabled and captioned "Managed by your organization". This is the new key picker.fullAccessManaged, in all locales.
  • A chat already shown learns the flag once per generation (a connect, start_mode_changed, a pick) through useFullAccessProbe. That is one ask per push, not a timer or a loop. Its microtask checks a live flag, which the effect's cleanup clears.
  • Each ask takes a ticket, and only the newest ask's answer counts. An older answer changes nothing, even when the newer ask failed. This was finding 6 in the review rounds.
  • The mark belongs to one connection (review 28): setStartModeSource (a reconnect, another daemon) takes a new ticket and clears the mark before it tells the pane, so a late answer from the old connection changes nothing. A daemon that predates _acpmux/start_mode answers method-not-found (-32601); direct.ts then clears the mark, instead of keeping what the previous daemon said. Any other refusal (invalid params, an unknown harness) comes from a daemon that may still manage full access, so the mark stays (review 34).
  • An ask that failed (the host refused to relay it, the socket closed) said nothing about full access either: it gives its generation back, and a shown local chat's probe asks once more. A probe's own failure starts no retry, so it never loops (review 42). An ask acpmux answered with a refusal (an unavailable harness) is treated the same way: its answer carried no full-access field, so the probe asks once more (review 45).
  • A harness that offers full access only as a config option (the Options chip, no declared modes) is covered too: a shown local chat probes for the mark, and the full-access choice in the Options menu is disabled and captioned the same way (review 48). A managed full-access row, the current one included, keeps the mode menu from collapsing into a plain label (review 48).
  • The mark is this Mac's daemon's (review 37): it bounds only the chats that daemon runs. A peer's, a remote host's or a cloud chat shown in the same pane keeps its own full-access rows.
  • Managed outranks an earlier refusal (review 34): a full-access row the agent refused before MDM turned it off is captioned "Managed by your organization", not the refusal. In a two-row menu (Manual and Bypass), a refused Bypass no longer collapses the chip into a plain label while managed: the row stays, disabled and captioned (review 37).

Tests

  • webviews/test/access-chip-refused-mode.test.tsx, four new tests:
    • a managed answer disables the full-access row, shows the caption, and the row can't be picked;
    • an answer without the field leaves full access as it was;
    • an older answer that arrives after a newer ask failed changes nothing;
    • an older answer that arrives after a newer one changes nothing.
    • Red at be3e1eb3bc (run 40362509713 on f69e8c73c6, the same tree: 3 of 6 fail). Green at 2476da51aa (run 40362509661 on e8c7ff2bca, the same tree: 6 of 6 pass, tsc clean).
  • Review 28, two more tests in the same file: "a daemon that predates start_mode clears what the previous daemon said" and "a new connection forgets the managed mark, and a late answer from the old one changes nothing". Red at 43010108cd (run 40375707624: both fail). Green at d3488501ca (run 40379261183: access-chip-refused-mode and start-mode-host-refusal 10/10, typecheck clean with no warnings).
  • Review 34, two more tests in the same file: "a refusal other than method-not-found keeps the managed mark" and "a full-access pick the agent refused says managed once full access is managed off". Red at 9b598318c8 (run 40385874180: both fail, 10 pass). Green at ac88294cad (run 40385969757: 12/12; typecheck run 40385969747: no type errors).
  • Review 37: "the managed mark is this Mac's: a peer's or another host's chat keeps its full access" is new, and the review 34 refusal test now uses the original two-row menu. Red at b6dc588625 (run 40387546785: both fail, 11 pass). Green at 9e04ba0663 (run 40387606734: 13/13; typecheck run 40387607022: no type errors).
  • Review 42: "an ask the host refused does not stop a shown chat from learning the managed mark". Red at ee406327ea (run 40397254097: the shown chat never asked again, 13 pass). Green at eb196fd2a0 (run 40397428630: 14/14; typecheck run 40397428407 clean; run 40397428561: ten nearby suites, from agent-pane-start-mode-chip to composer-row-layout, all pass).
  • Review 45: the review 42 test now runs twice, for a host's refusal and for a daemon's own -32602 refusal. Red at 985fee54c8 (run 40402638690: the daemon-refusal case fails, the chat never asked again; 14 pass). Green at 213d6e0d56 (run 40402736097: 15/15; typecheck run 40402736434 clean; run 40402736204: the same ten nearby suites all pass).
  • Review 48: "a full-access choice a chat offers only as a config option is managed too" and "a chat in full access whose narrower mode was refused keeps its menu once managed". Red at c340aa74ae (run 40404615455: both fail, 22 pass). Green at b59f236e24 (run 40404705034: access-chip-refused-mode, agent-options-menu and start-mode-host-refusal 24/24; typecheck run 40404705142 clean; twelve nearby suites pass).
  • Review 110: a peer's chat comes over this Mac's own connection, and the attach's detail names no peer, so the managed mark could disable a peer's full-access rows. onThisMac now also needs no peer on the chat's summary or its listed row. The review 37 test gains two cases (local origin with a summary's peer, and with only a listed row's peer). Red at 53a2592129 (run 40459751233: that test fails, 14 pass). Green at d73eee5d47 (run 40459962162: 24/24; typecheck run 40459962521 clean; vp fmt --check run 40459962140 clean). e7266e588d before it only formats the test file (vp fmt), which the fast gates' web lint asked for.
  • CmuxNextAppTests ChatSettingsPushFullAccessTests:
    • an MDM off goes out managed over the file;
    • the team policy's enforced off goes out managed;
    • a forced value that is not true goes out off;
    • with MDM unset nothing is forced.
    • Fleet runs (cmux-ci run ... package-test-lane.sh suite Packages/macOS/CmuxNext ChatSettingsPushFullAccessTests): red at be3e1eb3bc (step 3365633fa314f4f4795353cc: 4 tests, 12 issues, the push carries neither key), green at 2476da51aa (step 429ae48431421ed127d44396: 4/4).

Visual evidence

The changed state is the mode menu's full-access row, disabled and captioned "Managed by your organization". It is the new gallery variant permission-managed; the base menu is the unchanged permission variant. The gallery visual evidence run on this PR shows both states before and after.

Gallery: agent-pane.composer-pickers/permission-managed, agent-pane.composer-pickers/permission

Review: a fresh Codex gpt-6-astra xhigh review said SHIP at d73eee5d47d02e1482c5573d3bf5beef91fce0ab.

No capture: the only native file is ChatSettings.swift, which adds two fields to the settings push and draws nothing.

Agent session: agent session

šŸ¤– Generated with Claude Code