Skip to content

feat: add Run All Phases toggle to wizard and resize modal#507

Open
pedramamini wants to merge 3 commits intomainfrom
run-all-wizard-docs
Open

feat: add Run All Phases toggle to wizard and resize modal#507
pedramamini wants to merge 3 commits intomainfrom
run-all-wizard-docs

Conversation

@pedramamini
Copy link
Collaborator

@pedramamini pedramamini commented Mar 3, 2026

Summary

  • Resized wizard modal to match Director's Notes dimensions (1200px wide, 85vh tall)
  • Added "Run All Phases" toggle to Step 5 (Review Your Playbooks), visible when 2+ documents are generated
  • When toggled on, all documents with tasks are queued for batch run instead of only the first
  • Extracted reusable ToggleSwitch component to ui/ and refactored SettingCheckbox to use it

Test plan

  • New test added: verifies all 3 docs are included in batch config when runAllDocuments is true
  • All 67 tests pass (66 existing + 1 new)
  • TypeScript type checking passes
  • lint-staged (prettier + eslint) passes
  • Manual: open wizard, generate 2+ phases, verify toggle appears and label changes between "Auto Run All Phases" / "Auto Run First Phase Only For Now"
  • Manual: launch with toggle ON → verify all docs are queued in batch run
  • Manual: launch with toggle OFF → verify only first doc is queued (existing behavior)
  • Manual: verify wizard modal is visually larger and matches Director's Notes size

Closes #490

Summary by CodeRabbit

  • New Features

    • "Run All documents" option to run multiple documents sequentially; reusable ToggleSwitch control added and wired into settings and review UI.
  • UI/Style

    • Updated wizard modal sizing for improved layout and responsiveness.
  • Tests

    • Added test to verify auto-starting batch runs includes all documents when Run All is enabled.

- Resize wizard modal from max-w-5xl (1024px) to 1200px wide / 85vh tall,
  matching Director's Notes dimensions
- Add runAllDocuments toggle to PhaseReviewScreen (Step 5), visible when
  there are 2+ generated documents
- When enabled, all documents with tasks are included in the batch config
  instead of only the first
- Extract reusable ToggleSwitch component to ui/ and refactor
  SettingCheckbox to use it
- Add test for run-all-documents batch behavior

Closes #490
@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

📝 Walkthrough

Walkthrough

Adds an "Auto-run all phases" option: a new runAllDocuments boolean in Wizard state, a reusable ToggleSwitch UI, PhaseReviewScreen UI wiring, handler changes to build batch runs for all documents when enabled, and a test verifying auto-start with all documents.

Changes

Cohort / File(s) Summary
New UI Component
src/renderer/components/ui/ToggleSwitch.tsx, src/renderer/components/ui/index.ts
Adds ToggleSwitch component and ToggleSwitchProps, exports them from UI index.
State Management
src/renderer/components/Wizard/WizardContext.tsx
Adds runAllDocuments: boolean to WizardState, SET_RUN_ALL_DOCUMENTS action, reducer branch, setRunAllDocuments API, and includes field in serializable/resume state.
Wizard Screens & Small UI Refactors
src/renderer/components/Wizard/screens/PhaseReviewScreen.tsx, src/renderer/components/Wizard/MaestroWizard.tsx, src/renderer/components/SettingCheckbox.tsx
PhaseReviewScreen: shows Run All toggle and wires to setRunAllDocuments; MaestroWizard: modal sizing tweak; SettingCheckbox: replaced inline toggle with ToggleSwitch.
Batch Run Logic
src/renderer/hooks/wizard/useWizardHandlers.ts
Reads runAllDocuments from wizard state and builds batch documents either including all generated documents with tasks or only the first, updates log messaging accordingly.
Tests
src/__tests__/renderer/hooks/useWizardHandlers.test.ts
Adds test asserting that when runAllDocuments is true, startBatchRun is called with all generated documents and batch config contains expected count.

Sequence Diagram

sequenceDiagram
    participant User
    participant PhaseReviewScreen
    participant WizardContext
    participant useWizardHandlers
    participant BatchProcessor

    User->>PhaseReviewScreen: Toggle "Run All documents" ON
    PhaseReviewScreen->>WizardContext: setRunAllDocuments(true)
    WizardContext->>WizardContext: update state & persist

    User->>PhaseReviewScreen: Click Launch Session
    PhaseReviewScreen->>useWizardHandlers: handleWizardLaunchSession()
    useWizardHandlers->>WizardContext: read runAllDocuments

    alt runAllDocuments = true
        useWizardHandlers->>useWizardHandlers: build batch with ALL documents
    else runAllDocuments = false
        useWizardHandlers->>useWizardHandlers: build batch with FIRST document only
    end

    useWizardHandlers->>BatchProcessor: startBatchRun(BatchRunConfig)
    BatchProcessor->>BatchProcessor: process documents sequentially
Loading

Possibly related PRs

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the two main changes: adding a 'Run All Phases' toggle and resizing the wizard modal, both of which are clearly present in the changeset.
Linked Issues check ✅ Passed The PR fully implements issue #490 requirements: adds a toggleable 'Auto-run all phases' checkbox with proper state threading, conditionally builds BatchRunConfig with all documents when enabled, and includes test coverage validating multi-document batch behavior.
Out of Scope Changes check ✅ Passed All changes are directly related to issue #490 and PR objectives. The ToggleSwitch component extraction, SettingCheckbox refactoring, and modal resizing are all aligned with stated goals; no unrelated changes detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch run-all-wizard-docs

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.

@greptile-apps
Copy link

greptile-apps bot commented Mar 3, 2026

Greptile Summary

This PR adds a "Run All Phases" toggle to the wizard's Step 5 review screen, resizes the modal to 1200px/85vh, and extracts a reusable ToggleSwitch UI component.

Key changes:

  • ToggleSwitch component (src/renderer/components/ui/ToggleSwitch.tsx): Clean extraction with disabled prop support and ARIA attributes. SettingCheckbox is refactored to use it with no behavior change.
  • PhaseReviewScreen: Toggle UI is conditionally rendered when generatedDocuments.length > 1.
  • useWizardHandlers: Batch-run logic correctly filters documents with tasks and selects either all or just the first based on runAllDocuments flag.
  • Modal resize: Straightforward CSS change from w-[90vw] max-w-5xl to w-[1200px] max-w-[95vw] and height adjusted to 85vh.
  • WizardContext: New runAllDocuments state is properly initialized, reduced, serialized for resume persistence, and exposed via context API.
  • Tests: New test correctly verifies all 3 documents are included in batch config when runAllDocuments is true; all tests pass.

All changes are straightforward and well-integrated.

Confidence Score: 5/5

  • Safe to merge — all changes are well-tested, logically sound, and properly integrate with existing systems.
  • The PR implements a clean feature addition with proper state management, test coverage (all 67 tests pass), and no observable issues. The ToggleSwitch extraction is well-designed, the batch-run logic is correct, and WizardContext integration is consistent. Manual testing items remain to be completed, but the code is ready for that phase.
  • No files require special attention.

Important Files Changed

Filename Overview
src/renderer/components/Wizard/screens/PhaseReviewScreen.tsx Adds the "Run All Phases" toggle UI that's conditionally rendered when multiple documents are generated. The toggle correctly integrates with WizardContext state. The keyboard handling with preventDefault() properly prevents default button behavior, ensuring stable interaction for all users.
src/renderer/components/ui/ToggleSwitch.tsx New reusable toggle switch component extracted from SettingCheckbox. Well-typed with disabled state support and ARIA attributes (role="switch", aria-checked, aria-label). Native button element ensures proper keyboard accessibility out of the box.
src/renderer/hooks/wizard/useWizardHandlers.ts Correctly wires up runAllDocuments flag: filters documents with tasks, selects all or just the first based on the flag, and maps them into BatchRunConfig. New test verifies all 3 documents are included when runAllDocuments is true.
src/renderer/components/Wizard/WizardContext.tsx Clean addition of runAllDocuments state: properly initialized, reducer case added, serialization for resume persistence, and context API exports. Consistent with existing state management patterns.
src/renderer/components/SettingCheckbox.tsx Refactored to use the new ToggleSwitch component. No behavior change, no outer click handler complications. Clean delegation to the reusable component.
src/tests/renderer/hooks/useWizardHandlers.test.ts New test correctly verifies that all 3 documents (each with taskCount > 0) are included in the batch config when runAllDocuments is true. Validates the core feature requirement.
src/renderer/components/Wizard/MaestroWizard.tsx Modal resized from 90vw/80vh/max-w-5xl to 1200px fixed width/95vw max/85vh. Straightforward CSS change with appropriate responsive fallback.
src/renderer/components/ui/index.ts Exports ToggleSwitch and ToggleSwitchProps from the ui barrel file. Clean, no issues.

Sequence Diagram

sequenceDiagram
    participant User
    participant PhaseReviewScreen
    participant WizardContext
    participant useWizardHandlers
    participant startBatchRun

    User->>PhaseReviewScreen: Toggles "Run All Phases" switch
    PhaseReviewScreen->>WizardContext: setRunAllDocuments(true/false)
    WizardContext->>WizardContext: dispatch SET_RUN_ALL_DOCUMENTS
    WizardContext-->>PhaseReviewScreen: state.runAllDocuments updated

    User->>PhaseReviewScreen: Clicks "I'm Ready to Go"
    PhaseReviewScreen->>useWizardHandlers: handleWizardLaunchSession(false)
    useWizardHandlers->>useWizardHandlers: filter generatedDocuments where taskCount > 0
    alt runAllDocuments = true
        useWizardHandlers->>useWizardHandlers: docsToRun = all docsWithTasks
    else runAllDocuments = false
        useWizardHandlers->>useWizardHandlers: docsToRun = [docsWithTasks[0]]
    end
    useWizardHandlers->>useWizardHandlers: build BatchRunConfig with docsToRun
    useWizardHandlers->>startBatchRun: startBatchRun(sessionId, batchConfig, autoRunFolderPath)
    startBatchRun-->>User: All selected documents queued for batch run
Loading

Last reviewed commit: af3ec11

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/renderer/components/SettingCheckbox.tsx`:
- Line 66: The ToggleSwitch instance in SettingCheckbox (rendering ToggleSwitch
checked={checked} onChange={onChange} theme={theme}) is missing an accessible
name; update the JSX to pass an accessible label prop (e.g., ariaLabel or
aria-label depending on ToggleSwitch's API) populated from the setting's visible
label or a descriptive string (for example use the component prop/variable that
holds the setting name or `label`) so screen readers can identify the control;
ensure you use the ToggleSwitch prop name it expects (ariaLabel vs aria-label)
and keep the text concise and descriptive.

In `@src/renderer/components/ui/ToggleSwitch.tsx`:
- Around line 29-44: The ToggleSwitch component's button element is missing an
explicit type, causing it to act as a submit button inside forms; update the
button in ToggleSwitch.tsx (the element that uses onClick and props checked,
disabled, onChange, ariaLabel) to include type="button" to prevent unintended
form submissions while preserving the existing onClick, aria attributes and
styles.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dabda9d and af3ec11.

📒 Files selected for processing (8)
  • src/__tests__/renderer/hooks/useWizardHandlers.test.ts
  • src/renderer/components/SettingCheckbox.tsx
  • src/renderer/components/Wizard/MaestroWizard.tsx
  • src/renderer/components/Wizard/WizardContext.tsx
  • src/renderer/components/Wizard/screens/PhaseReviewScreen.tsx
  • src/renderer/components/ui/ToggleSwitch.tsx
  • src/renderer/components/ui/index.ts
  • src/renderer/hooks/wizard/useWizardHandlers.ts

- Add explicit type="button" to ToggleSwitch to prevent unintended form
  submissions
- Pass ariaLabel={title} in SettingCheckbox for screen reader accessibility
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/renderer/components/ui/ToggleSwitch.tsx (1)

12-13: Make accessible naming non-optional in the component API.

ariaLabel is optional on Line 12, so new call sites can accidentally render an unnamed switch. Prefer requiring an accessible name at the prop level to prevent silent a11y regressions.

Suggested API tightening
 export interface ToggleSwitchProps {
 	/** Whether the toggle is on */
 	checked: boolean;
 	/** Callback when the toggle state changes */
 	onChange: (checked: boolean) => void;
 	/** The current theme */
 	theme: Theme;
-	/** Optional aria-label for accessibility */
-	ariaLabel?: string;
+	/** aria-label for accessibility */
+	ariaLabel: string;
 	/** Whether the toggle is disabled */
 	disabled?: boolean;
 }

Also applies to: 43-43

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/renderer/components/ui/ToggleSwitch.tsx` around lines 12 - 13, The
ToggleSwitch component currently declares ariaLabel as optional which can lead
to unnamed controls; make the accessible name required by removing the optional
marker from the prop (e.g., in the ToggleSwitchProps or the ToggleSwitch
component signature where ariaLabel?: string is defined) and update any internal
handling that assumed it might be undefined (and update call sites to pass a
string). Also update any defaultProps or tests referencing ToggleSwitch to
supply a non-empty ariaLabel so the component API enforces an accessible name.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/renderer/components/ui/ToggleSwitch.tsx`:
- Around line 29-45: The ToggleSwitch button lacks explicit keyboard focus
hooks; add a tabIndex and focus handlers to make focus behavior explicit and
stylable: in the ToggleSwitch component, add tabIndex={disabled ? -1 : 0} to the
button, introduce local state (e.g., isFocused) and onFocus/onBlur handlers that
set/unset it, update the button className or inline style to reflect focus
(e.g., add a focus ring class when isFocused), and if the component accepts
optional onFocus/onBlur props forward/invoke them from these handlers; keep
existing behavior for checked, onChange, disabled and ariaLabel unchanged.

---

Nitpick comments:
In `@src/renderer/components/ui/ToggleSwitch.tsx`:
- Around line 12-13: The ToggleSwitch component currently declares ariaLabel as
optional which can lead to unnamed controls; make the accessible name required
by removing the optional marker from the prop (e.g., in the ToggleSwitchProps or
the ToggleSwitch component signature where ariaLabel?: string is defined) and
update any internal handling that assumed it might be undefined (and update call
sites to pass a string). Also update any defaultProps or tests referencing
ToggleSwitch to supply a non-empty ariaLabel so the component API enforces an
accessible name.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4807739a-ea23-4980-b552-4ade4e447337

📥 Commits

Reviewing files that changed from the base of the PR and between af3ec11 and 4ebad25.

📒 Files selected for processing (2)
  • src/renderer/components/SettingCheckbox.tsx
  • src/renderer/components/ui/ToggleSwitch.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/components/SettingCheckbox.tsx

Comment on lines +29 to +45
<button
type="button"
onClick={(e) => {
e.stopPropagation();
if (!disabled) onChange(!checked);
}}
className={`relative w-10 h-5 rounded-full transition-colors flex-shrink-0 ${
disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'
}`}
style={{
backgroundColor: checked ? theme.colors.accent : theme.colors.bgActivity,
}}
role="switch"
aria-checked={checked}
aria-label={ariaLabel}
disabled={disabled}
>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add explicit keyboard focus hooks required by renderer component guidelines.

On Line 29, this interactive control is focusable but currently lacks tabIndex and focus handlers. Please add tabIndex and onFocus/onBlur so focus behavior is explicit and consistently stylable.

Suggested update
 export function ToggleSwitch({
 	checked,
 	onChange,
 	theme,
 	ariaLabel,
 	disabled = false,
 }: ToggleSwitchProps): React.ReactElement {
+	const [isFocused, setIsFocused] = React.useState(false);
+
 	return (
 		<button
 			type="button"
+			tabIndex={disabled ? -1 : 0}
+			onFocus={() => setIsFocused(true)}
+			onBlur={() => setIsFocused(false)}
 			onClick={(e) => {
 				e.stopPropagation();
 				if (!disabled) onChange(!checked);
 			}}
 			className={`relative w-10 h-5 rounded-full transition-colors flex-shrink-0 ${
 				disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'
-			}`}
+			} ${isFocused ? 'ring-2 ring-offset-2' : ''}`}
 			style={{
 				backgroundColor: checked ? theme.colors.accent : theme.colors.bgActivity,
 			}}
 			role="switch"
 			aria-checked={checked}
 			aria-label={ariaLabel}
 			disabled={disabled}
 		>

As per coding guidelines, src/renderer/components/**/*.{ts,tsx}: Add tabIndex attribute and focus event handlers when implementing components that need keyboard focus.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/renderer/components/ui/ToggleSwitch.tsx` around lines 29 - 45, The
ToggleSwitch button lacks explicit keyboard focus hooks; add a tabIndex and
focus handlers to make focus behavior explicit and stylable: in the ToggleSwitch
component, add tabIndex={disabled ? -1 : 0} to the button, introduce local state
(e.g., isFocused) and onFocus/onBlur handlers that set/unset it, update the
button className or inline style to reflect focus (e.g., add a focus ring class
when isFocused), and if the component accepts optional onFocus/onBlur props
forward/invoke them from these handlers; keep existing behavior for checked,
onChange, disabled and ariaLabel unchanged.

@pedramamini pedramamini added the RC Getting soak time in RC branch now label Mar 7, 2026
@pedramamini pedramamini self-assigned this Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RC Getting soak time in RC branch now

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wizard: Add 'Auto-run all phases' checkbox

1 participant