Skip to content

fix(tabs): route hotkey duplicate through the tab menu duplicate path - #483

Merged
feigeCode merged 2 commits into
feigeCode:mainfrom
keenser:fix/duplicate-tab-cwd
Oct 29, 2026
Merged

feigeCode merged 2 commits into
feigeCode:mainfrom
keenser:fix/duplicate-tab-cwd

Conversation

@keenser

@keenser keenser commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes tab duplication so a duplicated tab preserves the working directory and connection settings of the source tab.

Previously the hotkey duplicated the active tab through its own HomePage::duplicate_active_tab path, which reopened tabs by connection kind and had several problems:

  • Local terminals fell back to default settings, losing the CWD and any custom/WSL profile.
  • SSH terminals ignored the current directory.
  • Temporary connections silently did nothing when no StoredConnection matched.
  • The copy never subscribed to the terminal's OpenSftp / SaveAsConnection events.

Now duplication delegates to TabContainer::duplicate_active_tab (the same path the tab context menu uses) and emits TabContainerEvent::TabDuplicated, so HomePage can attach the terminal event subscriptions to the copy. The inherited _ONETCLI_SHELL_INTEGRATED is also cleared for new sessions: a host process launched from a Navop terminal carries this variable, the integration script's re-entry guard returns early, OSC 7 stops being reported, and duplicated tabs lose the CWD.

In addition, two shell-integration tests are made parallel-safe by isolating them in their own tempfile::tempdir() directories instead of sharing the process-level $TMPDIR/onetcli-<pid> (which made one test delete the other's files).

How to Test

  1. Open a Navop terminal and cd into a project directory.
  2. Press the duplicate-tab hotkey (or use the tab context menu "Duplicate").
  3. Confirm the duplicated tab opens in the same directory with the same connection settings (local custom/WSL profile, SSH remote, etc.).
  4. From a Navop terminal, launch a child process that starts a new terminal and duplicate it again; confirm the CWD is still preserved (no lost OSC 7 reporting).
  5. Run the affected tests:
    cargo test -p terminal prepare_shell_integration
    cargo test -p one_core tab_container
    cargo run
    

Checklist

  • I have read the CONTRIBUTING document and followed the guidelines.
  • Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate.
  • Passed cargo run for story tests related to the changes.
  • Tested macOS, Windows and Linux platforms performance (if the change is platform-specific)

The hotkey used its own HomePage::duplicate_active_tab, reopening tabs by
connection kind: local terminals fell back to default settings (losing the
CWD and any custom/WSL profile), SSH ignored the current directory, temporary
connections silently did nothing when no StoredConnection matched, and the
copy never subscribed to the terminal's OpenSftp/SaveAsConnection events.

Duplicate now delegates to TabContainer::duplicate_active_tab and emits
TabContainerEvent::TabDuplicated so HomePage can attach the terminal event
subscriptions to the copy. Also clear the inherited _ONETCLI_SHELL_INTEGRATED
for new sessions: a host process launched from a Navop terminal carries it,
the integration script's re-entry guard returns early, OSC 7 stops being
reported, and duplicated tabs lose the CWD.
prepare_shell_integration_writes_lf_only_script and
zsh_shell_integration_sources_generated_zshrc both used
$TMPDIR/onetcli-<pid> and removed it at start and end, so running them in
parallel made one delete the other's files (flaky NotFound / missing script).

The body now lives in prepare_shell_integration_in(session_dir, shell); the
production wrapper still passes the process-level directory. Both tests take
their own tempfile::tempdir() (plus a temp HOME for zsh).
@feigeCode
feigeCode merged commit b668851 into feigeCode:main Oct 29, 2026
8 checks passed
feigeCode added a commit that referenced this pull request Oct 31, 2026
冲突解决:main/src/home/home_tabs.rs 保留三产品拆分布局,快捷键复制改走
TabContainer::duplicate_active_tab(等价 #483:与标签菜单共用复制路径,终端保留当前工作目录,
并对任何可复制标签生效),复制出的终端标签在 main/src/home_tab/lifecycle.rs 补回
OpenSftp / SaveAsConnection 订阅;随之删除不再被使用的 ShellExtras::duplicate_terminal_tab 契约。

origin/main 上的 #482 / #483 / #484 其余改动(标签收缩、Esc 只在编辑器上下文生效、
terminal 测试隔离)均无冲突合入。

顺带修 main/src/home/home_tabs.rs 里 notify_unsupported 的属性与文档注释空行(clippy 告警)。
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