Skip to content

core: a key fold in a tree stays folded - #649

Merged
foxnne merged 2 commits into
mainfrom
core/tree-key-fold-670l4p
Oct 19, 2026
Merged

foxnne merged 2 commits into
mainfrom
core/tree-key-fold-670l4p

Conversation

@foxnne

@foxnne foxnne commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Folding a tree branch with Left/Right stuck in every tree (settings, files, guides): Branch.expander compared init_options.expanded with the widget's own state every frame, so a caller passing its (stale) open value undid the key fold in the same frame.

Fix (core/widgets/TreeWidget.zig): Left/Right no longer set expanded in install(), before expander() compares it with a caller value the caller has not read back yet. The key asks for a toggle (key_toggle), and expander() takes it beside clicked: one path, animated as a click is, and the caller reads the new state back the same frame. The caller's expanded keeps its meaning (a filter forcing a branch open, hover auto-open, clearing a search back to the saved state).

Not done: the shared open-branches helper replacing the hand-written maps (guides/List.zig unfolded, SettingsTree open_branches, …) is left as a follow-up; this PR is the bug fix only.

Test: tests/integration.zig, "tree: a key fold stays folded when the caller passes its open state back" — a caller that keeps its open state and reads branch.expanded back, as the settings, file and guides trees do: Left folds (animated: the body is still drawn the frame after), stays folded, Right opens again.

Review (PM reviewer pass)

code-review at medium found the first take (drive the branch from the caller's value only when it changes) lost a caller's change made during the close animation, stopped hover auto-open on a branch a filter forces open, and broke clearing a search back to the saved state; and key folds did not animate. Replaced by the key-toggle fix above, which removes all four at the root. The shared open-branches helper stays a follow-up.

Local gates on macOS (this reviewer): scripts/check-fmt.sh, zig build test-integration (81/81 steps) , zig build, zig build test (115/115 steps), zig build check-web: all pass. No fizzy launched.

Verified (original author)

  • Not run locally: the cloud session had no Zig toolchain (ziglang.org blocked), so none of the local gates ran.
  • CI on head 5a1752c: Format, Tests (Linux/macOS/Windows), Integration tests (Linux, includes the new test), Windows cross-compile, Verdict run and ci-ok all passed; "Example repos (Linux)" was still running when this was marked ready.
  • Review: my own re-read of the diff only; no separate code-review pass was run.

Part of: bug found reviewing #628.

🤖 Generated with Claude Code

https://claude.ai/code/session_016JNGGzdR8958EwaYZWPz9w

A branch treated init_options.expanded as a controlled value, so a Left/Right
fold was undone in the same frame whenever the caller passed a stale open
state. The caller's value now drives the branch only when it changes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016JNGGzdR8958EwaYZWPz9w
@foxnne
foxnne marked this pull request as ready for review October 19, 2026 16:29
Left/Right set `expanded` in `install()`, before `expander()` compared it with the caller's
`init_options.expanded`, which the caller has not yet read back: the fold was undone in the same
frame. The previous take kept the caller's last value and drove the branch only on a change,
which lost a caller's change made during the close animation, stopped hover auto-open on a branch
a filter forces open, and broke clearing a search back to the saved state. Instead the key asks
for a toggle and `expander()` takes it beside `clicked`: one path, animated, and the caller's
value keeps meaning what it did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

foxnne commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator Author

Verdict run (Linux) on 1c4631f failed before any fizzy code ran: the step died at xvfb-run … vulkaninfo --summary ("XCB failed to connect to the X server", then "xvfb-run: error: problem while cleaning up temporary directory"), so no verdict was written. That is a runner/Xvfb startup failure, not something this diff touches; the same job passed on 5a1752c. I tried to re-run the failed job but GitHub refused while the workflow is still running (403), so I'll re-run it once the run finishes. If it fails again I'll treat it as real.


Generated by Claude Code

@foxnne
foxnne enabled auto-merge October 19, 2026 17:36
@foxnne
foxnne added this pull request to the merge queue Oct 19, 2026
Merged via the queue into main with commit 2489d74 Oct 19, 2026
20 of 22 checks passed
@foxnne
foxnne deleted the core/tree-key-fold-670l4p branch October 19, 2026 18:29
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.

2 participants