Skip to content

[CTX-1347] fix(ui): inherit surviving view cwd for new_panel (#2240) - #2242

Merged
Xuepoo merged 1 commit into
mainfrom
ctx-1347/fix-new-panel-cwd
Oct 19, 2026
Merged

Xuepoo merged 1 commit into
mainfrom
ctx-1347/fix-new-panel-cwd

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

new_panel materializing a tiled base over an empty workspace (the #2223
path) installs the layout before spawning the fresh shell. set_layout
re-homes focus to the new leaf, so a post-install inherited_cwd_for read
compared the target with itself, found no surviving source, and the new shell
fell back to the default $HOME instead of the surviving float/pin's OSC 7
directory.

commit_new_leaf now captures the inheritance source before
runtime.set_layout(layout) and passes it through
spawn_pane_shell_in(..., inherited_cwd.as_deref()). The capture contract is
unchanged: inherited_cwd_for still resolves the focused view, ignores a
source equal to the target, and only returns an existing directory from that
pane's session report (explicit spawn cwd or OSC 7); otherwise the PTY
default ($HOME/USERPROFILE, else process cwd) stands. inherited_cwd_for
is now pub + #[must_use] so layout-installing creation paths can read it
before the install.

Under BisectLargest only the focused-survivor source changed: split-target
selection (panel_bisect_target) is untouched, and spawn sizing plus cwd
inheritance still read the focused pane per the CTX-0964/DEC-0099 contract.

Regressions

Both tests drive the real chord and real PTY path, asserting the panel's
rendered grid shows the survivor's OSC 7 directory (/tmp):

  • new_panel_over_empty_base_inherits_float_osc7_cwd_issue_2240 — detach a
    float reporting file:///tmp, drain the tiled base, NewPanel.
  • new_panel_over_empty_base_inherits_pin_osc7_cwd_issue_2240 — pin a
    survivor reporting file:///tmp, drain the tiled base, NewPanel.

Mutation evidence

Moving the capture back after runtime.set_layout(layout) (throwing the fix
away, tests kept) fails both regressions deterministically after the 10s
drain bound:

FAIL tests::new_panel_over_empty_base_inherits_float_osc7_cwd_issue_2240
FAIL tests::new_panel_over_empty_base_inherits_pin_osc7_cwd_issue_2240
new panel must inherit the surviving float's OSC 7 cwd (/tmp):
  "/home/fuyu ..."
new panel must inherit the surviving pin's OSC 7 cwd (/tmp):
  "/home/fuyu ..."

The mutation was reverted byte-for-byte and the worktree is clean.

Gates

  • cargo fmt --all -- --check — pass
  • cargo clippy --workspace --all-targets --locked -- -D warnings — pass
  • cargo clippy -p bitty-terminal --features dev-tools --all-targets --locked -- -D warnings — pass
  • cargo nextest run -p bitty-terminal --locked — 1215 passed, 0 skipped
  • RUSTFLAGS="-D warnings" cargo check --workspace --all-targets --locked --target x86_64-pc-windows-gnu — pass

Rebased onto origin/main at 126579da (CTX-1346 Lua error decoding) on top
of ec3698eb (CTX-1338) and bb4c01ff (CTX-1332); no conflicts.

Closes #2240

Summary by CodeRabbit

  • Bug Fixes
    • New panels now start in the working directory reported by an existing panel, including floating and pinned panels.
    • Fixed cases where creating a panel on an empty tiled layout could start its shell in a different working directory.

@Xuepoo Xuepoo added this to the 0.0.24 milestone Oct 19, 2026
@Xuepoo Xuepoo added fix Bug fix area:ui Area: UI / layout P2 Priority: medium labels Oct 19, 2026
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dd1d87a2-0f98-4c90-9b6d-ec5acb32389f
📥 Commits

Reviewing files that changed from the base of the PR and between 126579d and dd35e7f.

📒 Files selected for processing: 3
  • crates/bitty-runtime/src/runtime/panes.rs
  • crates/bitty-terminal/src/chrome_keys.rs
  • crates/bitty-terminal/src/tests.rs

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

📝 Walkthrough

New panel creation now captures the inherited working directory before installing the layout and passes it to the new shell. Unix PTY tests verify inheritance from surviving floats and pinned panels.

Changes: New panel cwd inheritance

Layer / File(s) Summary
Capture and validate inherited cwd
crates/bitty-runtime/src/runtime/panes.rs, crates/bitty-terminal/src/chrome_keys.rs, crates/bitty-terminal/src/tests.rs
inherited_cwd_for is now public. commit_new_leaf captures the cwd before layout installation and passes it to shell creation. Unix PTY tests cover surviving floats and pinned panels with an OSC 7 cwd.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to dd35e

No actionable merge-blocking risk is identified for new-panel cwd inheritance. Normal checks remain appropriate before merging.

Pre-merge checks: Passed 5
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: inheriting the surviving view's working directory when creating a new panel.
Linked Issues check Passed Issue #2240 requires pre-install cwd capture and regression coverage for float and pin survivors. commit_new_leaf calls inherited_cwd_for(new_id) before set_layout, then passes the result to `sp…
Out of Scope Changes check Passed The changes stay within issue #2240. The public inherited_cwd_for API and its documentation enable the required pre-install read. The commit_new_leaf change fixes cwd propagation. The added test h…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files.
Full details: Linked Issues check

Explanation

Issue #2240 requires pre-install cwd capture and regression coverage for float and pin survivors. commit_new_leaf calls inherited_cwd_for(new_id) before set_layout, then passes the result to spawn_pane_shell_in. The PR summary reports real-chord, real-PTY tests for both float and pin survivors, with /tmp assertions. The focused diff confirms the capture order and spawn argument.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #2240. The public inherited_cwd_for API and its documentation enable the required pre-install read. The commit_new_leaf change fixes cwd propagation. The added test helpers and regression tests verify the requested UI behavior. No unrelated behavior is demonstrated.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@Xuepoo
Xuepoo merged commit d454b8b into main Oct 19, 2026
17 checks passed
@Xuepoo
Xuepoo deleted the ctx-1347/fix-new-panel-cwd branch October 19, 2026 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ui Area: UI / layout fix Bug fix P2 Priority: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P2] new panel over an empty tiled base ignores the surviving float/pin cwd

1 participant