Skip to content

Fix type#1239

Merged
claude-code-best merged 3 commits into
claude-code-best:mainfrom
xiaoFjun-eng:fixType
May 19, 2026
Merged

Fix type#1239
claude-code-best merged 3 commits into
claude-code-best:mainfrom
xiaoFjun-eng:fixType

Conversation

@xiaoFjun-eng
Copy link
Copy Markdown
Contributor

@xiaoFjun-eng xiaoFjun-eng commented May 18, 2026

修复CI不通过的问题。因为少提交了一个ts文件。

Summary by CodeRabbit

  • Refactor
    • Improved internal type definitions and contracts across terminal, plugins, tools, and components to enhance code quality and developer experience. Refined type safety for event handling, configuration schemas, and tool definitions.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

📝 Walkthrough

Walkthrough

This PR replaces 120+ auto-generated type stubs across the codebase with concrete TypeScript type definitions, covering built-in tool names, SDK hook contracts, UI state machines, data schemas, and utility types. No runtime behavior changes; purely type-system improvements.

Changes

Type Stub Replacement

Layer / File(s) Summary
Built-in tool name constants
packages/builtin-tools/src/tools/AgentTool/built-in/src/tools/*/toolName.ts, packages/builtin-tools/src/tools/AgentTool/built-in/src/tools/*/constants.ts, packages/builtin-tools/src/tools/AgentTool/built-in/src/tools/*/prompt.ts
Tool registration names ('Bash', 'Edit', 'Read', 'Write', 'Glob', 'Grep', 'NotebookEdit', 'SendMessage', 'WebFetch', 'WebSearch', 'ExitPlanMode') are now string-literal types instead of any placeholders.
Built-in tool module re-exports
packages/builtin-tools/src/tools/AgentTool/*/src/..., packages/builtin-tools/src/tools/{BashTool,AskUserQuestionTool}/src/...
Function and component types (buildTool, ToolDef, toolMatchesName, Message, NormalizedUserMessage, logForDebugging, getQuerySourceForAgent, SettingSource, and many others) now re-export concrete types from host modules instead of any.
SDK core hook type contracts
src/entrypoints/sdk/coreTypes.generated.ts, src/entrypoints/agentSdkTypes.ts
HookInputBase and HookInput are now a discriminated union over hook_event_name with event-specific required/optional fields; AsyncHookJSONOutput and SyncHookJSONOutput define structured async/sync decision types with optional hookSpecificOutput keyed by event. HookEvent and ExitReason derive literal unions from constants.
Plugin, wizard, and UI state types
src/commands/plugin/types.ts, src/commands/plugin/unifiedTypes.ts, src/components/wizard/types.ts, src/components/mcp/types.ts, src/components/FeedbackSurvey/utils.ts, src/components/Spinner/types.ts
ViewState is a discriminated union covering plugin workflow modes (menu, help, validate, marketplace browsing, plugin discovery, management, marketplace list/menu, add/manage marketplaces); PluginSettingsProps is a typed props object. UnifiedInstalledItem union models plugin/failed/flagged/MCP rows. Wizard system defines WizardContextValue<T>, WizardProviderProps, WizardStepComponent. MCP types (ServerInfo, AgentMcpServerInfo, MCPViewState) cover transport-specific server info. Feedback and spinner types constrain to specific literal unions.
Data and protocol contracts
src/cli/transports/Transport.ts, src/types/statusLine.ts, src/types/fileSuggestion.ts, src/types/notebook.ts, packages/@ant/ink/src/core/*.ts
Transport interface defines callback registration, connect/write/close methods. StatusLineCommandInput schema documents required/optional JSON fields (session, workspace, cost, context window, permissions). FileSuggestionCommandInput payload includes session/transcript/cwd/query fields. Notebook types span cell structure (NotebookCell, NotebookContent, NotebookCellSource) with normalized output shapes and image payloads. Terminal types add Cursor (x, y, visible) and event payloads (ResizeEvent, PasteEvent).
Service and utility types
src/services/tips/types.ts, src/services/tips/tipRegistry.ts, src/services/lsp/types.ts, src/utils/notebook.ts, src/utils/plugins/mcpbHandler.ts, src/utils/hooks.ts, src/utils/__tests__/notebook.test.ts
Tip and TipContext define async content/relevance callbacks with optional context (theme, file cache, bash tools). Tips registry updates callbacks to accept optional context and safely call optional isRelevant. LSP types (LspServerConfig via Zod schema inference, ScopedLspServerConfig, LspServerState union). Notebook utilities add type guards for image detection ('image' in o && o.image). McpbUserConfigurationOption models DXT schema attributes. AggregatedHookResult adds inline field documentation. Test cases cast notebook data to NotebookCellSource[].
Type narrowing and casting
src/commands/login/getAuthStatus.ts, src/commands/plugin/ManagePlugins.tsx, src/components/StatusLine.tsx, src/constants/querySource.ts
Added type-only imports (SubscriptionType, InstallableScope, UnifiedInstalledScope) and explicit casting for subscription tier derivation and plugin scope gating. rateLimits in StatusLine is narrowed to non-null. QuerySource is documented as string type.
Agent wizard state
src/components/agents/new-agent-creation/types.ts
AgentWizardData captures multi-step wizard state: optional system prompt, agent type, generation/manual mode flags, tool/memory selection, location, model/color picks, and a typed finalAgent draft.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Twitches whiskers with delight

From any stubs to types so bright,
A hundred thousand anys flight,
Now concrete shapes in TypeScript's light,
The contracts clear, the code more tight! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Fix type' is vague and overly broad. While the PR does fix types, the title lacks specificity about the scope or nature of the changes. Consider revising the title to be more descriptive, such as 'Replace auto-generated type stubs with concrete type definitions' or 'Add missing TypeScript type definitions and fix CI'. This would better convey the extent and purpose of the changes.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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 unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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
Contributor

@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: 3

🧹 Nitpick comments (2)
src/components/agents/new-agent-creation/types.ts (1)

3-3: ⚡ Quick win

Use src/* alias for internal import.

Please switch the SettingSource import to the configured src/* alias instead of a deep relative path.

Suggested diff
-import type { SettingSource } from '../../../utils/settings/constants.js'
+import type { SettingSource } from 'src/utils/settings/constants.js'

As per coding guidelines, Use src/* path alias for imports as configured in tsconfig; valid imports like import { ... } from 'src/utils/...' are preferred.

🤖 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/components/agents/new-agent-creation/types.ts` at line 3, Replace the
deep relative import of SettingSource with the project path-alias import: update
the import that currently references '../../../utils/settings/constants.js' to
use the tsconfig alias (e.g. import type { SettingSource } from
'src/utils/settings/constants'), removing the deep-relative traversal and the
.js extension so TypeScript path-mapping resolves correctly for the
SettingSource type used in this module.
src/commands/plugin/ManagePlugins.tsx (1)

1257-1257: ⚡ Quick win

Avoid scope casts; use a type guard to narrow UnifiedInstalledScope instead

Lines 1257 and 1583–1585 cast pluginScope to satisfy isInstallableScope and uninstallPluginOp. These casts are unnecessary because the unions are already compatible with the expected input types after the preceding isBuiltin check. The same function is called without casts at lines 1097 and 1685, revealing the casts are inconsistent. A local type guard narrows UnifiedInstalledScope properly and maintains type safety.

Suggested change
+const isInstallableUnifiedScope = (scope: UnifiedInstalledScope): scope is InstallableScope =>
+  scope === 'user' || scope === 'project' || scope === 'local';

-      if (isBuiltin || isInstallableScope(pluginScope as PersistablePluginScope)) {
+      if (isBuiltin || isInstallableUnifiedScope(pluginScope)) {

-            const result = isInstallableScope(pluginScope as PersistablePluginScope)
-              ? await uninstallPluginOp(pluginId, pluginScope as InstallableScope, false)
+            const result = isInstallableUnifiedScope(pluginScope)
+              ? await uninstallPluginOp(pluginId, pluginScope, false)
               : await uninstallPluginOp(pluginId, 'user', false);
🤖 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/commands/plugin/ManagePlugins.tsx` at line 1257, Replace the unsafe casts
of pluginScope to PersistablePluginScope by adding and using a local type guard
that narrows UnifiedInstalledScope (e.g., function isPersistableScope(s:
UnifiedInstalledScope): s is PersistablePluginScope) and use that guard wherever
isInstallableScope and uninstallPluginOp are called (locations referencing
isBuiltin, isInstallableScope, uninstallPluginOp and pluginScope) instead of
casting; this keeps type safety consistent with the other call sites that
already omit casts and removes the redundant explicit type assertions.
🤖 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/components/wizard/types.ts`:
- Around line 1-4: The type alias WizardStepComponent currently references
React.ComponentType without importing React; update the imports to pull
ComponentType directly (e.g., import type { Dispatch, ReactNode, SetStateAction,
ComponentType } from 'react') and change the union to use ComponentType (i.e.,
WizardStepComponent = (() => ReactNode) | ComponentType) so strict TypeScript
checking passes; ensure you only add the type import and adjust the type
reference in types.ts.

In `@src/components/wizard/WizardProvider.tsx`:
- Line 126: The component renders a fallback with a logical OR which treats
valid falsy React nodes (like 0, '', false) as absent; in WizardProvider replace
the fallback expression using children || <CurrentStepComponent /> with a
nullish coalescing fallback so only null/undefined trigger the fallback (use
children ?? <CurrentStepComponent />) when rendering inside the WizardProvider
component where children and CurrentStepComponent are used.

In `@src/entrypoints/sdk/coreTypes.generated.ts`:
- Around line 121-252: HookInput was changed to use SessionEnd.reason and
FileChanged.file_path but the public alias types still expect exit_reason and
path, causing conflicting SDK types; update the exported alias contracts to
accept the new keys (or provide backward-compatible unions) by replacing
references to exit_reason and path in the alias definitions with reason and
file_path (or define types that include both keys), and update any alias type
names that map to HookInput (referencing HookInput, SessionEnd, FileChanged and
the public alias types where exit_reason and path are defined) so the SDK
surface types align.

---

Nitpick comments:
In `@src/commands/plugin/ManagePlugins.tsx`:
- Line 1257: Replace the unsafe casts of pluginScope to PersistablePluginScope
by adding and using a local type guard that narrows UnifiedInstalledScope (e.g.,
function isPersistableScope(s: UnifiedInstalledScope): s is
PersistablePluginScope) and use that guard wherever isInstallableScope and
uninstallPluginOp are called (locations referencing isBuiltin,
isInstallableScope, uninstallPluginOp and pluginScope) instead of casting; this
keeps type safety consistent with the other call sites that already omit casts
and removes the redundant explicit type assertions.

In `@src/components/agents/new-agent-creation/types.ts`:
- Line 3: Replace the deep relative import of SettingSource with the project
path-alias import: update the import that currently references
'../../../utils/settings/constants.js' to use the tsconfig alias (e.g. import
type { SettingSource } from 'src/utils/settings/constants'), removing the
deep-relative traversal and the .js extension so TypeScript path-mapping
resolves correctly for the SettingSource type used in this module.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 89acc4cf-7261-447a-8a0b-cdcad8e5b2ba

📥 Commits

Reviewing files that changed from the base of the PR and between c499bfb and 80cd3dd.

📒 Files selected for processing (68)
  • packages/@ant/ink/src/core/cursor.ts
  • packages/@ant/ink/src/core/events/paste-event.ts
  • packages/@ant/ink/src/core/events/resize-event.ts
  • packages/builtin-tools/src/tools/AgentTool/built-in/src/tools/BashTool/toolName.ts
  • packages/builtin-tools/src/tools/AgentTool/built-in/src/tools/ExitPlanModeTool/constants.ts
  • packages/builtin-tools/src/tools/AgentTool/built-in/src/tools/FileEditTool/constants.ts
  • packages/builtin-tools/src/tools/AgentTool/built-in/src/tools/FileReadTool/prompt.ts
  • packages/builtin-tools/src/tools/AgentTool/built-in/src/tools/FileWriteTool/prompt.ts
  • packages/builtin-tools/src/tools/AgentTool/built-in/src/tools/GlobTool/prompt.ts
  • packages/builtin-tools/src/tools/AgentTool/built-in/src/tools/GrepTool/prompt.ts
  • packages/builtin-tools/src/tools/AgentTool/built-in/src/tools/NotebookEditTool/constants.ts
  • packages/builtin-tools/src/tools/AgentTool/built-in/src/tools/SendMessageTool/constants.ts
  • packages/builtin-tools/src/tools/AgentTool/built-in/src/tools/WebFetchTool/prompt.ts
  • packages/builtin-tools/src/tools/AgentTool/built-in/src/tools/WebSearchTool/prompt.ts
  • packages/builtin-tools/src/tools/AgentTool/built-in/src/utils/auth.ts
  • packages/builtin-tools/src/tools/AgentTool/built-in/src/utils/embeddedTools.ts
  • packages/builtin-tools/src/tools/AgentTool/built-in/src/utils/settings/settings.ts
  • packages/builtin-tools/src/tools/AgentTool/src/Tool.ts
  • packages/builtin-tools/src/tools/AgentTool/src/components/ConfigurableShortcutHint.ts
  • packages/builtin-tools/src/tools/AgentTool/src/components/CtrlOToExpand.ts
  • packages/builtin-tools/src/tools/AgentTool/src/components/design-system/Byline.ts
  • packages/builtin-tools/src/tools/AgentTool/src/components/design-system/KeyboardShortcutHint.ts
  • packages/builtin-tools/src/tools/AgentTool/src/types/message.ts
  • packages/builtin-tools/src/tools/AgentTool/src/utils/debug.ts
  • packages/builtin-tools/src/tools/AgentTool/src/utils/promptCategory.ts
  • packages/builtin-tools/src/tools/AgentTool/src/utils/settings/constants.ts
  • packages/builtin-tools/src/tools/AskUserQuestionTool/src/bootstrap/state.ts
  • packages/builtin-tools/src/tools/AskUserQuestionTool/src/components/MessageResponse.ts
  • packages/builtin-tools/src/tools/AskUserQuestionTool/src/constants/figures.ts
  • packages/builtin-tools/src/tools/AskUserQuestionTool/src/utils/permissions/PermissionMode.ts
  • packages/builtin-tools/src/tools/BashTool/src/Tool.ts
  • packages/builtin-tools/src/tools/BashTool/src/bootstrap/state.ts
  • packages/builtin-tools/src/tools/BashTool/src/hooks/useCanUseTool.ts
  • packages/builtin-tools/src/tools/BashTool/src/services/analytics/growthbook.ts
  • packages/builtin-tools/src/tools/BashTool/src/services/analytics/index.ts
  • packages/builtin-tools/src/tools/BashTool/src/state/AppState.ts
  • packages/builtin-tools/src/tools/BashTool/src/utils/Shell.ts
  • packages/builtin-tools/src/tools/BashTool/src/utils/cwd.ts
  • packages/builtin-tools/src/tools/BashTool/src/utils/permissions/filesystem.ts
  • packages/builtin-tools/src/tools/BashTool/src/utils/sandbox/sandbox-ui-utils.ts
  • packages/builtin-tools/src/tools/ExecuteTool/__tests__/ExecuteTool.test.ts
  • packages/builtin-tools/src/tools/NotebookEditTool/NotebookEditTool.ts
  • src/cli/transports/Transport.ts
  • src/commands/login/getAuthStatus.ts
  • src/commands/plugin/ManagePlugins.tsx
  • src/commands/plugin/types.ts
  • src/commands/plugin/unifiedTypes.ts
  • src/components/FeedbackSurvey/utils.ts
  • src/components/Spinner/types.ts
  • src/components/StatusLine.tsx
  • src/components/agents/new-agent-creation/types.ts
  • src/components/mcp/types.ts
  • src/components/ui/option.ts
  • src/components/wizard/WizardProvider.tsx
  • src/components/wizard/types.ts
  • src/constants/querySource.ts
  • src/entrypoints/agentSdkTypes.ts
  • src/entrypoints/sdk/coreTypes.generated.ts
  • src/services/lsp/types.ts
  • src/services/tips/tipRegistry.ts
  • src/services/tips/types.ts
  • src/types/fileSuggestion.ts
  • src/types/notebook.ts
  • src/types/statusLine.ts
  • src/utils/__tests__/notebook.test.ts
  • src/utils/hooks.ts
  • src/utils/notebook.ts
  • src/utils/plugins/mcpbHandler.ts

Comment on lines +1 to +4
import type { Dispatch, ReactNode, SetStateAction } from 'react'

/** 向导中每一步的组件(无 props 或由 Wizard 包裹后注入上下文)。 */
export type WizardStepComponent = (() => ReactNode) | React.ComponentType
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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Inspect TS config flags relevant to UMD global namespace access:"
for f in $(fd -i '^tsconfig(\..*)?\.json$'); do
  echo "== $f =="
  rg -n '"(strict|allowUmdGlobalAccess|jsx|types)"' "$f" || true
done

echo
echo "Confirm current usage in wizard types:"
rg -n 'React\.ComponentType|WizardStepComponent' src/components/wizard/types.ts

Repository: claude-code-best/claude-code

Length of output: 1553


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Full content of src/components/wizard/types.ts ==="
cat -n src/components/wizard/types.ts

echo ""
echo "=== Run type-checking on the file ==="
bunx tsc --noEmit src/components/wizard/types.ts 2>&1 || echo "tsc returned: $?"

echo ""
echo "=== Check if bundler/tsc resolves React.ComponentType ==="
bunx tsc --noEmit 2>&1 | head -20 || true

Repository: claude-code-best/claude-code

Length of output: 1493


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Search for other uses of React.ComponentType in the codebase ==="
rg 'React\.ComponentType|React\.FC|React\.ReactNode' -t ts -t tsx --context=2

echo ""
echo "=== Check for React namespace imports to understand pattern ==="
rg 'import\s+React\s+from|import\s+type\s+\*\s+as\s+React' -t ts -t tsx | head -20

echo ""
echo "=== Check if there are any global React declarations ==="
fd -e d.ts | xargs grep -l 'declare.*React' 2>/dev/null || echo "No global React declarations found"

Repository: claude-code-best/claude-code

Length of output: 187


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Search for React.ComponentType usages ==="
rg 'React\.ComponentType' --context=2

echo ""
echo "=== Search for React namespace imports ==="
rg 'import.*React\s+from' --context=1 | head -30

echo ""
echo "=== Check if ComponentType is imported directly elsewhere ==="
rg 'import.*ComponentType' | head -20

Repository: claude-code-best/claude-code

Length of output: 3075


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Check PermissionRequest.tsx for React import ==="
head -20 src/components/permissions/PermissionRequest.tsx | cat -n

echo ""
echo "=== Check launchCommand.ts for React import ==="
head -20 src/commands/_shared/launchCommand.ts | cat -n

echo ""
echo "=== Check the specific line in PermissionRequest.tsx where React.ComponentType is used ==="
rg -B 10 'React\.ComponentType<PermissionRequestProps>' src/components/permissions/PermissionRequest.tsx | head -20

Repository: claude-code-best/claude-code

Length of output: 3654


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Check launchCommand.ts for React import (full imports section) ==="
head -50 src/commands/_shared/launchCommand.ts | grep -E "^import|^export" | cat -n

echo ""
echo "=== Verify: does src/components/wizard/types.ts actually have React imported? ==="
head -10 src/components/wizard/types.ts | cat -n

echo ""
echo "=== Check for any type declarations or d.ts files that might provide global React ==="
fd -e d.ts -e d.ts.map | xargs grep -l 'declare.*React' 2>/dev/null || echo "No global React type declarations"

Repository: claude-code-best/claude-code

Length of output: 1009


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Check the global.d.ts file ==="
cat -n src/types/global.d.ts

echo ""
echo "=== Also check tsconfig to see if global.d.ts is included ==="
rg -A 5 -B 5 'include|typeRoots|types' tsconfig.json tsconfig.base.json 2>/dev/null | head -40

Repository: claude-code-best/claude-code

Length of output: 5513


Import ComponentType directly to resolve the strict type-checking error.

Line 4 references React.ComponentType without importing the React namespace. In strict TypeScript mode, this fails type-checking. The jsx transform (react-jsx) doesn't make the React namespace globally available for type annotations.

-import type { Dispatch, ReactNode, SetStateAction } from 'react'
+import type { ComponentType, Dispatch, ReactNode, SetStateAction } from 'react'
@@
-export type WizardStepComponent = (() => ReactNode) | React.ComponentType
+export type WizardStepComponent = (() => ReactNode) | ComponentType
🤖 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/components/wizard/types.ts` around lines 1 - 4, The type alias
WizardStepComponent currently references React.ComponentType without importing
React; update the imports to pull ComponentType directly (e.g., import type {
Dispatch, ReactNode, SetStateAction, ComponentType } from 'react') and change
the union to use ComponentType (i.e., WizardStepComponent = (() => ReactNode) |
ComponentType) so strict TypeScript checking passes; ensure you only add the
type import and adjust the type reference in types.ts.

return <WizardContext.Provider value={contextValue}>{children || <CurrentStepComponent />}</WizardContext.Provider>;
return (
<WizardContext.Provider value={contextValue as unknown as WizardContextValue<Record<string, unknown>>}>
{children || <CurrentStepComponent />}
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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use nullish fallback for children rendering.

Line 126 uses children || <CurrentStepComponent />, which treats valid falsy nodes (0, '', false) as missing. Use ?? so fallback only happens for null/undefined.

Suggested fix
-      {children || <CurrentStepComponent />}
+      {children ?? <CurrentStepComponent />}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{children || <CurrentStepComponent />}
{children ?? <CurrentStepComponent />}
🤖 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/components/wizard/WizardProvider.tsx` at line 126, The component renders
a fallback with a logical OR which treats valid falsy React nodes (like 0, '',
false) as absent; in WizardProvider replace the fallback expression using
children || <CurrentStepComponent /> with a nullish coalescing fallback so only
null/undefined trigger the fallback (use children ?? <CurrentStepComponent />)
when rendering inside the WizardProvider component where children and
CurrentStepComponent are used.

Comment on lines +121 to +252
| (HookInputBase & { hook_event_name: 'UserPromptSubmit'; prompt: string })
| (HookInputBase & {
hook_event_name: 'SessionStart'
source: 'startup' | 'resume' | 'clear' | 'compact'
agent_type?: string
model?: string
})
| (HookInputBase & {
hook_event_name: 'SessionEnd'
reason:
| 'clear'
| 'resume'
| 'logout'
| 'prompt_input_exit'
| 'other'
| 'bypass_permissions_disabled'
})
| (HookInputBase & {
hook_event_name: 'Setup'
trigger: 'init' | 'maintenance'
})
| (HookInputBase & {
hook_event_name: 'Stop'
stop_hook_active: boolean
last_assistant_message?: string
})
| (HookInputBase & {
hook_event_name: 'StopFailure'
error: string
error_details?: unknown
last_assistant_message?: string
})
| (HookInputBase & {
hook_event_name: 'SubagentStart'
agent_id: string
agent_type: string
})
| (HookInputBase & {
hook_event_name: 'SubagentStop'
stop_hook_active: boolean
agent_id: string
agent_transcript_path: string
agent_type: string
last_assistant_message?: string
})
| (HookInputBase & {
hook_event_name: 'PreCompact'
trigger: 'manual' | 'auto'
custom_instructions: string | null
})
| (HookInputBase & {
hook_event_name: 'PostCompact'
trigger: 'manual' | 'auto'
compact_summary: string
})
| (HookInputBase & {
hook_event_name: 'TeammateIdle'
teammate_name: string
team_name: string
})
| (HookInputBase & {
hook_event_name: 'TaskCreated'
task_id: string
task_subject: string
task_description?: string
teammate_name?: string
team_name?: string
})
| (HookInputBase & {
hook_event_name: 'TaskCompleted'
task_id: string
task_subject: string
task_description?: string
teammate_name?: string
team_name?: string
})
| (HookInputBase & {
hook_event_name: 'Elicitation'
mcp_server_name: string
message: string
mode?: 'form' | 'url'
url?: string
elicitation_id?: string
requested_schema?: Record<string, unknown>
})
| (HookInputBase & {
hook_event_name: 'ElicitationResult'
mcp_server_name: string
elicitation_id?: string
mode?: 'form' | 'url'
action: 'accept' | 'decline' | 'cancel'
content?: Record<string, unknown>
})
| (HookInputBase & {
hook_event_name: 'ConfigChange'
source:
| 'user_settings'
| 'project_settings'
| 'local_settings'
| 'policy_settings'
| 'skills'
file_path?: string
})
| (HookInputBase & {
hook_event_name: 'InstructionsLoaded'
file_path: string
memory_type: 'User' | 'Project' | 'Local' | 'Managed'
load_reason:
| 'session_start'
| 'nested_traversal'
| 'path_glob_match'
| 'include'
| 'compact'
globs?: string[]
trigger_file_path?: string
parent_file_path?: string
})
| (HookInputBase & { hook_event_name: 'WorktreeCreate'; name: string })
| (HookInputBase & {
hook_event_name: 'WorktreeRemove'
worktree_path: string
})
| (HookInputBase & {
hook_event_name: 'CwdChanged'
old_cwd: string
new_cwd: string
})
| (HookInputBase & {
hook_event_name: 'FileChanged'
file_path: string
event: 'change' | 'add' | 'unlink'
})
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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Align new hook payload keys with exported alias contracts.

HookInput now uses SessionEnd.reason and FileChanged.file_path, but public aliases still require exit_reason (Line 330) and path (Line 346). This creates conflicting SDK surface types.

Proposed fix
-export type SessionEndHookInput = HookInput & { exit_reason: string }
+export type SessionEndHookInput = Extract<
+  HookInput,
+  { hook_event_name: 'SessionEnd' }
+>

-export type FileChangedHookInput = HookInput & { path: string }
+export type FileChangedHookInput = Extract<
+  HookInput,
+  { hook_event_name: 'FileChanged' }
+>
🤖 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/entrypoints/sdk/coreTypes.generated.ts` around lines 121 - 252, HookInput
was changed to use SessionEnd.reason and FileChanged.file_path but the public
alias types still expect exit_reason and path, causing conflicting SDK types;
update the exported alias contracts to accept the new keys (or provide
backward-compatible unions) by replacing references to exit_reason and path in
the alias definitions with reason and file_path (or define types that include
both keys), and update any alias type names that map to HookInput (referencing
HookInput, SessionEnd, FileChanged and the public alias types where exit_reason
and path are defined) so the SDK surface types align.

@claude-code-best claude-code-best merged commit ea399f1 into claude-code-best:main May 19, 2026
3 checks passed
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