Skip to content

Add flowsheet move, edit, and rm commands - #5

Merged
rybesh merged 2 commits into
mainfrom
flowsheet-write-core
Jul 11, 2026
Merged

rybesh merged 2 commits into
mainfrom
flowsheet-write-core

Conversation

@rybesh

@rybesh rybesh commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Closes #3. Follow-up to the in-show write loop (#2), closing out the remaining mutating flowsheet operations for mid-show correction: reorder the queue, edit an entry, and delete one.

Shared plumbing

Factor postRaw's body-sending into a bodyRaw(method, path, in) helper, then add patchRaw and deleteRaw on top. DELETE carries a JSON body (the backend reads req.body.entry_id); the *bytes.Reader gives NewRequestWithContext a GetBody, so the auth Transport's 401-retry rewind still replays it — covered by an explicit rewind test.

Commands

  • flowsheet move <entry_id> <new_position> — PATCH /flowsheet/play-order, 1-based, validates new_position >= 1 client-side; both args int-parsed.
  • flowsheet edit <entry_id> [flags] — PATCH /flowsheet with only the flags actually changed (pointer/omitempty fields keyed off Flags().Changed), so an unset flag is left alone and --flag "" clears the field; fails fast on no fields rather than round-tripping to a 400. Booleans only send when explicitly passed.
  • flowsheet rm <entry_id> — DELETE /flowsheet, echoes the removed row, gated by --write.

All three decode the projected entry and reuse entryResultRows/entryHeaders for the confirmation; 404 maps to ExitNotFound.

Tests

Per the repo's red-green convention:

  • internal/api: method (PATCH/DELETE), path, and body assertions for each; the DELETE-with-body 401-retry rewind; 404 → StatusError.
  • cmd: write-gate block without --write; arg parsing/validation (non-int entry_id, new_position < 1, empty edit); confirmation output.

go test ./... and go vet ./... both pass.

Out of scope

The note command and read helpers (latest/on-air/show <id>) — separate follow-ups.

🤖 Generated with Claude Code

Follow-up to the in-show write loop (#2), closing out the remaining
mutating flowsheet operations for mid-show correction (#3): reorder the
queue, edit an entry, and delete one.

Shared plumbing: factor postRaw's body-sending path into bodyRaw and add
patchRaw/deleteRaw on top of it. DELETE carries a JSON body (the backend
reads req.body.entry_id); the *bytes.Reader gives NewRequestWithContext a
GetBody so the auth Transport's 401-retry rewind still replays it — covered
by an explicit rewind test.

- flowsheet move <entry_id> <new_position>: PATCH /flowsheet/play-order,
  1-based, validated client-side.
- flowsheet edit <entry_id> [flags]: PATCH /flowsheet with only the flags
  changed (pointer/omitempty fields keyed off Flags().Changed), so unset is
  left alone and --flag "" clears; fails fast on no fields rather than a 400.
- flowsheet rm <entry_id>: DELETE /flowsheet, echoes the removed row, gated
  by --write.

All three decode the projected entry and reuse entryResultRows for the
confirmation; 404 maps to ExitNotFound.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rybesh
rybesh force-pushed the flowsheet-write-core branch from b1ef231 to 6e771f8 Compare July 10, 2026 23:50
The FlowsheetUpdateFields doc claimed a uniform "clear vs leave alone"
distinction, but omitempty on a pointer only expresses a true clear for
the string fields; the *int fields can send 0 but not null. Correct the
comment to say so.

Also give DELETE /flowsheet a typed flowsheetDeleteRequest to match the
move/update request structs instead of an inline map.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rybesh
rybesh merged commit 8cfb8e1 into main Jul 11, 2026
1 check passed
@rybesh
rybesh deleted the flowsheet-write-core branch July 11, 2026 00:07
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.

Flowsheet: add move (reorder), edit, and rm commands

1 participant