Skip to content

chore: Keep setup skills step rendering separate from the window#1565

Merged
hatayama merged 1 commit into
v3-betafrom
codex/c4-12-extract-skills-step-presenter
Jul 6, 2026
Merged

chore: Keep setup skills step rendering separate from the window#1565
hatayama merged 1 commit into
v3-betafrom
codex/c4-12-extract-skills-step-presenter

Conversation

@hatayama

@hatayama hatayama commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

Extract SetupWizardSkillsStepPresenter from SetupWizardWindow so the setup wizard skills step rendering is isolated from window orchestration.

User Impact

No behavior change intended. The setup wizard should render the skills target/status/install controls exactly as before.

Changes

  • Added SetupWizardSkillsStepPresenter for the skills step target row/list, status label/divider, and install button.
  • Kept SkillSetupUseCase, async target refresh, async install flow, success dialog decision, first-install mode decision, and CLI-to-skills manageability policy on SetupWizardWindow.
  • Kept group-skills-row, group-skills-toggle, and group-skills-label on SetupWizardWindow because they mutate window state/settings rather than only render.
  • Retargeted skills-step display helper tests from SetupWizardWindow to SetupWizardSkillsStepPresenter.

Checking-State Mapping

The old skills checking block appeared in ApplyInitialCheckingState and RefreshUI with the same behavior split:

  • ViewDataBinder.SetVisible(_groupSkillsRow, false) remains in SetupWizardWindow.
  • _groupSkillsToggle.SetEnabled(false) remains in SetupWizardWindow.
  • UpdateSkillsStatusLabel("Checking installed skills...") moved into SetupWizardSkillsStepPresenter.ShowChecking(...).
  • _installSkillsButton.SetEnabled(false) moved into SetupWizardSkillsStepPresenter.ShowChecking(...).
  • _installSkillsButton.text = "Checking..." moved into SetupWizardSkillsStepPresenter.ShowChecking(...).
  • target row/list visibility moved into SetupWizardSkillsStepPresenter.ShowChecking(...).
  • target list clearing moved into SetupWizardSkillsStepPresenter.ShowChecking(...).

Deviations

  • The install-skills button click binding moved from SetupWizardWindow.BindEvents to the presenter constructor, matching the CLI presenter pattern.
  • UpdateSkillsStatusLabel is now a private presenter helper.
  • _groupSkillsToggle.SetEnabled(canManageSkills && !_isInstallingSkills) remains in SetupWizardWindow and is placed immediately before SetupWizardSkillsStepPresenter.Update(...) so the group-setting control stays window-owned.
  • ShowChecking takes shouldUseFirstInstallSkillsUi so presenter rendering stays parameterized by window-owned state.

Verification

  • dist/darwin-arm64/uloop compile --project-path "$(git rev-parse --show-toplevel)" -> 0 errors / 0 warnings
  • dist/darwin-arm64/uloop run-tests --project-path "$(git rev-parse --show-toplevel)" --test-mode EditMode --filter-type exact --filter-value "io.github.hatayama.UnityCliLoop.Tests.Editor.SetupWizardWindowTests" -> 110 passed

Review in cubic

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

A new SetupWizardSkillsStepPresenter class is introduced to encapsulate the skills-installation step UI logic previously embedded in SetupWizardWindow. SetupWizardWindow is refactored to construct and delegate to this presenter, removing inline UI handling. Unit tests are updated to invoke the presenter's helpers.

Changes

Skills step presenter extraction

Layer / File(s) Summary
Presenter core and update flow
Packages/src/Editor/Presentation/Setup/SetupWizardSkillsStepPresenter.cs
New presenter class wires the install button, exposes ShowChecking for the checking state, and implements Update to render target rows and compute status/button text.
Target selection and status helpers
Packages/src/Editor/Presentation/Setup/SetupWizardSkillsStepPresenter.cs
Static helpers filter installable targets, decide row/list visibility, resolve first-install/selected target info, and map install state/layout flags to status text, CSS classes, and button labels.
Window delegates to presenter
Packages/src/Editor/Presentation/Setup/SetupWizardWindow.cs
SetupWizardWindow removes direct skills-step UI fields, constructs _skillsStepPresenter during binding, and replaces manual checking/refresh/update logic with calls into the presenter; HandleInstallSkills uses the presenter's static helpers.
Tests repointed to presenter
Assets/Tests/Editor/SetupWizardWindowTests.cs
Skills-step tests now invoke SetupWizardSkillsStepPresenter methods instead of the removed SetupWizardWindow helpers; test inputs and assertions are unchanged.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SetupWizardWindow
  participant SetupWizardSkillsStepPresenter
  participant SkillsTargetList

  SetupWizardWindow->>SetupWizardSkillsStepPresenter: ShowChecking(shouldUseFirstInstallSkillsUi)
  SetupWizardSkillsStepPresenter->>SkillsTargetList: clear rows

  SetupWizardWindow->>SetupWizardSkillsStepPresenter: Update(canManageSkills, isInstallingSkills, targets, options)
  SetupWizardSkillsStepPresenter->>SetupWizardSkillsStepPresenter: FilterInstallableSkillTargets / GetSelectedSkillTargetInfo
  SetupWizardSkillsStepPresenter->>SkillsTargetList: render rows with status text and CSS class
  SetupWizardSkillsStepPresenter->>SetupWizardWindow: enable/disable install button, set label
Loading

Possibly related PRs

  • hatayama/unity-cli-loop#855: Further refactors the same SetupWizardWindow skills-step rendering logic that this PR moves into SetupWizardSkillsStepPresenter.
  • hatayama/unity-cli-loop#963: Changes the same FilterInstallableSkillTargets filtering logic and its unit tests that are relocated to the presenter here.
  • hatayama/unity-cli-loop#1432: Modifies the same HandleInstallSkills method that this PR updates to delegate target selection to the new presenter.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed It clearly summarizes the main extraction of skills-step rendering from SetupWizardWindow into a separate presenter.
Description check ✅ Passed It accurately describes the presenter extraction, retained window responsibilities, and test retargeting.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/c4-12-extract-skills-step-presenter

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
Packages/src/Editor/Presentation/Setup/SetupWizardSkillsStepPresenter.cs (2)

29-47: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Redundant double null-check in constructor.

Each parameter is null-checked twice: once via Debug.Assert (lines 29-34) and again via ?? throw new ArgumentNullException (lines 36-47). Since the throw always executes on null regardless of build configuration, the asserts add no additional protection here—they duplicate exactly the same check the throw already performs unconditionally.

♻️ Simplify by removing the redundant asserts
-            Debug.Assert(skillsTargetRow != null, "skillsTargetRow must not be null");
-            Debug.Assert(skillsTargetList != null, "skillsTargetList must not be null");
-            Debug.Assert(skillsStatusDivider != null, "skillsStatusDivider must not be null");
-            Debug.Assert(skillsStatusLabel != null, "skillsStatusLabel must not be null");
-            Debug.Assert(installSkillsButton != null, "installSkillsButton must not be null");
-            Debug.Assert(onInstallSkillsClicked != null, "onInstallSkillsClicked must not be null");
-
             _skillsTargetRow = skillsTargetRow
                 ?? throw new System.ArgumentNullException(nameof(skillsTargetRow));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Packages/src/Editor/Presentation/Setup/SetupWizardSkillsStepPresenter.cs`
around lines 29 - 47, Remove the redundant null guards in
SetupWizardSkillsStepPresenter’s constructor by deleting the Debug.Assert checks
and keeping the existing ArgumentNullException validation for skillsTargetRow,
skillsTargetList, skillsStatusDivider, skillsStatusLabel, installSkillsButton,
and onInstallSkillsClicked; the constructor already enforces the null checks
unconditionally, so the asserts in the initializer block add no extra value.

290-318: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Simplify the no-op ternary

GetSkillInstallStatusClass returns "setup-target-item__status--different-layout" in both branches, so the ternary can be collapsed to a single return.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Packages/src/Editor/Presentation/Setup/SetupWizardSkillsStepPresenter.cs`
around lines 290 - 318, In GetSkillInstallStatusClass, the final ternary is a
no-op because both branches return the same
"setup-target-item__status--different-layout" value. Simplify that return in
SetupWizardSkillsStepPresenter so the method directly returns the string once
after the hasDifferentLayoutSkills check, keeping the existing behavior
unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@Packages/src/Editor/Presentation/Setup/SetupWizardSkillsStepPresenter.cs`:
- Around line 29-47: Remove the redundant null guards in
SetupWizardSkillsStepPresenter’s constructor by deleting the Debug.Assert checks
and keeping the existing ArgumentNullException validation for skillsTargetRow,
skillsTargetList, skillsStatusDivider, skillsStatusLabel, installSkillsButton,
and onInstallSkillsClicked; the constructor already enforces the null checks
unconditionally, so the asserts in the initializer block add no extra value.
- Around line 290-318: In GetSkillInstallStatusClass, the final ternary is a
no-op because both branches return the same
"setup-target-item__status--different-layout" value. Simplify that return in
SetupWizardSkillsStepPresenter so the method directly returns the string once
after the hasDifferentLayoutSkills check, keeping the existing behavior
unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9b805ecf-b7c7-4d84-8073-74b6708d37d6

📥 Commits

Reviewing files that changed from the base of the PR and between ce01c51 and 2841f39.

⛔ Files ignored due to path filters (1)
  • Packages/src/Editor/Presentation/Setup/SetupWizardSkillsStepPresenter.cs.meta is excluded by none and included by none
📒 Files selected for processing (3)
  • Assets/Tests/Editor/SetupWizardWindowTests.cs
  • Packages/src/Editor/Presentation/Setup/SetupWizardSkillsStepPresenter.cs
  • Packages/src/Editor/Presentation/Setup/SetupWizardWindow.cs

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="Packages/src/Editor/Presentation/Setup/SetupWizardSkillsStepPresenter.cs">

<violation number="1" location="Packages/src/Editor/Presentation/Setup/SetupWizardSkillsStepPresenter.cs:74">
P2: Returning users with no existing tool folder can no longer install skills from the setup wizard; the presenter switches to the empty target-list path instead of the target-selection path when `installableTargets.Count == 0`. Consider preserving the previous `shouldUseFirstInstallSkillsUi || installableTargetCount == 0` condition and matching install-target selection logic.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

ShouldShowSkillsTargetRowForSetupWizard(shouldUseFirstInstallSkillsUi));
ViewDataBinder.SetVisible(
_skillsTargetList,
ShouldShowSkillsTargetListForSetupWizard(canManageSkills, shouldUseFirstInstallSkillsUi));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Returning users with no existing tool folder can no longer install skills from the setup wizard; the presenter switches to the empty target-list path instead of the target-selection path when installableTargets.Count == 0. Consider preserving the previous shouldUseFirstInstallSkillsUi || installableTargetCount == 0 condition and matching install-target selection logic.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Packages/src/Editor/Presentation/Setup/SetupWizardSkillsStepPresenter.cs, line 74:

<comment>Returning users with no existing tool folder can no longer install skills from the setup wizard; the presenter switches to the empty target-list path instead of the target-selection path when `installableTargets.Count == 0`. Consider preserving the previous `shouldUseFirstInstallSkillsUi || installableTargetCount == 0` condition and matching install-target selection logic.</comment>

<file context>
@@ -0,0 +1,328 @@
+                ShouldShowSkillsTargetRowForSetupWizard(shouldUseFirstInstallSkillsUi));
+            ViewDataBinder.SetVisible(
+                _skillsTargetList,
+                ShouldShowSkillsTargetListForSetupWizard(canManageSkills, shouldUseFirstInstallSkillsUi));
+
+            if (!canManageSkills)
</file context>

@hatayama
hatayama merged commit e755c76 into v3-beta Jul 6, 2026
10 checks passed
@hatayama
hatayama deleted the codex/c4-12-extract-skills-step-presenter branch July 6, 2026 17:15
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