Skip to content

pitis/perch#16: Cards resize by dragging the gap between them, and the widths are kept - #30

Merged
pitis merged 3 commits into
mainfrom
autopilot/pitis-perch-16-resize-cards
Nov 13, 2026
Merged

pitis merged 3 commits into
mainfrom
autopilot/pitis-perch-16-resize-cards

Conversation

@pitis

@pitis pitis commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Refs #16 (Refs, not Closes, per AGENTS.md: this hasn't been run in the real app yet, only unit-tested and rendered with sample data)

What changed

  • Drag the gap between two cards to resize them. Only those two cards trade width; the others stay put. The cursor becomes a left-right resize cursor over the gap.
  • Widths persist as a number. CardConfig.width (S/M/L enum) is replaced by CardConfig.weight: Double. Older files that store "width": "wide" load as that preset's weight, using lenient as AGENTS.md requires. The S/M/L picker in Customize still works: it sets the preset's weight, and a dragged width shows no segment selected.
  • Minimum widths per card (CardConfig.Kind.minWidth): Tasks 270pt, Focus 150, Notepad and Events 140. Dragging stops there, and the layout itself (CardLayout.widths) never puts a card below its minimum, which also covers S presets that squeezed a card too far before.
  • Dragged weights are held in view state during the drag and written to Workspace once, on release, so the store isn't rewritten every frame.
  • product.md: moved Resize cards by dragging #16 from "not built" to "written, but not tried for real".

How it was tested

  • make check: 46 tests pass, including new CardLayoutTests (proportional widths, minimum floors, resize trading only between neighbours, stopping at either minimum, weight round-trip and old preset files loading).
  • Minimums chosen by rendering the workspace with each card forced to its minimum (scratch render, not committed): at 270pt the Tasks header, day picker and To do / Completed / Overdue tabs stay on one line (at ~200pt they wrapped); Focus, Notepad and Events controls are intact at their minimums.

Not done / not run

  • Not run in the real app: the drag gesture, the hover cursor and the save on release are only compiled, not exercised. Someone needs to drag a gap in the running panel.
  • Not checked: the dot-matrix clock showing an hour-long countdown (1:30:00) at Focus's 150pt minimum.
  • The review step (/pr-review-toolkit:review-pr, /ponytail:ponytail-review) was run. The fixes are in the review comment below.

Card widths are now stored as a weight instead of an S/M/L preset, so a
dragged width persists. Older files keep their preset's weight. Each card
kind has a minimum width the layout never goes below, so controls don't
clip or wrap.
@pitis

pitis commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

Screens from make shots. With the default widths nothing looks different: resizing is a drag on the gap between cards, and the cursor change on hover can't be captured here (no Screen Recording permission).

Before (main) After (this branch)
Workspace Before After
Customize: S/M/L still selects the preset Before After

Scratch renders, not committed, with cards forced to their minimum widths (no "before": main had no minimums):

Focus, Notepad and Events at their minimums Tasks at its 270pt minimum
After After

@pitis pitis mentioned this pull request Nov 10, 2026
3 tasks
Resizing now turns every card's width on screen into its weight before
trading between the two neighbours, so a card held at its minimum no
longer makes the others jump or the gap fall behind the pointer. The
drag lives in gesture state, so a cancelled drag can't leave stale
widths behind, and release saves the cards in one change. A weight no
drag could make falls back to the preset when loading, the resize
cursor is set rather than pushed, and the comments and product notes
say what the code does.
@pitis

pitis commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

Review

Ran /pr-review-toolkit:review-pr (code, error handling, tests, comments) and /ponytail:ponytail-review on git diff origin/main...HEAD. Fixes are in 6ffa921. make check: 47 tests pass, and each new assertion failed before the fix. swift build gives no warnings. The resting layout (CardLayout.widths) didn't change, so the screens match the shots already posted.

Fixed

  1. Critical: a drag moved other cards when either neighbour sat at its minimum width. resize split the pair's weight in the ratio of their widths, which is only exact when no card is held. Setting Tasks to S in Customize was enough. Dragging the Tasks|Focus gap then left Tasks still while Focus shrank and Notepad and Events grew. A click on the gap shifted the layout, and Tasks at S could never be widened. One reviewer's sweep found 3,075 of 9,963 preset drags broke the rule. Now every card's width on screen becomes its weight, scaled to keep the total, before the pair trades. Test: weights [0.85, 1.9, 1, 1] with the real minimums. +110 gives [374, 150, 140, 140], and a click gives no change.
  2. Important: a cancelled drag left stale state. onEnded doesn't run on cancel, so the unsaved widths stayed on screen. If the visible card count then changed, widths[index] could index past the end. The live weights are now @GestureState, which resets itself, and release computes from the drag's translation. The stored weights don't change mid-drag, so they are the start.
  3. Important: a weight no drag could make broke saving. A huge hand-edited weight overflowed to NaN on the first drag, the store's encoder throws on NaN, and every save after that would fail. Zero or negative weights jammed the drag. Loading now keeps a weight only in 0.01...100 and otherwise uses the preset. Tests: -3 and 1e308.
  4. Important: comments. "Only those two cards trade width" is now true. "Dragging sets any weight in between" became "can fall outside their range". minWidth says it applies to every layout and how it was chosen. The CardLayout header says available excludes the gaps and that the row overflows when the minimums don't fit. product.md says the drag was never run.
  5. Suggestions, taken: release writes all cards in one change (one save, not four). The resize cursor is set() from onContinuousHover rather than pushed and popped, so it can't stay stuck if the panel closes while the pointer is on a gap.

Declined

  • Write the old width key too, so a downgrade keeps the layout. Going back to 0.1 would reset only card order, visibility and widths. Tasks and notes aren't touched. Downgrading isn't a supported path.
  • A drag on two cards at their minimums drops their S preset in Customize. A drag is meant to replace presets, and the widths don't move.
  • The segmented picker logs "selection is invalid" for a dragged weight. Showing no segment selected is deliberate. It's harmless on macOS.
  • Total width below the sum of minimums. That needs a screen under about 760pt. The row then overflows, as documented.

Not checked

The drag, the cursor and the save on release in the running app, and the 1:30:00 clock at Focus's 150pt minimum.

…-16-resize-cards

# Conflicts:
#	Tests/PerchCoreTests/PerchCoreTests.swift
@pitis
pitis merged commit eb233a1 into main Nov 13, 2026
@pitis
pitis deleted the autopilot/pitis-perch-16-resize-cards branch November 13, 2026 02:27
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