Skip to content

fix(workspace): honour the startup directory on cold start - #485

Merged
Kuddev merged 4 commits into
Kuddev:mainfrom
azzliang6:fix/issue-479-startup-directory-cold-start
Oct 5, 2026
Merged

Kuddev merged 4 commits into
Kuddev:mainfrom
azzliang6:fix/issue-479-startup-directory-cold-start

Conversation

@azzliang6

@azzliang6 azzliang6 commented Oct 5, 2026 •

Copy link
Copy Markdown

Advertising, commercial promotion, and traffic solicitation are prohibited in PRs
and Issues. Business requests must go through the email in the
contribution policy.
PRs or Issues containing unauthorized promotion will be closed directly.
严禁利用 PR 或 Issue 推广、引流,未经授权的推广将直接关闭;商业需求请通过贡献指南中的邮箱沟通,已获批准的赞助按批准范围处理。

Result / 用户结果

Addresses the cold-start part of #479. When no tab is restored at startup (empty session, restore_session=0, missing session.json, tripped boot breaker, or a failed post-update restore), the first terminal now opens in the configured Startup directory instead of the process working directory. With the login-autostart shortcut that process directory is %USERPROFILE%, so the setting was ignored on every boot while Ctrl+T tabs honoured it.

启动时没有恢复出任何标签(空会话、关闭「启动时恢复上次标签」、缺少 session.json、断路器跳闸、更新后恢复失败)时,首个终端现在进入设置里的「启动目录」,不再落在进程启动目录。开机自启动快捷方式的起始位置是 %USERPROFILE%,此前每次开机都会忽略该设置,而 Ctrl+T 新标签是正确的。

Design / 设计边界

  • Responsibility and affected modules: gpui_shell/workspace.rs — the RestoreOrDefault and RestoreUpdate cold-start fallbacks call Self::cold_start_cwd() instead of std::env::current_dir(). The helper lives in gpui_shell/workspace/session_recovery.rs (cold restoration) and reuses the existing NebulaWorkspace::startup_directory(), the same authority add_terminal uses, so no second reading of the setting is added.
  • Why this belongs here; interfaces that remain unchanged: priority stays "explicit CLI dir > restored session > startup directory > process cwd", matching the legacy shell's preferred_initial_cwd. windowing::initial_startup dispatch is unchanged, so an explicit CLI path still wins and a restored session still keeps its saved cwd.
  • Dependency, data-format, threading, or lifetime changes (ADR if applicable): none.
  • Compatibility and migration/fallback behavior: when the startup directory is unset or no longer a directory, behaviour is identical to before (inherit the launch directory, the 1.8.0 contract). The second-launch handoff to a resident instance mentioned at the end of [Bug] 设置启动目录后,开机自启动的首个终端仍打开在 %USERPROFILE% #479 is intentionally not changed here.

Evidence / 验证依据

  • Commands and actual results (include unrun checks), on Linux x86_64 with the pinned 1.97.1 toolchain:
    • cargo test --locked -p nebula --bin pebrel --features gpui-shell cold_start_tests — 2 passed (and configured_startup_directory_wins_over_the_launch_directory fails when the helper is reverted to the old "launch directory only" behaviour)
    • cargo check --locked -p nebula --bin pebrel --features gpui-shell --tests — passes (only pre-existing warnings)
    • python3 scripts/check_architecture.py --base origin/main (base b6e7b78d) — passes
    • python3 -m unittest scripts.tests.test_architecture_budgets scripts.tests.test_architecture_dependencies scripts.tests.test_architecture_governance — 54 tests OK
    • cargo fmt --all -- --check — passes
    • Not run: Windows build or manual autostart reproduction (no Windows machine available), macOS, the GPUI window tests behind gpui-test-support, the full native suite (left to CI).
  • Regression tests: configured_startup_directory_wins_over_the_launch_directory pins that a configured startup directory beats the launch directory (%USERPROFILE% in the autostart case). The old fallback passed std::env::current_dir() straight through, which is exactly the case this test rejects. unset_startup_directory_keeps_inheriting_the_launch_directory covers the preserved unset/invalid path.
  • UI changes: none.
  • Hot-path changes: none (one settings read on the cold-start path only, as Ctrl+T already does).

Required Review / 必须确认

  • I followed CONTRIBUTING.md, docs/architecture.md, and docs/project-constraints.md.
  • I split responsibilities, not arbitrary line ranges; no duplicate behavior authority was added.
  • python3 scripts/check_architecture.py --base <PR-base-commit> passes; budgets were not inflated to fit the change.
  • Tests cover success and failure; platform/feature coverage limitations are stated.
  • New messages use typed i18n IDs and matching placeholders; untranslated content has an explicit fallback. (N/A: no new messages)
  • Governance changes include a counterexample, corrected contract, tests, and a maintainer-reviewed decision. (N/A)

Checkboxes explain the review; they do not replace CI or maintainer approval.

When no tab is restored (empty session, restore disabled, missing
session, tripped boot breaker or failed post-update restore), the first
terminal used the process working directory. The login-autostart
shortcut sets that to %USERPROFILE%, so the configured startup directory
was ignored on every boot while Ctrl+T tabs honoured it.

Prefer the startup directory for both cold-start fallbacks, falling back
to the launch directory when it is unset or invalid.

Fixes Kuddev#479
@azzliang6
azzliang6 requested a review from Kuddev as a code owner October 5, 2026 12:40

@Kuddev Kuddev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已审阅两处冷启动入口及 startup_directory / initial_startup / restore 路径。修复复用现有目录校验,只在恢复未产生标签时读取配置目录;不改变显式 CLI 目录、已恢复会话目录及未配置/无效目录的回退。没有新依赖、线程或常驻缓存,成本限于冷启动路径。

维护者已直接把测试目录改为中性名称并同步 main。本地 Windows 产品测试构建使用 gpui-test-support,cold_start_tests 两项通过;架构、名称范围与差异检查通过。未运行真实登录自启动或全套本地 UI 场景。批准精确 head 的代码;合并仍等待该 head 的必需 CI,旧 head 的成功记录不替代它。

@Kuddev Kuddev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已同步 main 中合入的 #351。复核最终 diff 仍仅为原来的两处冷启动回退及共享 helper/测试,没有覆盖 WSL 主线逻辑。最终 head aedfd3e 的 Windows 产品 cold_start_tests 再次 2/2 通过,架构、格式、名称范围与差异检查通过。维持代码批准,等待这一 head 的必需 CI 完成后合并。

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