Skip to content

feat: expose source-list clicks and status menus - #7

Merged
bketelsen merged 3 commits into
mainfrom
feat/source-list-actions
Nov 11, 2026
Merged

bketelsen merged 3 commits into
mainfrom
feat/source-list-actions

Conversation

@bketelsen

@bketelsen bketelsen commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add explicit primary and middle-click callbacks to SourceList, preserving arrow-key selection as a separate action. Expose an expanded-item generation so clients can persist folder state only after changes. StatusItem can now open a popup menu.

These support frostyard/frostnotes#152, #153, #169 and #171. Uses MyGo v0.9.0 from current main, including its RowClicked API; no fork or additional dependency bump is required.

Risk tier

Risk tier: 3 — matched L2 path internal/repocheck/testdata/api.txt. The API snapshot contains four additive declarations; no existing public signatures change.

Verification

mise exec -- make ci BASE=origin/main passed: tidy, vet, formatting, four-platform lint, repository checks, full headless tests, WebAssembly tests, race detector, and all seven build/vet targets. Tests cover pointer activation versus arrow selection, middle click, stable expanded-item generation, and status popup choices.

Review fixes

Addressed M1 and m1–m4 from the review: removed the speculative Selection.Generation probe; documented Enter/OnActivate precedence and double clicks; made middle clicks commit only on a non-canceled release inside the row; and added selection, keyboard expansion, close/reopen, idempotence and equal-size membership tests. Pointer input uses a persistent Handle and local coordinates. Added the required dependency-adoption guard to AGENTS.md and appended the correction record.

Rebased onto main at 30fd87e, retaining its released MyGo v0.9.0 instead of the old pseudo-version. Rechecked that release in GOMODCACHE: frame theme reset, Window.Update main-thread dispatch/invalidation, and Tester.Click input-target selection retain the behavior this kit needs. The PR no longer changes go.mod or go.sum relative to main.

mise exec -- make ci BASE=origin/main passes after these fixes, including wasm, race, four-platform lint and all seven build/vet targets. Reverting sourcelist.go to the previous head makes the new release/cancel regressions fail; restoring the fix passes the gate.

@github-actions github-actions Bot added level:L2 Read the diff risk:high Touches a path in .github/risk-paths.json (core ADR-0068) labels Nov 11, 2026

@frostyard-machines frostyard-machines left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of head a6a2df5dd07d95500ceb5708905825887f1e4416 (base fa06b1d): 1 Major, 4 Minor.

M1 (Major): OpenGeneration has a branch for a MyGo API that does not exist, and the design doc describes it

  • sourcelist.go:217: any(&s.state.Open).(interface{ Generation() uint64 }). OutlineState.Open is a ui.Selection[K]. In the pinned MyGo (f5c3a6e111a3) and on upstream main today, Selection has Has, Len, Add, Remove, Clear and All, and no Generation. So this branch never runs and no test covers it.
  • The risk: a later MyGo bump that adds any Generation() uint64 method to Selection silently changes what this exported method returns. The numbers then jump to a different counter, with semantics that this kit never checked (for example, a counter that also moves on an Add of a key that is already present). An app that compares stored generations would then write its folder state again, or skip a write.
  • docs/design/frostui.md (API changes): "it uses MyGo's membership generation when available" states something that is not true at this head.
  • Fix: remove the type-assertion branch and its comment, and keep only the snapshot comparison. Remove the "when available" clause from the design doc. When MyGo ships such a method, adopt it in the MyGo bump PR, with a test that the value still changes exactly when the open set changes.

m1 (Minor): the OnClick doc does not say when Enter calls it

  • sourcelist.go:96-98: "Enter also activates the item." Enter, Cmd+Enter and Cmd+Alt+Enter call OnClick only when OnActivate is nil (sourcelist.go:558). With OnActivate set, Enter calls only OnActivate (I checked this with a scratch test).
  • A double click with OnActivate nil calls OnClick 2 times: once from RowClicked and once from Submitted. That is defensible (2 clicks), but an app with a toggle handler must know it.
  • Fix: say both in the field comment and in the design doc's SourceList bullet. For example: "When OnActivate is nil, Enter, Cmd+Enter and Cmd+Alt+Enter also run OnClick for the chosen item, and so does the second click of a double click."

m2 (Minor): the middle click acts on the press, not the click

  • sourcelist.go:623-631 runs OnMiddleClick on InputPointerDown with Button 2. A press that the user drags off the row, or that the system cancels, still opens the item.
  • Fix: run it on InputPointerUp with Button == 2, !ev.Canceled, and ev.X/ev.Y inside the row (as the auxclick event works). Take the InputPointerDown (return true) so that the release comes to the row. Alternatively, keep the press and say "on press" in the doc.

m3 (Minor): tests do not cover 2 documented claims

  • sourcelist_test.go, TestSourceListMiddleClick: the field says "without changing selection", but the test does not assert it. Add a check that Selected and OnSelect do not change after the middle click.
  • TestSourceListOpenGeneration covers only SetOpen. The doc lists "the arrows, assistive technology, Select and SetOpen". Add at least a Right or Left arrow on a folder row, and a close that follows an open, and assert that the generation changes each time.

m4 (Minor): the PR body does not record the MyGo bump check or the effect on the apps

  • frostui's AGENTS.md (MyGo's rules) says: "After a MyGo bump, read its source in GOMODCACHE (the theme reset, Window.Update, the Tester) before merging." The PR body should say that this check was done.
  • I did the check at f5c3a6e111a3. The theme still resets at the start of every frame (ui/context.go:131). Window.Update has no change. The Tester changes Click to choose the label whose input target takes the click, and adds buildNext, and the kit's tests pass with both changes.
  • The pin is 147 commits after v0.8.3. The set of shared libraries that the kit's MyGo packages load (libgtk-3, libepoxy, Pango and the rest) is the same as at v0.8.3, so the images need no change.
  • Effect on the apps: each app that takes this frostui release moves to at least MyGo f5c3a6e. An app on v0.8.3 gets all 147 commits. Frostnotes' fork replace (9e0be8b) contains f5c3a6e. Fix: add 1 or 2 lines about this to the PR body.

Checked and fine

  • api.txt: 4 additive lines (OnClick, OnMiddleClick, StatusItem.Menu, OpenGeneration), and no existing line changes. feat: is correct, and svu gives v0.3.0.
  • The risk-tier section names go.mod, go.sum and api.txt (L2) and says why the change is safe.
  • StatusItem.Menu takes precedence over OnClick, as its comment says. The new test opens the menu with tt.Click.
  • OnClick uses RowClicked, so the row keeps its accessible label for Tester.Click and screen readers.
  • GitHub CI: the 7 cross-build jobs are green, and verify is still running at the time of this review. My local make ci with go1.27.4 is also still running.

The cross-review comes after M1 is fixed.

@frostyard-machines frostyard-machines left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at head 50171fcd0901f1b09c458a37df4dc0134555ea76: M1 and m1–m4 are closed, and I have no new findings.

  • M1: the type-assertion branch is removed (sourcelist.go:217), and the design doc no longer makes the claim. The guard is the new rule in AGENTS.md ("Dependency API adoption") plus 1 line in .memory/corrections.jsonl with promoted_to: AGENTS.md. A rule is the right guard here, because no test can catch a method that does not exist yet.
  • m1: the field comment and the design doc now say when Enter, Cmd+Enter, Cmd+Alt+Enter and the second click of a double click call OnClick. TestSourceListEnterPrefersOnActivate and TestSourceListDoubleClickCallsOnClickTwice pin this behavior.
  • m2: the middle click now acts on a release that is not canceled and is inside the row. The row takes the press and so gets the release. ev.X/ev.Y are local to the row, and the check uses only the row's size, so the coordinate spaces agree.
  • m3: the middle-click test now has 3 cases (inside, outside, canceled) and asserts that the selection and OnSelect do not change. The OpenGeneration tests now cover open, close, an open or close that changes nothing, a member replaced by another with the same count, and the Right and Left arrows.
  • m4: the PR body records the MyGo source check and the effect on the apps.

Checks:

  • Local GOTOOLCHAIN=local make ci BASE=origin/main with go1.27.4 passes at this head.
  • Revert test: with sourcelist.go from a6a2df5, TestSourceListMiddleClick fails, and with this head it passes.
  • GitHub CI is green: verify and the 7 cross-build jobs.

The next step is the independent cross-review.

@frostyard-machines frostyard-machines mentioned this pull request Nov 11, 2026
2 tasks done
@frostyard-machines

Copy link
Copy Markdown
Contributor

#8 merged MyGo v0.9.0 into main (30fd87e). v0.9.0 contains f5c3a6e111a3, and 26 commits after it. This PR changes the same go.mod line, so it needs a rebase. In the rebase, keep github.com/egoist/mygo v0.9.0 and its go.sum lines, and drop the pseudo-version. Change the design-doc entry "The MyGo dependency is pinned to upstream commit f5c3a6e111a3 ... its next release can replace the pseudo-version" so that it names v0.9.0, which supplies RowClicked. The risk-tier section then names only api.txt at L2. I re-review the new head and start the cross-review again there.

@frostyard-machines frostyard-machines left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross-review at head 50171fcd0901f1b09c458a37df4dc0134555ea76 (base fa06b1d). Reviewer: openai/gpt-6.1-sol. Result: Not ready, 1 Blocking finding. I confirmed it in MyGo's source at the pinned commit and at v0.9.0.

B2 (Blocking): the middle-click handler leaks a handle registration each time a row mounts again

  • sourcelist.go:623-624: ui.Local(content, "middle-click", func() ui.Handle { return ui.Handle{} }) and then content.Bind(handle).
  • ui.Local belongs to the element. When the outline stops building a row (it scrolls out of view, or its section or parent closes), MyGo drops that row's local state. When the row comes back, ui.Local makes a new Handle.
  • Bind makes a new refState for each new handle and appends it to rt.refs (ui/ref.go:53). In both the pin and v0.9.0, nothing removes entries from rt.refs until the window closes (ui/runtime.go:1389-1394). applyFocusRequests goes through all of rt.refs on every build pass (ui/ref.go:182).
  • Effect: with OnMiddleClick set (Frostnotes sets it), each scroll or section toggle adds 1 retained registration per row that comes back. Memory and the work per frame grow without a limit for the life of the window, even with no middle click at all.
  • This also goes against the kit's rule (AGENTS.md, MyGo's rules) that state lives in structs, not in a view function.

Fix: do not create a Handle in a view, and do not create one for each mount. 2 options:

  1. Remove the handle. On InputPointerDown with Button 2, store the row's key in SourceList (for example s.middle, s.middleSet). On InputPointerUp, check !ev.Canceled, check that the key is the same, and check that ev.X, ev.Y lie inside the row's box. The row height is fixed at 28, and the width can come from a size that the row already knows. Clear the key on every release.
  2. Keep 1 handle for each item in a map on SourceList (for example map[sourceKey[K]]*ui.Handle), and remove the entries for items that go, as seen does. The same *Handle binds again without a new refState, because Handle.binding reuses the binding for the window. So the registrations stay bounded by the number of items.

Guard (Blocker to guard): a test cannot see rt.refs. So add a repository check in internal/repocheck that fails when a kit source file calls ui.Local to make a ui.Handle (or Binds a handle that a view makes). Alternatively, add an AGENTS.md rule under MyGo's rules: "Never create a ui.Handle in a view or with ui.Local: each one stays registered until the window closes. Keep handles in structs." Also add a test that scrolls a long list far down and back, or closes and opens a section, several times with OnMiddleClick set, and then checks that a middle click still works. Append 1 line to .memory/corrections.jsonl.

Checked and fine (cross-review)

  • api.txt: additive only.
  • StatusItem.Menu uses MyGo's menu-button role and its keyboard behavior.
  • The interaction of s.clicked, Submitted, RowClicked and the shortcuts showed no other defect.

Revert test: not run, because the review is Not ready. Note: #8 is merged, so the rebase also changes go.mod (see my earlier comment). I re-review the new head, and the cross-review runs again there.

@bketelsen
bketelsen force-pushed the feat/source-list-actions branch from 50171fc to 8905ddd Compare November 11, 2026 11:36
@bketelsen
bketelsen merged commit 23f37ce into main Nov 11, 2026
10 checks passed
@bketelsen
bketelsen deleted the feat/source-list-actions branch November 11, 2026 11:38
@frostyard-machines

Copy link
Copy Markdown
Contributor

Closing note: this PR merged as 23f37ce while the cross-review finding B2 (above) was still open. main keeps the per-mount ui.Local handle in sourcelist.go:623-624. Each row that comes back after a scroll, or after a section or parent opens again, adds a refState that stays until the window closes, and MyGo goes through every one on each build pass. The fix and the guard in the B2 comment still apply, now as a follow-up PR on main. Frostnotes' Files pane sets OnMiddleClick (internal/desktop/panes/files.go:184), so it gets the leak when it takes this code (frostnotes#191 pins 50171fc, which has the same handler).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:L2 Read the diff risk:high Touches a path in .github/risk-paths.json (core ADR-0068)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants