Repository navigation
fix: replace the active tab when opening a file from the tree - #56
Conversation
Gruvbox warmth on a blue-grey surface, with a dusty-mauve accent, matching the AETHER / G.A.I.A v2 desktop theme. Three slots deviate from the source palette because its literal values fail the crate's own contrast audit: accent.primary uses the source magenta (#c98fa0) since no foreground reaches AA on #a0607a, state.selection_bg is a lightened selection (#503a4a) to clear MIN_SELECTION_DELTA, and state.focus is the magenta accent at 6.45:1 on the base surface.
`Tabs::open_or_focus` answers `Replaced` for a tree-driven open of a file that is not already open, and hands back the active tab without rewriting its `current_path`. `apply_file_loaded` looks the receiving tab up by path, so it found no match and dropped the content it had just read: the tree cursor moved and focus switched to the viewer, but the previous document stayed on screen, which reads as the file tree no longer switching files. Fall back to the active tab for replacements, and cover it with a test that fails without the fallback. Co-Authored-By: Claude Code <[email protected]>
leboiko
left a comment
There was a problem hiding this comment.
Blocking correctness finding in src/app/file_ops.rs:249: a replacement load writes into the tab active at completion, which can differ from its original target. Reproduced with a regression test: request B in tab A, open tab C, then deliver FileLoaded(B); C changes from /fake/third.md to /fake/other.md. Rapid replacement requests and closed targets also need coverage. I am building on your commits to preserve request ownership and test these cases before merge.
Co-authored-by: yhqian <[email protected]>
|
Reviewed and corrected in 00cf5e4, preserving the contributor commits and credit.
Local validation passed: rustfmt, workspace/all-target Clippy, full workspace tests on stable and Rust 1.92, docs, cargo-deny and cargo-audit. Existing documentation warnings and six nonblocking audit warnings remain. A source-jump regression in the initial correction was caught by the existing harness and fixed without weakening that test. Detailed red-team review is committed in PR-56-review.md. No unresolved merge-blocking code findings; waiting for remote checks. |
leboiko
left a comment
There was a problem hiding this comment.
Reviewed corrected head 00cf5e4. The wrong-tab and stale-completion regressions are fixed, original contributor regression retained, and all local gates plus all 12 GitHub checks pass. Linux/macOS Nix builds and binary smoke tests pass. No unresolved merge-blocking findings; details in PR-56-review.md.
Summary
Opening a file from the tree (Enter,
l, or a mouse click) silently did nothingwhen that file was not already open in a tab: the tree cursor moved and focus
switched to the viewer, but the document on screen stayed the previous one — so
the file tree appeared to have stopped switching files.
Tabs::open_or_focusanswersOpenOutcome::Replacedfor that case and handsback the active tab without rewriting its
current_path, whileapply_file_loadedlooks the receiving tab up by path. It therefore found nomatch and dropped the content it had just read from the background reader. Only
files that were already open (
OpenOutcome::Focused) switched correctly, whichis why this was easy to miss — a restored session that already has the file in a
tab behaves fine.
Changes
src/app/file_ops.rs—apply_file_loadedfalls back to the active tab whenthe path-keyed lookup misses and the load is a replacement
(
new_tab == false); for a replacement the tabopen_or_focushanded backis the target.
new_tabis no longer_new_tab.src/app/tests.rs— new regression testopening_other_file_replaces_active_tab_content, driving the same sequence(
open_or_focus(second, false, None)followed byAction::FileLoaded) andasserting the tab's
current_path, content and label.CHANGELOG.md— entry under[Unreleased] / Fixed.Test Plan
cargo test --workspaceon Linux (x86_64-unknown-linux-gnu): all testbinaries pass, 0 failures (536 in
markdown-tui-explorer, 853 inmermaid-text, plus the integration binaries).The checks from CONTRIBUTING.md all pass on the same host:
cargo fmt --all,cargo clippy --all-targets --all-features -- -D warnings, andcargo test --all-targets(also 0 failures). No README change: it alreadydocuments
Enter/l/Rightas "Open file (current tab)", which isexactly the behaviour this restores.
The new test fails against the pre-fix
apply_file_loaded(
left: Some("/fake/test.md"), right: Some("/fake/other.md")), i.e. it coversthe bug rather than the fix.
Exercised by hand in the TUI on Windows Terminal: opened a two-file directory,
selected the second file in the tree and pressed Enter — the active tab
switched to it, confirmed on screen and by the session the app writes on quit
(
state.tomlrecords the tab's new path). No macOS machine available; thechange contains no
cfg(target_os)branches, so the code path is shared, butit has not been run on macOS.
Existing tests pass (
cargo test --workspace)New tests added where appropriate
Manually tested on macOS / Linux (specify which) — manual run was on
Windows; on Linux only the test suite was run
If a Mermaid block changed, verified rendering in TUI and via
mermaid-textCLI — N/A, no Mermaid code touchedChecklist
markdown-tui-explorer, crate-localfor
mermaid-text)clippywarnings (cargo clippy --all-targets -- -D warnings)Cargo.tomlif user-visible — left to arelease:commit, matching how the other
[Unreleased]fixes are handledLinked Issue
Closes #