Skip to content

Commit 008f250

Browse files
committed
feat(spec): record:path declares the allowStageChange opt-in
A record:path block may opt in to changing the record's stage by pressing a stage on the path. Off unless authored, no schema default; the spec declares the opt-in and its meaning only. The console parity gate books the key as unpublished until the path renderer reads it. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibxNQzFQH8nBAaoSUkx
1 parent 9f13ee8 commit 008f250

4 files changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@objectstack/spec': minor
3+
---
4+
5+
feat(spec): a `record:path` block may opt in to `allowStageChange`, so a stage can be pressed to move the record there
6+
7+
Clause-②: yes (widening)
8+
Metadata-protocol: added (record:path allowStageChange)
9+
10+
A `record:path` block draws the status field's stages as a progress rail, and nothing on it can be pressed: moving a deal to the next stage means opening the edit form and changing the picklist.
11+
12+
- **Spec.** `RecordPathProps` (`ComponentPropsMap['record:path']`) declares an optional boolean `allowStageChange`. Off unless authored, with no schema default, so every existing path keeps its read-only look and parses exactly as before. Any value other than a boolean is refused at the key.
13+
- **Meaning.** With the key on, each stage the reader may move the record to is a button, offered only to a reader who may edit `statusField`. A press asks for confirmation, then saves `statusField` through the same record update `record:details` uses, carrying the record's concurrency token, so the object's state machine validation and the field's edit rights decide the move like any other edit. A refused move (an illegal transition, a missing required field) is shown in place. Nothing new is judged on the server.
14+
- **Renderer.** The console does not read the key yet; the path stays a readout until the `plugin-detail` path renderer honours it. The block's registry does not publish the input until then.
15+
16+
Nothing to do for existing pages. Once the console honours it, add `allowStageChange: true` to a `record:path` node's properties to let readers change the stage from the path.

‎packages/spec/src/ui/component.test.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2602,6 +2602,38 @@ describe('RecordPathProps stages[].terminal — declared because the path render
26022602
});
26032603
});
26042604

2605+
// #28061 — `allowStageChange` is the opt-in that turns the path's stages into
2606+
// presses requesting that status. Off unless authored, so the readout keeps its
2607+
// non-interactive look.
2608+
describe('RecordPathProps allowStageChange — opt-in, off unless authored', () => {
2609+
it('accepts the opt-in and keeps the authored value', () => {
2610+
const result = RecordPathProps.safeParse({ statusField: 'stage', allowStageChange: true });
2611+
expect(result.success).toBe(true);
2612+
expect(result.data!.allowStageChange).toBe(true);
2613+
});
2614+
2615+
it('leaves an existing path unchanged: no default is written', () => {
2616+
const authored = {
2617+
statusField: 'status',
2618+
stages: [
2619+
{ value: 'todo', label: 'To Do' },
2620+
{ value: 'done', label: 'Done', terminal: 'won' as const },
2621+
],
2622+
};
2623+
const result = RecordPathProps.parse(authored);
2624+
expect(result).toEqual(authored);
2625+
expect('allowStageChange' in result).toBe(false);
2626+
});
2627+
2628+
it('refuses a non-boolean at the key, with the code and path', () => {
2629+
const result = RecordPathProps.safeParse({ statusField: 'stage', allowStageChange: 'yes' });
2630+
expect(result.success).toBe(false);
2631+
expect(result.error!.issues).toEqual([
2632+
expect.objectContaining({ code: 'invalid_type', path: ['allowStageChange'] }),
2633+
]);
2634+
});
2635+
});
2636+
26052637
// ---------------------------------------------------------------------------
26062638
// Enhanced RecordActivityProps (Unified Timeline)
26072639
// ---------------------------------------------------------------------------

‎packages/spec/src/ui/component.zod.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,6 +2082,24 @@ export const RecordPathProps = strictObject({
20822082
*/
20832083
terminal: z.enum(['won', 'lost']).optional().describe('Mark this stage a terminus and its kind — overrides the renderer\'s value/label token heuristic'),
20842084
})).optional().describe('Explicit stage definitions (if not using field metadata)'),
2085+
/**
2086+
* Opt in to changing the record's stage from the path itself. Off unless
2087+
* authored: an unset key is the read-only progress rail, so every existing
2088+
* path keeps its non-interactive look. No schema default, for the
2089+
* `RecordChatterProps` reason — a default would write `false` onto every
2090+
* parsed component and turn "the author said nothing" into "the author
2091+
* asked for it".
2092+
*
2093+
* The spec declares the opt-in and its meaning only; nothing new is judged
2094+
* on the server. With the key on, each stage the reader may move the record
2095+
* to is a button, offered only when the reader may edit `statusField`. A
2096+
* press asks for confirmation, then writes `statusField` through the same
2097+
* record update `record:details` uses, carrying the record's concurrency
2098+
* token, so the object's `state_machine` validation (ADR-0020) and the
2099+
* field's edit rights judge the move like any other edit; a refusal (an
2100+
* illegal transition, a missing required field) is shown in place.
2101+
*/
2102+
allowStageChange: z.boolean().optional().describe('Let the reader change the record\'s stage by pressing a stage on the path (default: off — the path is a read-only progress rail). Each press asks for confirmation and saves `statusField` through the ordinary record update, so the object\'s state machine validation and the field\'s edit rights decide; stages appear pressable only to readers who may edit `statusField`, and a refused move is shown in place.'),
20852103
/** ARIA accessibility */
20862104
aria: AriaPropsSchema.optional().describe('ARIA accessibility attributes'),
20872105
});

‎ui/apps/console/src/__tests__/registry-inputs-spec-parity.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,6 +1663,12 @@ const UNPUBLISHED_EXEMPTIONS: Record<string, string> = {
16631663
'Unpublished by measurement (objectui#13047): read by nothing on a page `list-view` node. The node draws, queries and hands its view the same thing with and without it — the view\'s own `name` is its identity in metadata, which an embedded list has no use for.',
16641664
'list-view.sharing':
16651665
'Unpublished by measurement (objectui#13047): `sharing.type` draws a Share button with no click handler, and the sharing config is enforced nowhere in the renderer. Publishing it would advertise a dead control (objectui#13047\'s report).',
1666+
// Spec-first opt-in (objectstack#28061): the spec half landed before the
1667+
// console half, so the path renderer does not read it yet. The console card
1668+
// that makes `record-path.tsx` honour it publishes the input, and the stale
1669+
// check above then demands this entry's deletion in the same change.
1670+
'record:path.allowStageChange':
1671+
'Unpublished until the renderer reads it (objectstack#28061): the spec declares the opt-in that turns path stages into presses requesting that status, and `record-path.tsx` still draws a read-only rail. Publishing it now would advertise a control that does nothing.',
16661672
};
16671673

16681674
/**

0 commit comments

Comments
 (0)