@mseep/claudian 2.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.local.example +2 -0
- package/.github/workflows/ci.yml +59 -0
- package/.github/workflows/claude-code-review.yml +57 -0
- package/.github/workflows/claude.yml +50 -0
- package/.github/workflows/duplicate-issues.yml +22 -0
- package/.github/workflows/release.yml +73 -0
- package/.github/workflows/stale.yml +21 -0
- package/.node-version +1 -0
- package/AGENTS.md +3 -0
- package/CLAUDE.md +80 -0
- package/LICENSE +21 -0
- package/README.md +190 -0
- package/assets/Preview.png +0 -0
- package/assets/sponsors/MOMA.png +0 -0
- package/bun.lock +1618 -0
- package/esbuild.config.mjs +195 -0
- package/eslint.config.mjs +143 -0
- package/jest.config.js +41 -0
- package/main.js +104915 -0
- package/manifest.json +10 -0
- package/package.json +65 -0
- package/scripts/build-css.mjs +119 -0
- package/scripts/build.mjs +19 -0
- package/scripts/postinstall.mjs +25 -0
- package/scripts/rendererSafeUnref.js +205 -0
- package/scripts/run-jest.js +19 -0
- package/scripts/sync-version.js +16 -0
- package/src/app/settings/ClaudianSettingsStorage.ts +435 -0
- package/src/app/settings/defaultSettings.ts +54 -0
- package/src/app/storage/SharedStorageService.ts +106 -0
- package/src/core/CLAUDE.md +84 -0
- package/src/core/auxiliary/AuxQueryRunner.ts +11 -0
- package/src/core/auxiliary/QueryBackedInlineEditService.ts +73 -0
- package/src/core/auxiliary/QueryBackedInstructionRefineService.ts +78 -0
- package/src/core/auxiliary/QueryBackedTitleGenerationService.ts +90 -0
- package/src/core/bootstrap/SessionStorage.ts +179 -0
- package/src/core/bootstrap/StoragePaths.ts +7 -0
- package/src/core/bootstrap/storage.ts +20 -0
- package/src/core/commands/builtInCommands.ts +141 -0
- package/src/core/mcp/McpConfigParser.ts +102 -0
- package/src/core/mcp/McpServerManager.ts +119 -0
- package/src/core/mcp/McpTester.ts +310 -0
- package/src/core/prompt/inlineEdit.ts +252 -0
- package/src/core/prompt/instructionRefine.ts +72 -0
- package/src/core/prompt/mainAgent.ts +213 -0
- package/src/core/prompt/titleGeneration.ts +44 -0
- package/src/core/providers/ProviderRegistry.ts +253 -0
- package/src/core/providers/ProviderSettingsCoordinator.ts +434 -0
- package/src/core/providers/ProviderWorkspaceRegistry.ts +119 -0
- package/src/core/providers/commands/ProviderCommandCatalog.ts +21 -0
- package/src/core/providers/commands/ProviderCommandEntry.ts +33 -0
- package/src/core/providers/commands/hiddenCommands.ts +74 -0
- package/src/core/providers/modelRouting.ts +17 -0
- package/src/core/providers/modelSelection.ts +72 -0
- package/src/core/providers/providerConfig.ts +34 -0
- package/src/core/providers/providerEnvironment.ts +364 -0
- package/src/core/providers/types.ts +544 -0
- package/src/core/runtime/ChatRuntime.ts +66 -0
- package/src/core/runtime/QueuedTurn.ts +97 -0
- package/src/core/runtime/types.ts +118 -0
- package/src/core/security/ApprovalManager.ts +142 -0
- package/src/core/storage/HomeFileAdapter.ts +75 -0
- package/src/core/storage/VaultFileAdapter.ts +132 -0
- package/src/core/tools/todo.ts +65 -0
- package/src/core/tools/toolIcons.ts +80 -0
- package/src/core/tools/toolInput.ts +119 -0
- package/src/core/tools/toolNames.ts +149 -0
- package/src/core/tools/toolResultContent.ts +26 -0
- package/src/core/types/agent.ts +28 -0
- package/src/core/types/chat.ts +177 -0
- package/src/core/types/diff.ts +31 -0
- package/src/core/types/index.ts +78 -0
- package/src/core/types/mcp.ts +97 -0
- package/src/core/types/plugins.ts +9 -0
- package/src/core/types/provider.ts +1 -0
- package/src/core/types/settings.ts +152 -0
- package/src/core/types/tools.ts +80 -0
- package/src/features/chat/CLAUDE.md +136 -0
- package/src/features/chat/ClaudianView.ts +762 -0
- package/src/features/chat/constants.ts +114 -0
- package/src/features/chat/controllers/BrowserSelectionController.ts +295 -0
- package/src/features/chat/controllers/CanvasSelectionController.ts +142 -0
- package/src/features/chat/controllers/ConversationController.ts +1103 -0
- package/src/features/chat/controllers/InputController.ts +1707 -0
- package/src/features/chat/controllers/NavigationController.ts +209 -0
- package/src/features/chat/controllers/SelectionController.ts +430 -0
- package/src/features/chat/controllers/StreamController.ts +1560 -0
- package/src/features/chat/controllers/contextRowVisibility.ts +18 -0
- package/src/features/chat/rendering/DiffRenderer.ts +134 -0
- package/src/features/chat/rendering/InlineAskUserQuestion.ts +702 -0
- package/src/features/chat/rendering/InlineExitPlanMode.ts +263 -0
- package/src/features/chat/rendering/InlinePlanApproval.ts +183 -0
- package/src/features/chat/rendering/MessageRenderer.ts +907 -0
- package/src/features/chat/rendering/SubagentRenderer.ts +678 -0
- package/src/features/chat/rendering/ThinkingBlockRenderer.ts +126 -0
- package/src/features/chat/rendering/TodoListRenderer.ts +5 -0
- package/src/features/chat/rendering/ToolCallRenderer.ts +1161 -0
- package/src/features/chat/rendering/WriteEditRenderer.ts +232 -0
- package/src/features/chat/rendering/collapsible.ts +101 -0
- package/src/features/chat/rendering/subagentLifecycleResolution.ts +25 -0
- package/src/features/chat/rendering/todoUtils.ts +29 -0
- package/src/features/chat/rewind.ts +31 -0
- package/src/features/chat/services/BangBashService.ts +56 -0
- package/src/features/chat/services/SubagentManager.ts +1107 -0
- package/src/features/chat/state/ChatState.ts +436 -0
- package/src/features/chat/state/types.ts +138 -0
- package/src/features/chat/tabs/Tab.ts +1886 -0
- package/src/features/chat/tabs/TabBar.ts +179 -0
- package/src/features/chat/tabs/TabManager.ts +1021 -0
- package/src/features/chat/tabs/providerResolution.ts +34 -0
- package/src/features/chat/tabs/types.ts +287 -0
- package/src/features/chat/ui/BangBashModeManager.ts +121 -0
- package/src/features/chat/ui/FileContext.ts +385 -0
- package/src/features/chat/ui/ImageContext.ts +366 -0
- package/src/features/chat/ui/InputToolbar.ts +1244 -0
- package/src/features/chat/ui/InstructionModeManager.ts +158 -0
- package/src/features/chat/ui/NavigationSidebar.ts +126 -0
- package/src/features/chat/ui/StatusPanel.ts +589 -0
- package/src/features/chat/ui/file-context/state/FileContextState.ts +83 -0
- package/src/features/chat/ui/file-context/view/FileChipsView.ts +70 -0
- package/src/features/chat/ui/textareaResize.ts +47 -0
- package/src/features/chat/utils/usageInfo.ts +26 -0
- package/src/features/inline-edit/ui/InlineEditModal.ts +895 -0
- package/src/features/inline-edit/ui/inlineEditMarkdownPreview.ts +55 -0
- package/src/features/settings/ClaudianSettings.ts +672 -0
- package/src/features/settings/keyboardNavigation.ts +60 -0
- package/src/features/settings/ui/EnvSnippetManager.ts +430 -0
- package/src/features/settings/ui/EnvironmentSettingsSection.ts +85 -0
- package/src/features/settings/ui/McpServerModal.ts +335 -0
- package/src/features/settings/ui/McpSettingsManager.ts +400 -0
- package/src/features/settings/ui/McpTestModal.ts +346 -0
- package/src/i18n/constants.ts +58 -0
- package/src/i18n/i18n.ts +140 -0
- package/src/i18n/locales/de.json +322 -0
- package/src/i18n/locales/en.json +322 -0
- package/src/i18n/locales/es.json +322 -0
- package/src/i18n/locales/fr.json +322 -0
- package/src/i18n/locales/ja.json +322 -0
- package/src/i18n/locales/ko.json +322 -0
- package/src/i18n/locales/pt.json +322 -0
- package/src/i18n/locales/ru.json +322 -0
- package/src/i18n/locales/zh-CN.json +322 -0
- package/src/i18n/locales/zh-TW.json +322 -0
- package/src/i18n/types.ts +248 -0
- package/src/main.ts +772 -0
- package/src/providers/acp/AcpClientConnection.ts +361 -0
- package/src/providers/acp/AcpJsonRpcTransport.ts +427 -0
- package/src/providers/acp/AcpSessionConfig.ts +139 -0
- package/src/providers/acp/AcpSessionUpdateNormalizer.ts +371 -0
- package/src/providers/acp/AcpSubprocess.ts +155 -0
- package/src/providers/acp/AcpToolStreamAdapter.ts +132 -0
- package/src/providers/acp/buildAcpUsageInfo.ts +41 -0
- package/src/providers/acp/index.ts +9 -0
- package/src/providers/acp/methodNames.ts +50 -0
- package/src/providers/acp/types.ts +566 -0
- package/src/providers/claude/CLAUDE.md +78 -0
- package/src/providers/claude/agents/AgentManager.ts +225 -0
- package/src/providers/claude/agents/AgentStorage.ts +101 -0
- package/src/providers/claude/app/ClaudeWorkspaceServices.ts +90 -0
- package/src/providers/claude/auxiliary/ClaudeInlineEditService.ts +122 -0
- package/src/providers/claude/auxiliary/ClaudeInstructionRefineService.ts +90 -0
- package/src/providers/claude/auxiliary/ClaudeTitleGenerationService.ts +129 -0
- package/src/providers/claude/auxiliary/extractAssistantText.ts +28 -0
- package/src/providers/claude/capabilities.ts +17 -0
- package/src/providers/claude/cli/findClaudeCLIPath.ts +261 -0
- package/src/providers/claude/commands/ClaudeCommandCatalog.ts +149 -0
- package/src/providers/claude/commands/probeRuntimeCommands.ts +86 -0
- package/src/providers/claude/env/ClaudeSettingsReconciler.ts +90 -0
- package/src/providers/claude/env/claudeModelEnv.ts +86 -0
- package/src/providers/claude/history/ClaudeConversationHistoryService.ts +446 -0
- package/src/providers/claude/history/ClaudeHistoryStore.ts +170 -0
- package/src/providers/claude/history/sdkAsyncSubagent.ts +92 -0
- package/src/providers/claude/history/sdkBranchFilter.ts +271 -0
- package/src/providers/claude/history/sdkHistoryTypes.ts +61 -0
- package/src/providers/claude/history/sdkMessageParsing.ts +413 -0
- package/src/providers/claude/history/sdkSessionPaths.ts +98 -0
- package/src/providers/claude/history/sdkSubagentSidecar.ts +261 -0
- package/src/providers/claude/hooks/SubagentHooks.ts +31 -0
- package/src/providers/claude/modelLabels.ts +77 -0
- package/src/providers/claude/modelOptions.ts +113 -0
- package/src/providers/claude/modelSelection.ts +17 -0
- package/src/providers/claude/plugins/PluginManager.ts +194 -0
- package/src/providers/claude/prompt/ClaudeTurnEncoder.ts +46 -0
- package/src/providers/claude/registration.ts +39 -0
- package/src/providers/claude/runtime/ClaudeApprovalHandler.ts +153 -0
- package/src/providers/claude/runtime/ClaudeChatRuntime.ts +1812 -0
- package/src/providers/claude/runtime/ClaudeCliResolver.ts +94 -0
- package/src/providers/claude/runtime/ClaudeDynamicUpdates.ts +164 -0
- package/src/providers/claude/runtime/ClaudeMessageChannel.ts +209 -0
- package/src/providers/claude/runtime/ClaudeQueryOptionsBuilder.ts +315 -0
- package/src/providers/claude/runtime/ClaudeRewindService.ts +220 -0
- package/src/providers/claude/runtime/ClaudeSessionManager.ts +92 -0
- package/src/providers/claude/runtime/ClaudeTaskResultInterpreter.ts +172 -0
- package/src/providers/claude/runtime/ClaudeUserMessageFactory.ts +83 -0
- package/src/providers/claude/runtime/claudeColdStartQuery.ts +152 -0
- package/src/providers/claude/runtime/customSpawn.ts +87 -0
- package/src/providers/claude/runtime/types.ts +134 -0
- package/src/providers/claude/sdk/messages.ts +17 -0
- package/src/providers/claude/sdk/toolResultContent.ts +4 -0
- package/src/providers/claude/sdk/typeGuards.ts +14 -0
- package/src/providers/claude/sdk/types.ts +15 -0
- package/src/providers/claude/security/ClaudePermissionUpdates.ts +44 -0
- package/src/providers/claude/settings.ts +138 -0
- package/src/providers/claude/storage/AgentVaultStorage.ts +101 -0
- package/src/providers/claude/storage/CCSettingsStorage.ts +153 -0
- package/src/providers/claude/storage/ClaudianSettingsStorage.ts +6 -0
- package/src/providers/claude/storage/McpStorage.ts +139 -0
- package/src/providers/claude/storage/SessionStorage.ts +5 -0
- package/src/providers/claude/storage/SkillStorage.ts +61 -0
- package/src/providers/claude/storage/SlashCommandStorage.ts +96 -0
- package/src/providers/claude/storage/StorageService.ts +185 -0
- package/src/providers/claude/stream/toolInputStreamState.ts +318 -0
- package/src/providers/claude/stream/transformClaudeMessage.ts +586 -0
- package/src/providers/claude/types/agent.ts +2 -0
- package/src/providers/claude/types/models.ts +168 -0
- package/src/providers/claude/types/plugins.ts +14 -0
- package/src/providers/claude/types/providerState.ts +16 -0
- package/src/providers/claude/types/settings.ts +98 -0
- package/src/providers/claude/ui/AgentSettings.ts +389 -0
- package/src/providers/claude/ui/ClaudeChatUIConfig.ts +113 -0
- package/src/providers/claude/ui/ClaudeSettingsTab.ts +407 -0
- package/src/providers/claude/ui/PluginSettingsManager.ts +149 -0
- package/src/providers/claude/ui/SlashCommandSettings.ts +527 -0
- package/src/providers/codex/CLAUDE.md +64 -0
- package/src/providers/codex/agents/CodexAgentMentionProvider.ts +33 -0
- package/src/providers/codex/app/CodexWorkspaceServices.ts +76 -0
- package/src/providers/codex/auxiliary/CodexInlineEditService.ts +9 -0
- package/src/providers/codex/auxiliary/CodexInstructionRefineService.ts +9 -0
- package/src/providers/codex/auxiliary/CodexTaskResultInterpreter.ts +29 -0
- package/src/providers/codex/auxiliary/CodexTitleGenerationService.ts +22 -0
- package/src/providers/codex/capabilities.ts +16 -0
- package/src/providers/codex/commands/CodexSkillCatalog.ts +180 -0
- package/src/providers/codex/env/CodexSettingsReconciler.ts +68 -0
- package/src/providers/codex/history/CodexConversationHistoryService.ts +212 -0
- package/src/providers/codex/history/CodexHistoryStore.ts +1672 -0
- package/src/providers/codex/modelOptions.ts +99 -0
- package/src/providers/codex/modelSelection.ts +17 -0
- package/src/providers/codex/normalization/codexSubagentNormalization.ts +227 -0
- package/src/providers/codex/normalization/codexToolNormalization.ts +390 -0
- package/src/providers/codex/prompt/encodeCodexTurn.ts +57 -0
- package/src/providers/codex/registration.ts +29 -0
- package/src/providers/codex/runtime/CodexAppServerProcess.ts +105 -0
- package/src/providers/codex/runtime/CodexAuxQueryRunner.ts +180 -0
- package/src/providers/codex/runtime/CodexBinaryLocator.ts +49 -0
- package/src/providers/codex/runtime/CodexChatRuntime.ts +1296 -0
- package/src/providers/codex/runtime/CodexCliResolver.ts +65 -0
- package/src/providers/codex/runtime/CodexExecutionTargetResolver.ts +104 -0
- package/src/providers/codex/runtime/CodexLaunchSpecBuilder.ts +85 -0
- package/src/providers/codex/runtime/CodexNotificationRouter.ts +1033 -0
- package/src/providers/codex/runtime/CodexPathMapper.ts +155 -0
- package/src/providers/codex/runtime/CodexRpcTransport.ts +171 -0
- package/src/providers/codex/runtime/CodexRuntimeContext.ts +109 -0
- package/src/providers/codex/runtime/CodexServerRequestRouter.ts +331 -0
- package/src/providers/codex/runtime/CodexSessionFileTail.ts +792 -0
- package/src/providers/codex/runtime/CodexSessionManager.ts +39 -0
- package/src/providers/codex/runtime/codexAppServerSupport.ts +58 -0
- package/src/providers/codex/runtime/codexAppServerTypes.ts +705 -0
- package/src/providers/codex/runtime/codexLaunchTypes.ts +30 -0
- package/src/providers/codex/settings.ts +236 -0
- package/src/providers/codex/skills/CodexSkillListingService.ts +173 -0
- package/src/providers/codex/storage/CodexSkillStorage.ts +250 -0
- package/src/providers/codex/storage/CodexSubagentStorage.ts +212 -0
- package/src/providers/codex/types/index.ts +16 -0
- package/src/providers/codex/types/models.ts +46 -0
- package/src/providers/codex/types/subagent.ts +23 -0
- package/src/providers/codex/ui/CodexChatUIConfig.ts +128 -0
- package/src/providers/codex/ui/CodexSettingsTab.ts +432 -0
- package/src/providers/codex/ui/CodexSkillSettings.ts +275 -0
- package/src/providers/codex/ui/CodexSubagentSettings.ts +400 -0
- package/src/providers/defaultProviderConfigs.ts +14 -0
- package/src/providers/index.ts +30 -0
- package/src/providers/opencode/agents/OpencodeAgentMentionProvider.ts +42 -0
- package/src/providers/opencode/app/OpencodeRuntimeCommandLoader.ts +67 -0
- package/src/providers/opencode/app/OpencodeWorkspaceServices.ts +55 -0
- package/src/providers/opencode/auxiliary/OpencodeInlineEditService.ts +13 -0
- package/src/providers/opencode/auxiliary/OpencodeInstructionRefineService.ts +12 -0
- package/src/providers/opencode/auxiliary/OpencodeTaskResultInterpreter.ts +29 -0
- package/src/providers/opencode/auxiliary/OpencodeTitleGenerationService.ts +27 -0
- package/src/providers/opencode/capabilities.ts +16 -0
- package/src/providers/opencode/commands/OpencodeCommandCatalog.ts +92 -0
- package/src/providers/opencode/discoveryState.ts +135 -0
- package/src/providers/opencode/env/OpencodeSettingsReconciler.ts +178 -0
- package/src/providers/opencode/history/OpencodeConversationHistoryService.ts +84 -0
- package/src/providers/opencode/history/OpencodeHistoryStore.ts +472 -0
- package/src/providers/opencode/history/OpencodeSqliteReader.ts +284 -0
- package/src/providers/opencode/internal/compareCollections.ts +72 -0
- package/src/providers/opencode/internal/providerProjection.ts +15 -0
- package/src/providers/opencode/models.ts +378 -0
- package/src/providers/opencode/modes.ts +150 -0
- package/src/providers/opencode/normalization/opencodeToolNormalization.ts +406 -0
- package/src/providers/opencode/registration.ts +27 -0
- package/src/providers/opencode/runtime/OpencodeAuxQueryRunner.ts +436 -0
- package/src/providers/opencode/runtime/OpencodeChatRuntime.ts +1603 -0
- package/src/providers/opencode/runtime/OpencodeCliResolver.ts +57 -0
- package/src/providers/opencode/runtime/OpencodeLaunchArtifacts.ts +231 -0
- package/src/providers/opencode/runtime/OpencodePaths.ts +113 -0
- package/src/providers/opencode/runtime/OpencodeRuntimeEnvironment.ts +18 -0
- package/src/providers/opencode/runtime/buildOpencodePrompt.ts +66 -0
- package/src/providers/opencode/settings.ts +427 -0
- package/src/providers/opencode/storage/OpencodeAgentStorage.ts +346 -0
- package/src/providers/opencode/types/agent.ts +37 -0
- package/src/providers/opencode/types/index.ts +9 -0
- package/src/providers/opencode/ui/OpencodeAgentSettings.ts +579 -0
- package/src/providers/opencode/ui/OpencodeChatUIConfig.ts +316 -0
- package/src/providers/opencode/ui/OpencodeSettingsTab.ts +674 -0
- package/src/providers/pi/app/PiRuntimeCommandLoader.ts +57 -0
- package/src/providers/pi/app/PiWorkspaceServices.ts +39 -0
- package/src/providers/pi/auxiliary/PiInlineEditService.ts +9 -0
- package/src/providers/pi/auxiliary/PiInstructionRefineService.ts +9 -0
- package/src/providers/pi/auxiliary/PiTaskResultInterpreter.ts +29 -0
- package/src/providers/pi/auxiliary/PiTitleGenerationService.ts +19 -0
- package/src/providers/pi/capabilities.ts +16 -0
- package/src/providers/pi/commands/PiCommandCatalog.ts +92 -0
- package/src/providers/pi/env/PiSettingsReconciler.ts +180 -0
- package/src/providers/pi/history/PiConversationHistoryService.ts +123 -0
- package/src/providers/pi/history/PiHistoryStore.ts +664 -0
- package/src/providers/pi/internal/compareCollections.ts +4 -0
- package/src/providers/pi/internal/providerProjection.ts +18 -0
- package/src/providers/pi/models.ts +302 -0
- package/src/providers/pi/normalizations/piEventNormalization.ts +211 -0
- package/src/providers/pi/normalizations/piToolNormalization.ts +97 -0
- package/src/providers/pi/registration.ts +30 -0
- package/src/providers/pi/runtime/PiAuxQueryRunner.ts +216 -0
- package/src/providers/pi/runtime/PiChatRuntime.ts +1064 -0
- package/src/providers/pi/runtime/PiCliResolver.ts +53 -0
- package/src/providers/pi/runtime/PiExtensionUiBridge.ts +161 -0
- package/src/providers/pi/runtime/PiJsonl.ts +71 -0
- package/src/providers/pi/runtime/PiLaunchSpec.ts +70 -0
- package/src/providers/pi/runtime/PiModelDiscoveryService.ts +92 -0
- package/src/providers/pi/runtime/PiRpcPayloads.ts +18 -0
- package/src/providers/pi/runtime/PiRpcTransport.ts +243 -0
- package/src/providers/pi/runtime/PiSubprocess.ts +159 -0
- package/src/providers/pi/runtime/buildPiPrompt.ts +62 -0
- package/src/providers/pi/runtime/buildPiUsageInfo.ts +69 -0
- package/src/providers/pi/settings.ts +468 -0
- package/src/providers/pi/types.ts +64 -0
- package/src/providers/pi/ui/ObsidianPiExtensionUiRenderer.ts +251 -0
- package/src/providers/pi/ui/PiChatUIConfig.ts +265 -0
- package/src/providers/pi/ui/PiExtensionUiRenderer.ts +12 -0
- package/src/providers/pi/ui/PiSettingsTab.ts +642 -0
- package/src/shared/components/ResumeSessionDropdown.ts +185 -0
- package/src/shared/components/SelectableDropdown.ts +140 -0
- package/src/shared/components/SelectionHighlight.ts +77 -0
- package/src/shared/components/SlashCommandDropdown.ts +421 -0
- package/src/shared/icons.ts +180 -0
- package/src/shared/mention/MentionDropdownController.ts +627 -0
- package/src/shared/mention/VaultMentionCache.ts +106 -0
- package/src/shared/mention/VaultMentionDataProvider.ts +51 -0
- package/src/shared/mention/types.ts +67 -0
- package/src/shared/modals/ConfirmModal.ts +60 -0
- package/src/shared/modals/ForkTargetModal.ts +47 -0
- package/src/shared/modals/InstructionConfirmModal.ts +281 -0
- package/src/style/CLAUDE.md +49 -0
- package/src/style/accessibility.css +40 -0
- package/src/style/base/animations.css +44 -0
- package/src/style/base/container.css +20 -0
- package/src/style/base/variables.css +46 -0
- package/src/style/base/visibility.css +15 -0
- package/src/style/components/code.css +97 -0
- package/src/style/components/context-footer.css +76 -0
- package/src/style/components/header.css +27 -0
- package/src/style/components/history.css +221 -0
- package/src/style/components/input.css +312 -0
- package/src/style/components/messages.css +262 -0
- package/src/style/components/nav-sidebar.css +58 -0
- package/src/style/components/status-panel.css +202 -0
- package/src/style/components/subagent.css +248 -0
- package/src/style/components/tabs.css +112 -0
- package/src/style/components/thinking.css +88 -0
- package/src/style/components/toolcalls.css +278 -0
- package/src/style/features/ask-user-question.css +315 -0
- package/src/style/features/diff.css +197 -0
- package/src/style/features/file-context.css +188 -0
- package/src/style/features/file-link.css +22 -0
- package/src/style/features/image-context.css +179 -0
- package/src/style/features/image-embed.css +40 -0
- package/src/style/features/image-modal.css +52 -0
- package/src/style/features/inline-edit.css +278 -0
- package/src/style/features/plan-mode.css +103 -0
- package/src/style/features/resume-session.css +119 -0
- package/src/style/features/slash-commands.css +91 -0
- package/src/style/index.css +63 -0
- package/src/style/modals/fork-target.css +21 -0
- package/src/style/modals/instruction.css +161 -0
- package/src/style/modals/mcp-modal.css +241 -0
- package/src/style/settings/agent-settings.css +2 -0
- package/src/style/settings/base.css +300 -0
- package/src/style/settings/env-snippets.css +366 -0
- package/src/style/settings/mcp-settings.css +211 -0
- package/src/style/settings/plugin-settings.css +164 -0
- package/src/style/settings/provider-model-picker.css +367 -0
- package/src/style/settings/slash-settings.css +16 -0
- package/src/style/toolbar/external-context.css +177 -0
- package/src/style/toolbar/mcp-selector.css +176 -0
- package/src/style/toolbar/mode-selector.css +19 -0
- package/src/style/toolbar/model-selector.css +99 -0
- package/src/style/toolbar/permission-toggle.css +56 -0
- package/src/style/toolbar/service-tier-toggle.css +39 -0
- package/src/style/toolbar/thinking-selector.css +83 -0
- package/src/types/smol-toml.d.ts +4 -0
- package/src/utils/agent.ts +50 -0
- package/src/utils/animationFrame.ts +46 -0
- package/src/utils/browser.ts +46 -0
- package/src/utils/canvas.ts +14 -0
- package/src/utils/cliBinaryLocator.ts +97 -0
- package/src/utils/context.ts +117 -0
- package/src/utils/contextMentionResolver.ts +154 -0
- package/src/utils/date.ts +31 -0
- package/src/utils/diff.ts +384 -0
- package/src/utils/editor.ts +104 -0
- package/src/utils/electronCompat.ts +53 -0
- package/src/utils/env.ts +465 -0
- package/src/utils/externalContext.ts +143 -0
- package/src/utils/externalContextScanner.ts +135 -0
- package/src/utils/fileLink.ts +263 -0
- package/src/utils/frontmatter.ts +194 -0
- package/src/utils/imageEmbed.ts +139 -0
- package/src/utils/inlineEdit.ts +22 -0
- package/src/utils/interrupt.ts +23 -0
- package/src/utils/markdown.ts +25 -0
- package/src/utils/markdownMath.ts +130 -0
- package/src/utils/mcp.ts +96 -0
- package/src/utils/obsidianCompat.ts +23 -0
- package/src/utils/path.ts +342 -0
- package/src/utils/session.ts +240 -0
- package/src/utils/slashCommand.ts +152 -0
- package/src/utils/subagentJsonl.ts +52 -0
- package/src/utils/windowsCmdShim.ts +98 -0
- package/tests/__mocks__/claude-agent-sdk.ts +317 -0
- package/tests/__mocks__/codex-sdk.ts +88 -0
- package/tests/__mocks__/obsidian.ts +434 -0
- package/tests/helpers/mockElement.ts +403 -0
- package/tests/helpers/sdkMessages.ts +291 -0
- package/tests/integration/core/agent/ClaudianService.test.ts +1845 -0
- package/tests/integration/core/mcp/mcp.test.ts +905 -0
- package/tests/integration/features/chat/imagePersistence.test.ts +38 -0
- package/tests/integration/main.test.ts +1701 -0
- package/tests/setupWindow.ts +26 -0
- package/tests/tsconfig.json +7 -0
- package/tests/unit/core/commands/builtInCommands.test.ts +239 -0
- package/tests/unit/core/mcp/McpServerManager.test.ts +405 -0
- package/tests/unit/core/mcp/McpTester.test.ts +282 -0
- package/tests/unit/core/mcp/createNodeFetch.test.ts +188 -0
- package/tests/unit/core/providers/ProviderRegistry.test.ts +275 -0
- package/tests/unit/core/providers/ProviderSettingsCoordinator.test.ts +490 -0
- package/tests/unit/core/providers/ProviderWorkspaceRegistry.test.ts +84 -0
- package/tests/unit/core/providers/modelRouting.test.ts +91 -0
- package/tests/unit/core/providers/modelSelection.test.ts +155 -0
- package/tests/unit/core/providers/providerEnvironment.test.ts +162 -0
- package/tests/unit/core/providers/tabLifecycle.test.ts +217 -0
- package/tests/unit/core/security/ApprovalManager.test.ts +152 -0
- package/tests/unit/core/storage/VaultFileAdapter.test.ts +535 -0
- package/tests/unit/core/tools/todo.test.ts +227 -0
- package/tests/unit/core/tools/toolIcons.test.ts +75 -0
- package/tests/unit/core/tools/toolInput.test.ts +350 -0
- package/tests/unit/core/tools/toolNames.test.ts +464 -0
- package/tests/unit/core/types/mcp.test.ts +115 -0
- package/tests/unit/features/chat/ClaudianView.test.ts +404 -0
- package/tests/unit/features/chat/controllers/BrowserSelectionController.test.ts +179 -0
- package/tests/unit/features/chat/controllers/CanvasSelectionController.test.ts +216 -0
- package/tests/unit/features/chat/controllers/ConversationController.test.ts +2764 -0
- package/tests/unit/features/chat/controllers/InputController.test.ts +3188 -0
- package/tests/unit/features/chat/controllers/NavigationController.test.ts +640 -0
- package/tests/unit/features/chat/controllers/SelectionController.test.ts +695 -0
- package/tests/unit/features/chat/controllers/StreamController.test.ts +2534 -0
- package/tests/unit/features/chat/controllers/contextRowVisibility.test.ts +46 -0
- package/tests/unit/features/chat/controllers/index.test.ts +16 -0
- package/tests/unit/features/chat/rendering/DiffRenderer.test.ts +355 -0
- package/tests/unit/features/chat/rendering/InlineAskUserQuestion.test.ts +1035 -0
- package/tests/unit/features/chat/rendering/InlineExitPlanMode.test.ts +191 -0
- package/tests/unit/features/chat/rendering/InlinePlanApproval.test.ts +126 -0
- package/tests/unit/features/chat/rendering/MessageRenderer.test.ts +2004 -0
- package/tests/unit/features/chat/rendering/SubagentRenderer.test.ts +917 -0
- package/tests/unit/features/chat/rendering/ThinkingBlockRenderer.test.ts +124 -0
- package/tests/unit/features/chat/rendering/TodoListRenderer.test.ts +173 -0
- package/tests/unit/features/chat/rendering/ToolCallRenderer.test.ts +909 -0
- package/tests/unit/features/chat/rendering/WriteEditRenderer.test.ts +474 -0
- package/tests/unit/features/chat/rendering/collapsible.test.ts +158 -0
- package/tests/unit/features/chat/rendering/todoUtils.test.ts +105 -0
- package/tests/unit/features/chat/rewind.test.ts +56 -0
- package/tests/unit/features/chat/services/BangBashService.test.ts +142 -0
- package/tests/unit/features/chat/services/InstructionRefineService.test.ts +371 -0
- package/tests/unit/features/chat/services/SubagentManager.test.ts +1759 -0
- package/tests/unit/features/chat/services/TitleGenerationService.test.ts +480 -0
- package/tests/unit/features/chat/state/ChatState.test.ts +581 -0
- package/tests/unit/features/chat/tabs/Tab.test.ts +4287 -0
- package/tests/unit/features/chat/tabs/TabBar.test.ts +357 -0
- package/tests/unit/features/chat/tabs/TabManager.test.ts +2962 -0
- package/tests/unit/features/chat/tabs/index.test.ts +11 -0
- package/tests/unit/features/chat/ui/BangBashModeManager.test.ts +321 -0
- package/tests/unit/features/chat/ui/ExternalContextSelector.test.ts +555 -0
- package/tests/unit/features/chat/ui/FileContextManager.test.ts +876 -0
- package/tests/unit/features/chat/ui/ImageContext.test.ts +777 -0
- package/tests/unit/features/chat/ui/InputToolbar.test.ts +1139 -0
- package/tests/unit/features/chat/ui/InstructionModeManager.test.ts +243 -0
- package/tests/unit/features/chat/ui/NavigationSidebar.test.ts +570 -0
- package/tests/unit/features/chat/ui/StatusPanel.test.ts +953 -0
- package/tests/unit/features/chat/ui/file-context/state/FileContextState.test.ts +155 -0
- package/tests/unit/features/chat/ui/textareaResize.test.ts +102 -0
- package/tests/unit/features/chat/utils/usageInfo.test.ts +56 -0
- package/tests/unit/features/inline-edit/InlineEditService.test.ts +1199 -0
- package/tests/unit/features/inline-edit/ui/InlineEditModal.openAndWait.test.ts +1482 -0
- package/tests/unit/features/inline-edit/ui/InlineEditModal.test.ts +495 -0
- package/tests/unit/features/inline-edit/ui/inlineEditMarkdownPreview.test.ts +92 -0
- package/tests/unit/features/settings/AgentSettings.test.ts +82 -0
- package/tests/unit/features/settings/keyboardNavigation.test.ts +73 -0
- package/tests/unit/features/settings/ui/CodexSkillSettings.test.ts +294 -0
- package/tests/unit/features/settings/ui/CodexSubagentSettings.test.ts +207 -0
- package/tests/unit/i18n/constants.test.ts +43 -0
- package/tests/unit/i18n/i18n.test.ts +244 -0
- package/tests/unit/i18n/locales.test.ts +134 -0
- package/tests/unit/providers/acp/AcpClientConnection.test.ts +248 -0
- package/tests/unit/providers/acp/AcpJsonRpcTransport.test.ts +186 -0
- package/tests/unit/providers/acp/AcpSessionConfig.test.ts +247 -0
- package/tests/unit/providers/acp/AcpSessionUpdateNormalizer.test.ts +145 -0
- package/tests/unit/providers/acp/AcpSubprocess.test.ts +105 -0
- package/tests/unit/providers/acp/buildAcpUsageInfo.test.ts +51 -0
- package/tests/unit/providers/claude/agents/AgentManager.test.ts +590 -0
- package/tests/unit/providers/claude/agents/AgentStorage.test.ts +434 -0
- package/tests/unit/providers/claude/agents/index.test.ts +10 -0
- package/tests/unit/providers/claude/commands/ClaudeCommandCatalog.test.ts +396 -0
- package/tests/unit/providers/claude/commands/probeRuntimeCommands.test.ts +92 -0
- package/tests/unit/providers/claude/env/ClaudeSettingsReconciler.test.ts +57 -0
- package/tests/unit/providers/claude/env/claudeModelEnv.test.ts +228 -0
- package/tests/unit/providers/claude/hooks/SubagentHooks.test.ts +83 -0
- package/tests/unit/providers/claude/plugins/PluginManager.test.ts +832 -0
- package/tests/unit/providers/claude/plugins/index.test.ts +7 -0
- package/tests/unit/providers/claude/prompt/ClaudeTurnEncoder.test.ts +145 -0
- package/tests/unit/providers/claude/prompt/instructionRefine.test.ts +185 -0
- package/tests/unit/providers/claude/prompt/systemPrompt.test.ts +163 -0
- package/tests/unit/providers/claude/prompt/titleGeneration.test.ts +20 -0
- package/tests/unit/providers/claude/runtime/ClaudeTaskResultInterpreter.test.ts +28 -0
- package/tests/unit/providers/claude/runtime/ClaudianService.test.ts +3796 -0
- package/tests/unit/providers/claude/runtime/MessageChannel.test.ts +421 -0
- package/tests/unit/providers/claude/runtime/QueryOptionsBuilder.test.ts +775 -0
- package/tests/unit/providers/claude/runtime/SessionManager.test.ts +182 -0
- package/tests/unit/providers/claude/runtime/claudeColdStartQuery.test.ts +331 -0
- package/tests/unit/providers/claude/runtime/customSpawn.test.ts +374 -0
- package/tests/unit/providers/claude/runtime/index.test.ts +13 -0
- package/tests/unit/providers/claude/runtime/types.test.ts +190 -0
- package/tests/unit/providers/claude/sdk/typeGuards.test.ts +50 -0
- package/tests/unit/providers/claude/security/ClaudePermissionUpdates.test.ts +198 -0
- package/tests/unit/providers/claude/storage/AgentVaultStorage.test.ts +413 -0
- package/tests/unit/providers/claude/storage/CCSettingsStorage.test.ts +408 -0
- package/tests/unit/providers/claude/storage/ClaudianSettingsStorage.test.ts +653 -0
- package/tests/unit/providers/claude/storage/McpStorage.test.ts +619 -0
- package/tests/unit/providers/claude/storage/SessionStorage.test.ts +680 -0
- package/tests/unit/providers/claude/storage/SkillStorage.test.ts +275 -0
- package/tests/unit/providers/claude/storage/SlashCommandStorage.test.ts +612 -0
- package/tests/unit/providers/claude/storage/storage.test.ts +360 -0
- package/tests/unit/providers/claude/storage/storageService.convenience.test.ts +447 -0
- package/tests/unit/providers/claude/stream/transformSDKMessage.test.ts +1729 -0
- package/tests/unit/providers/claude/types/types.test.ts +726 -0
- package/tests/unit/providers/claude/ui/ClaudeChatUIConfig.test.ts +173 -0
- package/tests/unit/providers/claude/ui/ClaudeSettingsTab.test.ts +466 -0
- package/tests/unit/providers/codex/agents/CodexAgentMentionProvider.test.ts +89 -0
- package/tests/unit/providers/codex/auxiliary/CodexInstructionRefineService.test.ts +81 -0
- package/tests/unit/providers/codex/capabilities.test.ts +39 -0
- package/tests/unit/providers/codex/commands/CodexSkillCatalog.test.ts +413 -0
- package/tests/unit/providers/codex/env/CodexSettingsReconciler.test.ts +106 -0
- package/tests/unit/providers/codex/fixtures/codex-session-abort.jsonl +9 -0
- package/tests/unit/providers/codex/fixtures/codex-session-agent-lifecycle.jsonl +12 -0
- package/tests/unit/providers/codex/fixtures/codex-session-persisted-tools.jsonl +15 -0
- package/tests/unit/providers/codex/fixtures/codex-session-simple.jsonl +10 -0
- package/tests/unit/providers/codex/fixtures/codex-session-tools.jsonl +12 -0
- package/tests/unit/providers/codex/fixtures/codex-session-websearch-persisted.jsonl +3 -0
- package/tests/unit/providers/codex/fixtures/codex-session-websearch.jsonl +7 -0
- package/tests/unit/providers/codex/history/CodexConversationHistoryService.test.ts +690 -0
- package/tests/unit/providers/codex/history/CodexHistoryStore.test.ts +2202 -0
- package/tests/unit/providers/codex/normalization/codexSubagentNormalization.test.ts +81 -0
- package/tests/unit/providers/codex/normalization/codexToolNormalization.test.ts +322 -0
- package/tests/unit/providers/codex/prompt/encodeCodexTurn.test.ts +168 -0
- package/tests/unit/providers/codex/runtime/CodexAppServerProcess.test.ts +255 -0
- package/tests/unit/providers/codex/runtime/CodexAuxQueryRunner.test.ts +130 -0
- package/tests/unit/providers/codex/runtime/CodexBinaryLocator.test.ts +90 -0
- package/tests/unit/providers/codex/runtime/CodexChatRuntime.test.ts +2445 -0
- package/tests/unit/providers/codex/runtime/CodexCliResolver.test.ts +103 -0
- package/tests/unit/providers/codex/runtime/CodexExecutionTargetResolver.test.ts +105 -0
- package/tests/unit/providers/codex/runtime/CodexLaunchSpecBuilder.test.ts +150 -0
- package/tests/unit/providers/codex/runtime/CodexNotificationRouter.test.ts +1248 -0
- package/tests/unit/providers/codex/runtime/CodexPathMapper.test.ts +51 -0
- package/tests/unit/providers/codex/runtime/CodexRpcTransport.test.ts +220 -0
- package/tests/unit/providers/codex/runtime/CodexRuntimeContext.test.ts +107 -0
- package/tests/unit/providers/codex/runtime/CodexServerRequestRouter.test.ts +537 -0
- package/tests/unit/providers/codex/runtime/CodexSessionFileTail.test.ts +1305 -0
- package/tests/unit/providers/codex/runtime/CodexSessionManager.test.ts +82 -0
- package/tests/unit/providers/codex/runtime/codexAppServerTypes.test.ts +336 -0
- package/tests/unit/providers/codex/settings.test.ts +189 -0
- package/tests/unit/providers/codex/skills/CodexSkillListingService.test.ts +178 -0
- package/tests/unit/providers/codex/storage/CodexSkillStorage.test.ts +342 -0
- package/tests/unit/providers/codex/storage/CodexSubagentStorage.test.ts +376 -0
- package/tests/unit/providers/codex/ui/CodexChatUIConfig.test.ts +211 -0
- package/tests/unit/providers/codex/ui/CodexSettingsTab.test.ts +578 -0
- package/tests/unit/providers/defaultProviderConfigs.test.ts +18 -0
- package/tests/unit/providers/opencode/OpencodeAuxQueryRunner.test.ts +355 -0
- package/tests/unit/providers/opencode/OpencodeChatRuntime.test.ts +808 -0
- package/tests/unit/providers/opencode/OpencodeCliResolver.test.ts +93 -0
- package/tests/unit/providers/opencode/OpencodeCommandCatalog.test.ts +75 -0
- package/tests/unit/providers/opencode/OpencodeConversationHistoryService.test.ts +103 -0
- package/tests/unit/providers/opencode/OpencodeHistoryStore.test.ts +418 -0
- package/tests/unit/providers/opencode/OpencodeLaunchArtifacts.test.ts +268 -0
- package/tests/unit/providers/opencode/OpencodePaths.test.ts +35 -0
- package/tests/unit/providers/opencode/OpencodeRuntimeCommandLoader.test.ts +129 -0
- package/tests/unit/providers/opencode/OpencodeSettingsReconciler.test.ts +96 -0
- package/tests/unit/providers/opencode/OpencodeSettingsTab.test.ts +649 -0
- package/tests/unit/providers/opencode/OpencodeSqliteReader.test.ts +185 -0
- package/tests/unit/providers/opencode/agents/OpencodeAgentMentionProvider.test.ts +56 -0
- package/tests/unit/providers/opencode/buildOpencodePrompt.test.ts +87 -0
- package/tests/unit/providers/opencode/capabilities.test.ts +39 -0
- package/tests/unit/providers/opencode/models.test.ts +273 -0
- package/tests/unit/providers/opencode/modes.test.ts +151 -0
- package/tests/unit/providers/opencode/opencodeToolNormalization.test.ts +197 -0
- package/tests/unit/providers/opencode/settings.test.ts +469 -0
- package/tests/unit/providers/opencode/storage/OpencodeAgentStorage.test.ts +377 -0
- package/tests/unit/providers/opencode/ui/OpencodeAgentSettings.test.ts +91 -0
- package/tests/unit/providers/pi/PiRuntimeCommandLoader.test.ts +149 -0
- package/tests/unit/providers/pi/capabilities.test.ts +20 -0
- package/tests/unit/providers/pi/commands/PiCommandCatalog.test.ts +69 -0
- package/tests/unit/providers/pi/env/PiSettingsReconciler.test.ts +61 -0
- package/tests/unit/providers/pi/history/PiConversationHistoryService.test.ts +147 -0
- package/tests/unit/providers/pi/history/PiHistoryStore.test.ts +523 -0
- package/tests/unit/providers/pi/models.test.ts +96 -0
- package/tests/unit/providers/pi/registration.test.ts +54 -0
- package/tests/unit/providers/pi/runtime/PiAuxQueryRunner.test.ts +172 -0
- package/tests/unit/providers/pi/runtime/PiChatRuntime.test.ts +830 -0
- package/tests/unit/providers/pi/runtime/PiCliResolver.test.ts +105 -0
- package/tests/unit/providers/pi/runtime/PiEventNormalization.test.ts +147 -0
- package/tests/unit/providers/pi/runtime/PiExtensionUiBridge.test.ts +98 -0
- package/tests/unit/providers/pi/runtime/PiJsonl.test.ts +42 -0
- package/tests/unit/providers/pi/runtime/PiLaunchSpec.test.ts +92 -0
- package/tests/unit/providers/pi/runtime/PiModelDiscoveryService.test.ts +135 -0
- package/tests/unit/providers/pi/runtime/PiRpcPayloads.test.ts +15 -0
- package/tests/unit/providers/pi/runtime/PiRpcTransport.test.ts +116 -0
- package/tests/unit/providers/pi/runtime/PiSubprocess.test.ts +151 -0
- package/tests/unit/providers/pi/runtime/buildPiPrompt.test.ts +84 -0
- package/tests/unit/providers/pi/runtime/buildPiUsageInfo.test.ts +69 -0
- package/tests/unit/providers/pi/settings.test.ts +253 -0
- package/tests/unit/providers/pi/ui/PiChatUIConfig.test.ts +161 -0
- package/tests/unit/providers/pi/ui/PiSettingsTab.test.ts +492 -0
- package/tests/unit/scripts/rendererSafeUnref.test.ts +101 -0
- package/tests/unit/shared/components/ResumeSessionDropdown.test.ts +356 -0
- package/tests/unit/shared/components/SelectableDropdown.test.ts +406 -0
- package/tests/unit/shared/components/SlashCommandDropdown.provider.test.ts +354 -0
- package/tests/unit/shared/components/SlashCommandDropdown.test.ts +508 -0
- package/tests/unit/shared/icons.test.ts +56 -0
- package/tests/unit/shared/index.test.ts +46 -0
- package/tests/unit/shared/mention/MentionDropdownController.test.ts +823 -0
- package/tests/unit/shared/mention/VaultFileCache.test.ts +195 -0
- package/tests/unit/shared/mention/VaultFolderCache.test.ts +143 -0
- package/tests/unit/shared/mention/VaultMentionDataProvider.test.ts +87 -0
- package/tests/unit/shared/modals/ConfirmModal.test.ts +111 -0
- package/tests/unit/shared/modals/ForkTargetModal.test.ts +101 -0
- package/tests/unit/shared/modals/InstructionConfirmModal.test.ts +305 -0
- package/tests/unit/utils/agent.test.ts +395 -0
- package/tests/unit/utils/animationFrame.test.ts +59 -0
- package/tests/unit/utils/browser.test.ts +73 -0
- package/tests/unit/utils/canvas.test.ts +54 -0
- package/tests/unit/utils/claudeCli.test.ts +294 -0
- package/tests/unit/utils/cliBinaryLocator.test.ts +33 -0
- package/tests/unit/utils/context.test.ts +288 -0
- package/tests/unit/utils/contextMentionResolver.test.ts +270 -0
- package/tests/unit/utils/date.test.ts +80 -0
- package/tests/unit/utils/diff.test.ts +291 -0
- package/tests/unit/utils/editor.test.ts +249 -0
- package/tests/unit/utils/electronCompat.test.ts +87 -0
- package/tests/unit/utils/env.test.ts +1240 -0
- package/tests/unit/utils/externalContext.test.ts +336 -0
- package/tests/unit/utils/externalContextScanner.test.ts +186 -0
- package/tests/unit/utils/fileLink.dom.test.ts +273 -0
- package/tests/unit/utils/fileLink.handler.test.ts +64 -0
- package/tests/unit/utils/fileLink.test.ts +233 -0
- package/tests/unit/utils/frontmatter.test.ts +434 -0
- package/tests/unit/utils/imageEmbed.test.ts +407 -0
- package/tests/unit/utils/inlineEdit.test.ts +63 -0
- package/tests/unit/utils/interrupt.test.ts +73 -0
- package/tests/unit/utils/markdown.test.ts +35 -0
- package/tests/unit/utils/markdownMath.test.ts +54 -0
- package/tests/unit/utils/mcp.test.ts +256 -0
- package/tests/unit/utils/obsidianCompat.test.ts +18 -0
- package/tests/unit/utils/path.test.ts +677 -0
- package/tests/unit/utils/sdkSession.test.ts +2359 -0
- package/tests/unit/utils/session.test.ts +971 -0
- package/tests/unit/utils/slashCommand.test.ts +778 -0
- package/tests/unit/utils/utils.test.ts +809 -0
- package/tsconfig.jest.json +8 -0
- package/tsconfig.json +26 -0
- package/versions.json +4 -0
|
@@ -0,0 +1,1035 @@
|
|
|
1
|
+
import { createMockEl } from '@test/helpers/mockElement';
|
|
2
|
+
|
|
3
|
+
import { type InlineAskQuestionConfig, InlineAskUserQuestion } from '@/features/chat/rendering/InlineAskUserQuestion';
|
|
4
|
+
|
|
5
|
+
beforeAll(() => {
|
|
6
|
+
globalThis.requestAnimationFrame = (cb: FrameRequestCallback) => {
|
|
7
|
+
cb(0);
|
|
8
|
+
return 0;
|
|
9
|
+
};
|
|
10
|
+
// Mock document.activeElement for focus checks in updateFocusIndicator
|
|
11
|
+
(globalThis as any).document = { activeElement: null };
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
function makeInput(
|
|
15
|
+
questions: Array<{
|
|
16
|
+
question: string;
|
|
17
|
+
options: unknown[];
|
|
18
|
+
multiSelect?: boolean;
|
|
19
|
+
header?: string;
|
|
20
|
+
isOther?: boolean;
|
|
21
|
+
}>,
|
|
22
|
+
): Record<string, unknown> {
|
|
23
|
+
return { questions };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function renderWidget(
|
|
27
|
+
input: Record<string, unknown>,
|
|
28
|
+
signal?: AbortSignal,
|
|
29
|
+
): { container: any; resolve: jest.Mock; widget: InlineAskUserQuestion } {
|
|
30
|
+
const container = createMockEl();
|
|
31
|
+
const resolve = jest.fn();
|
|
32
|
+
const widget = new InlineAskUserQuestion(container, input, resolve, signal);
|
|
33
|
+
widget.render();
|
|
34
|
+
return { container, resolve, widget };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function fireKeyDown(
|
|
38
|
+
root: any,
|
|
39
|
+
key: string,
|
|
40
|
+
opts: { shiftKey?: boolean } = {},
|
|
41
|
+
): void {
|
|
42
|
+
const event = {
|
|
43
|
+
type: 'keydown',
|
|
44
|
+
key,
|
|
45
|
+
shiftKey: opts.shiftKey ?? false,
|
|
46
|
+
preventDefault: jest.fn(),
|
|
47
|
+
stopPropagation: jest.fn(),
|
|
48
|
+
};
|
|
49
|
+
root.dispatchEvent(event);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function findRoot(container: any): any {
|
|
53
|
+
return container.querySelector('.claudian-ask-question-inline');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function findItems(container: any): any[] {
|
|
57
|
+
return container.querySelectorAll('claudian-ask-item');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
describe('InlineAskUserQuestion', () => {
|
|
61
|
+
describe('parseQuestions', () => {
|
|
62
|
+
it('resolves null when input has no questions', () => {
|
|
63
|
+
const { resolve } = renderWidget({});
|
|
64
|
+
expect(resolve).toHaveBeenCalledWith(null);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('resolves null when questions is not an array', () => {
|
|
68
|
+
const { resolve } = renderWidget({ questions: 'bad' });
|
|
69
|
+
expect(resolve).toHaveBeenCalledWith(null);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('resolves null when questions array is empty', () => {
|
|
73
|
+
const { resolve } = renderWidget({ questions: [] });
|
|
74
|
+
expect(resolve).toHaveBeenCalledWith(null);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('filters out questions with no options', () => {
|
|
78
|
+
const input = makeInput([
|
|
79
|
+
{ question: 'Q1', options: [] },
|
|
80
|
+
{ question: 'Q2', options: ['A'] },
|
|
81
|
+
]);
|
|
82
|
+
const { resolve } = renderWidget(input);
|
|
83
|
+
// Should render — Q2 is valid
|
|
84
|
+
expect(resolve).not.toHaveBeenCalled();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('resolves null when all questions have empty options', () => {
|
|
88
|
+
const input = makeInput([
|
|
89
|
+
{ question: 'Q1', options: [] },
|
|
90
|
+
{ question: 'Q2', options: [] },
|
|
91
|
+
]);
|
|
92
|
+
const { resolve } = renderWidget(input);
|
|
93
|
+
expect(resolve).toHaveBeenCalledWith(null);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('keeps questions that only allow free-form input', () => {
|
|
97
|
+
const input = {
|
|
98
|
+
questions: [
|
|
99
|
+
{
|
|
100
|
+
id: 'secret_q',
|
|
101
|
+
question: 'Enter token',
|
|
102
|
+
header: 'Token',
|
|
103
|
+
options: null,
|
|
104
|
+
isOther: true,
|
|
105
|
+
isSecret: true,
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
};
|
|
109
|
+
const { container, resolve } = renderWidget(input);
|
|
110
|
+
|
|
111
|
+
expect(resolve).not.toHaveBeenCalled();
|
|
112
|
+
expect(container.querySelector('claudian-ask-custom-item')).not.toBeNull();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('filters out entries missing required fields', () => {
|
|
116
|
+
const input = {
|
|
117
|
+
questions: [
|
|
118
|
+
{ question: 'Valid', options: ['A'] },
|
|
119
|
+
{ options: ['B'] }, // missing question
|
|
120
|
+
'not an object',
|
|
121
|
+
null,
|
|
122
|
+
],
|
|
123
|
+
};
|
|
124
|
+
const { resolve } = renderWidget(input);
|
|
125
|
+
// Only "Valid" survives — widget should render
|
|
126
|
+
expect(resolve).not.toHaveBeenCalled();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('deduplicates options with the same label', () => {
|
|
130
|
+
const input = makeInput([
|
|
131
|
+
{ question: 'Pick', options: ['A', 'A', 'B'] },
|
|
132
|
+
]);
|
|
133
|
+
const { container } = renderWidget(input);
|
|
134
|
+
// Find option items (excluding custom input row)
|
|
135
|
+
const items = container.querySelectorAll('claudian-ask-item');
|
|
136
|
+
// 2 unique options + 1 custom input row = 3
|
|
137
|
+
const optionLabels = items
|
|
138
|
+
.filter((item: any) => !item.hasClass('claudian-ask-custom-item'))
|
|
139
|
+
.map((item: any) => {
|
|
140
|
+
const labelEl = item.querySelector('claudian-ask-item-label');
|
|
141
|
+
return labelEl?.textContent;
|
|
142
|
+
});
|
|
143
|
+
expect(optionLabels).toEqual(['A', 'B']);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('uses header when provided, falls back to Q index', () => {
|
|
147
|
+
const input = makeInput([
|
|
148
|
+
{ question: 'First', options: ['A'], header: 'MyHeader' },
|
|
149
|
+
{ question: 'Second', options: ['B'] },
|
|
150
|
+
]);
|
|
151
|
+
const { container } = renderWidget(input);
|
|
152
|
+
const tabLabels = container.querySelectorAll('claudian-ask-tab-label');
|
|
153
|
+
// Tab labels: MyHeader, Q2, Submit
|
|
154
|
+
expect(tabLabels[0]?.textContent).toBe('MyHeader');
|
|
155
|
+
expect(tabLabels[1]?.textContent).toBe('Q2');
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('treats non-boolean multiSelect values as false', () => {
|
|
159
|
+
const input = {
|
|
160
|
+
questions: [
|
|
161
|
+
{ question: 'Pick one', options: ['A', 'B'], multiSelect: 'false' },
|
|
162
|
+
],
|
|
163
|
+
};
|
|
164
|
+
const { container } = renderWidget(input);
|
|
165
|
+
|
|
166
|
+
const items = findItems(container).filter(
|
|
167
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
168
|
+
);
|
|
169
|
+
items[0]?.click();
|
|
170
|
+
|
|
171
|
+
expect(container.querySelector('claudian-ask-review-title')?.textContent).toBe('Review your answers');
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('truncates header to 12 characters', () => {
|
|
175
|
+
const input = makeInput([
|
|
176
|
+
{ question: 'Q', options: ['A'], header: 'VeryLongHeaderText' },
|
|
177
|
+
]);
|
|
178
|
+
const { container } = renderWidget(input);
|
|
179
|
+
const tabLabels = container.querySelectorAll('claudian-ask-tab-label');
|
|
180
|
+
expect(tabLabels[0]?.textContent).toBe('VeryLongHead');
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
describe('coerceOption / extractLabel', () => {
|
|
185
|
+
it('handles string options', () => {
|
|
186
|
+
const input = makeInput([{ question: 'Q', options: ['Yes', 'No'] }]);
|
|
187
|
+
const { container } = renderWidget(input);
|
|
188
|
+
const labels = container
|
|
189
|
+
.querySelectorAll('claudian-ask-item-label')
|
|
190
|
+
.map((el: any) => el.textContent);
|
|
191
|
+
expect(labels).toContain('Yes');
|
|
192
|
+
expect(labels).toContain('No');
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('extracts label from object with label property', () => {
|
|
196
|
+
const input = makeInput([
|
|
197
|
+
{
|
|
198
|
+
question: 'Q',
|
|
199
|
+
options: [
|
|
200
|
+
{ label: 'Option A', description: 'desc A' },
|
|
201
|
+
{ value: 'Option B' },
|
|
202
|
+
{ text: 'Option C' },
|
|
203
|
+
{ name: 'Option D' },
|
|
204
|
+
],
|
|
205
|
+
},
|
|
206
|
+
]);
|
|
207
|
+
const { container } = renderWidget(input);
|
|
208
|
+
const labels = container
|
|
209
|
+
.querySelectorAll('claudian-ask-item-label')
|
|
210
|
+
.map((el: any) => el.textContent);
|
|
211
|
+
expect(labels).toContain('Option A');
|
|
212
|
+
expect(labels).toContain('Option B');
|
|
213
|
+
expect(labels).toContain('Option C');
|
|
214
|
+
expect(labels).toContain('Option D');
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('shows description when provided', () => {
|
|
218
|
+
const input = makeInput([
|
|
219
|
+
{ question: 'Q', options: [{ label: 'A', description: 'Some desc' }] },
|
|
220
|
+
]);
|
|
221
|
+
const { container } = renderWidget(input);
|
|
222
|
+
const descEl = container.querySelector('claudian-ask-item-desc');
|
|
223
|
+
expect(descEl?.textContent).toBe('Some desc');
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it('coerces non-string/non-object options to string', () => {
|
|
227
|
+
const input = makeInput([{ question: 'Q', options: [42] }]);
|
|
228
|
+
const { container } = renderWidget(input);
|
|
229
|
+
const labels = container
|
|
230
|
+
.querySelectorAll('claudian-ask-item-label')
|
|
231
|
+
.map((el: any) => el.textContent);
|
|
232
|
+
expect(labels).toContain('42');
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it('uses option value for resolution when provided', () => {
|
|
236
|
+
const input = makeInput([
|
|
237
|
+
{
|
|
238
|
+
question: 'Q',
|
|
239
|
+
options: [{ label: 'Approve and remember', value: 'allow_with_policy' }],
|
|
240
|
+
},
|
|
241
|
+
]);
|
|
242
|
+
const { container } = renderWidget(input);
|
|
243
|
+
const labels = container
|
|
244
|
+
.querySelectorAll('claudian-ask-item-label')
|
|
245
|
+
.map((el: any) => el.textContent);
|
|
246
|
+
expect(labels).toContain('Approve and remember');
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
describe('selectOption', () => {
|
|
251
|
+
it('selects single-select option via click', () => {
|
|
252
|
+
jest.useFakeTimers();
|
|
253
|
+
const input = makeInput([
|
|
254
|
+
{ question: 'Pick one', options: ['A', 'B'] },
|
|
255
|
+
]);
|
|
256
|
+
const { container, resolve } = renderWidget(input);
|
|
257
|
+
|
|
258
|
+
// Click first option
|
|
259
|
+
const items = findItems(container).filter(
|
|
260
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
261
|
+
);
|
|
262
|
+
items[0]?.click();
|
|
263
|
+
jest.advanceTimersByTime(200);
|
|
264
|
+
|
|
265
|
+
// Auto-advanced to submit tab — now submit
|
|
266
|
+
const submitItems = container.querySelectorAll('claudian-ask-item');
|
|
267
|
+
const submitRow = submitItems.find(
|
|
268
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
269
|
+
);
|
|
270
|
+
submitRow?.click();
|
|
271
|
+
|
|
272
|
+
expect(resolve).toHaveBeenCalledWith({ 'Pick one': 'A' });
|
|
273
|
+
jest.useRealTimers();
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it('toggles multi-select options', () => {
|
|
277
|
+
const input = makeInput([
|
|
278
|
+
{ question: 'Pick many', options: ['X', 'Y', 'Z'], multiSelect: true },
|
|
279
|
+
]);
|
|
280
|
+
const { container } = renderWidget(input);
|
|
281
|
+
|
|
282
|
+
const items = findItems(container).filter(
|
|
283
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
284
|
+
);
|
|
285
|
+
// Select X and Y
|
|
286
|
+
items[0]?.click();
|
|
287
|
+
items[1]?.click();
|
|
288
|
+
|
|
289
|
+
// Check marks for multi-select
|
|
290
|
+
const checks = container.querySelectorAll('claudian-ask-check');
|
|
291
|
+
const checkedCount = checks.filter((c: any) => c.hasClass('is-checked')).length;
|
|
292
|
+
expect(checkedCount).toBe(2);
|
|
293
|
+
|
|
294
|
+
// Deselect X
|
|
295
|
+
items[0]?.click();
|
|
296
|
+
const checksAfter = container.querySelectorAll('claudian-ask-check');
|
|
297
|
+
const checkedAfter = checksAfter.filter((c: any) => c.hasClass('is-checked')).length;
|
|
298
|
+
expect(checkedAfter).toBe(1);
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
describe('handleSubmit', () => {
|
|
303
|
+
it('does not submit when not all questions are answered', () => {
|
|
304
|
+
const input = makeInput([
|
|
305
|
+
{ question: 'Q1', options: ['A'] },
|
|
306
|
+
{ question: 'Q2', options: ['B'] },
|
|
307
|
+
]);
|
|
308
|
+
const { container, resolve } = renderWidget(input);
|
|
309
|
+
|
|
310
|
+
// Navigate to submit tab without answering
|
|
311
|
+
const root = findRoot(container);
|
|
312
|
+
fireKeyDown(root, 'Tab');
|
|
313
|
+
|
|
314
|
+
// Try to submit
|
|
315
|
+
fireKeyDown(root, 'Enter');
|
|
316
|
+
// Should navigate to submit tab first, not resolve
|
|
317
|
+
// Eventually press Enter on submit tab
|
|
318
|
+
fireKeyDown(root, 'Tab');
|
|
319
|
+
fireKeyDown(root, 'Enter');
|
|
320
|
+
// Still not submitted because not all answered
|
|
321
|
+
expect(resolve).not.toHaveBeenCalled();
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it('submits answers with correct question-answer mapping', () => {
|
|
325
|
+
jest.useFakeTimers();
|
|
326
|
+
const input = makeInput([
|
|
327
|
+
{ question: 'Color?', options: ['Red', 'Blue'] },
|
|
328
|
+
{ question: 'Size?', options: ['S', 'M', 'L'] },
|
|
329
|
+
]);
|
|
330
|
+
const { container, resolve } = renderWidget(input);
|
|
331
|
+
|
|
332
|
+
// Select "Red" for Q1
|
|
333
|
+
const items = findItems(container).filter(
|
|
334
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
335
|
+
);
|
|
336
|
+
items[0]?.click();
|
|
337
|
+
jest.advanceTimersByTime(200);
|
|
338
|
+
|
|
339
|
+
// Now on Q2 — select "M" (index 1)
|
|
340
|
+
const q2Items = findItems(container).filter(
|
|
341
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
342
|
+
);
|
|
343
|
+
q2Items[1]?.click();
|
|
344
|
+
jest.advanceTimersByTime(200);
|
|
345
|
+
|
|
346
|
+
// Now on submit tab — click submit
|
|
347
|
+
const submitItems = container.querySelectorAll('claudian-ask-item');
|
|
348
|
+
const submitRow = submitItems.find(
|
|
349
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
350
|
+
);
|
|
351
|
+
submitRow?.click();
|
|
352
|
+
|
|
353
|
+
expect(resolve).toHaveBeenCalledWith({
|
|
354
|
+
'Color?': 'Red',
|
|
355
|
+
'Size?': 'M',
|
|
356
|
+
});
|
|
357
|
+
jest.useRealTimers();
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
it('submits multi-select answers as arrays instead of joining them into one string', () => {
|
|
361
|
+
const input = makeInput([
|
|
362
|
+
{ question: 'Pick many', options: ['X', 'Y', 'Z'], multiSelect: true },
|
|
363
|
+
]);
|
|
364
|
+
const { container, resolve } = renderWidget(input);
|
|
365
|
+
|
|
366
|
+
const items = findItems(container).filter(
|
|
367
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
368
|
+
);
|
|
369
|
+
items[0]?.click();
|
|
370
|
+
items[1]?.click();
|
|
371
|
+
|
|
372
|
+
const root = findRoot(container);
|
|
373
|
+
fireKeyDown(root, 'Tab');
|
|
374
|
+
fireKeyDown(root, 'Enter');
|
|
375
|
+
|
|
376
|
+
expect(resolve).toHaveBeenCalledWith({
|
|
377
|
+
'Pick many': ['X', 'Y'],
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
describe('question metadata', () => {
|
|
383
|
+
it('shows custom input only when the question allows "other"', () => {
|
|
384
|
+
const disallowOtherInput = {
|
|
385
|
+
questions: [{ question: 'Pick one', options: ['A', 'B'], isOther: false }],
|
|
386
|
+
};
|
|
387
|
+
const { container: noOther } = renderWidget(disallowOtherInput);
|
|
388
|
+
expect(noOther.querySelectorAll('claudian-ask-custom-item')).toHaveLength(0);
|
|
389
|
+
|
|
390
|
+
const allowOtherInput = {
|
|
391
|
+
questions: [{ question: 'Pick one', options: ['A', 'B'], isOther: true }],
|
|
392
|
+
};
|
|
393
|
+
const { container: withOther } = renderWidget(allowOtherInput);
|
|
394
|
+
expect(withOther.querySelectorAll('claudian-ask-custom-item')).toHaveLength(1);
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
it('renders secret free-form questions with password input', () => {
|
|
398
|
+
const input = {
|
|
399
|
+
questions: [
|
|
400
|
+
{
|
|
401
|
+
question: 'Enter API token',
|
|
402
|
+
options: null,
|
|
403
|
+
isOther: true,
|
|
404
|
+
isSecret: true,
|
|
405
|
+
},
|
|
406
|
+
],
|
|
407
|
+
};
|
|
408
|
+
const { container } = renderWidget(input);
|
|
409
|
+
|
|
410
|
+
const customInput = container.querySelector('claudian-ask-custom-text');
|
|
411
|
+
expect(customInput?.getAttribute('type')).toBe('password');
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
describe('question id keying', () => {
|
|
416
|
+
it('keys submit results by question id when id is provided', () => {
|
|
417
|
+
jest.useFakeTimers();
|
|
418
|
+
const input = {
|
|
419
|
+
questions: [
|
|
420
|
+
{ id: 'color_q', question: 'Favorite color?', options: ['Red', 'Blue'], header: 'Color' },
|
|
421
|
+
{ id: 'size_q', question: 'Preferred size?', options: ['S', 'M'], header: 'Size' },
|
|
422
|
+
],
|
|
423
|
+
};
|
|
424
|
+
const { container, resolve } = renderWidget(input);
|
|
425
|
+
|
|
426
|
+
// Select "Red" for Q1
|
|
427
|
+
const items = findItems(container).filter(
|
|
428
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
429
|
+
);
|
|
430
|
+
items[0]?.click();
|
|
431
|
+
jest.advanceTimersByTime(200);
|
|
432
|
+
|
|
433
|
+
// Select "M" for Q2
|
|
434
|
+
const q2Items = findItems(container).filter(
|
|
435
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
436
|
+
);
|
|
437
|
+
q2Items[1]?.click();
|
|
438
|
+
jest.advanceTimersByTime(200);
|
|
439
|
+
|
|
440
|
+
// Submit
|
|
441
|
+
const submitItems = container.querySelectorAll('claudian-ask-item');
|
|
442
|
+
const submitRow = submitItems.find(
|
|
443
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
444
|
+
);
|
|
445
|
+
submitRow?.click();
|
|
446
|
+
|
|
447
|
+
expect(resolve).toHaveBeenCalledWith({
|
|
448
|
+
color_q: 'Red',
|
|
449
|
+
size_q: 'M',
|
|
450
|
+
});
|
|
451
|
+
jest.useRealTimers();
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
it('falls back to question text when id is not provided', () => {
|
|
455
|
+
jest.useFakeTimers();
|
|
456
|
+
const input = makeInput([{ question: 'Pick one', options: ['A', 'B'] }]);
|
|
457
|
+
const { container, resolve } = renderWidget(input);
|
|
458
|
+
|
|
459
|
+
const items = findItems(container).filter(
|
|
460
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
461
|
+
);
|
|
462
|
+
items[0]?.click();
|
|
463
|
+
jest.advanceTimersByTime(200);
|
|
464
|
+
|
|
465
|
+
const submitItems = container.querySelectorAll('claudian-ask-item');
|
|
466
|
+
const submitRow = submitItems.find(
|
|
467
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
468
|
+
);
|
|
469
|
+
submitRow?.click();
|
|
470
|
+
|
|
471
|
+
expect(resolve).toHaveBeenCalledWith({ 'Pick one': 'A' });
|
|
472
|
+
jest.useRealTimers();
|
|
473
|
+
});
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
describe('abort lifecycle', () => {
|
|
477
|
+
it('resolves null when signal is aborted', () => {
|
|
478
|
+
const controller = new AbortController();
|
|
479
|
+
const input = makeInput([{ question: 'Q', options: ['A'] }]);
|
|
480
|
+
const { resolve } = renderWidget(input, controller.signal);
|
|
481
|
+
|
|
482
|
+
expect(resolve).not.toHaveBeenCalled();
|
|
483
|
+
controller.abort();
|
|
484
|
+
expect(resolve).toHaveBeenCalledWith(null);
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
it('does not double-resolve on abort after manual resolve', () => {
|
|
488
|
+
const controller = new AbortController();
|
|
489
|
+
const input = makeInput([{ question: 'Q', options: ['A'] }]);
|
|
490
|
+
const { container, resolve } = renderWidget(input, controller.signal);
|
|
491
|
+
|
|
492
|
+
// Cancel via Escape
|
|
493
|
+
const root = findRoot(container);
|
|
494
|
+
fireKeyDown(root, 'Escape');
|
|
495
|
+
expect(resolve).toHaveBeenCalledTimes(1);
|
|
496
|
+
|
|
497
|
+
// Abort should not trigger a second resolve
|
|
498
|
+
controller.abort();
|
|
499
|
+
expect(resolve).toHaveBeenCalledTimes(1);
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
it('cleans up abort listener on resolve', () => {
|
|
503
|
+
const controller = new AbortController();
|
|
504
|
+
const input = makeInput([{ question: 'Q', options: ['A'] }]);
|
|
505
|
+
const { container, resolve } = renderWidget(input, controller.signal);
|
|
506
|
+
|
|
507
|
+
// Cancel via Escape
|
|
508
|
+
const root = findRoot(container);
|
|
509
|
+
fireKeyDown(root, 'Escape');
|
|
510
|
+
expect(resolve).toHaveBeenCalledTimes(1);
|
|
511
|
+
expect(resolve).toHaveBeenCalledWith(null);
|
|
512
|
+
});
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
describe('destroy', () => {
|
|
516
|
+
it('resolves null on destroy', () => {
|
|
517
|
+
const input = makeInput([{ question: 'Q', options: ['A'] }]);
|
|
518
|
+
const { resolve, widget } = renderWidget(input);
|
|
519
|
+
|
|
520
|
+
widget.destroy();
|
|
521
|
+
expect(resolve).toHaveBeenCalledWith(null);
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
it('does not double-resolve if already resolved', () => {
|
|
525
|
+
const input = makeInput([{ question: 'Q', options: ['A'] }]);
|
|
526
|
+
const { container, resolve, widget } = renderWidget(input);
|
|
527
|
+
|
|
528
|
+
const root = findRoot(container);
|
|
529
|
+
fireKeyDown(root, 'Escape');
|
|
530
|
+
expect(resolve).toHaveBeenCalledTimes(1);
|
|
531
|
+
|
|
532
|
+
widget.destroy();
|
|
533
|
+
expect(resolve).toHaveBeenCalledTimes(1);
|
|
534
|
+
});
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
describe('keyboard navigation', () => {
|
|
538
|
+
it('Escape resolves null', () => {
|
|
539
|
+
const input = makeInput([{ question: 'Q', options: ['A', 'B'] }]);
|
|
540
|
+
const { container, resolve } = renderWidget(input);
|
|
541
|
+
|
|
542
|
+
const root = findRoot(container);
|
|
543
|
+
fireKeyDown(root, 'Escape');
|
|
544
|
+
expect(resolve).toHaveBeenCalledWith(null);
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
it('ArrowDown moves focus down', () => {
|
|
548
|
+
const input = makeInput([{ question: 'Q', options: ['A', 'B'] }]);
|
|
549
|
+
const { container } = renderWidget(input);
|
|
550
|
+
const root = findRoot(container);
|
|
551
|
+
|
|
552
|
+
// Initially focused on item 0
|
|
553
|
+
fireKeyDown(root, 'ArrowDown');
|
|
554
|
+
|
|
555
|
+
const items = findItems(container);
|
|
556
|
+
// Item 1 should now be focused
|
|
557
|
+
expect(items[1]?.hasClass('is-focused')).toBe(true);
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
it('ArrowDown clamps at max index', () => {
|
|
561
|
+
const input = makeInput([{ question: 'Q', options: ['A'] }]);
|
|
562
|
+
const { container } = renderWidget(input);
|
|
563
|
+
const root = findRoot(container);
|
|
564
|
+
|
|
565
|
+
// Press ArrowDown many times
|
|
566
|
+
fireKeyDown(root, 'ArrowDown');
|
|
567
|
+
fireKeyDown(root, 'ArrowDown');
|
|
568
|
+
fireKeyDown(root, 'ArrowDown');
|
|
569
|
+
|
|
570
|
+
// Should not crash, max focus is 1 (option A + custom input)
|
|
571
|
+
const items = findItems(container);
|
|
572
|
+
// Last item (custom input) should be focused
|
|
573
|
+
expect(items[items.length - 1]?.hasClass('is-focused')).toBe(true);
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
it('ArrowDown clamps at last option when custom input is hidden', () => {
|
|
577
|
+
const input = makeInput([{ question: 'Q', options: ['A', 'B'] }]);
|
|
578
|
+
const container = createMockEl();
|
|
579
|
+
const resolve = jest.fn();
|
|
580
|
+
const widget = new InlineAskUserQuestion(container, input, resolve, undefined, { showCustomInput: false });
|
|
581
|
+
widget.render();
|
|
582
|
+
const root = findRoot(container);
|
|
583
|
+
|
|
584
|
+
fireKeyDown(root, 'ArrowDown');
|
|
585
|
+
fireKeyDown(root, 'ArrowDown');
|
|
586
|
+
fireKeyDown(root, 'ArrowDown');
|
|
587
|
+
|
|
588
|
+
const items = findItems(container);
|
|
589
|
+
expect(items).toHaveLength(2);
|
|
590
|
+
expect(items[1]?.hasClass('is-focused')).toBe(true);
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
it('ArrowUp moves focus up and clamps at 0', () => {
|
|
594
|
+
const input = makeInput([{ question: 'Q', options: ['A', 'B'] }]);
|
|
595
|
+
const { container } = renderWidget(input);
|
|
596
|
+
const root = findRoot(container);
|
|
597
|
+
|
|
598
|
+
// Move down then back up past 0
|
|
599
|
+
fireKeyDown(root, 'ArrowDown');
|
|
600
|
+
fireKeyDown(root, 'ArrowUp');
|
|
601
|
+
fireKeyDown(root, 'ArrowUp');
|
|
602
|
+
|
|
603
|
+
const items = findItems(container);
|
|
604
|
+
expect(items[0]?.hasClass('is-focused')).toBe(true);
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
it('Tab navigates to next question tab', () => {
|
|
608
|
+
const input = makeInput([
|
|
609
|
+
{ question: 'Q1', options: ['A'] },
|
|
610
|
+
{ question: 'Q2', options: ['B'] },
|
|
611
|
+
]);
|
|
612
|
+
const { container } = renderWidget(input);
|
|
613
|
+
const root = findRoot(container);
|
|
614
|
+
|
|
615
|
+
fireKeyDown(root, 'Tab');
|
|
616
|
+
|
|
617
|
+
// Should now be on Q2 — check tab bar
|
|
618
|
+
const tabs = container.querySelectorAll('claudian-ask-tab');
|
|
619
|
+
expect(tabs[1]?.hasClass('is-active')).toBe(true);
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
it('Shift+Tab navigates to previous tab', () => {
|
|
623
|
+
const input = makeInput([
|
|
624
|
+
{ question: 'Q1', options: ['A'] },
|
|
625
|
+
{ question: 'Q2', options: ['B'] },
|
|
626
|
+
]);
|
|
627
|
+
const { container } = renderWidget(input);
|
|
628
|
+
const root = findRoot(container);
|
|
629
|
+
|
|
630
|
+
// Go to Q2 then back
|
|
631
|
+
fireKeyDown(root, 'Tab');
|
|
632
|
+
fireKeyDown(root, 'Tab', { shiftKey: true });
|
|
633
|
+
|
|
634
|
+
const tabs = container.querySelectorAll('claudian-ask-tab');
|
|
635
|
+
expect(tabs[0]?.hasClass('is-active')).toBe(true);
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
it('ArrowRight navigates forward on question tab', () => {
|
|
639
|
+
const input = makeInput([
|
|
640
|
+
{ question: 'Q1', options: ['A'] },
|
|
641
|
+
{ question: 'Q2', options: ['B'] },
|
|
642
|
+
]);
|
|
643
|
+
const { container } = renderWidget(input);
|
|
644
|
+
const root = findRoot(container);
|
|
645
|
+
|
|
646
|
+
fireKeyDown(root, 'ArrowRight');
|
|
647
|
+
|
|
648
|
+
const tabs = container.querySelectorAll('claudian-ask-tab');
|
|
649
|
+
expect(tabs[1]?.hasClass('is-active')).toBe(true);
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
it('Enter on submit tab calls handleSubmit', () => {
|
|
653
|
+
jest.useFakeTimers();
|
|
654
|
+
const input = makeInput([{ question: 'Q', options: ['A'] }]);
|
|
655
|
+
const { container, resolve } = renderWidget(input);
|
|
656
|
+
const root = findRoot(container);
|
|
657
|
+
|
|
658
|
+
// Select option A
|
|
659
|
+
const items = findItems(container).filter(
|
|
660
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
661
|
+
);
|
|
662
|
+
items[0]?.click();
|
|
663
|
+
jest.advanceTimersByTime(200);
|
|
664
|
+
|
|
665
|
+
// Now on submit tab, Enter should submit
|
|
666
|
+
fireKeyDown(root, 'Enter');
|
|
667
|
+
|
|
668
|
+
expect(resolve).toHaveBeenCalledWith({ Q: 'A' });
|
|
669
|
+
jest.useRealTimers();
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
it('Enter on cancel row resolves null', () => {
|
|
673
|
+
jest.useFakeTimers();
|
|
674
|
+
const input = makeInput([{ question: 'Q', options: ['A'] }]);
|
|
675
|
+
const { container, resolve } = renderWidget(input);
|
|
676
|
+
const root = findRoot(container);
|
|
677
|
+
|
|
678
|
+
// Select A and auto-advance to submit
|
|
679
|
+
const items = findItems(container).filter(
|
|
680
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
681
|
+
);
|
|
682
|
+
items[0]?.click();
|
|
683
|
+
jest.advanceTimersByTime(200);
|
|
684
|
+
|
|
685
|
+
// Move focus to cancel row
|
|
686
|
+
fireKeyDown(root, 'ArrowDown');
|
|
687
|
+
fireKeyDown(root, 'Enter');
|
|
688
|
+
|
|
689
|
+
expect(resolve).toHaveBeenCalledWith(null);
|
|
690
|
+
jest.useRealTimers();
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
it('Enter on question option selects it', () => {
|
|
694
|
+
jest.useFakeTimers();
|
|
695
|
+
const input = makeInput([{ question: 'Q', options: ['A', 'B'] }]);
|
|
696
|
+
const { container } = renderWidget(input);
|
|
697
|
+
const root = findRoot(container);
|
|
698
|
+
|
|
699
|
+
// Focus is on item 0, press Enter to select
|
|
700
|
+
fireKeyDown(root, 'Enter');
|
|
701
|
+
jest.advanceTimersByTime(200);
|
|
702
|
+
|
|
703
|
+
// After auto-advance we should be on submit tab
|
|
704
|
+
const tabs = container.querySelectorAll('claudian-ask-tab');
|
|
705
|
+
const submitTab = tabs[tabs.length - 1];
|
|
706
|
+
expect(submitTab?.hasClass('is-active')).toBe(true);
|
|
707
|
+
|
|
708
|
+
jest.useRealTimers();
|
|
709
|
+
});
|
|
710
|
+
|
|
711
|
+
it('click on custom row focuses it', () => {
|
|
712
|
+
const input = makeInput([{ question: 'Q', options: ['A', 'B'], isOther: true }]);
|
|
713
|
+
const { container } = renderWidget(input);
|
|
714
|
+
|
|
715
|
+
const items = findItems(container);
|
|
716
|
+
const customItem = items.find((i: any) => i.hasClass('claudian-ask-custom-item'));
|
|
717
|
+
customItem?.click();
|
|
718
|
+
|
|
719
|
+
expect(customItem?.hasClass('is-focused')).toBe(true);
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
it('ArrowUp from custom row blurs input focus and moves to option above', () => {
|
|
723
|
+
const input = makeInput([{ question: 'Q', options: ['A', 'B'], isOther: true }]);
|
|
724
|
+
const { container } = renderWidget(input);
|
|
725
|
+
const root = findRoot(container);
|
|
726
|
+
|
|
727
|
+
const items = findItems(container);
|
|
728
|
+
const customItem = items.find((i: any) => i.hasClass('claudian-ask-custom-item'));
|
|
729
|
+
// Simulate click on custom row (focusedItemIndex = options.length, isInputFocused = true)
|
|
730
|
+
customItem?.click();
|
|
731
|
+
|
|
732
|
+
fireKeyDown(root, 'ArrowUp');
|
|
733
|
+
|
|
734
|
+
// Focus should move to the last regular option (index = options.length - 1)
|
|
735
|
+
const updatedItems = findItems(container);
|
|
736
|
+
const lastOption = updatedItems.filter(
|
|
737
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
738
|
+
);
|
|
739
|
+
expect(lastOption[lastOption.length - 1]?.hasClass('is-focused')).toBe(true);
|
|
740
|
+
expect(customItem?.hasClass('is-focused')).toBe(false);
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
it('Enter on custom item activates input without advancing tab', () => {
|
|
744
|
+
const input = makeInput([
|
|
745
|
+
{ question: 'Q1', options: ['A'], isOther: true },
|
|
746
|
+
{ question: 'Q2', options: ['B'] },
|
|
747
|
+
]);
|
|
748
|
+
const { container } = renderWidget(input);
|
|
749
|
+
const root = findRoot(container);
|
|
750
|
+
|
|
751
|
+
// Arrow down to custom item
|
|
752
|
+
fireKeyDown(root, 'ArrowDown'); // Focus on option A (index 0)
|
|
753
|
+
fireKeyDown(root, 'ArrowDown'); // Focus on custom item (index 1)
|
|
754
|
+
|
|
755
|
+
// Press Enter — should activate input, NOT advance tab
|
|
756
|
+
fireKeyDown(root, 'Enter');
|
|
757
|
+
|
|
758
|
+
// Should still be on Q1 tab
|
|
759
|
+
const tabs = container.querySelectorAll('claudian-ask-tab');
|
|
760
|
+
expect(tabs[0]?.hasClass('is-active')).toBe(true);
|
|
761
|
+
});
|
|
762
|
+
|
|
763
|
+
it('Enter on custom item then Enter again advances to next tab', () => {
|
|
764
|
+
const input = makeInput([
|
|
765
|
+
{ question: 'Q1', options: ['A'], isOther: true },
|
|
766
|
+
{ question: 'Q2', options: ['B'] },
|
|
767
|
+
]);
|
|
768
|
+
const { container } = renderWidget(input);
|
|
769
|
+
const root = findRoot(container);
|
|
770
|
+
|
|
771
|
+
// Arrow down to custom item
|
|
772
|
+
fireKeyDown(root, 'ArrowDown');
|
|
773
|
+
fireKeyDown(root, 'ArrowDown');
|
|
774
|
+
|
|
775
|
+
// First Enter activates input
|
|
776
|
+
fireKeyDown(root, 'Enter');
|
|
777
|
+
// Second Enter advances
|
|
778
|
+
fireKeyDown(root, 'Enter');
|
|
779
|
+
|
|
780
|
+
// Should be on Q2 tab now
|
|
781
|
+
const tabs = container.querySelectorAll('claudian-ask-tab');
|
|
782
|
+
expect(tabs[1]?.hasClass('is-active')).toBe(true);
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
it('ArrowDown from custom input blurs and clamps at max', () => {
|
|
786
|
+
const input = makeInput([{ question: 'Q', options: ['A', 'B'], isOther: true }]);
|
|
787
|
+
const { container } = renderWidget(input);
|
|
788
|
+
const root = findRoot(container);
|
|
789
|
+
|
|
790
|
+
const items = findItems(container);
|
|
791
|
+
const customItem = items.find((i: any) => i.hasClass('claudian-ask-custom-item'));
|
|
792
|
+
customItem?.click();
|
|
793
|
+
|
|
794
|
+
fireKeyDown(root, 'ArrowDown');
|
|
795
|
+
|
|
796
|
+
// Custom row is last item, ArrowDown clamps — focus stays on custom row (navigation mode)
|
|
797
|
+
expect(customItem?.hasClass('is-focused')).toBe(true);
|
|
798
|
+
});
|
|
799
|
+
|
|
800
|
+
it('Escape from custom input returns to navigation without cancelling dialog', () => {
|
|
801
|
+
const input = makeInput([
|
|
802
|
+
{ question: 'Q1', options: ['A'], isOther: true },
|
|
803
|
+
{ question: 'Q2', options: ['B'] },
|
|
804
|
+
]);
|
|
805
|
+
const { container, resolve } = renderWidget(input);
|
|
806
|
+
const root = findRoot(container);
|
|
807
|
+
|
|
808
|
+
// Navigate to custom input and activate
|
|
809
|
+
fireKeyDown(root, 'ArrowDown'); // focus on custom row (index 1)
|
|
810
|
+
fireKeyDown(root, 'Enter'); // activate input
|
|
811
|
+
|
|
812
|
+
// Escape should exit input mode, not cancel
|
|
813
|
+
fireKeyDown(root, 'Escape');
|
|
814
|
+
|
|
815
|
+
// Dialog should NOT be resolved
|
|
816
|
+
expect(resolve).not.toHaveBeenCalled();
|
|
817
|
+
|
|
818
|
+
// Should still be on Q1 tab
|
|
819
|
+
const tabs = container.querySelectorAll('claudian-ask-tab');
|
|
820
|
+
expect(tabs[0]?.hasClass('is-active')).toBe(true);
|
|
821
|
+
|
|
822
|
+
// Custom row should still be focused in navigation mode
|
|
823
|
+
const items = findItems(container);
|
|
824
|
+
const customItem = items.find((i: any) => i.hasClass('claudian-ask-custom-item'));
|
|
825
|
+
expect(customItem?.hasClass('is-focused')).toBe(true);
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
it('Enter from custom input commits text and advances tab', () => {
|
|
829
|
+
const input = makeInput([
|
|
830
|
+
{ question: 'Q1', options: ['A'], isOther: true },
|
|
831
|
+
{ question: 'Q2', options: ['B'] },
|
|
832
|
+
]);
|
|
833
|
+
const { container } = renderWidget(input);
|
|
834
|
+
const root = findRoot(container);
|
|
835
|
+
|
|
836
|
+
// Navigate to custom input and activate
|
|
837
|
+
fireKeyDown(root, 'ArrowDown'); // focus on custom row (index 1)
|
|
838
|
+
fireKeyDown(root, 'Enter'); // activate input
|
|
839
|
+
|
|
840
|
+
// Simulate typing text
|
|
841
|
+
const customItem = findItems(container).find((i: any) =>
|
|
842
|
+
i.hasClass('claudian-ask-custom-item'),
|
|
843
|
+
);
|
|
844
|
+
const inputEl = customItem?.querySelector('.claudian-ask-custom-text');
|
|
845
|
+
inputEl.value = 'my custom text';
|
|
846
|
+
inputEl.dispatchEvent({ type: 'input' });
|
|
847
|
+
|
|
848
|
+
// Enter should commit and advance
|
|
849
|
+
fireKeyDown(root, 'Enter');
|
|
850
|
+
|
|
851
|
+
// Should be on Q2 tab
|
|
852
|
+
const tabs = container.querySelectorAll('claudian-ask-tab');
|
|
853
|
+
expect(tabs[1]?.hasClass('is-active')).toBe(true);
|
|
854
|
+
});
|
|
855
|
+
});
|
|
856
|
+
});
|
|
857
|
+
|
|
858
|
+
function renderImmediateWidget(
|
|
859
|
+
input: Record<string, unknown>,
|
|
860
|
+
config?: InlineAskQuestionConfig,
|
|
861
|
+
): { container: any; resolve: jest.Mock; widget: InlineAskUserQuestion } {
|
|
862
|
+
const container = createMockEl();
|
|
863
|
+
const resolve = jest.fn();
|
|
864
|
+
const widget = new InlineAskUserQuestion(
|
|
865
|
+
container,
|
|
866
|
+
input,
|
|
867
|
+
resolve,
|
|
868
|
+
undefined,
|
|
869
|
+
{ immediateSelect: true, showCustomInput: false, ...config },
|
|
870
|
+
);
|
|
871
|
+
widget.render();
|
|
872
|
+
return { container, resolve, widget };
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
describe('InlineAskUserQuestion - immediateSelect mode', () => {
|
|
876
|
+
describe('multi-question fallback', () => {
|
|
877
|
+
it('falls back to tab-bar rendering when questions.length !== 1', () => {
|
|
878
|
+
const input = makeInput([
|
|
879
|
+
{ question: 'Q1', options: ['A'] },
|
|
880
|
+
{ question: 'Q2', options: ['B'] },
|
|
881
|
+
]);
|
|
882
|
+
const { container, resolve } = renderImmediateWidget(input);
|
|
883
|
+
|
|
884
|
+
// Should render tab bar (immediateSelect disabled due to multi-question)
|
|
885
|
+
const tabBar = container.querySelector('claudian-ask-tab-bar');
|
|
886
|
+
expect(tabBar).not.toBeNull();
|
|
887
|
+
const tabs = container.querySelectorAll('claudian-ask-tab');
|
|
888
|
+
expect(tabs.length).toBeGreaterThan(0);
|
|
889
|
+
|
|
890
|
+
// Should NOT resolve immediately on click (normal multi-tab flow)
|
|
891
|
+
const items = findItems(container).filter(
|
|
892
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
893
|
+
);
|
|
894
|
+
items[0]?.click();
|
|
895
|
+
expect(resolve).not.toHaveBeenCalled();
|
|
896
|
+
});
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
describe('rendering', () => {
|
|
900
|
+
it('does not render tab bar', () => {
|
|
901
|
+
const input = makeInput([{ question: 'Pick', options: ['A', 'B'] }]);
|
|
902
|
+
const { container } = renderImmediateWidget(input);
|
|
903
|
+
const tabBar = container.querySelector('claudian-ask-tab-bar');
|
|
904
|
+
expect(tabBar).toBeNull();
|
|
905
|
+
const tabs = container.querySelectorAll('claudian-ask-tab');
|
|
906
|
+
expect(tabs).toHaveLength(0);
|
|
907
|
+
});
|
|
908
|
+
|
|
909
|
+
it('does not render custom input row', () => {
|
|
910
|
+
const input = makeInput([{ question: 'Pick', options: ['A', 'B'] }]);
|
|
911
|
+
const { container } = renderImmediateWidget(input);
|
|
912
|
+
const customItems = container.querySelectorAll('claudian-ask-custom-item');
|
|
913
|
+
expect(customItems).toHaveLength(0);
|
|
914
|
+
});
|
|
915
|
+
|
|
916
|
+
it('uses custom title when provided', () => {
|
|
917
|
+
const input = makeInput([{ question: 'Pick', options: ['A'] }]);
|
|
918
|
+
const { container } = renderImmediateWidget(input, { title: 'Permission required' });
|
|
919
|
+
const title = container.querySelector('claudian-ask-inline-title');
|
|
920
|
+
expect(title?.textContent).toBe('Permission required');
|
|
921
|
+
});
|
|
922
|
+
|
|
923
|
+
it('renders headerEl between title and content', () => {
|
|
924
|
+
const headerEl = createMockEl('div');
|
|
925
|
+
headerEl.addClass('claudian-ask-approval-info');
|
|
926
|
+
const input = makeInput([{ question: 'Pick', options: ['A'] }]);
|
|
927
|
+
const { container } = renderImmediateWidget(input, { headerEl: headerEl as any });
|
|
928
|
+
const root = findRoot(container);
|
|
929
|
+
expect(root.children.some((c: any) => c.hasClass('claudian-ask-approval-info'))).toBe(true);
|
|
930
|
+
});
|
|
931
|
+
});
|
|
932
|
+
|
|
933
|
+
describe('selection', () => {
|
|
934
|
+
it('resolves immediately on click', () => {
|
|
935
|
+
const input = makeInput([{ question: 'Pick', options: ['A', 'B'] }]);
|
|
936
|
+
const { container, resolve } = renderImmediateWidget(input);
|
|
937
|
+
|
|
938
|
+
const items = findItems(container).filter(
|
|
939
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
940
|
+
);
|
|
941
|
+
items[0]?.click();
|
|
942
|
+
|
|
943
|
+
expect(resolve).toHaveBeenCalledWith({ Pick: 'A' });
|
|
944
|
+
});
|
|
945
|
+
|
|
946
|
+
it('resolves with second option on click', () => {
|
|
947
|
+
const input = makeInput([{ question: 'Pick', options: ['A', 'B'] }]);
|
|
948
|
+
const { container, resolve } = renderImmediateWidget(input);
|
|
949
|
+
|
|
950
|
+
const items = findItems(container).filter(
|
|
951
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
952
|
+
);
|
|
953
|
+
items[1]?.click();
|
|
954
|
+
|
|
955
|
+
expect(resolve).toHaveBeenCalledWith({ Pick: 'B' });
|
|
956
|
+
});
|
|
957
|
+
|
|
958
|
+
it('keys immediate-select result by id when provided', () => {
|
|
959
|
+
const input = {
|
|
960
|
+
questions: [
|
|
961
|
+
{ id: 'approval_q', question: 'Allow execution?', options: ['Yes', 'No'], header: 'Approve' },
|
|
962
|
+
],
|
|
963
|
+
};
|
|
964
|
+
const { container, resolve } = renderImmediateWidget(input);
|
|
965
|
+
|
|
966
|
+
const items = findItems(container).filter(
|
|
967
|
+
(i: any) => !i.hasClass('claudian-ask-custom-item'),
|
|
968
|
+
);
|
|
969
|
+
items[0]?.click();
|
|
970
|
+
|
|
971
|
+
expect(resolve).toHaveBeenCalledWith({ approval_q: 'Yes' });
|
|
972
|
+
});
|
|
973
|
+
});
|
|
974
|
+
|
|
975
|
+
describe('keyboard navigation', () => {
|
|
976
|
+
it('ArrowDown/Up navigates focus', () => {
|
|
977
|
+
const input = makeInput([{ question: 'Pick', options: ['A', 'B', 'C'] }]);
|
|
978
|
+
const { container } = renderImmediateWidget(input);
|
|
979
|
+
const root = findRoot(container);
|
|
980
|
+
|
|
981
|
+
fireKeyDown(root, 'ArrowDown');
|
|
982
|
+
const items = findItems(container);
|
|
983
|
+
expect(items[1]?.hasClass('is-focused')).toBe(true);
|
|
984
|
+
|
|
985
|
+
fireKeyDown(root, 'ArrowUp');
|
|
986
|
+
const items2 = findItems(container);
|
|
987
|
+
expect(items2[0]?.hasClass('is-focused')).toBe(true);
|
|
988
|
+
});
|
|
989
|
+
|
|
990
|
+
it('Enter selects and resolves immediately', () => {
|
|
991
|
+
const input = makeInput([{ question: 'Pick', options: ['A', 'B'] }]);
|
|
992
|
+
const { container, resolve } = renderImmediateWidget(input);
|
|
993
|
+
const root = findRoot(container);
|
|
994
|
+
|
|
995
|
+
// Move to second option and press Enter
|
|
996
|
+
fireKeyDown(root, 'ArrowDown');
|
|
997
|
+
fireKeyDown(root, 'Enter');
|
|
998
|
+
|
|
999
|
+
expect(resolve).toHaveBeenCalledWith({ Pick: 'B' });
|
|
1000
|
+
});
|
|
1001
|
+
|
|
1002
|
+
it('Escape cancels', () => {
|
|
1003
|
+
const input = makeInput([{ question: 'Pick', options: ['A', 'B'] }]);
|
|
1004
|
+
const { container, resolve } = renderImmediateWidget(input);
|
|
1005
|
+
const root = findRoot(container);
|
|
1006
|
+
|
|
1007
|
+
fireKeyDown(root, 'Escape');
|
|
1008
|
+
expect(resolve).toHaveBeenCalledWith(null);
|
|
1009
|
+
});
|
|
1010
|
+
|
|
1011
|
+
it('Tab does not switch tabs (no-op in immediateSelect)', () => {
|
|
1012
|
+
const input = makeInput([{ question: 'Pick', options: ['A', 'B'] }]);
|
|
1013
|
+
const { container, resolve } = renderImmediateWidget(input);
|
|
1014
|
+
const root = findRoot(container);
|
|
1015
|
+
|
|
1016
|
+
fireKeyDown(root, 'Tab');
|
|
1017
|
+
expect(resolve).not.toHaveBeenCalled();
|
|
1018
|
+
const items = findItems(container);
|
|
1019
|
+
expect(items.length).toBeGreaterThan(0);
|
|
1020
|
+
});
|
|
1021
|
+
|
|
1022
|
+
it('ArrowDown clamps at last option', () => {
|
|
1023
|
+
const input = makeInput([{ question: 'Pick', options: ['A', 'B'] }]);
|
|
1024
|
+
const { container } = renderImmediateWidget(input);
|
|
1025
|
+
const root = findRoot(container);
|
|
1026
|
+
|
|
1027
|
+
fireKeyDown(root, 'ArrowDown');
|
|
1028
|
+
fireKeyDown(root, 'ArrowDown');
|
|
1029
|
+
fireKeyDown(root, 'ArrowDown');
|
|
1030
|
+
|
|
1031
|
+
const items = findItems(container);
|
|
1032
|
+
expect(items[1]?.hasClass('is-focused')).toBe(true);
|
|
1033
|
+
});
|
|
1034
|
+
});
|
|
1035
|
+
});
|