Skip to content

fix(launch-wizard): preserve user-selected agent across hydration#2745

Merged
akiojin merged 1 commit into
developfrom
work/20260515-1332
May 15, 2026
Merged

fix(launch-wizard): preserve user-selected agent across hydration#2745
akiojin merged 1 commit into
developfrom
work/20260515-1332

Conversation

@akiojin
Copy link
Copy Markdown
Owner

@akiojin akiojin commented May 15, 2026

Summary

  • Wizard の Settings step で選んだ agent が Runtime confirmation 後に前回 Launch agent (preferred agent) で上書きされる regression を解消
  • LaunchWizardState::apply_hydration から agent identity 上書きを除き、現在選択 agent の per-agent draft / previous profile だけを refresh する設計へ補正
  • SPEC-2014 に新 phase 2026-05-15 Wizard Hydration Preserves User-Selected Agent を追加し、US-24 / FR-054..FR-056 / SC-029..SC-030 を spec / plan / tasks に反映

Changes

  • crates/gwt/src/launch_wizard.rs: apply_hydration 内の apply_preferred_agent_profile() 呼び出しを restore_agent_draft_or_defaults() に置換 (line 1043-1049 周辺)。apply_preferred_agent_profile 自体は constructor 経由 (line 781) と set_agent_id 経由の明示的切替で利用するため残し、関数 doc コメントに constructor-only と明示
  • crates/gwt/src/launch_wizard.rs (mod tests): RED test を 2 件追加
    • apply_runtime_context_preserves_user_selected_agent_after_settings_step — Runtime confirmation 経路で user の agent_id 選択が保持されることを固定
    • custom_agent_cache_refresh_preserves_user_selected_agent — custom agent cache refresh 経路で同じ性質を固定
  • SPEC-2014 (Issue SPEC-2014: Launch Wizard — エージェント起動ウィザード GUI・ステップフロー・セッション再開 #2014): spec / plan / tasks## 2026-05-15 Wizard Hydration Preserves User-Selected Agent phase を追加 (US-24 / FR-054..FR-056 / SC-029..SC-030 / T85..T88)

Testing

  • cargo test -p gwt --lib launch_wizard::tests::apply_runtime_context_preserves_user_selected_agent_after_settings_step --nocapture — fix 前 FAILED (left: "codex" right: "claude") → fix 後 PASSED
  • cargo test -p gwt --lib launch_wizard::tests::custom_agent_cache_refresh_preserves_user_selected_agent --nocapture — fix 前 FAILED → fix 後 PASSED
  • cargo test -p gwt --lib launch_wizard::tests::hydration_refresh_preserves_open_wizard_agent_settings_without_reapplying_preferences --nocapture — GREEN を維持
  • cargo test -p gwt --lib launch_wizard::tests — 75 passed / 0 failed
  • cargo test -p gwt-core -p gwt --all-features — 全 suite green
  • cargo clippy --all-targets --all-features -- -D warnings — warning なし
  • cargo fmt -- --check — diff なし
  • cargo build -p gwt --bin gwt --bin gwtd — success
  • bunx commitlint --from HEAD~1 --to HEAD — exit 0

Manual Verification (推奨)

  1. cargo run -p gwt --bin gwt で gwt 起動
  2. Branches 画面で branch を選択 → Launch Agent
  3. Settings step で agent を前回と異なる agent (例: 前回 Codex なら Claude Code) に切り替え
  4. Continue で Runtime confirmation step に進む
  5. 期待: agent indicator / summary が手順 3 で選んだ agent を維持し、Launch 時に同 agent の PTY が起動する
  6. Start Work 経由でも同手順で再現確認

Closing Issues

  • None

Related Issues / Links

Checklist

  • Tests added/updated
  • Lint/format passed (cargo clippy, cargo fmt)
  • Documentation updated (if user-facing change) — SPEC-2014 spec/plan/tasks 更新
  • Migration/backfill plan included (if schema/data change) — schema/data 変更なし
  • CHANGELOG impact considered (breaking change flagged in commit) — fix: patch 扱い、breaking change なし

Context

  • 直近の SPEC-2014 追加項目 2026-05-11 Local User Agent Preferences2026-05-12 Host/Docker Per-Repo Persistence で hydration 経路の previous_profiles refresh が強化された際、apply_preferred_agent_profile() が agent_id まで上書きしていた点が見落とされた regression
  • SPEC-2014 plan の LaunchWizardState の初期化と agent 切替時の fallback を、open Wizard draft -> local user agent preference -> agent defaults の順にする 規定 (2026-05-11 Local User Agent Preferences) と実装の乖離を解消する

Risk / Impact

  • Affected areas: Launch Wizard hydration 経路 (Runtime confirmation / custom agent cache refresh / runtime hydration の 3 経路)
  • Rollback plan: apply_hydration 内の 1 行 (restore_agent_draft_or_defaultsapply_preferred_agent_profile) を戻すだけで挙動が元に戻る。SPEC-2014 phase 追加は revert 不要 (記録として保持可)

`LaunchWizardState::apply_hydration` が Runtime confirmation や custom agent
cache refresh の経路で `apply_preferred_agent_profile()` を再実行し、
ユーザーが Settings step で明示的に選んだ `agent_id` を前回 Launch agent
(preferred agent) で上書きしていた。SPEC-2014 FR-024 / FR-025 / FR-026
(2026-05-11 Local User Agent Preferences) の plan は preferred agent identity を
wizard 初期化と明示的 agent 切替時のみ適用すると規定しており、hydration 経路で
再適用するとは記述されていない。

`apply_hydration` 内の `apply_preferred_agent_profile()` 呼び出しを
`restore_agent_draft_or_defaults()` に置き換え、現在選択 agent の per-agent
draft / previous profile だけを refresh するようにする。
`apply_preferred_agent_profile` 自体は constructor 経由 (initial open) と
`set_agent_id` 経由の明示的切替で利用するため残し、関数 doc コメントに
constructor-only と明示。

SPEC-2014 に新 phase `2026-05-15 Wizard Hydration Preserves User-Selected
Agent` を追加し、US-24 / FR-054..FR-056 / SC-029..SC-030 を spec / plan /
tasks に反映。RED test 2 件 (apply_runtime_context / custom agent cache
refresh path) と既存の hydration_refresh_preserves_open_wizard_agent_settings
test を併走させ、hydration 経路で agent identity が保持されることを固定する。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Warning

Rate limit exceeded

@akiojin has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e14007b8-6005-4167-9411-267d376a3b13

📥 Commits

Reviewing files that changed from the base of the PR and between 0ba2064 and 04c9889.

📒 Files selected for processing (1)
  • crates/gwt/src/launch_wizard.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch work/20260515-1332

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 and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 04c9889b8e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 1046 to +1047
if refreshed_previous_profiles && self.launch_path != LaunchWizardLaunchPath::QuickStart {
self.apply_preferred_agent_profile();
self.restore_agent_draft_or_defaults();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Re-apply preferred agent during hydration for loading wizard

In the open_loading flow, the wizard starts with empty previous_profiles and receives them only on async hydration (open_launch_wizard_for_branch creates open_loading, then apply_hydration applies resolved profiles). Replacing apply_preferred_agent_profile() with restore_agent_draft_or_defaults() here means preferred_agent_id is never applied in that path, so users can be reset to the first detected agent instead of their saved preferred agent whenever hydration completes. This regresses the persisted agent-preference behavior for normal Launch Wizard opens.

Useful? React with 👍 / 👎.

@akiojin akiojin merged commit e360182 into develop May 15, 2026
13 checks passed
@akiojin akiojin mentioned this pull request May 16, 2026
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.

1 participant