Skip to content

BlocksUI: ops reach lanes and rounds, children keyed by id, app figure and poster hooks, fold colour, openBeside and pending acts (#295) - #316

Merged
jirathip-k merged 3 commits into
stagingfrom
issue-295
Nov 21, 2026
Merged

jirathip-k merged 3 commits into
stagingfrom
issue-295

Conversation

@jirathip-k

Copy link
Copy Markdown
Contributor

Closes #295

For humans

  • The iOS app can now draw every screen through blocks: live scene updates no longer stop when a lane or a round changes.
  • A field you are typing in keeps its text and cursor when something new appears above it.
  • Apps can draw their own art for row figures and their own poster (avatar and name) on cards; paused cards show their line in the fleet's colour.
  • On a wide screen an app can open links beside the screen, and buttons dim while their action is being sent.

For apps: replace now carries the same child as insert (a block, lane, round or table row; a block payload decodes as before), and merge, replace and remove reach lanes and rounds in Rust, web and Swift. A row's title is optional (Swift Row.title is String?, TS title?), so a figure-only row decodes. A card takes color (l, p, c, g, a) for its folded line. Swift: AppBlocks(_, figure:, poster:) (figure now draws row figures too; poster draws in the card header and reads card.poster for who posted), BlocksView(openBeside:, pending:). Nothing to do for apps that don't opt in; Rust code that builds Op::Replace wraps its block in Child::Block.

What changed

  1. Ops on lanes and rounds: Rust patch.rs finds a lane, round or table row by id for merge, replace and remove (spot / drop_part replace the table-row-only row / take_row); a replace with the wrong kind of child is a Shape error. Web apply.ts walks lanes; Swift Apply.swift walks a scene's lanes and a row's rounds. Op::Replace.block is a Child now: it has to be, because a lane or a round is no Block. This is additive on the wire (an old block payload still decodes), so the schema version stays the same.
  2. BlockStack, card buttons, rounds and stage lanes are keyed by id, and by position only when there is no id or the id repeats (ChildKey). ListBlock was keyed by id already.
  3. AppBlocks.figure draws row figures too, from the figure's JSON (state, tool, …). Row.title is #[serde(default)], so a figure-only row decodes. Two fixture tests used a title-less row as their bad example; they use "title": 3 now, so they still cover the shape fault.
  4. Card.color (a string, the same as a scene repo's color) maps l/p/c/g/a to lead, purple, cyan, green and amber for the folded line.
  5. AppBlocks(poster:) draws in the card header after the kind label. When it is set, the plugin's · name suffix is left off.
  6. BlocksView(openBeside:, pending:): ActButton already sent tap.open to an openBeside in the environment, but nothing set it. A pending action's ActButton and the fold's main button are disabled, and the button is dimmed to 0.5.

Decided: pending is a Set<String> of action names, because that is what ActButton sends. I didn't touch the Debug-build stack depth of Block decoding the issue mentions ("worth a look"); it is out of this diff.

Not done here: web rounds have no data-id, so the web view patcher redraws nothing for a round op (the model applies). Adding it changes the Rust site HTML fixtures, which is outside this issue.

src/ net +101 (budget: none stated). Most of it is the Swift hooks and the Rust lane and round lookup. Cap after merging staging: 42984 / 44000.

Tests (all at 229f086)

command exit
just fmt 0
just clippy 0
just test (incl. new crates/blocks/tests/parts.rs) 0
just web (incl. new lane/round apply test in web/test/patch.test.ts) 0
BLOCKS_STRICT=1 swift test + node web/lint.mjs swift/Sources/BlocksUI (just swift) 0
just arch 0
just cap 0
just guard 0

New Swift tests, one per AC:

  • ApplyTests.testMergeReplaceAndRemoveReachALaneAndARound
  • LiveTests.testATypedFieldKeepsItsTextAndFocusWhenABlockIsInsertedAboveIt: a hosted window. I type into the field and insert a block above it. It fails on position keys (checked: "" ≠ "Ada", focus lost).
  • AppFixtureTests.testAnAppDrawsARowsFigureFromItsStateAndToolAndAFigureOnlyRowDecodes and testAnAppDrawsACardsPosterInItsHeader: pixels, through public API only.
  • RenderTests.testAFoldedCardDrawsItsLineInItsFleetColour: amber pixels with color: "a", none with an unknown code.
  • LiveTests.testATapOpenGoesBesideWhenTheAppSetsItAndAPendingActionsButtonIsDisabled: real mouse clicks at each block's drawn frame. tap.open goes to openBeside and tap.sheet to open; the pending approve sends nothing and reject sends. Without the pending disable it fails (checked: ["approve", "reject"]).

The tag (AC 7) has to be cut on the merged commit after drover merge; a lane can't do that.

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