Skip to content

Add the editing core of the Designer: draft, stage text, findings and editor state - #98

Open
knihit wants to merge 2 commits into
wc/06-executionfrom
wc/07a-edit-core
Open

knihit wants to merge 2 commits into
wc/06-executionfrom
wc/07a-edit-core

Conversation

@knihit

@knihit knihit commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

Layer 1 of 4 of the editing work in the Designer (the first of four PRs that replace a single large one; the stack is on #93). This layer is the editing core only: it has no UI and nothing on the page changes.

What it adds (workflow-canvas/src/designer/core/, no IO):

  • draft.ts: the draft of the stages. Each stage keeps an id while it is renamed or when another is deleted. Add takes the first free agent-N; the 40 and 1 stage limits; the neighbour to select after a delete.
  • stage-text.ts: the text a save will write. Only the block of stages of the loaded file is replaced, so name, intent, version and the comments outside the block stay byte for byte (a CRLF file stays CRLF). If stages is not a block, the whole file is written in the plain layout. Values that are not plain YAML text are double-quoted.
  • problems.ts: puts the findings of a check on the stage and field they are about, by index or by name.
  • edit-state.ts, edit-reducer.ts, edit-view.ts: the state of the editor, its reducer for every event (including events that do not fit, such as a check for an older draft), and the selectors (dirty, text, why Save is off, problems to show).

Wire types (src/api/types.ts, parse.ts):

  • WorkflowDocument carries the hash and read_only; DiagnosticView carries the path and severity (an unknown severity counts as an error). Nothing in the page reads them yet.

Tests: unit tests for every module above, test-support/designer-purity.test.ts (the core imports only its own modules and the wire types and reads no clock, randomness, environment or network), and the stub wire test now also reads hash and readOnly.

How to review

  • Read draft.ts, then stage-text.ts and its test (the part with the most edge cases), then problems.ts, then the state, reducer and selectors.
  • Nothing calls the core yet, so there is nothing to click. npm test in workflow-canvas/ is the evidence.
  • The API contract and the stub are unchanged.

What the next layer adds

PR #99: Properties for the selected stage, the agent list, Add stage, rename, Delete stage and the selection on the canvas, with the draft kept in App.

Fixes from the hands-on QA run

  • A repeated stage name was not marked at the field being edited. The server reports a repeated name on the later stage only, so renaming the first stage to the name of the second marked nothing at the field the person was typing in. withEchoes (used by problemsOfDraft) copies a name problem to the earlier stages with that name that have no name problem of their own; listedOf leaves the copies out of a list, and joinMessages joins a message once.
  • Tests: problems.test.ts and edit-view.test.ts; the one at problemsOfDraft failed before the change.

Type of Change

  • Other: the editing core of the Designer tab of the workflow canvas, in workflow-canvas/

Testing

  • Root npm test (tests/scripts/**/*.test.js): not applicable; this PR changes only workflow-canvas/.
  • If cli/ changed: not applicable, cli/ is untouched
  • Smoke tested affected agent(s): not applicable, no agent changed
  • If an agent's or skill's behavior changed: not applicable, none changed
  • New or changed code files carry the required SPDX header (see AGENTS.md's License headers rule); formats without comment syntax (e.g. JSON) are exempt

Checked in workflow-canvas/ on this head: npm run lint, npm run typecheck (3 projects), npm test (53 files, 807 tests), npm run test:stub (19 files, 324 tests), npm run api:lint, npm run build and npm run test:e2e (49 tests) all pass. npm run screenshots gives byte-identical files, as nothing on the page changed.

Screenshots

None: this layer has no UI.

Checklist

  • My code follows the style guidelines of this project (see AGENTS.md's Code Style & Conventions)
  • I have performed a self-review of my own changes
  • I have commented my code where necessary
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings - build is clean
  • I have added or updated tests that prove my change works (see Testing above for the exact commands)

Notes for Reviewers

@knihit
knihit added this pull request to stack #101 October 27, 2026 02:47
@knihit
knihit removed this pull request from stack #101 October 27, 2026 02:48
@knihit
knihit added this pull request to stack #102 October 27, 2026 02:48
@knihit
knihit force-pushed the wc/07a-edit-core branch 5 times, most recently from 3ea4ab5 to 9883213 Compare October 27, 2026 21:25
@knihit
knihit removed this pull request from stack #102 October 27, 2026 22:40
@knihit
knihit added this pull request to stack #117 October 27, 2026 22:42
@knihit
knihit force-pushed the wc/07a-edit-core branch 2 times, most recently from 42010ee to b7669fa Compare October 27, 2026 23:45
… editor state

The IO-free part of editing a workflow in the Designer, with no UI yet:
- the draft of the stages, where each stage keeps an id while it is renamed
- the text a save writes, which replaces only the block of stages
- the findings of a check, put on the stage and field they are about
- the state of the editor and its reducer, with the selectors on it

The wire types gain the hash and read-only flag of a workflow and the path
and severity of a finding, and the page reads them.
The server reports a repeated stage name on the later stage only. A person who
renames the first stage to a name the second one has saw no mark at the field
they were editing. The problems of the draft now hold a copy of such a name
problem for the earlier stages with that name. A list of problems leaves the
copies out, and a message that several stages repeat is joined once.
@knihit
knihit marked this pull request as ready for review October 28, 2026 15:37

This branch has not been deployed

No deployments
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.

1 participant