Skip to content

refactor(document-generation-wizard): focuses on Inline Wizard hook and document generation takeover view#1106

Merged
reachrazamair merged 2 commits into
rcfrom
refactoring
Jun 18, 2026
Merged

refactor(document-generation-wizard): focuses on Inline Wizard hook and document generation takeover view#1106
reachrazamair merged 2 commits into
rcfrom
refactoring

Conversation

@reachrazamair

@reachrazamair reachrazamair commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Refactors the Inline Wizard hook and document generation takeover view into smaller SOC/SRP-driven modules while preserving existing behavior, public imports, UI copy, tab routing semantics, and generation flow.

Changes

  • Split useInlineWizard into a small public composer plus internal modules for:
    • per-tab state
    • document loading
    • conversation actions
    • generation actions
    • lifecycle cleanup
    • simple state setters
  • Moved Inline Wizard data contracts into inlineWizard/types.ts and preserved existing type re-exports.
  • Converted DocumentGenerationView.tsx into a directory-based shell with extracted:
    • status header
    • elapsed timer hook
    • created-file list and entry components
    • completion actions
    • empty state
    • document stats utilities
    • legacy DocumentSelector and DocumentEditor wrappers
  • Preserved public barrel exports and compatibility paths.
  • Added focused regression coverage for the new hook internals and split generation view.

Behavior Delta

None intended.

Existing app behavior, UI layout, public props, public exports, tab sync semantics, SSH/custom override flow, conductor profile forwarding, Auto Run folder handling, and generation service behavior are intended to remain unchanged.

Tests

Passed:

  • npm run test -- src/__tests__/renderer/hooks/useInlineWizard.test.ts src/__tests__/renderer/hooks/useInlineWizard_overrides.test.ts src/__tests__/renderer/contexts/InlineWizardContext.test.tsx src/__tests__/renderer/components/InlineWizard src/__tests__/integration/InlineWizardFlow.test.tsx src/__tests__/renderer/components/Wizard/shared
  • npm run test -- src/__tests__/renderer/hooks/batch/inlineWizard src/__tests__/renderer/components/InlineWizard/DocumentGenerationView
  • npm run test -- src/__tests__/renderer/hooks/useWizardHandlers.test.ts src/__tests__/renderer/components/MainPanel/MainPanelContent.test.tsx src/__tests__/renderer/components/SessionList.test.tsx
  • npm run format:check
  • npm run lint
  • npm run lint:eslint
  • npx tsc --noEmit --pretty
  • npm run test

Full suite result: 1,099 files passed, 1 skipped; 31,403 tests passed, 108 skipped.

Summary by CodeRabbit

Release Notes

  • New Features
    • Redesigned inline document generation view with a “Work Plans Drafted” list.
    • Each entry supports expand/collapse with file size, task count, and description; the newest file auto-expands and user-expanded older files stay expanded when new documents appear.
    • Generation status now includes elapsed time; completion offers “Exit Wizard” and (when available) “Start Auto Run”.
    • Empty state shows “No documents generated yet.” with an optional cancel action.
  • Refactor
    • Split the document generation UI into smaller, focused components and supporting hooks.
  • Tests
    • Added extensive Vitest + React Testing Library coverage for UI behavior, state/lifecycle actions, and generation/stat utilities.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 43e44fad-545d-41c1-88dc-a3f97cb244b2

📥 Commits

Reviewing files that changed from the base of the PR and between c6d6485 and 1932bf8.

📒 Files selected for processing (9)
  • src/__tests__/renderer/components/InlineWizard/DocumentGenerationView/useElapsedGenerationTime.test.tsx
  • src/renderer/components/InlineWizard/DocumentGenerationView/DocumentGenerationView.tsx
  • src/renderer/components/InlineWizard/DocumentGenerationView/components/EmptyGenerationState.tsx
  • src/renderer/components/InlineWizard/DocumentGenerationView/components/GenerationActions.tsx
  • src/renderer/components/InlineWizard/DocumentGenerationView/hooks/useElapsedGenerationTime.ts
  • src/renderer/hooks/batch/inlineWizard/conversationActions.ts
  • src/renderer/hooks/batch/inlineWizard/documents.ts
  • src/renderer/hooks/batch/inlineWizard/lifecycleActions.ts
  • src/renderer/hooks/batch/inlineWizard/state.ts
💤 Files with no reviewable changes (1)
  • src/renderer/hooks/batch/inlineWizard/conversationActions.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/tests/renderer/components/InlineWizard/DocumentGenerationView/useElapsedGenerationTime.test.tsx
  • src/renderer/components/InlineWizard/DocumentGenerationView/components/EmptyGenerationState.tsx
  • src/renderer/components/InlineWizard/DocumentGenerationView/hooks/useElapsedGenerationTime.ts
  • src/renderer/hooks/batch/inlineWizard/lifecycleActions.ts
  • src/renderer/components/InlineWizard/DocumentGenerationView/DocumentGenerationView.tsx
  • src/renderer/components/InlineWizard/DocumentGenerationView/components/GenerationActions.tsx
  • src/renderer/hooks/batch/inlineWizard/documents.ts

📝 Walkthrough

Walkthrough

Removes the 625-line DocumentGenerationView.tsx and the 1,495-line useInlineWizard.ts, redistributing their logic across dedicated sub-modules: new typed interfaces, per-tab state management, simple setters, document I/O helpers, lifecycle/conversation/generation action hooks, DocumentGenerationView UI sub-components with a custom elapsed-time hook, and a thin composer entry point. Adds Vitest suites for all new units.

Changes

InlineWizard Hook Decomposition and DocumentGenerationView Modularization

Layer / File(s) Summary
Wizard state types and initial state
src/renderer/hooks/batch/inlineWizard/types.ts, src/renderer/hooks/batch/inlineWizard/state.ts
Exports InlineWizardMode, InlineWizardMessage, PreviousUIState, InlineGeneratedDocument, GenerationProgress, InlineWizardSshRemoteConfig, InlineWizardSessionOverrides, InlineWizardState, SetInlineWizardTabState, and UseInlineWizardReturn; provides generateMessageId() and initialInlineWizardState with zero/null field defaults.
Per-tab wizard state management
src/renderer/hooks/batch/inlineWizard/useInlineWizardTabState.ts, src/__tests__/renderer/hooks/batch/inlineWizard/useInlineWizardTabState.test.tsx
useInlineWizardTabState maintains a Map<tabId, InlineWizardState>, stable callbacks for state mutation/lookup/activity checks, refs for previous UI state and conversation sessions, and a memoized wizardActiveSessions aggregation. Tests verify isolation, backward compatibility, and cross-tab session aggregation.
Simple state setters and document I/O helpers
src/renderer/hooks/batch/inlineWizard/simpleActions.ts, src/renderer/hooks/batch/inlineWizard/documents.ts, src/__tests__/renderer/hooks/batch/inlineWizard/simpleActions.test.ts, src/__tests__/renderer/hooks/batch/inlineWizard/documents.test.ts
clampConfidence and useInlineWizardSimpleActions provide memoized setters. Document helpers resolve auto-run paths, detect/list/load existing documents via window.maestro.autorun and window.maestro.history APIs with safe fallbacks. Tests cover confidence clamping, path resolution, document discovery, content loading with error placeholders, and SSH session history-path skipping.
Lifecycle and conversation actions
src/renderer/hooks/batch/inlineWizard/lifecycleActions.ts, src/renderer/hooks/batch/inlineWizard/conversationActions.ts, src/__tests__/renderer/hooks/batch/inlineWizard/lifecycleActions.test.tsx
useInlineWizardLifecycleActions exposes endWizard (with previous UI state restoration) and reset. useInlineWizardConversationActions implements startWizard (with document seeding), sendMessage (with image support and auto-session creation), addAssistantMessage, setMode (with lazy session initialization), retryLastMessage, and clearConversation. Tests verify state/session cleanup and per-tab isolation.
Generation actions and hook composer
src/renderer/hooks/batch/inlineWizard/generationActions.ts, src/renderer/hooks/batch/useInlineWizard.ts, src/renderer/services/inlineWizardConversation.ts, src/renderer/services/inlineWizardDocumentGeneration.ts, src/__tests__/renderer/hooks/batch/inlineWizard/generationActions.test.ts
parseGenerationProgress and getProjectNameForGeneration parse progress formats and derive project names. useInlineWizardGenerationActions drives document generation via callbacks. useInlineWizard is rewritten as a thin composer wiring all sub-hooks and computing readyToGenerate. Service files update type imports to inlineWizard/types.
DocumentGenerationView types, utils, and wrapper components
src/renderer/components/InlineWizard/DocumentGenerationView/types.ts, .../utils/documentStats.ts, .../components/DocumentSelector.tsx, .../components/DocumentEditor.tsx, src/__tests__/renderer/components/InlineWizard/DocumentGenerationView/utils.test.ts, src/__tests__.../wrappers.test.tsx
Declares DocumentGenerationViewProps, DocumentSelectorProps, DocumentEditorProps. Exports utility functions countTasks, countTotalTasks, and extractDocumentDescription for markdown task counting and description extraction. DocumentSelector and DocumentEditor wrap shared components with fixed layout/prose/header defaults.
DocumentGenerationView UI sub-components
src/renderer/components/InlineWizard/DocumentGenerationView/hooks/useElapsedGenerationTime.ts, .../components/EmptyGenerationState.tsx, .../components/GenerationActions.tsx, .../components/GenerationStatus.tsx, .../components/CreatedFileEntry.tsx, .../components/CreatedFilesList.tsx, .../components/index.ts, src/__tests__/renderer/components/InlineWizard/DocumentGenerationView/useElapsedGenerationTime.test.tsx, src/__tests__.../CreatedFilesList.test.tsx
Adds useElapsedGenerationTime hook (1-second interval timer during generation). Adds EmptyGenerationState, GenerationActions (Exit Wizard / Start Auto Run buttons), GenerationStatus (complete vs in-progress with animated bounce dots), CreatedFileEntry (expandable file with task count, file size, description), and CreatedFilesList (auto-expands newest document, preserves user toggles via refs). Barrel index re-exports all components.
DocumentGenerationView root component and barrel
src/renderer/components/InlineWizard/DocumentGenerationView/DocumentGenerationView.tsx, src/renderer/components/InlineWizard/DocumentGenerationView/index.ts, src/__tests__/renderer/components/InlineWizard/DocumentGenerationView/DocumentGenerationView.test.tsx
Root component derives totalTasks, elapsedMs, and isComplete; returns EmptyGenerationState when idle with no documents, otherwise renders centered layout with GenerationStatus, CreatedFilesList, and either GenerationActions (when complete) or progress area with AustinFactsDisplay. Inlines CSS keyframe animations for fade-slide and bounce-dot effects. Barrel re-exports component, types, wrappers, and related modules. Tests cover empty/generating/complete states and button interactions.

Sequence Diagram(s)

sequenceDiagram
  participant UI
  participant useInlineWizard
  participant conversationActions
  participant generationActions
  participant tabState as useInlineWizardTabState
  participant maestro as window.maestro

  UI->>useInlineWizard: startWizard(params)
  useInlineWizard->>conversationActions: startWizard()
  conversationActions->>maestro: autorun.listDocs() [iterate mode]
  maestro-->>conversationActions: existingDocs
  conversationActions->>tabState: setTabState({isActive, mode, conversation})

  UI->>useInlineWizard: sendMessage(content)
  useInlineWizard->>conversationActions: sendMessage()
  conversationActions->>tabState: setTabState({isWaiting, conversation+userMsg})
  conversationActions->>maestro: sendWizardMessage()
  maestro-->>conversationActions: {confidence, ready, content}
  conversationActions->>tabState: setTabState({confidence, ready, conversation+assistantMsg})

  UI->>useInlineWizard: generateDocuments()
  useInlineWizard->>generationActions: generateDocuments()
  generationActions->>maestro: generateInlineDocuments()
  maestro-->>generationActions: onProgress / onDocumentComplete / onComplete
  generationActions->>tabState: setTabState({isGeneratingDocs, generatedDocuments, subfolderName})

  UI->>useInlineWizard: endWizard(tabId)
  useInlineWizard->>conversationActions: endWizard()
  conversationActions->>tabState: setTabStates (remove tab)
  conversationActions->>maestro: endInlineWizardConversation()
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

  • RunMaestro/Maestro#525: Directly refactors the same DocumentGenerationView path, removing the selector/editor UI and reorganizing it into a modular DocumentGenerationView directory matching the structure introduced here.
  • RunMaestro/Maestro#1084: Refactors the shared DocumentEditor/DocumentSelector components that the new wrapper components in this PR delegate to via SharedDocumentEditor/SharedDocumentSelector.

Suggested labels

refactor

Poem

🐇 Hop, hop, one big file becomes many small,
Each hook in its burrow, each component a hall.
The wizard's state map now neatly per-tab,
With tests to assert every expand and collapse,
No more monolith — just modules in rows,
This rabbit approves how the clean codebase grows! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main refactoring focus: restructuring the Inline Wizard hook and document generation view into modular components.
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.

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

✨ 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 refactoring

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


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

greptile-apps Bot commented Jun 18, 2026

Copy link
Copy Markdown

Greptile Summary

This PR splits the 1,500-line useInlineWizard hook and 625-line DocumentGenerationView component into focused sub-modules (state, conversation actions, generation actions, lifecycle actions, document helpers, and a set of extracted UI components) while preserving the public API surface through re-export barrel files. Existing behavior, tab routing semantics, SSH/override forwarding, and generation flow are all intended to be unchanged.

  • The useInlineWizard monolith is replaced by a thin composer that wires together five independently testable hook modules, each covering a single responsibility (tab-state, conversation, generation, lifecycle, simple setters).
  • DocumentGenerationView is converted to a directory-based shell; the extracted components (GenerationStatus, CreatedFilesList, CreatedFileEntry, GenerationActions, EmptyGenerationState, useElapsedGenerationTime) and utility helpers (documentStats) are focused and each covered by new unit tests.

Confidence Score: 4/5

This is a large structural refactoring with no logic changes; the extracted modules are faithful ports of the original monolith and are covered by new unit tests. The only actionable finding is the deprecated .substr() in generateMessageId, a low-impact style issue that was present before the refactoring.

The split is clean, public barrel exports are preserved, service import paths are updated correctly, and the full test suite (31,403 tests) continues to pass. The generateMessageId function uses .substr() (deprecated) and bypasses the canonical generateId() utility — worth fixing but has no runtime impact.

src/renderer/hooks/batch/inlineWizard/state.ts — the only file with a style issue worth addressing before merge.

Important Files Changed

Filename Overview
src/renderer/hooks/batch/useInlineWizard.ts Now a thin composer: wires sub-hooks together and re-exports all public types. Clean delegation with no logic of its own.
src/renderer/hooks/batch/inlineWizard/state.ts Holds initialInlineWizardState and generateMessageId(). The ID generator uses the deprecated .substr() method and duplicates a pattern the codebase already has a canonical utility for.
src/renderer/hooks/batch/inlineWizard/conversationActions.ts Direct extraction of startWizard, sendMessage, addAssistantMessage, setMode, retryLastMessage, clearConversation from the original file. Logic is identical to the previous monolith.
src/renderer/hooks/batch/inlineWizard/generationActions.ts Extracted generateDocuments plus pure helper functions parseGenerationProgress and getProjectNameForGeneration. Behavior matches original; helpers are independently tested.
src/renderer/hooks/batch/inlineWizard/lifecycleActions.ts Extracted endWizard and reset. Correctly synchronizes state removal before async conversation cleanup.
src/renderer/hooks/batch/inlineWizard/useInlineWizardTabState.ts Manages the per-tab Map of wizard states; getEffectiveTabId has a preserved side-effect (calling setCurrentTabId) when currentTabId is null, identical to original behavior.
src/renderer/components/InlineWizard/DocumentGenerationView/DocumentGenerationView.tsx The new shell renders the same visual output as before. Eight props (onDocumentSelect, folderPath, onContentChange, etc.) are accepted but intentionally unused to preserve the public interface.
src/renderer/components/InlineWizard/DocumentGenerationView/hooks/useElapsedGenerationTime.ts Clean extraction of the inline timer logic. Correctly restarts the interval when startTime changes and freezes the counter once isGenerating is false.
src/renderer/hooks/batch/inlineWizard/documents.ts Pure async helpers extracted from the original startWizard body. Each function is independently testable and all are covered by the new documents.test.ts.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[useInlineWizard] --> B[useInlineWizardTabState]
    A --> C[useInlineWizardSimpleActions]
    A --> D[useInlineWizardLifecycleActions]
    A --> E[useInlineWizardConversationActions]
    A --> F[useInlineWizardGenerationActions]

    B --> G[(tabStates Map)]
    B --> H[(tabStatesRef)]
    B --> I[(conversationSessionsMap ref)]
    B --> J[(previousUIStateRefsMap ref)]

    E --> K[conversationActions.ts]
    K --> L[inlineWizardConversation service]
    K --> M[documents.ts helpers]

    F --> N[generationActions.ts]
    N --> O[inlineWizardDocumentGeneration service]

    D --> P[lifecycleActions.ts]
    P --> L

    subgraph DocumentGenerationView
        Q[DocumentGenerationView shell] --> R[GenerationStatus]
        Q --> S[CreatedFilesList]
        S --> T[CreatedFileEntry]
        Q --> U[GenerationActions]
        Q --> V[EmptyGenerationState]
        Q --> W[useElapsedGenerationTime hook]
    end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[useInlineWizard] --> B[useInlineWizardTabState]
    A --> C[useInlineWizardSimpleActions]
    A --> D[useInlineWizardLifecycleActions]
    A --> E[useInlineWizardConversationActions]
    A --> F[useInlineWizardGenerationActions]

    B --> G[(tabStates Map)]
    B --> H[(tabStatesRef)]
    B --> I[(conversationSessionsMap ref)]
    B --> J[(previousUIStateRefsMap ref)]

    E --> K[conversationActions.ts]
    K --> L[inlineWizardConversation service]
    K --> M[documents.ts helpers]

    F --> N[generationActions.ts]
    N --> O[inlineWizardDocumentGeneration service]

    D --> P[lifecycleActions.ts]
    P --> L

    subgraph DocumentGenerationView
        Q[DocumentGenerationView shell] --> R[GenerationStatus]
        Q --> S[CreatedFilesList]
        S --> T[CreatedFileEntry]
        Q --> U[GenerationActions]
        Q --> V[EmptyGenerationState]
        Q --> W[useElapsedGenerationTime hook]
    end
Loading

Reviews (1): Last reviewed commit: "Refactor inline wizard internals" | Re-trigger Greptile

Comment on lines +3 to +8
/**
* Generate a unique message ID.
*/
export function generateMessageId(): string {
return `iwm-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
}

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 The generateMessageId function re-implements ID generation with the deprecated .substr() method. CLAUDE.md designates generateId() from src/renderer/utils/ids.ts as the canonical ID generator to avoid duplicated implementations. This refactoring was a good opportunity to consolidate to the shared utility.

Suggested change
/**
* Generate a unique message ID.
*/
export function generateMessageId(): string {
return `iwm-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
}
import { generateId } from '../../../utils/ids';
/**
* Generate a unique message ID.
*/
export function generateMessageId(): string {
return `iwm-${generateId()}`;
}

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@coderabbitai coderabbitai 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.

Actionable comments posted: 8

🧹 Nitpick comments (1)
src/__tests__/renderer/components/InlineWizard/DocumentGenerationView/useElapsedGenerationTime.test.tsx (1)

25-37: ⚡ Quick win

Add a true→false transition test for elapsed finalization.

Current cases miss the stop-transition path (isGenerating becomes false). A rerender-based test would lock in the final elapsed value and guard against stale-timer regressions.

🤖 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
`@src/__tests__/renderer/components/InlineWizard/DocumentGenerationView/useElapsedGenerationTime.test.tsx`
around lines 25 - 37, Add a new test case after the existing test in this file
that verifies the true-to-false transition behavior for the isGenerating prop.
The test should render the useElapsedGenerationTime hook with isGenerating as
true and a start time, advance timers by some amount to let the elapsed time
accumulate, then use rerender to change isGenerating to false, advance timers
again, and assert that the elapsed time remains constant at the value it had
when the transition occurred (verifying the timer was properly stopped and the
value finalized). This guards against stale timer regressions when generation
completes.
🤖 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.

Inline comments:
In
`@src/renderer/components/InlineWizard/DocumentGenerationView/components/EmptyGenerationState.tsx`:
- Around line 16-18: The button element with the onCancel onClick handler is
missing an explicit type attribute, which could cause unintended form submission
if the button is rendered inside a form container. Add type="button" to the
button element in the EmptyGenerationState component to ensure it only triggers
the onCancel callback without submitting any parent form.

In
`@src/renderer/components/InlineWizard/DocumentGenerationView/components/GenerationActions.tsx`:
- Around line 18-33: Both button elements in GenerationActions are missing
explicit type attributes, which can cause unintended form submissions in form
contexts. Add type="button" attribute to the button element with
onClick={onComplete} (the "Exit Wizard" button) and to the button element with
onClick={onCompleteAndStartAutoRun} to ensure they function as regular buttons
and do not trigger form submission behavior.

In
`@src/renderer/components/InlineWizard/DocumentGenerationView/DocumentGenerationView.tsx`:
- Around line 64-67: The Cancel button in DocumentGenerationView is missing an
explicit type attribute, which can cause it to behave as a form submit button if
wrapped in a form element. Locate the button element with onClick={onCancel} and
className containing "mt-4 px-4 py-2", and add type="button" as an explicit
attribute to ensure it only triggers the cancel action without submitting any
parent form.

In
`@src/renderer/components/InlineWizard/DocumentGenerationView/hooks/useElapsedGenerationTime.ts`:
- Around line 8-18: The useElapsedGenerationTime hook in the useEffect
dependency array has isGenerating and startTime, but when isGenerating becomes
false, the cleanup function only clears the interval without performing a final
update to setElapsedMs. This causes the displayed elapsed time to potentially be
stale by up to one second. Add a final setElapsedMs call that executes when
isGenerating transitions to false to capture the most recent elapsed time before
the interval stops updating.

In `@src/renderer/hooks/batch/inlineWizard/conversationActions.ts`:
- Around line 307-350: The sendWizardMessage function already triggers
callbacks.onError internally when there's an error, causing duplicate error
callback emissions. Remove the redundant callbacks?.onError?.(errorMessage) call
in the else block that handles errors from sendWizardMessage, keeping only the
logger.error call and setTabState update in that error handling section.

In `@src/renderer/hooks/batch/inlineWizard/documents.ts`:
- Around line 56-57: The condition in the documents.ts file that checks
`result.success && result.content` incorrectly treats empty file contents as
failures because empty strings are falsy in JavaScript. Change the condition to
only check `result.success`, or alternatively use a more explicit check that
distinguishes between undefined/null and empty strings (such as checking
`result.content !== null && result.content !== undefined` or `result.content !=
null`). This ensures that successfully read empty documents are still added to
the docsWithContent array.

In `@src/renderer/hooks/batch/inlineWizard/lifecycleActions.ts`:
- Around line 46-48: In the useInlineWizard hook in the lifecycleActions.ts
file, the catch blocks at lines 46-48 and 62-64 are currently only logging
cleanup failures without reporting them to Sentry. Import captureException from
Sentry at the top of the file (if not already imported), then in both catch
blocks (the one after the failed conversation session end and the one at line
62-64), add a call to captureException(error) alongside or instead of the
logger.warn call to ensure these cleanup failures are tracked in production
telemetry. Optionally, you can also add a captureMessage call before or after
captureException to provide additional context about which cleanup operation
failed.

In `@src/renderer/hooks/batch/inlineWizard/state.ts`:
- Around line 6-8: The generateMessageId() function in the state.ts file is
reimplementing ID generation locally instead of using shared utilities. Replace
this function's implementation to use either generateId() from
src/renderer/utils/ids.ts or generateUUID() from src/shared/uuid.ts to maintain
consistent ID generation behavior across the codebase, then remove the local
reimplementation.

---

Nitpick comments:
In
`@src/__tests__/renderer/components/InlineWizard/DocumentGenerationView/useElapsedGenerationTime.test.tsx`:
- Around line 25-37: Add a new test case after the existing test in this file
that verifies the true-to-false transition behavior for the isGenerating prop.
The test should render the useElapsedGenerationTime hook with isGenerating as
true and a start time, advance timers by some amount to let the elapsed time
accumulate, then use rerender to change isGenerating to false, advance timers
again, and assert that the elapsed time remains constant at the value it had
when the transition occurred (verifying the timer was properly stopped and the
value finalized). This guards against stale timer regressions when generation
completes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4bb44a82-34e5-4911-90e4-4ec7d2e2f107

📥 Commits

Reviewing files that changed from the base of the PR and between 7310f99 and c6d6485.

📒 Files selected for processing (35)
  • src/__tests__/renderer/components/InlineWizard/DocumentGenerationView/CreatedFilesList.test.tsx
  • src/__tests__/renderer/components/InlineWizard/DocumentGenerationView/DocumentGenerationView.test.tsx
  • src/__tests__/renderer/components/InlineWizard/DocumentGenerationView/useElapsedGenerationTime.test.tsx
  • src/__tests__/renderer/components/InlineWizard/DocumentGenerationView/utils.test.ts
  • src/__tests__/renderer/components/InlineWizard/DocumentGenerationView/wrappers.test.tsx
  • src/__tests__/renderer/hooks/batch/inlineWizard/documents.test.ts
  • src/__tests__/renderer/hooks/batch/inlineWizard/generationActions.test.ts
  • src/__tests__/renderer/hooks/batch/inlineWizard/lifecycleActions.test.tsx
  • src/__tests__/renderer/hooks/batch/inlineWizard/simpleActions.test.ts
  • src/__tests__/renderer/hooks/batch/inlineWizard/useInlineWizardTabState.test.tsx
  • src/renderer/components/InlineWizard/DocumentGenerationView.tsx
  • src/renderer/components/InlineWizard/DocumentGenerationView/DocumentGenerationView.tsx
  • src/renderer/components/InlineWizard/DocumentGenerationView/components/CreatedFileEntry.tsx
  • src/renderer/components/InlineWizard/DocumentGenerationView/components/CreatedFilesList.tsx
  • src/renderer/components/InlineWizard/DocumentGenerationView/components/DocumentEditor.tsx
  • src/renderer/components/InlineWizard/DocumentGenerationView/components/DocumentSelector.tsx
  • src/renderer/components/InlineWizard/DocumentGenerationView/components/EmptyGenerationState.tsx
  • src/renderer/components/InlineWizard/DocumentGenerationView/components/GenerationActions.tsx
  • src/renderer/components/InlineWizard/DocumentGenerationView/components/GenerationStatus.tsx
  • src/renderer/components/InlineWizard/DocumentGenerationView/components/index.ts
  • src/renderer/components/InlineWizard/DocumentGenerationView/hooks/useElapsedGenerationTime.ts
  • src/renderer/components/InlineWizard/DocumentGenerationView/index.ts
  • src/renderer/components/InlineWizard/DocumentGenerationView/types.ts
  • src/renderer/components/InlineWizard/DocumentGenerationView/utils/documentStats.ts
  • src/renderer/hooks/batch/inlineWizard/conversationActions.ts
  • src/renderer/hooks/batch/inlineWizard/documents.ts
  • src/renderer/hooks/batch/inlineWizard/generationActions.ts
  • src/renderer/hooks/batch/inlineWizard/lifecycleActions.ts
  • src/renderer/hooks/batch/inlineWizard/simpleActions.ts
  • src/renderer/hooks/batch/inlineWizard/state.ts
  • src/renderer/hooks/batch/inlineWizard/types.ts
  • src/renderer/hooks/batch/inlineWizard/useInlineWizardTabState.ts
  • src/renderer/hooks/batch/useInlineWizard.ts
  • src/renderer/services/inlineWizardConversation.ts
  • src/renderer/services/inlineWizardDocumentGeneration.ts
💤 Files with no reviewable changes (1)
  • src/renderer/components/InlineWizard/DocumentGenerationView.tsx

Comment thread src/renderer/hooks/batch/inlineWizard/conversationActions.ts
Comment thread src/renderer/hooks/batch/inlineWizard/documents.ts Outdated
Comment thread src/renderer/hooks/batch/inlineWizard/lifecycleActions.ts
Comment thread src/renderer/hooks/batch/inlineWizard/state.ts
@pedramamini

Copy link
Copy Markdown
Collaborator

@reachrazamair thank you for this contribution, it's a genuinely high-quality refactor. 🙏

I reviewed the PR alongside the Greptile and CodeRabbit feedback and everything checks out:

  • Both AI reviews are addressed. Every actionable finding from CodeRabbit (button type="button" declarations, the empty-file-content read check in documents.ts, the duplicate onError emission in conversationActions.ts, and Sentry captureException on lifecycle cleanup) and Greptile's generateMessageId finding are resolved in 1932bf8. I confirmed state.ts now uses the canonical generateId() per our dedup guidance, and CodeRabbit's re-review reports no remaining actionable comments.
  • Clean structural split. The 1,500-line useInlineWizard hook and 625-line DocumentGenerationView are decomposed into focused SRP modules with the public API preserved via barrel re-exports, and the new units are covered by tests.
  • Green CI. lint-and-format and the full test suite pass.
  • No merge conflicts.

The only outstanding item is CodeRabbit's soft "Docstring Coverage" pre-merge warning, which is non-blocking and consistent with the surrounding code, so I'm not asking for changes there.

Approving and tagging approved. Nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants