Skip to content

gui: typing on the Presets screen no longer works the preset out twice per key - #131

Merged
donislawdev merged 1 commit into
mainfrom
gui/settle-once
Sep 23, 2026
Merged

donislawdev merged 1 commit into
mainfrom
gui/settle-once

Conversation

@donislawdev

@donislawdev donislawdev commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

What changes for the user

Typing on the Presets screen no longer lags. With upload-validation chosen, every key typed into a box held the window for about 0.3 s, because the preset was worked out twice for each key - and working it out encodes images.

How

  • One reading per change. recheck settled the form for the line (refreshLine) and then again to mark the box. It now settles once and hands the reading to lineFrom. The comment on refreshLine that said settling costs nothing is corrected.
  • The Presets screen remembers its last expansion (lastExpansion), keyed by the preset and a copy of the values it is given. The seed and the output directory are not given to a preset, so typing in them expands nothing. A refusal is remembered too - internal/preset reads no clock, randomness, environment or disk. Every settle runs on the window's thread, so there is no lock. Parameters and Defaulted go to the manifest as copies.
  • Two optional host interfaces (countedSettle, tellExpanding) let a guard count readings and expansions. Nothing in the shipped program implements them.

Measured

tools/probes/guilag, the real window, main and this branch interleaved, three runs each, median time the window's thread was busy per key / garbage per key:

main this branch
seed, upload-validation 303-335 ms / 117 MB 0-6 ms / 2 MB
seed, tabular-import 70-81 ms / 168 MB 0 ms / 1 MB
the preset's limit, upload-validation 295-379 ms / 117 MB 149-160 ms / 59 MB

The live heap is unchanged (29.3 MB after every phase).

Guards

internal/guard/settleonce_test.go:

  • TestOneChangeOfABoxReadsTheFormOnce - exactly one reading per change on all three screens, an emptied box included. Nought readings fails as "not in the state it asks about".
  • TestTypingWhatAPresetIsNotGivenDoesNotExpandItAgain - the seed and the directory expand nothing, and four keys are checked to have read the form four times.
  • TestAChangedPresetValueIsExpandedAgain - a new value and another preset are expanded again and the line follows. It checks that the two presets are given nothing (nothingGiven) instead of assuming it: size-boundaries arrives with its format menu set, which let the first version pass a mutation that ignored the preset's name.

Seven new mutation entries, all caught. Four existing entries whose patterns this change moved were re-pointed and caught again.

Not changed

  • On Several batches, menus and switches that rebuild the screen still read the form twice (counted: batch format, the base switch, the base preset). A key typed there with a preset switched on still expands the preset once per key.
  • Making the expansion itself cheaper is engine work and is not in this PR.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Reduced typing lag on the Presets screen, including when editing the seed or output folder.
    • Changing preset settings is faster, and typing in a field with a preset enabled no longer triggers duplicate preset evaluation.

…e per key

Every change of a box settled the form twice - once in refreshLine for the
line under the buttons and once in recheck to mark the box - and on the
Presets screen each settle expanded the preset. With upload-validation
chosen that is image encoding: about 300 ms of the window's thread and
117 MB of garbage for every key, while the seed was what was being typed.

recheck now settles once and hands the reading to lineFrom, which says the
line from it. refreshLine keeps its shape for the other callers, and its
comment no longer says settling costs nothing.

The Presets screen remembers the last expansion (lastExpansion), keyed by
the preset and a copy of the values it is given. The seed and the output
directory are not among them, so typing in them expands nothing. A refusal
is kept too, since internal/preset reads no clock, randomness, environment
or disk. Every settle is on the window's thread, so there is no lock. The
parameters and the defaulted list go to the manifest as copies.

Measured in the real window (tools/probes/guilag, main and this branch
interleaved, three runs each, median per key):
- seed, upload-validation: 303-335 ms / 117 MB -> 0-6 ms / 2 MB;
- seed, tabular-import: 70-81 ms / 168 MB -> 0 ms / 1 MB;
- the preset's own limit, upload-validation: 295-379 ms -> 149-160 ms.

Two optional host interfaces let a guard count readings and expansions
(countedSettle, tellExpanding). Nothing in the shipped program implements
them. New guards in settleonce_test.go: one change of a box reads the form
exactly once on all three screens, typing what a preset is not given does
not expand it again, and a changed value or another preset is expanded
again with the line following it.

Not changed: menus and switches that rebuild the Several batches screen
still read the form twice, and a key typed there with a preset switched on
still expands the preset once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: d813b500-ed66-4008-bfcd-2e3d4cb3f33c

📥 Commits

Reviewing files that changed from the base of the PR and between 6e6655e and 1282c9c.

📒 Files selected for processing (9)
  • CHANGELOG.md
  • internal/guard/settleonce_test.go
  • internal/guard/window_test.go
  • internal/gui/window/generate.go
  • internal/gui/window/open.go
  • internal/gui/window/preset.go
  • internal/gui/window/recipe.go
  • internal/gui/window/run.go
  • internal/gui/window/runrefuse.go

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (15)
  • GitHub Check: race detector
  • GitHub Check: bill of materials
  • GitHub Check: test on macos-latest
  • GitHub Check: test on ubuntu-latest
  • GitHub Check: linters
  • GitHub Check: reference tools actually installed
  • GitHub Check: test on windows-latest
  • GitHub Check: semgrep
  • GitHub Check: coverage gate
  • GitHub Check: import table of the window binary
  • GitHub Check: known vulnerabilities
  • GitHub Check: staticcheck
  • GitHub Check: Analyze (actions)
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (go)
🧰 Additional context used
📓 Path-based instructions (10)
Applies to text shown to the user (labels, buttons, tooltips, placeholders, dialogs, errors, status messages, empty states, translations).

⚙️ CodeRabbit configuration file

Files:

  • internal/guard/window_test.go
  • internal/gui/window/open.go
  • internal/gui/window/runrefuse.go
  • internal/gui/window/generate.go
  • internal/gui/window/recipe.go
  • internal/gui/window/run.go
  • internal/guard/settleonce_test.go
  • internal/gui/window/preset.go
Verify tests check real behavior and would fail if the implementation were broken.

⚙️ CodeRabbit configuration file

Files:

  • internal/guard/window_test.go
  • internal/guard/settleonce_test.go
Performance is a known weak spot of these projects.

⚙️ CodeRabbit configuration file

Files:

  • internal/guard/window_test.go
  • internal/gui/window/open.go
  • internal/gui/window/runrefuse.go
  • internal/gui/window/generate.go
  • internal/gui/window/recipe.go
  • internal/gui/window/run.go
  • internal/guard/settleonce_test.go
  • internal/gui/window/preset.go
Applies only to code that builds or styles a GUI.

⚙️ CodeRabbit configuration file

Files:

  • internal/guard/window_test.go
  • internal/gui/window/open.go
  • internal/gui/window/runrefuse.go
  • internal/gui/window/generate.go
  • internal/gui/window/recipe.go
  • internal/gui/window/run.go
  • internal/guard/settleonce_test.go
  • internal/gui/window/preset.go
User-facing changelog.

⚙️ CodeRabbit configuration file

Files:

  • CHANGELOG.md
SECURITY, HIGH PRIORITY.

⚙️ CodeRabbit configuration file

Files:

  • internal/guard/window_test.go
  • internal/gui/window/open.go
  • internal/gui/window/runrefuse.go
  • internal/gui/window/generate.go
  • internal/gui/window/recipe.go
  • internal/gui/window/run.go
  • internal/guard/settleonce_test.go
  • internal/gui/window/preset.go
Go code.

⚙️ CodeRabbit configuration file

Files:

  • internal/guard/window_test.go
  • internal/gui/window/open.go
  • internal/gui/window/runrefuse.go
  • internal/gui/window/generate.go
  • internal/gui/window/recipe.go
  • internal/gui/window/run.go
  • internal/guard/settleonce_test.go
  • internal/gui/window/preset.go
Check that documentation matches the actual code in this PR: commands, flags, config keys, file paths, build steps and examples must exist.

⚙️ CodeRabbit configuration file

Files:

  • CHANGELOG.md
All code in this repository is written by an AI coding agent (Claude Code).

⚙️ CodeRabbit configuration file

Files:

  • CHANGELOG.md
  • internal/guard/window_test.go
  • internal/gui/window/open.go
  • internal/gui/window/runrefuse.go
  • internal/gui/window/generate.go
  • internal/gui/window/recipe.go
  • internal/gui/window/run.go
  • internal/guard/settleonce_test.go
  • internal/gui/window/preset.go
Source excerpt: **Words a user reads are English, with a flat hyphen and no semicolons.**

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • CHANGELOG.md
🔇 Additional comments (1)
internal/guard/settleonce_test.go (1)

89-95: 📐 Maintainability & Code Quality

The finding cannot be decided. The supplied snippet does not use a rejected preset argument, but the repository source needed to determine whether another test covers cached refusals was unavailable. The proposed test cannot be required from the available evidence.


📝 Walkthrough

Walkthrough

The change caches preset expansions for matching inputs and reuses settled form values during runner rechecks. Tests measure form reads and preset expansions across screens. The changelog records reduced typing delays on the Presets screen.

Changes

Form settling and preset expansion

Layer / File(s) Summary
Cache preset expansions
internal/gui/window/open.go, internal/gui/window/generate.go, internal/gui/window/recipe.go, internal/gui/window/preset.go, internal/guard/window_test.go, internal/guard/settleonce_test.go
Preset reuses the expansion, notes, or error when the preset ID and arguments match. The window host can record settling and expansion calls. Tests check expansion counts and behavior when preset inputs change.
Reuse settled values during rechecks
internal/gui/window/run.go, internal/gui/window/runrefuse.go, internal/guard/settleonce_test.go, CHANGELOG.md
Status updates and refusal checks use the results of one form settlement. Tests check form-read counts across screens. The changelog describes reduced typing delays.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PresetsScreen
  participant Recheck as runner.recheck
  participant PresetSettle as Preset.settle
  participant LastExpansion as lastExpansion
  PresetsScreen->>Recheck: Field change triggers recheck
  Recheck->>PresetSettle: Settle form once
  PresetSettle->>LastExpansion: Look up selected preset and arguments
  LastExpansion-->>PresetSettle: Return cached or new expansion result
  PresetSettle-->>Recheck: Return targets, options, and error
  Recheck->>Recheck: Update status line and refusal marks
Loading

Suggested labels: bug, performance, ui

🚥 Pre-merge checks | ✅ 13 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Clear User-Facing Text ⚠️ Warning The PR adds user-facing release-note text in CHANGELOG.md. It calls the same destination concept the “output folder,” while the GUI label and nearby user text use “Output directory.” It also describ… Use the established terms: change “output folder” to “output directory,” and replace “with a preset switched on” with “with the Start from a preset box ticked.”
✅ Passed checks (13 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: preventing duplicate preset expansion while typing on the Presets screen. It is specific, user-focused, and suitable for release notes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Tests For Changed Behavior ✅ Passed The PR changes runtime behavior in form settling and preset expansion, and it adds tests for that behavior. internal/guard/settleonce_test.go checks single reads on all three screens, empty fields, …
No Secrets Or Debug Leftovers ✅ Passed PASS: The PR adds no CLAUDE.md, CLAUDE.local.md, AGENTS.md, .claude/, or .env files. The added Go code and changelog contain no credentials, tokens, API keys, private URLs, local absolute paths, IP ad…
No Hardcoded Ui Styling ✅ Passed The PR changes Fyne GUI code, but only settling, caching, and status-line behavior. The diff adds no literal colors, fonts, sizes, margins, paddings, corner radii, or duplicated controls. It does not …
No Obvious Performance Problems ✅ Passed No new qualifying performance problem is introduced. The diff changes recheck from two synchronous settle calls to one and adds lastExpansion caching for unchanged preset arguments, including se…
Desktop Robustness ✅ Passed PASS. The authoritative diff changes form-settling, preset-expansion caching, status-line reuse, and guard tests. It adds no asset loading, file/settings persistence, number/date parsing, network or p…
Safe File Parsing ✅ Passed No safe-file-parsing issue is introduced. The PR changes GUI settling and caches preset.Expand results. The existing recipe.Parse(expanded.Source) call still parses generated in-memory bytes; the …
System Changes Are Reversible ✅ Passed The pull request changes GUI form settling, preset expansion caching, status-line rendering, and guard tests. The authoritative diff contains no changes to network filters or rules, proxies, firewalls…
No Resource Leaks ✅ Passed No resource leak is introduced. The new lastExpansion cache in internal/gui/window/preset.go has one entry per Preset and replaces its got, given, notes, and err on each cache miss, so i…
Scope, Duplication And Docs ✅ Passed The PR scope matches the title and description. The changed code implements the stated single-settle flow, preset expansion cache, and guard counters; the description also covers the Several batches b…
Full details: Clear User-Facing Text

Explanation

The PR adds user-facing release-note text in CHANGELOG.md. It calls the same destination concept the “output folder,” while the GUI label and nearby user text use “Output directory.” It also describes the preset control as “switched on,” while the UI wording identifies it as a box that is ticked.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
✨ Simplify code
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added bug Something isn't working performance ui labels Sep 23, 2026
@donislawdev
donislawdev merged commit 364cda2 into main Sep 23, 2026
20 checks passed
@donislawdev
donislawdev deleted the gui/settle-once branch September 23, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working performance ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant