Skip to content

Ribbon: each window keeps its own tab, so Table Design stays active (#2903) - #3041

Merged
h-a-n-a-s-h-i merged 2 commits into
storytold:mainfrom
maxm11:fix/2903-table-design-tab
Nov 1, 2026
Merged

h-a-n-a-s-h-i merged 2 commits into
storytold:mainfrom
maxm11:fix/2903-table-design-tab

Conversation

@maxm11

@maxm11 maxm11 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2903.

Root cause

app.ui.ribbon_tab was global to the app, while ribbon::show resets an unavailable contextual tab to Home for the window it is drawing. With two windows (e.g. one on each screen), DocWindows::show draws every window each frame. A window whose active cell is outside the table reset the shared tab to Home after the other window had selected Table Design, so the tab flashed and fell back to Home even though the first window's selection was still in the table. Restarting removed the second window, which is why the reporter saw it work after a restart.

Change

WindowUi now carries the window's ribbon_tab, swapped with the rest of the per-window interface state. A new window inherits the current tab (preserving File › New/Open keeping the ribbon as it was); after that, each window's contextual tab is judged against its own selection.

Test

contextual_ribbon_tab::a_second_window_does_not_reset_the_first_windows_table_design_tab creates a second window on the same workbook with its active cell outside the table, clicks Table Design in the first window, draws the second window's frame, and asserts the first window's tab and table selection survive while the second window shows Home. It fails on main (left: "Home", right: "Table Design").

Validation

  • cargo test -p gridcraft-ui-egui --test it: 903 passed, 2 failed; both failures are pre-existing on main without the optional CRAFT_FONTS_DIR input (interaction::column_autocomplete_folds_case_beyond_ascii: no glyph for ẞ; interaction::language_switch_renders_the_ribbon_and_persists: no glyph for ẻ). Confirmed the autocomplete failure on unmodified main.
  • cargo test --workspace --lib --bins --tests with those two font-dependent tests skipped: passes (24 test binaries).
  • cargo xtask ci: i18n-report, fmt, clippy pass; test stops at the same two environmental font failures. assets, layers, parity --check, keytips --check, cargo test --workspace --doc pass separately.
  • cargo xtask wasm could not run here: this machine's Rust is a Homebrew install with no rustup and no wasm32-unknown-unknown target. The change is ordinary String state in ui-egui.
  • Offscreen snapshot of the sample workbook renders normally. A Table Design snapshot is blocked by the example's strict accessibility check on the existing unlabelled Table Name TextInput (unrelated to this change).

Summary by CodeRabbit

  • Bug Fixes
    • Ribbon tabs now stay in sync with the active window. Switching between windows restores each window’s selected tab, including contextual tabs such as Table Design, without changing the other window’s selection. Each window retains its own tab choice as you move between windows, even when the windows have different selections.

@maxm11
maxm11 force-pushed the fix/2903-table-design-tab branch from 620c520 to 85bfe35 Compare October 31, 2026 15:58
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 85bfe35 and aacdec4.

Files selected for processing: 1
  • contributors/people.toml

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Walkthrough

Each window now retains its ribbon tab when the active window changes. An integration test checks tab and selection context across two windows. The contributor data also gains an entry with GitHub-name synchronization enabled.

Changes: Per-window ribbon state

Layer / File(s) Summary
Store and verify per-window ribbon tabs
crates/ui-egui/src/window_ui.rs, crates/ui-egui/tests/it/contextual_ribbon_tab.rs
WindowUi initializes and swaps each window’s ribbon tab. The integration test checks the tab and selection across two windows.

Contributor entry

Layer / File(s) Summary
Add contributor entry
contributors/people.toml
The contributor data adds an entry with GitHub-name synchronization enabled.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: aiongg, dylanmtaylor

Merge Risk: Minimal · up to aacde

No actionable merge-blocking risk is established; the changes are safe to merge.

Architecture risk: Low · up to aacde

The change affects 2 systems.

Changed systems: crates, contributors

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — crates (service) was modified; 2 changed files map to changed impact.
  • observed — contributors (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in crates/ui-egui/src/window_ui.rs: WindowUi adds a per-window ribbon_tab field. WindowUi::fresh now accepts the current ribbon tab and initializes the new state with a copy of it.
  • observed — Modified behavior in crates/ui-egui/src/window_ui.rs: swap_window_ui now destructures the per-window ribbon tab from WindowUi.
  • observed — Modified behavior in crates/ui-egui/src/window_ui.rs: swap_window_ui now exchanges self.ui.ribbon_tab with the tab stored in the window state.
  • observed — Modified behavior in crates/ui-egui/src/window_ui.rs: When creating the outgoing window state, follow_active_window now passes the current ribbon tab to WindowUi::fresh.
Pre-merge checks: Passed 3 · Failed 1 · Inconclusive 1

Failed Failed checks: 1 warning · 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Out of Scope Changes check Inconclusive The window_ui.rs and contextual_ribbon_tab.rs changes connect directly to #2903. The raw summary also lists contributors/people.toml (+3/-0), which adds a [people.maxm11] entry. This entry does not re… Confirm that the contributors/people.toml change is present in this PR and is the entry for the PR author. Make the base and head blobs of contributors/people.toml readable so that the diff can be checked. If the change is confirmed and the…
Passed Passed checks: 3 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: ribbon tabs are stored per window so the Table Design tab remains active.
Linked Issues check Passed Issue #2903 requires that the Table Design contextual tab stays selected while a cell inside the table is active. The tab must not flash and return to Home. The root cause is the app-wide ui.ribbon_ta…
Full details: Linked Issues check

Explanation

Issue #2903 requires that the Table Design contextual tab stays selected while a cell inside the table is active. The tab must not flash and return to Home. The root cause is the app-wide ui.ribbon_tab, which another window's frame reset. The whole-PR diff (merge base 67e39fa to head aacdec4) confirms the source fix in crates/ui-egui/src/window_ui.rs. WindowUi now stores ribbon_tab. swap_window_ui swaps it with self.ui.ribbon_tab, so each window's contextual tab is judged against its own selection. WindowUi::fresh copies the current tab into a new window, so File › New/Open keeps the ribbon as it was. The regression test contextual_ribbon_tab::a_second_window_does_not_reset_the_first_windows_table_design_tab covers the reported two-window case. This pass did not re-read the test diff or run the test suite. The PR reports that the test fails on main and passes with the change. That report is not verified here.

Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Full details: Out of Scope Changes check

Explanation

The window_ui.rs and contextual_ribbon_tab.rs changes connect directly to #2903. The raw summary also lists contributors/people.toml (+3/-0), which adds a [people.maxm11] entry. This entry does not relate to the ribbon defect in #2903. The file header allows a contributor to add only their own entry, in their own PR. The base blob and the diff for contributors/people.toml could not be read because the changed blobs are missing from the checkout. The head file shows the maxm11 entry at its end, but the change against base is not confirmed. The PR description does not name the PR author, so it is not established that maxm11 is the author.

Resolution

Confirm that the contributors/people.toml change is present in this PR and is the entry for the PR author. Make the base and head blobs of contributors/people.toml readable so that the diff can be checked. If the change is confirmed and the entry belongs to the author, keep it as an administrative change or move it to a separate PR. If it belongs to another person, remove it from this PR.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@FredApps FredApps 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.

ReviewerA — source-read COMMENT (not an approval)

I read the hunks: each window keeps its own ribbon tab (ribbon_tab on WindowUi), because a contextual tab like Table Design depends on that window's selection and another window's frame reset it (#2903). The reasoning is right. The PR also adds maxm11 to contributors/people.toml; #3038 adds the same lines at the same spot, so whichever merges second will conflict. Please rebase one on the other or drop the duplicate. I did not read the rest of window_ui.rs; add a two-window test.

I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.

Status: waiting_author.

@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit 81ee96f into storytold:main Nov 1, 2026
1 check passed
@echelon

echelon commented Nov 1, 2026

Copy link
Copy Markdown
Member

Merged in ea1d52f. Thanks, per-window ribbon tabs fix the Table Design flicker nicely.

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.

Table Design contextual tab doesn't open: clicking it flashes the ribbon and switches to "Home". Everything else stays the same

4 participants