Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(canvas): arrange's flag refusals run on the desktop too

Fabricio Casalie23cc47fa822
diff --git a/CLAUDE.md b/CLAUDE.md
index 11acd001f..ba99ee516 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -4091,7 +4091,10 @@ command-bearing opens; this does not add a human-confirm dialog or change mobile
instead of listing its children: the frame's direct children are laid out and the frame chain is
re-fitted — `arrangeGroupChildren`, the SAME transform the frame's menu rows run (see
**Arrange inside a group** under Canvas interaction). The flag gate is the pure
- `arrangeArgsRefusal` (`@shared/arrange-verb`, called from `parseControlRequest`): `--nodes` and
+ `arrangeArgsRefusal` (`@shared/arrange-verb`), called in THREE places: `parseControlRequest`
+ (Server Edition), desktop main's control handler (which never runs `parseControlRequest` — the
+ `--issue` trap; with the gate only in the parser, all three refusals were missing on the desktop
+ and the request ran as a grid), and Canvas's `case 'arrange'` as the belt: `--nodes` and
`--group` together are refused rather than resolved silently, an unknown `--layout` on the
`--group` form is refused by name, and `--layout lineage` on the `--nodes` form is refused
instead of being delivered as a grid (any OTHER unknown word there still falls back to `grid`,
diff --git a/src/main/index.ts b/src/main/index.ts
index 8fd0903e0..cbcc5af56 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -312,6 +312,7 @@ import { initCanvasControl, installCanvasSkillInto } from './canvas-control'
import { DRY_RUN_VERBS, dryRunRequested, dryRunRefusal } from '../shared/control-verbs'
import { issueFlagRefusal } from '../core/canvas-control-core'
import { afterPrFlagRefusal } from '../shared/pr-wait'
+import { arrangeArgsRefusal } from '../shared/arrange-verb'
import { CONTROL_REQUEST_TIMEOUT_MS } from '../shared/control-confirm'
import { createControlForwarder, type ControlForwardReply } from './control-forward'
import { claimOpenedBrowser } from './browser-open-claim'
@@ -4072,6 +4073,12 @@ app.whenReady().then(async () => {
// placement, same reason. Whether a named station exists and can report is the renderer's.
const afterSuccessRefusal = afterSuccessFlagRefusal(verb, args)
if (afterSuccessRefusal) return { ok: false, error: afterSuccessRefusal, message: afterSuccessRefusal }
+ // `arrange`'s flag shape (`--nodes` with `--group`, an unknown `--layout` on the `--group` form,
+ // `--layout lineage` on the `--nodes` form): same placement, same reason. This handler never
+ // runs `parseControlRequest`, so without the gate here those requests reached the renderer and
+ // ran as a grid.
+ const arrangeRefusal = verb === 'arrange' ? arrangeArgsRefusal(args) : null
+ if (arrangeRefusal) return { ok: false, error: arrangeRefusal, message: arrangeRefusal }
// A station's report about ITSELF: recorded in main's store, board-logged on its own card, and
// never forwarded — there is no canvas work in it, and the renderer hears the store's push.
if (verb === 'report-outcome') {
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index f703ff262..620f6e422 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -7,6 +7,7 @@ import { VisibleMiniMap } from './VisibleMiniMap'
import { MinimapDock } from './MinimapDock'
import { keepGlassBlurWhileMoving } from '../lib/glassContrast'
import { LINK_ENDPOINT_NOT_FOUND } from '@shared/canvas-link'
+import { arrangeArgsRefusal } from '@shared/arrange-verb'
import { createControlOpenBatch } from '../lib/controlOpenBatch'
import { commitOwnedLaunchAttempt, registerLaunchCommit } from '../terminal/launch-attempt'
import { hasLaunchWriter, launchCommand } from '../terminal/launch-command'
@@ -14035,6 +14036,14 @@ export function Canvas() {
case 'arrange':
case 'align': {
const live = nodesRef.current as CanvasNode[]
+ // The flag shape was refused in main (`arrangeArgsRefusal`); this is the belt. With it,
+ // `--layout` on the `--group` form is absent or a known word by the time it is read
+ // below — an unknown one is refused by name, never delivered as a grid.
+ const shapeRefusal = verb === 'arrange' ? arrangeArgsRefusal(args) : null
+ if (shapeRefusal) {
+ reply({ ok: false, error: shapeRefusal })
+ return
+ }
// `arrange --group <frameId>`: name the FRAME instead of listing its children. The
// whole rule set is `arrangeGroupChildren` — the same transform the frame's menu rows
// and the palette run — so this branch only parses, refuses by name and replies.
diff --git a/src/renderer/canvas/arrange-group.source.test.ts b/src/renderer/canvas/arrange-group.source.test.ts
index 3f9cc6a24..eda490b95 100644
--- a/src/renderer/canvas/arrange-group.source.test.ts
+++ b/src/renderer/canvas/arrange-group.source.test.ts
@@ -82,6 +82,29 @@ describe('arrange inside a group (source pins)', () => {
expect(groupBranch).toContain('reply({ ok: false, error: `arrange: ${refusal}` })')
})
+ // Desktop main never runs `parseControlRequest` (the Server Edition's parser), so the shape gate
+ // has to be called in its control handler too — without it `--group` with `--nodes`, an unknown
+ // `--layout` and `--nodes --layout lineage` all reached the renderer and ran as a grid.
+ it('desktop main refuses a malformed arrange before the forward to the renderer', () => {
+ const mainSrc = readFileSync(new URL('../../main/index.ts', import.meta.url), 'utf8').replace(/\r\n/g, '\n')
+ const handler = code(mainSrc.slice(mainSrc.indexOf('hookServer.setControlHandler(')))
+ const gate = handler.indexOf("verb === 'arrange' ? arrangeArgsRefusal(args) : null")
+ expect(gate).toBeGreaterThan(-1)
+ expect(handler.slice(gate, gate + 300)).toContain(
+ 'if (arrangeRefusal) return { ok: false, error: arrangeRefusal, message: arrangeRefusal }'
+ )
+ expect(gate).toBeLessThan(handler.indexOf("'window unavailable'"))
+ })
+
+ it('the renderer belt runs the same gate before either form reads its flags', () => {
+ const gate = verb.indexOf("verb === 'arrange' ? arrangeArgsRefusal(args) : null")
+ expect(gate).toBeGreaterThan(-1)
+ expect(verb.slice(gate, gate + 200)).toContain('reply({ ok: false, error: shapeRefusal })')
+ // Before the --group branch: its `?? 'grid'` then only ever answers an ABSENT --layout.
+ expect(gate).toBeLessThan(verb.indexOf("if (verb === 'arrange' && args.group)"))
+ expect(gate).toBeLessThan(verb.indexOf('GROUP_ARRANGE_LAYOUTS.find('))
+ })
+
it('the --nodes form re-fits the ancestor chain too, not just the one frame', () => {
const nodesForm = verb.slice(verb.indexOf('const ids ='))
expect(nodesForm).toContain('fitAncestorChain(next, container, snapGridNow())')