diff --git a/eslint.config.mjs b/eslint.config.mjs index 711bbaa6..6088f29c 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -105,12 +105,12 @@ const generatedAppServerImportLegacyFiles = [ "src/features/chat/display/hooks.ts", "src/features/chat/display/permission-details.ts", "src/features/chat/display/review.ts", - "src/features/chat/display/thread-items.ts", - "src/features/chat/inbound/controller.ts", - "src/features/chat/inbound/notification-plan.ts", - "src/features/chat/inbound/routing.ts", - "src/features/chat/requests/approval.ts", - "src/features/chat/requests/user-input.ts", + "src/features/chat/protocol/display-items.ts", + "src/features/chat/protocol/inbound/controller.ts", + "src/features/chat/protocol/inbound/notification-plan.ts", + "src/features/chat/protocol/inbound/routing.ts", + "src/features/chat/protocol/requests/approval.ts", + "src/features/chat/protocol/requests/user-input.ts", "src/features/chat/threads/thread-goal-actions.ts", "src/features/chat/threads/thread-rename-controller.ts", "src/features/chat/threads/thread-resume.ts", @@ -400,7 +400,7 @@ export default defineConfig([ }, }, { - files: ["src/features/chat/chat-state.ts", "src/features/chat/display/**/*.{ts,tsx}"], + files: ["src/features/chat/state/reducer.ts", "src/features/chat/display/**/*.{ts,tsx}"], rules: { "no-restricted-syntax": [ "error", diff --git a/src/features/chat/session/app-server-warmup-controller.ts b/src/features/chat/connection/app-server-warmup-controller.ts similarity index 100% rename from src/features/chat/session/app-server-warmup-controller.ts rename to src/features/chat/connection/app-server-warmup-controller.ts diff --git a/src/features/chat/session/composition.ts b/src/features/chat/connection/composition.ts similarity index 95% rename from src/features/chat/session/composition.ts rename to src/features/chat/connection/composition.ts index 7fe7986e..59dd2279 100644 --- a/src/features/chat/session/composition.ts +++ b/src/features/chat/connection/composition.ts @@ -2,17 +2,17 @@ import { Notice } from "obsidian"; import type { ConnectionManager } from "../../../app-server/connection-manager"; import type { RuntimeSnapshot } from "../runtime/effective-settings"; -import type { ChatStateStore } from "../chat-state"; +import type { ChatStateStore } from "../state/reducer"; import type { CodexChatHost } from "../chat-host"; -import { createChatServerDiagnosticsActions, type ChatServerDiagnosticsActions } from "../server-actions/diagnostics-actions"; -import { createChatServerMetadataActions, type ChatServerMetadataActions } from "../server-actions/metadata-actions"; -import { createChatServerThreadActions } from "../server-actions/thread-actions"; +import { createChatServerDiagnosticsActions, type ChatServerDiagnosticsActions } from "../protocol/client-actions/diagnostics-actions"; +import { createChatServerMetadataActions, type ChatServerMetadataActions } from "../protocol/client-actions/metadata-actions"; +import { createChatServerThreadActions } from "../protocol/client-actions/thread-actions"; import { ChatConnectionController } from "./connection-controller"; import { createChatReconnectActions } from "./reconnect-actions"; -import type { rejectServerRequest, respondToServerRequest } from "../requests/server-request-responder"; +import type { rejectServerRequest, respondToServerRequest } from "../protocol/requests/server-request-responder"; import type { ChatThreadGoalActions } from "../threads/thread-goal-actions"; import type { ThreadRenameController } from "../threads/thread-rename-controller"; -import { ChatInboundController } from "../inbound/controller"; +import { ChatInboundController } from "../protocol/inbound/controller"; import type { ChatConnectionWorkTracker } from "../panel/lifecycle"; interface ChatServerActionControllerPorts { diff --git a/src/features/chat/session/connection-controller.ts b/src/features/chat/connection/connection-controller.ts similarity index 98% rename from src/features/chat/session/connection-controller.ts rename to src/features/chat/connection/connection-controller.ts index a9581f59..06195eba 100644 --- a/src/features/chat/session/connection-controller.ts +++ b/src/features/chat/connection/connection-controller.ts @@ -1,8 +1,8 @@ import { StaleConnectionError } from "../../../app-server/connection-manager"; import type { AppServerClient } from "../../../app-server/client"; import type { AppServerInitialization } from "../../../app-server/initialization"; -import { clearDisconnectedConnectionStateAction, connectionInitializedAction } from "../chat-state-actions"; -import type { ChatStateStore } from "../chat-state"; +import { clearDisconnectedConnectionStateAction, connectionInitializedAction } from "../state/actions"; +import type { ChatStateStore } from "../state/reducer"; import type { ChatConnectionWorkTracker, ActiveChatConnection } from "../panel/lifecycle"; export interface ChatConnectionAdapter { diff --git a/src/features/chat/session/reconnect-actions.ts b/src/features/chat/connection/reconnect-actions.ts similarity index 87% rename from src/features/chat/session/reconnect-actions.ts rename to src/features/chat/connection/reconnect-actions.ts index f16551a3..3a9b50c3 100644 --- a/src/features/chat/session/reconnect-actions.ts +++ b/src/features/chat/connection/reconnect-actions.ts @@ -1,6 +1,6 @@ -import { clearLocalTurnAction, closePanelsAction } from "../chat-state-actions"; -import { activeThreadId } from "../chat-state-selectors"; -import type { ChatStateStore } from "../chat-state"; +import { clearLocalTurnAction, closePanelsAction } from "../state/actions"; +import { activeThreadId } from "../state/selectors"; +import type { ChatStateStore } from "../state/reducer"; export interface ChatReconnectActionsHost { stateStore: ChatStateStore; diff --git a/src/features/chat/composer/boundary-scroll.ts b/src/features/chat/conversation/composer/boundary-scroll.ts similarity index 100% rename from src/features/chat/composer/boundary-scroll.ts rename to src/features/chat/conversation/composer/boundary-scroll.ts diff --git a/src/features/chat/composer/controller.ts b/src/features/chat/conversation/composer/controller.ts similarity index 96% rename from src/features/chat/composer/controller.ts rename to src/features/chat/conversation/composer/controller.ts index 00263230..42855a03 100644 --- a/src/features/chat/composer/controller.ts +++ b/src/features/chat/conversation/composer/controller.ts @@ -1,12 +1,12 @@ import type { App, EventRef } from "obsidian"; import type { ComponentChild as UiNode } from "preact"; -import type { CodexInput } from "../../../app-server/request-input"; -import { isComposerSendKey, type SendShortcut } from "../../../shared/ui/keyboard"; -import { textareaCursorAtVisualBoundary } from "../../../shared/ui/textarea-caret"; -import { chatTurnBusy, type ChatAction, type ChatState, type ChatStateStore } from "../chat-state"; -import type { ComposerMetaViewModel } from "../panel/model"; -import { composerShellNode, syncComposerHeight, type ComposerCallbacks } from "../ui/composer"; +import type { CodexInput } from "../../../../app-server/request-input"; +import { isComposerSendKey, type SendShortcut } from "../../../../shared/ui/keyboard"; +import { textareaCursorAtVisualBoundary } from "../../../../shared/ui/textarea-caret"; +import { chatTurnBusy, type ChatAction, type ChatState, type ChatStateStore } from "../../state/reducer"; +import type { ComposerMetaViewModel } from "../../panel/view-model"; +import { composerShellNode, syncComposerHeight, type ComposerCallbacks } from "../../ui/composer"; import { composerBoundaryScrollDirection, type ComposerBoundaryScrollAction } from "./boundary-scroll"; import { noteCandidates as appNoteCandidates, resolveWikiLinkMention as resolveAppWikiLinkMention } from "./obsidian-context"; import { diff --git a/src/features/chat/composer/obsidian-context.ts b/src/features/chat/conversation/composer/obsidian-context.ts similarity index 100% rename from src/features/chat/composer/obsidian-context.ts rename to src/features/chat/conversation/composer/obsidian-context.ts diff --git a/src/features/chat/composer/slash-commands.ts b/src/features/chat/conversation/composer/slash-commands.ts similarity index 100% rename from src/features/chat/composer/slash-commands.ts rename to src/features/chat/conversation/composer/slash-commands.ts diff --git a/src/features/chat/composer/suggestions.ts b/src/features/chat/conversation/composer/suggestions.ts similarity index 97% rename from src/features/chat/composer/suggestions.ts rename to src/features/chat/conversation/composer/suggestions.ts index d062cf7c..09d95782 100644 --- a/src/features/chat/composer/suggestions.ts +++ b/src/features/chat/conversation/composer/suggestions.ts @@ -1,11 +1,11 @@ -import type { Thread } from "../../../domain/threads/model"; -import type { ModelMetadata, SkillMetadata } from "../../../domain/catalog/metadata"; +import type { Thread } from "../../../../domain/threads/model"; +import type { ModelMetadata, SkillMetadata } from "../../../../domain/catalog/metadata"; import { prepareFuzzySearch, sortSearchResults, type SearchResult } from "obsidian"; -import { findModelMetadataByIdOrName, sortedModelMetadata } from "../../../domain/catalog/metadata"; -import { isReasoningEffort, REASONING_EFFORTS, supportedEffortsForModelMetadata } from "../../../domain/catalog/metadata"; +import { findModelMetadataByIdOrName, sortedModelMetadata } from "../../../../domain/catalog/metadata"; +import { isReasoningEffort, REASONING_EFFORTS, supportedEffortsForModelMetadata } from "../../../../domain/catalog/metadata"; import { SLASH_COMMANDS, slashCommandSubcommands, type SlashCommandName } from "./slash-commands"; -import { getThreadTitle } from "../../../domain/threads/model"; -import { shortThreadId } from "../../../utils"; +import { getThreadTitle } from "../../../../domain/threads/model"; +import { shortThreadId } from "../../../../utils"; export interface ComposerSuggestion { display: string; diff --git a/src/features/chat/composer/wikilink-context.ts b/src/features/chat/conversation/composer/wikilink-context.ts similarity index 93% rename from src/features/chat/composer/wikilink-context.ts rename to src/features/chat/conversation/composer/wikilink-context.ts index c919115e..0c92407c 100644 --- a/src/features/chat/composer/wikilink-context.ts +++ b/src/features/chat/conversation/composer/wikilink-context.ts @@ -1,6 +1,6 @@ -import { codexTextInputWithMentions, type RequestMention } from "../../../app-server/request-input"; -import type { SkillMetadata } from "../../../domain/catalog/metadata"; -import { parseObsidianWikiLink } from "../../../shared/obsidian/wikilinks"; +import { codexTextInputWithMentions, type RequestMention } from "../../../../app-server/request-input"; +import type { SkillMetadata } from "../../../../domain/catalog/metadata"; +import { parseObsidianWikiLink } from "../../../../shared/obsidian/wikilinks"; export interface ParsedWikiLink { raw: string; diff --git a/src/features/chat/turns/composer-submission-actions.ts b/src/features/chat/conversation/turns/composer-submission-actions.ts similarity index 91% rename from src/features/chat/turns/composer-submission-actions.ts rename to src/features/chat/conversation/turns/composer-submission-actions.ts index 563e5f54..1165a0fe 100644 --- a/src/features/chat/turns/composer-submission-actions.ts +++ b/src/features/chat/conversation/turns/composer-submission-actions.ts @@ -1,11 +1,11 @@ -import type { AppServerClient } from "../../../app-server/client"; -import type { CodexInput } from "../../../app-server/request-input"; -import { submissionStateSnapshot } from "../chat-state-selectors"; -import type { ChatStateStore } from "../chat-state"; +import type { AppServerClient } from "../../../../app-server/client"; +import type { CodexInput } from "../../../../app-server/request-input"; +import { submissionStateSnapshot } from "../../state/selectors"; +import type { ChatStateStore } from "../../state/reducer"; import { parseSlashCommand } from "../composer/suggestions"; import type { SlashCommandExecutionResult } from "./slash-command-execution"; import type { SlashCommandName } from "../composer/slash-commands"; -import type { ReferencedThreadDisplay } from "../../../domain/threads/reference"; +import type { ReferencedThreadDisplay } from "../../../../domain/threads/reference"; interface ComposerDraftPort { readonly trimmedDraft: string; diff --git a/src/features/chat/turns/composition.ts b/src/features/chat/conversation/turns/composition.ts similarity index 87% rename from src/features/chat/turns/composition.ts rename to src/features/chat/conversation/turns/composition.ts index 53996958..a37c5aa0 100644 --- a/src/features/chat/turns/composition.ts +++ b/src/features/chat/conversation/turns/composition.ts @@ -1,27 +1,27 @@ import type { App, Component } from "obsidian"; -import type { AppServerClient } from "../../../app-server/client"; -import type { ChatServerThreadActions } from "../server-actions/thread-actions"; +import type { AppServerClient } from "../../../../app-server/client"; +import type { ChatServerThreadActions } from "../../protocol/client-actions/thread-actions"; import { ChatComposerController } from "../composer/controller"; -import { activeTurnId, type ChatState, type ChatStateStore } from "../chat-state"; -import type { ChatReconnectActions } from "../session/reconnect-actions"; -import { PendingRequestController } from "../requests/pending-request-controller"; -import type { ChatRuntimeSettingsActions } from "../runtime/runtime-settings-actions"; +import { activeTurnId, type ChatState, type ChatStateStore } from "../../state/reducer"; +import type { ChatReconnectActions } from "../../connection/reconnect-actions"; +import { PendingRequestController } from "../../pending-requests/controller"; +import type { ChatRuntimeSettingsActions } from "../../runtime/runtime-settings-actions"; import { createComposerSubmissionActions } from "./composer-submission-actions"; import { createPlanImplementationActions } from "./plan-implementation-actions"; import { createSlashCommandActions } from "./slash-command-actions"; import { TurnSubmissionController } from "./turn-submission-controller"; -import type { ChatThreadActions } from "../threads/thread-actions"; -import type { ChatThreadGoalActions } from "../threads/thread-goal-actions"; -import type { ThreadHistoryController } from "../threads/thread-history-controller"; -import type { ThreadRenameController } from "../threads/thread-rename-controller"; -import type { ChatInboundController } from "../inbound/controller"; -import { currentModel, type RuntimeSnapshot } from "../runtime/effective-settings"; -import { ChatMessageRenderer } from "../ui/message-stream"; -import type { CodexChatHost } from "../chat-host"; -import type { DisplayDetailSection } from "../display/types"; -import type { ChatMessageScrollIntentController } from "../panel/message-scroll-intent-controller"; -import type { ComposerMetaViewModel } from "../panel/model"; +import type { ChatThreadActions } from "../../threads/thread-actions"; +import type { ChatThreadGoalActions } from "../../threads/thread-goal-actions"; +import type { ThreadHistoryController } from "../../threads/thread-history-controller"; +import type { ThreadRenameController } from "../../threads/thread-rename-controller"; +import type { ChatInboundController } from "../../protocol/inbound/controller"; +import { currentModel, type RuntimeSnapshot } from "../../runtime/effective-settings"; +import { ChatMessageRenderer } from "../../ui/message-stream"; +import type { CodexChatHost } from "../../chat-host"; +import type { DisplayDetailSection } from "../../display/types"; +import type { ChatMessageScrollIntentController } from "../../panel/message-scroll-intent-controller"; +import type { ComposerMetaViewModel } from "../../panel/view-model"; interface ConversationSurfaceControllerGroupPorts { obsidian: { diff --git a/src/features/chat/turns/plan-implementation-actions.ts b/src/features/chat/conversation/turns/plan-implementation-actions.ts similarity index 82% rename from src/features/chat/turns/plan-implementation-actions.ts rename to src/features/chat/conversation/turns/plan-implementation-actions.ts index 81ad3d29..74d0df66 100644 --- a/src/features/chat/turns/plan-implementation-actions.ts +++ b/src/features/chat/conversation/turns/plan-implementation-actions.ts @@ -1,8 +1,8 @@ -import type { AppServerClient } from "../../../app-server/client"; -import { closePanelsAction, setRequestedCollaborationModeDefaultAction } from "../chat-state-actions"; -import { activeThreadId, canImplementPlan } from "../chat-state-selectors"; -import type { ChatStateStore } from "../chat-state"; -import type { DisplayItem } from "../display/types"; +import type { AppServerClient } from "../../../../app-server/client"; +import { closePanelsAction, setRequestedCollaborationModeDefaultAction } from "../../state/actions"; +import { activeThreadId, canImplementPlan } from "../../state/selectors"; +import type { ChatStateStore } from "../../state/reducer"; +import type { DisplayItem } from "../../display/types"; const IMPLEMENT_PLAN_PROMPT = "Please implement this plan."; diff --git a/src/features/chat/turns/runtime-overrides.ts b/src/features/chat/conversation/turns/runtime-overrides.ts similarity index 97% rename from src/features/chat/turns/runtime-overrides.ts rename to src/features/chat/conversation/turns/runtime-overrides.ts index 7117189b..ef0d78ea 100644 --- a/src/features/chat/turns/runtime-overrides.ts +++ b/src/features/chat/conversation/turns/runtime-overrides.ts @@ -1,4 +1,4 @@ -import { isReasoningEffort, type ReasoningEffort } from "../../../domain/catalog/metadata"; +import { isReasoningEffort, type ReasoningEffort } from "../../../../domain/catalog/metadata"; const DEFAULT_ALIASES = new Set(["default", "reset", "clear", "off"]); diff --git a/src/features/chat/turns/slash-command-actions.ts b/src/features/chat/conversation/turns/slash-command-actions.ts similarity index 90% rename from src/features/chat/turns/slash-command-actions.ts rename to src/features/chat/conversation/turns/slash-command-actions.ts index bd5d6d5f..2d97ba1c 100644 --- a/src/features/chat/turns/slash-command-actions.ts +++ b/src/features/chat/conversation/turns/slash-command-actions.ts @@ -1,19 +1,19 @@ -import type { AppServerClient } from "../../../app-server/client"; -import { codexTextInputWithAttachments, type CodexInput } from "../../../app-server/request-input"; -import { chronologicalConversationSummariesFromAppServerTurns } from "../../../app-server/turn-model"; -import { referencedThreadPromptBundle, referencedThreadTurns, REFERENCED_THREAD_TURN_LIMIT } from "../../../domain/threads/reference"; -import type { Thread } from "../../../domain/threads/model"; +import type { AppServerClient } from "../../../../app-server/client"; +import { codexTextInputWithAttachments, type CodexInput } from "../../../../app-server/request-input"; +import { chronologicalConversationSummariesFromAppServerTurns } from "../../../../app-server/turn-model"; +import { referencedThreadPromptBundle, referencedThreadTurns, REFERENCED_THREAD_TURN_LIMIT } from "../../../../domain/threads/reference"; +import type { Thread } from "../../../../domain/threads/model"; import { executeSlashCommand as runSlashCommand, type SlashCommandExecutionResult, type ThreadReferenceInput, } from "./slash-command-execution"; import type { SlashCommandName } from "../composer/slash-commands"; -import type { DisplayDetailSection } from "../display/types"; -import type { ReasoningEffort } from "../../../domain/catalog/metadata"; -import type { ThreadGoal, ThreadGoalStatus } from "../../../app-server/thread-goal"; -import { submissionStateSnapshot } from "../chat-state-selectors"; -import type { ChatStateStore } from "../chat-state"; +import type { DisplayDetailSection } from "../../display/types"; +import type { ReasoningEffort } from "../../../../domain/catalog/metadata"; +import type { ThreadGoal, ThreadGoalStatus } from "../../../../app-server/thread-goal"; +import { submissionStateSnapshot } from "../../state/selectors"; +import type { ChatStateStore } from "../../state/reducer"; export interface SlashCommandThreadPort { startNewThread: () => Promise; diff --git a/src/features/chat/turns/slash-command-execution.ts b/src/features/chat/conversation/turns/slash-command-execution.ts similarity index 96% rename from src/features/chat/turns/slash-command-execution.ts rename to src/features/chat/conversation/turns/slash-command-execution.ts index 632dcfe9..087acdd4 100644 --- a/src/features/chat/turns/slash-command-execution.ts +++ b/src/features/chat/conversation/turns/slash-command-execution.ts @@ -1,9 +1,9 @@ -import type { CodexInput } from "../../../app-server/request-input"; -import type { ThreadGoal, ThreadGoalStatus } from "../../../app-server/thread-goal"; -import type { ReasoningEffort } from "../../../domain/catalog/metadata"; -import type { Thread } from "../../../domain/threads/model"; -import { getThreadTitle } from "../../../domain/threads/model"; -import type { ReferencedThreadDisplay } from "../../../domain/threads/reference"; +import type { CodexInput } from "../../../../app-server/request-input"; +import type { ThreadGoal, ThreadGoalStatus } from "../../../../app-server/thread-goal"; +import type { ReasoningEffort } from "../../../../domain/catalog/metadata"; +import type { Thread } from "../../../../domain/threads/model"; +import { getThreadTitle } from "../../../../domain/threads/model"; +import type { ReferencedThreadDisplay } from "../../../../domain/threads/reference"; import { slashCommandDefinition, slashCommandHelpSections, @@ -12,7 +12,7 @@ import { type SlashCommandName, type SlashCommandSubcommandDefinition, } from "../composer/slash-commands"; -import type { DisplayDetailSection, DisplayDetailMetaRow } from "../display/types"; +import type { DisplayDetailSection, DisplayDetailMetaRow } from "../../display/types"; import { modelOverrideMessage, parseModelOverride, diff --git a/src/features/chat/turns/turn-state.ts b/src/features/chat/conversation/turns/turn-state.ts similarity index 100% rename from src/features/chat/turns/turn-state.ts rename to src/features/chat/conversation/turns/turn-state.ts diff --git a/src/features/chat/turns/turn-submission-controller.ts b/src/features/chat/conversation/turns/turn-submission-controller.ts similarity index 94% rename from src/features/chat/turns/turn-submission-controller.ts rename to src/features/chat/conversation/turns/turn-submission-controller.ts index f8de3fcb..c1034605 100644 --- a/src/features/chat/turns/turn-submission-controller.ts +++ b/src/features/chat/conversation/turns/turn-submission-controller.ts @@ -1,14 +1,14 @@ -import type { AppServerClient } from "../../../app-server/client"; -import type { CodexInput } from "../../../app-server/request-input"; -import type { ReferencedThreadDisplay } from "../../../domain/threads/reference"; +import type { AppServerClient } from "../../../../app-server/client"; +import type { CodexInput } from "../../../../app-server/request-input"; +import type { ReferencedThreadDisplay } from "../../../../domain/threads/reference"; import { addTranscriptItemAction, optimisticTurnStartedAction, turnStartAcknowledgedAction, turnStartFailedAction, -} from "../chat-state-actions"; -import { submissionStateSnapshot } from "../chat-state-selectors"; -import type { ChatStateStore } from "../chat-state"; +} from "../../state/actions"; +import { submissionStateSnapshot } from "../../state/selectors"; +import type { ChatStateStore } from "../../state/reducer"; import { acknowledgeOptimisticTurnStart, cleanupFailedTurnStart, diff --git a/src/features/chat/turns/turn-submission.ts b/src/features/chat/conversation/turns/turn-submission.ts similarity index 93% rename from src/features/chat/turns/turn-submission.ts rename to src/features/chat/conversation/turns/turn-submission.ts index 3afbb64b..ef2da785 100644 --- a/src/features/chat/turns/turn-submission.ts +++ b/src/features/chat/conversation/turns/turn-submission.ts @@ -1,8 +1,8 @@ -import type { PendingTurnStart } from "../chat-state"; -import type { DisplayFileMention, DisplayItem, MessageDisplayItem } from "../display/types"; -import { fileMentionsFromInput, userMessageDisplayText } from "../display/thread-items"; -import { attachHookRunsToTurn } from "../display/hooks"; -import type { CodexInput } from "../../../app-server/request-input"; +import type { PendingTurnStart } from "../../state/reducer"; +import type { DisplayFileMention, DisplayItem, MessageDisplayItem } from "../../display/types"; +import { fileMentionsFromInput, userMessageDisplayText } from "../../protocol/display-items"; +import { attachHookRunsToTurn } from "../../display/hooks"; +import type { CodexInput } from "../../../../app-server/request-input"; export interface LocalUserMessageParams { id: string; diff --git a/src/features/chat/display/action-candidates.ts b/src/features/chat/display/action-candidates.ts index 2f9f1a34..1b33021c 100644 --- a/src/features/chat/display/action-candidates.ts +++ b/src/features/chat/display/action-candidates.ts @@ -4,7 +4,7 @@ import { type ChatRuntimeState, type ChatTranscriptState, type ChatTurnState, -} from "../chat-state"; +} from "../state/reducer"; import type { DisplayItem, MessageDisplayItem } from "./types"; import { isCompletedTurnOutcomeMessage } from "./turn-outcome-message"; diff --git a/src/features/chat/panel/cached-app-server-state.ts b/src/features/chat/panel/cached-app-server-state.ts index 76429ceb..eebaa4dd 100644 --- a/src/features/chat/panel/cached-app-server-state.ts +++ b/src/features/chat/panel/cached-app-server-state.ts @@ -1,7 +1,7 @@ import type { SharedAppServerMetadata } from "../../../app-server/shared-cache-state"; import type { Thread } from "../../../domain/threads/model"; -import type { ChatServerMetadataActions } from "../server-actions/metadata-actions"; -import type { ChatServerThreadActions } from "../server-actions/thread-actions"; +import type { ChatServerMetadataActions } from "../protocol/client-actions/metadata-actions"; +import type { ChatServerThreadActions } from "../protocol/client-actions/thread-actions"; export interface CachedSharedAppServerStateSource { cachedThreadList: () => readonly Thread[] | null; diff --git a/src/features/chat/panel/composition.ts b/src/features/chat/panel/composition.ts index d41ef228..f17c4ca8 100644 --- a/src/features/chat/panel/composition.ts +++ b/src/features/chat/panel/composition.ts @@ -1,20 +1,20 @@ import { ConnectionManager } from "../../../app-server/connection-manager"; -import type { ChatServerDiagnosticsActions } from "../server-actions/diagnostics-actions"; -import type { ChatServerMetadataActions } from "../server-actions/metadata-actions"; -import type { ChatServerThreadActions } from "../server-actions/thread-actions"; -import type { ChatComposerController } from "../composer/controller"; -import type { ChatInboundController } from "../inbound/controller"; +import type { ChatServerDiagnosticsActions } from "../protocol/client-actions/diagnostics-actions"; +import type { ChatServerMetadataActions } from "../protocol/client-actions/metadata-actions"; +import type { ChatServerThreadActions } from "../protocol/client-actions/thread-actions"; +import type { ChatComposerController } from "../conversation/composer/controller"; +import type { ChatInboundController } from "../protocol/inbound/controller"; import type { ChatThreadGoalActions } from "../threads/thread-goal-actions"; import { createChatRuntimeSettingsActions, type ChatRuntimeSettingsActions } from "../runtime/runtime-settings-actions"; import type { ChatThreadActions } from "../threads/thread-actions"; import type { ThreadHistoryController } from "../threads/thread-history-controller"; import type { ThreadRenameController } from "../threads/thread-rename-controller"; import type { ToolbarPanelController } from "./toolbar-controller"; -import type { ChatConnectionController } from "../session/connection-controller"; -import type { ChatReconnectActions } from "../session/reconnect-actions"; -import type { PendingRequestController } from "../requests/pending-request-controller"; -import { rejectServerRequest, respondToServerRequest } from "../requests/server-request-responder"; -import type { ComposerSubmissionActions } from "../turns/composer-submission-actions"; +import type { ChatConnectionController } from "../connection/connection-controller"; +import type { ChatReconnectActions } from "../connection/reconnect-actions"; +import type { PendingRequestController } from "../pending-requests/controller"; +import { rejectServerRequest, respondToServerRequest } from "../protocol/requests/server-request-responder"; +import type { ComposerSubmissionActions } from "../conversation/turns/composer-submission-actions"; import type { RestoredThreadController } from "../threads/restored-thread-controller"; import type { ThreadIdentityActions } from "../threads/thread-identity-actions"; import type { ThreadResumeController } from "../threads/thread-resume-controller"; @@ -28,9 +28,9 @@ import { createChatConnectionControllers, createChatInboundController, createChatReconnectControllerGroup, -} from "../session/composition"; +} from "../connection/composition"; import { createThreadControllerGroup, createThreadSelectionControllerGroup } from "../threads/composition"; -import { createConversationSurfaceControllerGroup } from "../turns/composition"; +import { createConversationSurfaceControllerGroup } from "../conversation/turns/composition"; import { createConnectionLifecycleControllerGroup, createPanelUiControllerGroup, createViewRenderControllerGroup } from "./ui-composition"; export interface ChatViewControllers { diff --git a/src/features/chat/panel/controller-ports.ts b/src/features/chat/panel/controller-ports.ts index f8992666..000b24a6 100644 --- a/src/features/chat/panel/controller-ports.ts +++ b/src/features/chat/panel/controller-ports.ts @@ -4,12 +4,12 @@ import type { ComponentChild as UiNode } from "preact"; import type { AppServerClient } from "../../../app-server/client"; import type { ArchiveExportAdapter } from "../../../domain/threads/export"; import type { RuntimeSnapshot } from "../runtime/effective-settings"; -import type { ChatState, ChatStateStore } from "../chat-state"; +import type { ChatState, ChatStateStore } from "../state/reducer"; import type { CodexChatHost } from "../chat-host"; import type { ChatMessageScrollIntentController } from "../panel/message-scroll-intent-controller"; import type { DisplayDetailSection, DisplayItem } from "../display/types"; import type { ChatConnectionWorkTracker, ChatResumeWorkTracker, ChatViewDeferredTasks } from "./lifecycle"; -import type { ComposerMetaViewModel } from "./model"; +import type { ComposerMetaViewModel } from "./view-model"; export interface ChatControllerCompositionPorts { obsidian: ChatPanelObsidianContext; diff --git a/src/features/chat/panel/controller-wiring.ts b/src/features/chat/panel/controller-wiring.ts index 6f58218a..1fec52b6 100644 --- a/src/features/chat/panel/controller-wiring.ts +++ b/src/features/chat/panel/controller-wiring.ts @@ -1,6 +1,6 @@ -import type { ChatComposerController } from "../composer/controller"; +import type { ChatComposerController } from "../conversation/composer/controller"; import type { DisplayDetailSection } from "../display/types"; -import type { ChatConnectionController } from "../session/connection-controller"; +import type { ChatConnectionController } from "../connection/connection-controller"; import type { ThreadSelectionActions } from "../threads/thread-selection-controller"; import type { ChatMessageRenderer } from "../ui/message-stream"; import type { ChatControllerCompositionPorts } from "./controller-ports"; diff --git a/src/features/chat/panel/shell-render.ts b/src/features/chat/panel/shell-render.ts index 52f5bdfc..4160c42b 100644 --- a/src/features/chat/panel/shell-render.ts +++ b/src/features/chat/panel/shell-render.ts @@ -1,6 +1,6 @@ import type { ComponentChild as UiNode } from "preact"; -import type { ChatStateStore } from "../chat-state"; +import type { ChatStateStore } from "../state/reducer"; import { renderChatPanelShell } from "../ui/shell"; export interface ChatShellRenderPort { diff --git a/src/features/chat/panel/snapshot.ts b/src/features/chat/panel/snapshot.ts index 45146325..67e2bd3e 100644 --- a/src/features/chat/panel/snapshot.ts +++ b/src/features/chat/panel/snapshot.ts @@ -1,5 +1,5 @@ import type { OpenCodexPanelSnapshot } from "../../../workspace/open-panel-snapshot"; -import type { ChatState } from "../chat-state"; +import type { ChatState } from "../state/reducer"; import type { DisplayItem } from "../display/types"; import type { RestoredThreadState } from "./lifecycle"; diff --git a/src/features/chat/panel/toolbar-controller.ts b/src/features/chat/panel/toolbar-controller.ts index 5526bbab..89c6726a 100644 --- a/src/features/chat/panel/toolbar-controller.ts +++ b/src/features/chat/panel/toolbar-controller.ts @@ -1,4 +1,4 @@ -import type { ChatAction, ChatState, ChatStateStore } from "../chat-state"; +import type { ChatAction, ChatState, ChatStateStore } from "../state/reducer"; import type { ChatThreadActions } from "../threads/thread-actions"; import type { ToolbarArchiveConfirmState } from "./toolbar-archive-confirm-state"; diff --git a/src/features/chat/panel/ui-composition.ts b/src/features/chat/panel/ui-composition.ts index d9760e38..ee73b5bf 100644 --- a/src/features/chat/panel/ui-composition.ts +++ b/src/features/chat/panel/ui-composition.ts @@ -1,12 +1,12 @@ import type { ConnectionManager } from "../../../app-server/connection-manager"; import type { ComponentChild as UiNode } from "preact"; -import type { ChatStateStore } from "../chat-state"; +import type { ChatStateStore } from "../state/reducer"; import type { CodexChatHost } from "../chat-host"; -import type { ChatServerMetadataActions } from "../server-actions/metadata-actions"; -import type { ChatServerThreadActions } from "../server-actions/thread-actions"; -import type { ChatComposerController } from "../composer/controller"; +import type { ChatServerMetadataActions } from "../protocol/client-actions/metadata-actions"; +import type { ChatServerThreadActions } from "../protocol/client-actions/thread-actions"; +import type { ChatComposerController } from "../conversation/composer/controller"; import type { ChatThreadActions } from "../threads/thread-actions"; -import { scheduleAppServerWarmup } from "../session/app-server-warmup-controller"; +import { scheduleAppServerWarmup } from "../connection/app-server-warmup-controller"; import { closeChatView, openChatView, type ChatViewLifecycleHost } from "./view-lifecycle"; import { ToolbarPanelController } from "./toolbar-controller"; import { ChatViewRenderController } from "./view-render-controller"; diff --git a/src/features/chat/panel/ui-ports.ts b/src/features/chat/panel/ui-ports.ts index 29b5dfd4..fcccf4cf 100644 --- a/src/features/chat/panel/ui-ports.ts +++ b/src/features/chat/panel/ui-ports.ts @@ -1,10 +1,10 @@ -import type { ChatState } from "../chat-state"; +import type { ChatState } from "../state/reducer"; import type { ReasoningEffort } from "../../../domain/catalog/metadata"; import type { RuntimeSnapshot } from "../runtime/effective-settings"; import type { SendShortcut } from "../../../shared/ui/keyboard"; import type { ToolbarActions } from "../ui/toolbar"; -import type { ToolbarThreadRow } from "./model/types"; -import type { RestoredThreadTitleSnapshot } from "./model"; +import type { ToolbarThreadRow } from "./view-model/types"; +import type { RestoredThreadTitleSnapshot } from "./view-model"; interface ChatPanelToolbarState { archiveConfirmId: () => string | null; diff --git a/src/features/chat/panel/model/composer.ts b/src/features/chat/panel/view-model/composer.ts similarity index 96% rename from src/features/chat/panel/model/composer.ts rename to src/features/chat/panel/view-model/composer.ts index 33a72128..bad5f242 100644 --- a/src/features/chat/panel/model/composer.ts +++ b/src/features/chat/panel/view-model/composer.ts @@ -5,9 +5,9 @@ import { fastModeActive, runtimeConfigOrDefault, } from "../../runtime/effective-settings"; -import { compactReasoningEffortLabel } from "../../turns/runtime-overrides"; +import { compactReasoningEffortLabel } from "../../conversation/turns/runtime-overrides"; import { contextSummary } from "../../runtime/status-summary"; -import type { ChatState } from "../../chat-state"; +import type { ChatState } from "../../state/reducer"; import type { ComposerContextMeterCellViewModel, ComposerContextMeterViewModel, ComposerMetaViewModel } from "./types"; import type { runtimeSnapshotForChatSlices } from "./runtime"; diff --git a/src/features/chat/panel/model/index.ts b/src/features/chat/panel/view-model/index.ts similarity index 100% rename from src/features/chat/panel/model/index.ts rename to src/features/chat/panel/view-model/index.ts diff --git a/src/features/chat/panel/model/runtime.ts b/src/features/chat/panel/view-model/runtime.ts similarity index 100% rename from src/features/chat/panel/model/runtime.ts rename to src/features/chat/panel/view-model/runtime.ts diff --git a/src/features/chat/panel/model/thread-title.ts b/src/features/chat/panel/view-model/thread-title.ts similarity index 95% rename from src/features/chat/panel/model/thread-title.ts rename to src/features/chat/panel/view-model/thread-title.ts index a465771a..2887b46f 100644 --- a/src/features/chat/panel/model/thread-title.ts +++ b/src/features/chat/panel/view-model/thread-title.ts @@ -1,5 +1,5 @@ import { codexPanelDisplayTitle, explicitThreadName, getThreadTitle } from "../../../../domain/threads/model"; -import type { ChatState } from "../../chat-state"; +import type { ChatState } from "../../state/reducer"; import type { RestoredThreadTitleSnapshot } from "./types"; export function chatViewDisplayTitle(state: ChatState, restoredThreadTitle: string | null): string { diff --git a/src/features/chat/panel/model/toolbar.ts b/src/features/chat/panel/view-model/toolbar.ts similarity index 100% rename from src/features/chat/panel/model/toolbar.ts rename to src/features/chat/panel/view-model/toolbar.ts diff --git a/src/features/chat/panel/model/types.ts b/src/features/chat/panel/view-model/types.ts similarity index 98% rename from src/features/chat/panel/model/types.ts rename to src/features/chat/panel/view-model/types.ts index 007fa4d0..eff6c03f 100644 --- a/src/features/chat/panel/model/types.ts +++ b/src/features/chat/panel/view-model/types.ts @@ -1,7 +1,7 @@ import type { ReasoningEffort } from "../../../../domain/catalog/metadata"; import type { RuntimeSnapshot } from "../../runtime/effective-settings"; import type { RuntimeConfigSection, RateLimitSummary } from "../../runtime/status-summary"; -import type { ChatState } from "../../chat-state"; +import type { ChatState } from "../../state/reducer"; export interface RuntimeSnapshotInput { runtimeConfig: ChatState["connection"]["runtimeConfig"]; diff --git a/src/features/chat/requests/pending-request-controller.ts b/src/features/chat/pending-requests/controller.ts similarity index 87% rename from src/features/chat/requests/pending-request-controller.ts rename to src/features/chat/pending-requests/controller.ts index 2d21de1d..1d8e2474 100644 --- a/src/features/chat/requests/pending-request-controller.ts +++ b/src/features/chat/pending-requests/controller.ts @@ -1,11 +1,11 @@ -import { setDetailOpenAction, setUserInputDraftAction } from "../chat-state-actions"; -import { pendingRequestSnapshot, type PendingRequestSnapshot } from "../chat-state-selectors"; -import type { ChatStateStore } from "../chat-state"; -import type { ApprovalAction, PendingApproval } from "../requests/approval"; -import type { ChatInboundController } from "../inbound/controller"; -import { pendingRequestFocusSignature } from "../requests/view-model"; +import { setDetailOpenAction, setUserInputDraftAction } from "../state/actions"; +import { pendingRequestSnapshot, type PendingRequestSnapshot } from "../state/selectors"; +import type { ChatStateStore } from "../state/reducer"; +import type { ApprovalAction, PendingApproval } from "../protocol/requests/approval"; +import type { ChatInboundController } from "../protocol/inbound/controller"; +import { pendingRequestFocusSignature } from "./view-model"; import type { PendingRequestMessageActions } from "../ui/pending-request-message"; -import { answersForPendingUserInput, type PendingUserInput } from "../requests/user-input"; +import { answersForPendingUserInput, type PendingUserInput } from "../protocol/requests/user-input"; export interface PendingRequestControllerHost { stateStore: ChatStateStore; diff --git a/src/features/chat/requests/request-state.ts b/src/features/chat/pending-requests/state.ts similarity index 94% rename from src/features/chat/requests/request-state.ts rename to src/features/chat/pending-requests/state.ts index ea9209b2..a0d51ec4 100644 --- a/src/features/chat/requests/request-state.ts +++ b/src/features/chat/pending-requests/state.ts @@ -1,5 +1,5 @@ -import type { PendingApproval } from "./approval"; -import type { PendingUserInput } from "./user-input"; +import type { PendingApproval } from "../protocol/requests/approval"; +import type { PendingUserInput } from "../protocol/requests/user-input"; export interface ChatRequestState { approvals: readonly PendingApproval[]; diff --git a/src/features/chat/requests/view-model.ts b/src/features/chat/pending-requests/view-model.ts similarity index 97% rename from src/features/chat/requests/view-model.ts rename to src/features/chat/pending-requests/view-model.ts index 8803a184..b5cdd5b2 100644 --- a/src/features/chat/requests/view-model.ts +++ b/src/features/chat/pending-requests/view-model.ts @@ -5,10 +5,10 @@ import { approvalTitle, type ApprovalAction, type PendingApproval, -} from "./approval"; +} from "../protocol/requests/approval"; import type { DisplayDetailSection, DisplayItem } from "../display/types"; import { definedProp } from "../../../utils"; -import type { PendingUserInput } from "./user-input"; +import type { PendingUserInput } from "../protocol/requests/user-input"; export function pendingRequestsSignature( approvals: readonly PendingApproval[], diff --git a/src/features/chat/server-actions/diagnostics-actions.ts b/src/features/chat/protocol/client-actions/diagnostics-actions.ts similarity index 96% rename from src/features/chat/server-actions/diagnostics-actions.ts rename to src/features/chat/protocol/client-actions/diagnostics-actions.ts index 93d939c1..5059fad1 100644 --- a/src/features/chat/server-actions/diagnostics-actions.ts +++ b/src/features/chat/protocol/client-actions/diagnostics-actions.ts @@ -1,4 +1,4 @@ -import type { AppServerClient } from "../../../app-server/client"; +import type { AppServerClient } from "../../../../app-server/client"; import { diagnosticProbeError, diagnosticProbeOk, @@ -8,9 +8,9 @@ import { type DiagnosticProbeMethod, type McpServerStartupStatus, type McpServerStatusSummary, -} from "../../../app-server/diagnostics"; -import type { SharedAppServerMetadata } from "../../../app-server/shared-cache-state"; -import { mcpStatusLines as buildMcpStatusLines } from "../mcp-status"; +} from "../../../../app-server/diagnostics"; +import type { SharedAppServerMetadata } from "../../../../app-server/shared-cache-state"; +import { mcpStatusLines as buildMcpStatusLines } from "../../mcp-status"; import { cloneAppServerDiagnostics, type ChatServerActionHost } from "./shared"; interface RefreshDiagnosticProbesOptions { diff --git a/src/features/chat/server-actions/metadata-actions.ts b/src/features/chat/protocol/client-actions/metadata-actions.ts similarity index 96% rename from src/features/chat/server-actions/metadata-actions.ts rename to src/features/chat/protocol/client-actions/metadata-actions.ts index f43dc81e..27d86c82 100644 --- a/src/features/chat/server-actions/metadata-actions.ts +++ b/src/features/chat/protocol/client-actions/metadata-actions.ts @@ -1,9 +1,9 @@ -import { type Diagnostics, diagnosticProbeError, diagnosticProbeOk } from "../../../app-server/diagnostics"; -import { listModelMetadata, listSkillCatalog } from "../../../app-server/resource-operations"; -import { runtimeConfigSnapshotFromAppServerConfig } from "../../../app-server/runtime-config"; -import { rateLimitSnapshotFromAppServerSnapshot } from "../../../app-server/runtime-metrics"; -import type { SharedAppServerMetadata } from "../../../app-server/shared-cache-state"; -import type { ModelMetadata, SkillMetadata } from "../../../domain/catalog/metadata"; +import { type Diagnostics, diagnosticProbeError, diagnosticProbeOk } from "../../../../app-server/diagnostics"; +import { listModelMetadata, listSkillCatalog } from "../../../../app-server/resource-operations"; +import { runtimeConfigSnapshotFromAppServerConfig } from "../../../../app-server/runtime-config"; +import { rateLimitSnapshotFromAppServerSnapshot } from "../../../../app-server/runtime-metrics"; +import type { SharedAppServerMetadata } from "../../../../app-server/shared-cache-state"; +import type { ModelMetadata, SkillMetadata } from "../../../../domain/catalog/metadata"; import { cloneAppServerDiagnostics, type ChatServerActionHost } from "./shared"; interface RateLimitMetadataResult { diff --git a/src/features/chat/server-actions/shared.ts b/src/features/chat/protocol/client-actions/shared.ts similarity index 63% rename from src/features/chat/server-actions/shared.ts rename to src/features/chat/protocol/client-actions/shared.ts index b71a074b..e946e6d0 100644 --- a/src/features/chat/server-actions/shared.ts +++ b/src/features/chat/protocol/client-actions/shared.ts @@ -1,6 +1,6 @@ -import type { AppServerClient } from "../../../app-server/client"; -import type { Diagnostics } from "../../../app-server/diagnostics"; -import type { ChatStateStore } from "../chat-state"; +import type { AppServerClient } from "../../../../app-server/client"; +import type { Diagnostics } from "../../../../app-server/diagnostics"; +import type { ChatStateStore } from "../../state/reducer"; export interface ChatServerActionHost { stateStore: ChatStateStore; diff --git a/src/features/chat/server-actions/thread-actions.ts b/src/features/chat/protocol/client-actions/thread-actions.ts similarity index 86% rename from src/features/chat/server-actions/thread-actions.ts rename to src/features/chat/protocol/client-actions/thread-actions.ts index f05cd39c..33c70236 100644 --- a/src/features/chat/server-actions/thread-actions.ts +++ b/src/features/chat/protocol/client-actions/thread-actions.ts @@ -1,8 +1,8 @@ -import { listThreads } from "../../../app-server/resource-operations"; -import type { Thread } from "../../../domain/threads/model"; -import type { RuntimeSnapshot } from "../runtime/effective-settings"; -import { serviceTierRequestForThreadStart } from "../runtime/turn-settings"; -import { resumedThreadActionFromAppServerResponse } from "../threads/thread-resume"; +import { listThreads } from "../../../../app-server/resource-operations"; +import type { Thread } from "../../../../domain/threads/model"; +import type { RuntimeSnapshot } from "../../runtime/effective-settings"; +import { serviceTierRequestForThreadStart } from "../../runtime/turn-settings"; +import { resumedThreadActionFromAppServerResponse } from "../../threads/thread-resume"; import type { ChatServerActionHost } from "./shared"; interface StartedThreadSummary { diff --git a/src/features/chat/display/thread-items.ts b/src/features/chat/protocol/display-items.ts similarity index 98% rename from src/features/chat/display/thread-items.ts rename to src/features/chat/protocol/display-items.ts index 87680310..2ab4848e 100644 --- a/src/features/chat/display/thread-items.ts +++ b/src/features/chat/protocol/display-items.ts @@ -1,4 +1,4 @@ -import type { DisplayDetailSection, DisplayFileChange, DisplayFileMention, DisplayItem } from "./types"; +import type { DisplayDetailSection, DisplayFileChange, DisplayFileMention, DisplayItem } from "../display/types"; import type { CodexInput, CodexInputItem } from "../../../app-server/request-input"; import type { FileUpdateChange } from "../../../generated/app-server/v2/FileUpdateChange"; import type { ThreadItem } from "../../../generated/app-server/v2/ThreadItem"; @@ -6,16 +6,16 @@ import type { Turn } from "../../../generated/app-server/v2/Turn"; import { definedProp, truncate } from "../../../utils"; import { referencedThreadDisplayFromPrompt } from "../../../domain/threads/reference"; import { appServerUserItemText } from "../../../app-server/turn-model"; -import { agentDisplayItem } from "./agent"; -import { pathRelativeToRoot } from "./paths"; -import { normalizeProposedPlanMarkdown } from "./plan"; +import { agentDisplayItem } from "../display/agent"; +import { pathRelativeToRoot } from "../display/paths"; +import { normalizeProposedPlanMarkdown } from "../display/plan"; import { commandExecutionState, dynamicToolCallExecutionState, imageGenerationExecutionState, mcpToolCallExecutionState, patchApplyExecutionState, -} from "./state"; +} from "../display/state"; import { bodyDetail, compactToolSummary, @@ -24,7 +24,7 @@ import { jsonTargetLabel, metaDetail, statusQualifier, -} from "./tool-format"; +} from "../display/tool-format"; type UserMessageItem = Extract; type AgentMessageItem = Extract; diff --git a/src/features/chat/inbound/app-server-logs.ts b/src/features/chat/protocol/inbound/app-server-logs.ts similarity index 100% rename from src/features/chat/inbound/app-server-logs.ts rename to src/features/chat/protocol/inbound/app-server-logs.ts diff --git a/src/features/chat/inbound/controller.ts b/src/features/chat/protocol/inbound/controller.ts similarity index 92% rename from src/features/chat/inbound/controller.ts rename to src/features/chat/protocol/inbound/controller.ts index a681489a..736556b2 100644 --- a/src/features/chat/inbound/controller.ts +++ b/src/features/chat/protocol/inbound/controller.ts @@ -1,15 +1,15 @@ -import type { RequestId } from "../../../generated/app-server/RequestId"; -import type { ServerNotification } from "../../../generated/app-server/ServerNotification"; -import type { ServerRequest } from "../../../generated/app-server/ServerRequest"; -import type { Turn } from "../../../generated/app-server/v2/Turn"; -import type { McpServerStartupStatus } from "../../../app-server/diagnostics"; +import type { RequestId } from "../../../../generated/app-server/RequestId"; +import type { ServerNotification } from "../../../../generated/app-server/ServerNotification"; +import type { ServerRequest } from "../../../../generated/app-server/ServerRequest"; +import type { Turn } from "../../../../generated/app-server/v2/Turn"; +import type { McpServerStartupStatus } from "../../../../app-server/diagnostics"; import { classifyAppServerLog } from "./app-server-logs"; -import { activeTurnId, type ChatAction, type ChatState, type ChatStateStore } from "../chat-state"; -import { createStructuredSystemItem, createSystemItem } from "../display/system"; -import type { DisplayDetailSection } from "../display/types"; +import { activeTurnId, type ChatAction, type ChatState, type ChatStateStore } from "../../state/reducer"; +import { createStructuredSystemItem, createSystemItem } from "../../display/system"; +import type { DisplayDetailSection } from "../../display/types"; import { approvalResponse, type ApprovalAction, type PendingApproval } from "../requests/approval"; import { userInputResponse, type PendingUserInput } from "../requests/user-input"; -import { createApprovalResultItem, createUserInputResultItem } from "../requests/view-model"; +import { createApprovalResultItem, createUserInputResultItem } from "../../pending-requests/view-model"; import { planChatNotification, type ChatNotificationEffect } from "./notification-plan"; import { routeServerRequest } from "./routing"; diff --git a/src/features/chat/inbound/notification-plan.ts b/src/features/chat/protocol/inbound/notification-plan.ts similarity index 93% rename from src/features/chat/inbound/notification-plan.ts rename to src/features/chat/protocol/inbound/notification-plan.ts index bcc4d46a..18f415d9 100644 --- a/src/features/chat/inbound/notification-plan.ts +++ b/src/features/chat/protocol/inbound/notification-plan.ts @@ -1,13 +1,13 @@ -import { activeThreadSettingsAppliedAction } from "../chat-state-actions"; -import type { McpServerStartupStatus } from "../../../app-server/diagnostics"; -import { threadTokenUsageFromAppServerUsage } from "../../../app-server/runtime-metrics"; -import type { ServerNotification } from "../../../generated/app-server/ServerNotification"; -import type { FileUpdateChange } from "../../../generated/app-server/v2/FileUpdateChange"; -import type { ThreadItem } from "../../../generated/app-server/v2/ThreadItem"; -import type { Turn } from "../../../generated/app-server/v2/Turn"; -import { jsonPreview } from "../../../utils"; -import { activeTurnId, pendingTurnStart as pendingTurnStartForState, type ChatAction, type ChatState } from "../chat-state"; -import { createAutoReviewResultItem, createReviewResultItem } from "../display/review"; +import { activeThreadSettingsAppliedAction } from "../../state/actions"; +import type { McpServerStartupStatus } from "../../../../app-server/diagnostics"; +import { threadTokenUsageFromAppServerUsage } from "../../../../app-server/runtime-metrics"; +import type { ServerNotification } from "../../../../generated/app-server/ServerNotification"; +import type { FileUpdateChange } from "../../../../generated/app-server/v2/FileUpdateChange"; +import type { ThreadItem } from "../../../../generated/app-server/v2/ThreadItem"; +import type { Turn } from "../../../../generated/app-server/v2/Turn"; +import { jsonPreview } from "../../../../utils"; +import { activeTurnId, pendingTurnStart as pendingTurnStartForState, type ChatAction, type ChatState } from "../../state/reducer"; +import { createAutoReviewResultItem, createReviewResultItem } from "../../display/review"; import { appendAssistantDelta, appendItemOutput, @@ -16,18 +16,13 @@ import { appendToolOutput, completeReasoningItems, upsertDisplayItem, -} from "../display/stream-updates"; -import { - displayItemFromThreadItem, - displayItemsFromTurns, - normalizeFileChanges, - shouldSuppressLifecycleItem, -} from "../display/thread-items"; -import { planProgressDisplayItem } from "../display/plan"; -import { createSystemItem } from "../display/system"; -import type { DisplayItem, DisplayKind, MessageDisplayItem } from "../display/types"; -import { goalChangeItem } from "../display/goal-messages"; -import { attachHookRunsToTurn, hookRunDisplayItem } from "../display/hooks"; +} from "../../display/stream-updates"; +import { displayItemFromThreadItem, displayItemsFromTurns, normalizeFileChanges, shouldSuppressLifecycleItem } from "../display-items"; +import { planProgressDisplayItem } from "../../display/plan"; +import { createSystemItem } from "../../display/system"; +import type { DisplayItem, DisplayKind, MessageDisplayItem } from "../../display/types"; +import { goalChangeItem } from "../../display/goal-messages"; +import { attachHookRunsToTurn, hookRunDisplayItem } from "../../display/hooks"; import { routeServerNotification } from "./routing"; export type ChatNotificationEffect = diff --git a/src/features/chat/inbound/routing.ts b/src/features/chat/protocol/inbound/routing.ts similarity index 98% rename from src/features/chat/inbound/routing.ts rename to src/features/chat/protocol/inbound/routing.ts index b6986a3a..ff659700 100644 --- a/src/features/chat/inbound/routing.ts +++ b/src/features/chat/protocol/inbound/routing.ts @@ -1,5 +1,5 @@ -import type { ServerNotification } from "../../../generated/app-server/ServerNotification"; -import type { ServerRequest } from "../../../generated/app-server/ServerRequest"; +import type { ServerNotification } from "../../../../generated/app-server/ServerNotification"; +import type { ServerRequest } from "../../../../generated/app-server/ServerRequest"; import { toPendingApproval, type PendingApproval } from "../requests/approval"; import { toPendingUserInput, type PendingUserInput } from "../requests/user-input"; diff --git a/src/features/chat/requests/approval.ts b/src/features/chat/protocol/requests/approval.ts similarity index 94% rename from src/features/chat/requests/approval.ts rename to src/features/chat/protocol/requests/approval.ts index 6bd6e768..e29e939e 100644 --- a/src/features/chat/requests/approval.ts +++ b/src/features/chat/protocol/requests/approval.ts @@ -1,11 +1,11 @@ -import type { RequestId } from "../../../generated/app-server/RequestId"; -import type { ServerRequest } from "../../../generated/app-server/ServerRequest"; -import type { CommandExecutionApprovalDecision } from "../../../generated/app-server/v2/CommandExecutionApprovalDecision"; -import type { CommandExecutionRequestApprovalResponse } from "../../../generated/app-server/v2/CommandExecutionRequestApprovalResponse"; -import type { FileChangeRequestApprovalResponse } from "../../../generated/app-server/v2/FileChangeRequestApprovalResponse"; -import type { GrantedPermissionProfile } from "../../../generated/app-server/v2/GrantedPermissionProfile"; -import type { PermissionsRequestApprovalResponse } from "../../../generated/app-server/v2/PermissionsRequestApprovalResponse"; -import { addOptional, nonEmptyString, permissionRows } from "../display/permission-details"; +import type { RequestId } from "../../../../generated/app-server/RequestId"; +import type { ServerRequest } from "../../../../generated/app-server/ServerRequest"; +import type { CommandExecutionApprovalDecision } from "../../../../generated/app-server/v2/CommandExecutionApprovalDecision"; +import type { CommandExecutionRequestApprovalResponse } from "../../../../generated/app-server/v2/CommandExecutionRequestApprovalResponse"; +import type { FileChangeRequestApprovalResponse } from "../../../../generated/app-server/v2/FileChangeRequestApprovalResponse"; +import type { GrantedPermissionProfile } from "../../../../generated/app-server/v2/GrantedPermissionProfile"; +import type { PermissionsRequestApprovalResponse } from "../../../../generated/app-server/v2/PermissionsRequestApprovalResponse"; +import { addOptional, nonEmptyString, permissionRows } from "../../display/permission-details"; export type ApprovalAction = "accept" | "accept-session" | "decline" | "cancel" | CommandApprovalDecisionAction; interface CommandApprovalDecisionAction { diff --git a/src/features/chat/requests/server-request-responder.ts b/src/features/chat/protocol/requests/server-request-responder.ts similarity index 92% rename from src/features/chat/requests/server-request-responder.ts rename to src/features/chat/protocol/requests/server-request-responder.ts index e0faec46..0fa8c5b2 100644 --- a/src/features/chat/requests/server-request-responder.ts +++ b/src/features/chat/protocol/requests/server-request-responder.ts @@ -1,4 +1,4 @@ -import type { AppServerClient } from "../../../app-server/client"; +import type { AppServerClient } from "../../../../app-server/client"; type RespondRequestId = Parameters[0]; type RejectRequestId = Parameters[0]; diff --git a/src/features/chat/requests/user-input.ts b/src/features/chat/protocol/requests/user-input.ts similarity index 75% rename from src/features/chat/requests/user-input.ts rename to src/features/chat/protocol/requests/user-input.ts index 82b36a9b..a610493a 100644 --- a/src/features/chat/requests/user-input.ts +++ b/src/features/chat/protocol/requests/user-input.ts @@ -1,8 +1,8 @@ -import type { RequestId } from "../../../generated/app-server/RequestId"; -import type { ServerRequest } from "../../../generated/app-server/ServerRequest"; -import type { ToolRequestUserInputParams } from "../../../generated/app-server/v2/ToolRequestUserInputParams"; -import type { ToolRequestUserInputQuestion } from "../../../generated/app-server/v2/ToolRequestUserInputQuestion"; -import type { ToolRequestUserInputResponse } from "../../../generated/app-server/v2/ToolRequestUserInputResponse"; +import type { RequestId } from "../../../../generated/app-server/RequestId"; +import type { ServerRequest } from "../../../../generated/app-server/ServerRequest"; +import type { ToolRequestUserInputParams } from "../../../../generated/app-server/v2/ToolRequestUserInputParams"; +import type { ToolRequestUserInputQuestion } from "../../../../generated/app-server/v2/ToolRequestUserInputQuestion"; +import type { ToolRequestUserInputResponse } from "../../../../generated/app-server/v2/ToolRequestUserInputResponse"; type UserInputRequest = Extract; diff --git a/src/features/chat/runtime/runtime-settings-actions.ts b/src/features/chat/runtime/runtime-settings-actions.ts index 5edcf013..69f3639b 100644 --- a/src/features/chat/runtime/runtime-settings-actions.ts +++ b/src/features/chat/runtime/runtime-settings-actions.ts @@ -11,8 +11,8 @@ import { } from "./turn-settings"; import type { ThreadSettingsUpdate } from "../../../app-server/thread-settings"; import type { RequestedServiceTier } from "./effective-settings"; -import { modelOverrideMessage, reasoningEffortOverrideMessage } from "../turns/runtime-overrides"; -import type { ChatAction, ChatState, ChatStateStore } from "../chat-state"; +import { modelOverrideMessage, reasoningEffortOverrideMessage } from "../conversation/turns/runtime-overrides"; +import type { ChatAction, ChatState, ChatStateStore } from "../state/reducer"; const COLLABORATION_MODE_WARNING_MESSAGES: Record = { "missing-model": "No effective model is available. Sending without a mode override.", diff --git a/src/features/chat/chat-state-actions.ts b/src/features/chat/state/actions.ts similarity index 90% rename from src/features/chat/chat-state-actions.ts rename to src/features/chat/state/actions.ts index b3143046..d9eeab6a 100644 --- a/src/features/chat/chat-state-actions.ts +++ b/src/features/chat/state/actions.ts @@ -1,12 +1,12 @@ -import type { AppServerInitialization } from "../../app-server/initialization"; -import type { Thread } from "../../domain/threads/model"; -import type { ThreadTokenUsage } from "../../app-server/runtime-metrics"; -import { parseServiceTier, type ServiceTier } from "../../app-server/runtime-policy"; -import type { ReasoningEffort } from "../../domain/catalog/metadata"; -import type { ChatRuntimeState } from "./runtime/state"; -import type { CollaborationMode } from "./runtime/turn-settings"; -import type { DisplayItem } from "./display/types"; -import type { PendingTurnStart } from "./turns/turn-state"; +import type { AppServerInitialization } from "../../../app-server/initialization"; +import type { Thread } from "../../../domain/threads/model"; +import type { ThreadTokenUsage } from "../../../app-server/runtime-metrics"; +import { parseServiceTier, type ServiceTier } from "../../../app-server/runtime-policy"; +import type { ReasoningEffort } from "../../../domain/catalog/metadata"; +import type { ChatRuntimeState } from "../runtime/state"; +import type { CollaborationMode } from "../runtime/turn-settings"; +import type { DisplayItem } from "../display/types"; +import type { PendingTurnStart } from "../conversation/turns/turn-state"; export interface ActiveThreadResumedAction { type: "active-thread/resumed"; diff --git a/src/features/chat/chat-state.ts b/src/features/chat/state/reducer.ts similarity index 94% rename from src/features/chat/chat-state.ts rename to src/features/chat/state/reducer.ts index 353cb1c5..d08d99b3 100644 --- a/src/features/chat/chat-state.ts +++ b/src/features/chat/state/reducer.ts @@ -1,15 +1,15 @@ -import type { AppServerInitialization } from "../../app-server/initialization"; -import type { ReasoningEffort } from "../../domain/catalog/metadata"; -import type { Thread } from "../../domain/threads/model"; -import type { ModelMetadata, SkillMetadata } from "../../domain/catalog/metadata"; -import type { ThreadGoal } from "../../app-server/thread-goal"; -import type { ThreadSettingsUpdate } from "../../app-server/thread-settings"; -import type { ApprovalsReviewer } from "../../app-server/runtime-policy"; -import type { Diagnostics } from "../../app-server/diagnostics"; -import { createAppServerDiagnostics } from "../../app-server/diagnostics"; -import type { RuntimeConfigSnapshot } from "../../app-server/runtime-config"; -import type { RateLimitSnapshot, ThreadTokenUsage } from "../../app-server/runtime-metrics"; -import type { CollaborationMode } from "./runtime/turn-settings"; +import type { AppServerInitialization } from "../../../app-server/initialization"; +import type { ReasoningEffort } from "../../../domain/catalog/metadata"; +import type { Thread } from "../../../domain/threads/model"; +import type { ModelMetadata, SkillMetadata } from "../../../domain/catalog/metadata"; +import type { ThreadGoal } from "../../../app-server/thread-goal"; +import type { ThreadSettingsUpdate } from "../../../app-server/thread-settings"; +import type { ApprovalsReviewer } from "../../../app-server/runtime-policy"; +import type { Diagnostics } from "../../../app-server/diagnostics"; +import { createAppServerDiagnostics } from "../../../app-server/diagnostics"; +import type { RuntimeConfigSnapshot } from "../../../app-server/runtime-config"; +import type { RateLimitSnapshot, ThreadTokenUsage } from "../../../app-server/runtime-metrics"; +import type { CollaborationMode } from "../runtime/turn-settings"; import { commitPendingThreadSettingsRuntimeState, initialActiveChatRuntimeState, @@ -20,12 +20,12 @@ import { setRequestedServiceTierRuntimeState, setSelectedCollaborationModeRuntimeState, type ChatRuntimeState, -} from "./runtime/state"; -import type { RequestedServiceTier } from "./runtime/effective-settings"; -import type { PendingApproval } from "./requests/approval"; -import type { ComposerSuggestion } from "./composer/suggestions"; -import { upsertDisplayItem } from "./display/stream-updates"; -import type { DisplayItem } from "./display/types"; +} from "../runtime/state"; +import type { RequestedServiceTier } from "../runtime/effective-settings"; +import type { PendingApproval } from "../protocol/requests/approval"; +import type { ComposerSuggestion } from "../conversation/composer/suggestions"; +import { upsertDisplayItem } from "../display/stream-updates"; +import type { DisplayItem } from "../display/types"; import type { ActiveThreadResumedAction, ActiveThreadRestoredPlaceholderAction, @@ -44,16 +44,21 @@ import type { TurnStartAcknowledgedAction, TurnStartFailedAction, UserInputDraftSetAction, -} from "./chat-state-actions"; -import { initialChatTranscriptState, reduceTranscriptSlice, type ChatTranscriptState, type TranscriptAction } from "./transcript-state"; +} from "./actions"; +import { initialChatTranscriptState, reduceTranscriptSlice, type ChatTranscriptState, type TranscriptAction } from "./transcript"; import { initialChatRequestState, reduceRequestSlice, resolveChatRequest, type ChatRequestState, type RequestAction, -} from "./requests/request-state"; -import { initialChatTurnState, transitionChatTurnLifecycleState, type ChatTurnState, type PendingTurnStart } from "./turns/turn-state"; +} from "../pending-requests/state"; +import { + initialChatTurnState, + transitionChatTurnLifecycleState, + type ChatTurnState, + type PendingTurnStart, +} from "../conversation/turns/turn-state"; export { activeTurnId, @@ -63,8 +68,8 @@ export { type ChatTurnLifecycleState, type ChatTurnState, type PendingTurnStart, -} from "./turns/turn-state"; -export type { ChatTranscriptState } from "./transcript-state"; +} from "../conversation/turns/turn-state"; +export type { ChatTranscriptState } from "./transcript"; interface ChatConnectionState { status: string; @@ -88,7 +93,7 @@ export interface ChatActiveThreadState { tokenUsage: ThreadTokenUsage | null; } -export type { ChatRuntimeState } from "./runtime/state"; +export type { ChatRuntimeState } from "../runtime/state"; interface ChatComposerState { draft: string; diff --git a/src/features/chat/chat-state-selectors.ts b/src/features/chat/state/selectors.ts similarity index 80% rename from src/features/chat/chat-state-selectors.ts rename to src/features/chat/state/selectors.ts index a2943b52..6d7dc49e 100644 --- a/src/features/chat/chat-state-selectors.ts +++ b/src/features/chat/state/selectors.ts @@ -1,10 +1,10 @@ -import { activeTurnId as selectActiveTurnId, chatTurnBusy, pendingTurnStart } from "./chat-state"; -import type { ChatState, PendingTurnStart } from "./chat-state"; -import type { Thread } from "../../domain/threads/model"; -import type { PendingApproval } from "./requests/approval"; -import type { PendingUserInput } from "./requests/user-input"; -import type { DisplayItem } from "./display/types"; -import { implementPlanCandidateFromState } from "./display/action-candidates"; +import { activeTurnId as selectActiveTurnId, chatTurnBusy, pendingTurnStart } from "./reducer"; +import type { ChatState, PendingTurnStart } from "./reducer"; +import type { Thread } from "../../../domain/threads/model"; +import type { PendingApproval } from "../protocol/requests/approval"; +import type { PendingUserInput } from "../protocol/requests/user-input"; +import type { DisplayItem } from "../display/types"; +import { implementPlanCandidateFromState } from "../display/action-candidates"; export interface PendingRequestSnapshot { approvals: readonly PendingApproval[]; diff --git a/src/features/chat/transcript-state.ts b/src/features/chat/state/transcript.ts similarity index 96% rename from src/features/chat/transcript-state.ts rename to src/features/chat/state/transcript.ts index 480301c4..00efb3c6 100644 --- a/src/features/chat/transcript-state.ts +++ b/src/features/chat/state/transcript.ts @@ -1,5 +1,5 @@ -import { upsertDisplayItem } from "./display/stream-updates"; -import type { DisplayItem } from "./display/types"; +import { upsertDisplayItem } from "../display/stream-updates"; +import type { DisplayItem } from "../display/types"; export interface ChatTranscriptState { displayItems: readonly DisplayItem[]; diff --git a/src/features/chat/threads/composition.ts b/src/features/chat/threads/composition.ts index f727bfb2..cd696cd8 100644 --- a/src/features/chat/threads/composition.ts +++ b/src/features/chat/threads/composition.ts @@ -11,7 +11,7 @@ import { ThreadResumeController } from "./thread-resume-controller"; import { createThreadSelectionActions } from "./thread-selection-controller"; import { RestoredThreadController } from "./restored-thread-controller"; import type { ToolbarPanelController } from "../panel/toolbar-controller"; -import type { ChatStateStore } from "../chat-state"; +import type { ChatStateStore } from "../state/reducer"; import type { CodexChatHost } from "../chat-host"; import type { ChatResumeWorkTracker, ChatViewDeferredTasks } from "../panel/lifecycle"; diff --git a/src/features/chat/threads/restored-thread-controller.ts b/src/features/chat/threads/restored-thread-controller.ts index 328a085b..c4f1ee09 100644 --- a/src/features/chat/threads/restored-thread-controller.ts +++ b/src/features/chat/threads/restored-thread-controller.ts @@ -1,5 +1,5 @@ -import { restoreThreadPlaceholderAction } from "../chat-state-actions"; -import type { ChatStateStore } from "../chat-state"; +import { restoreThreadPlaceholderAction } from "../state/actions"; +import type { ChatStateStore } from "../state/reducer"; import { transitionRestoredThreadLifecycle, type RestoredThreadLifecycleState, diff --git a/src/features/chat/threads/thread-actions.ts b/src/features/chat/threads/thread-actions.ts index c3bee5aa..50a57037 100644 --- a/src/features/chat/threads/thread-actions.ts +++ b/src/features/chat/threads/thread-actions.ts @@ -7,9 +7,9 @@ import { exportArchivedThreadMarkdown } from "../../../domain/threads/export"; import type { ArchiveExportAdapter } from "../../../domain/threads/export"; import { inheritedForkThreadName } from "../../../domain/threads/model"; import type { CodexPanelSettings } from "../../../settings/model"; -import { chatTurnBusy, type ChatAction, type ChatState, type ChatStateStore } from "../chat-state"; +import { chatTurnBusy, type ChatAction, type ChatState, type ChatStateStore } from "../state/reducer"; import { rollbackCandidateFromItems, turnsAfterTurnId } from "../display/action-candidates"; -import { displayItemsFromTurns } from "../display/thread-items"; +import { displayItemsFromTurns } from "../protocol/display-items"; import { resumedThreadActionFromActiveRuntime } from "./thread-resume"; export interface ChatThreadActionsHost { diff --git a/src/features/chat/threads/thread-goal-actions.ts b/src/features/chat/threads/thread-goal-actions.ts index a24aa78e..14229124 100644 --- a/src/features/chat/threads/thread-goal-actions.ts +++ b/src/features/chat/threads/thread-goal-actions.ts @@ -6,7 +6,7 @@ import { type ThreadGoalUpdate, } from "../../../app-server/thread-goal"; import type { JsonValue } from "../../../generated/app-server/serde_json/JsonValue"; -import type { ChatStateStore } from "../chat-state"; +import type { ChatStateStore } from "../state/reducer"; import type { GoalDisplayItem } from "../display/types"; import { goalChangeItem } from "../display/goal-messages"; diff --git a/src/features/chat/threads/thread-history-controller.ts b/src/features/chat/threads/thread-history-controller.ts index bac03685..ba6fef74 100644 --- a/src/features/chat/threads/thread-history-controller.ts +++ b/src/features/chat/threads/thread-history-controller.ts @@ -1,7 +1,7 @@ import type { AppServerClient } from "../../../app-server/client"; import type { ThreadTurnsPage } from "../../../app-server/turn-history"; -import type { ChatAction, ChatState, ChatStateStore } from "../chat-state"; -import { displayItemsFromTurns } from "../display/thread-items"; +import type { ChatAction, ChatState, ChatStateStore } from "../state/reducer"; +import { displayItemsFromTurns } from "../protocol/display-items"; export interface ThreadHistoryControllerHost { stateStore: ChatStateStore; diff --git a/src/features/chat/threads/thread-identity-actions.ts b/src/features/chat/threads/thread-identity-actions.ts index 2b274d48..aa603512 100644 --- a/src/features/chat/threads/thread-identity-actions.ts +++ b/src/features/chat/threads/thread-identity-actions.ts @@ -1,7 +1,7 @@ import type { RestoredThreadController } from "./restored-thread-controller"; -import { applyThreadListAction, clearActiveThreadAction } from "../chat-state-actions"; -import { activeThreadId, listedThreads } from "../chat-state-selectors"; -import type { ChatStateStore } from "../chat-state"; +import { applyThreadListAction, clearActiveThreadAction } from "../state/actions"; +import { activeThreadId, listedThreads } from "../state/selectors"; +import type { ChatStateStore } from "../state/reducer"; export interface ThreadIdentityActionsHost { stateStore: ChatStateStore; diff --git a/src/features/chat/threads/thread-rename-controller.ts b/src/features/chat/threads/thread-rename-controller.ts index 679e68d2..4318f501 100644 --- a/src/features/chat/threads/thread-rename-controller.ts +++ b/src/features/chat/threads/thread-rename-controller.ts @@ -9,7 +9,7 @@ import { import type { Thread } from "../../../domain/threads/model"; import type { Turn } from "../../../generated/app-server/v2/Turn"; import type { CodexPanelSettings } from "../../../settings/model"; -import type { ChatAction, ChatState, ChatStateStore } from "../chat-state"; +import type { ChatAction, ChatState, ChatStateStore } from "../state/reducer"; import { generateThreadTitleWithCodex } from "../../../app-server/thread-title-generation"; import { completedConversationSummaryFromAppServerTurn } from "../../../app-server/turn-model"; import { firstNamingContextFromDisplayItems, namingContextFromDisplayItems } from "./thread-naming"; diff --git a/src/features/chat/threads/thread-resume-controller.ts b/src/features/chat/threads/thread-resume-controller.ts index 42e217bf..4402418c 100644 --- a/src/features/chat/threads/thread-resume-controller.ts +++ b/src/features/chat/threads/thread-resume-controller.ts @@ -1,8 +1,8 @@ import type { AppServerClient } from "../../../app-server/client"; import type { ThreadTokenUsage } from "../../../app-server/runtime-metrics"; -import { setActiveThreadTokenUsageAction } from "../chat-state-actions"; -import { activeThreadId, canSwitchToThread, displayItemsEmpty, listedThreads } from "../chat-state-selectors"; -import type { ChatStateStore } from "../chat-state"; +import { setActiveThreadTokenUsageAction } from "../state/actions"; +import { activeThreadId, canSwitchToThread, displayItemsEmpty, listedThreads } from "../state/selectors"; +import type { ChatStateStore } from "../state/reducer"; import type { RestoredThreadController } from "./restored-thread-controller"; import { resumedThreadActionFromAppServerResponse } from "./thread-resume"; import type { ThreadHistoryController } from "./thread-history-controller"; diff --git a/src/features/chat/threads/thread-resume.ts b/src/features/chat/threads/thread-resume.ts index ad040c2f..a99eff27 100644 --- a/src/features/chat/threads/thread-resume.ts +++ b/src/features/chat/threads/thread-resume.ts @@ -7,7 +7,7 @@ import type { ThreadStartResponse } from "../../../generated/app-server/v2/Threa import type { ThreadResumeResponse } from "../../../generated/app-server/v2/ThreadResumeResponse"; import type { ChatRuntimeState } from "../runtime/state"; import type { DisplayItem } from "../display/types"; -import type { ActiveThreadResumedAction } from "../chat-state-actions"; +import type { ActiveThreadResumedAction } from "../state/actions"; interface ThreadActivationResponse { thread: Thread; diff --git a/src/features/chat/threads/thread-selection-controller.ts b/src/features/chat/threads/thread-selection-controller.ts index ce067ddf..06ebef1b 100644 --- a/src/features/chat/threads/thread-selection-controller.ts +++ b/src/features/chat/threads/thread-selection-controller.ts @@ -1,6 +1,6 @@ -import { closePanelsAction } from "../chat-state-actions"; -import { canSwitchToThread } from "../chat-state-selectors"; -import type { ChatStateStore } from "../chat-state"; +import { closePanelsAction } from "../state/actions"; +import { canSwitchToThread } from "../state/selectors"; +import type { ChatStateStore } from "../state/reducer"; export interface ThreadSelectionControllerHost { stateStore: ChatStateStore; diff --git a/src/features/chat/ui/composer.tsx b/src/features/chat/ui/composer.tsx index cb357a9f..6fa165ae 100644 --- a/src/features/chat/ui/composer.tsx +++ b/src/features/chat/ui/composer.tsx @@ -2,8 +2,8 @@ import { setIcon } from "obsidian"; import type { ButtonHTMLAttributes, ComponentChild as UiNode, Ref } from "preact"; import { useLayoutEffect, useRef, useState } from "preact/hooks"; -import type { ComposerSuggestion } from "../composer/suggestions"; -import type { ComposerMetaViewModel, RuntimeChoice } from "../panel/model"; +import type { ComposerSuggestion } from "../conversation/composer/suggestions"; +import type { ComposerMetaViewModel, RuntimeChoice } from "../panel/view-model"; import { IconButton } from "../../../shared/ui/components"; import { syncTextareaHeight } from "../../../shared/ui/textarea-autogrow"; diff --git a/src/features/chat/ui/message-stream/blocks.tsx b/src/features/chat/ui/message-stream/blocks.tsx index f1d9a197..2381fd5c 100644 --- a/src/features/chat/ui/message-stream/blocks.tsx +++ b/src/features/chat/ui/message-stream/blocks.tsx @@ -1,11 +1,11 @@ import { Fragment, type ComponentChild as UiNode } from "preact"; import { useLayoutEffect, useState } from "preact/hooks"; -import { activeTurnId } from "../../chat-state"; +import { activeTurnId } from "../../state/reducer"; import { displayBlocksForItems } from "../../display/blocks"; import type { ToolResultDisplayItem } from "../../display/tool-view"; import type { DisplayBlock, DisplayItem } from "../../display/types"; -import { userInputDraftKey, userInputOtherDraftKey } from "../../requests/user-input"; +import { userInputDraftKey, userInputOtherDraftKey } from "../../protocol/requests/user-input"; import { pendingRequestMessageNode } from "../pending-request-message"; import { toolResultNode } from "../tool-result"; import { activeAgentRunSummaryBlock, agentRunSummaryNode, workItemNode, type WorkItemDisplayItem } from "../work-items"; diff --git a/src/features/chat/ui/message-stream/context-builder.ts b/src/features/chat/ui/message-stream/context-builder.ts index e625fd31..81e94519 100644 --- a/src/features/chat/ui/message-stream/context-builder.ts +++ b/src/features/chat/ui/message-stream/context-builder.ts @@ -1,6 +1,6 @@ -import type { ChatState } from "../../chat-state"; -import type { PendingRequestSnapshot } from "../../chat-state-selectors"; -import { chatTurnBusy } from "../../chat-state"; +import type { ChatState } from "../../state/reducer"; +import type { PendingRequestSnapshot } from "../../state/selectors"; +import { chatTurnBusy } from "../../state/reducer"; import type { DisplayItem } from "../../display/types"; import { forkCandidatesFromItems, diff --git a/src/features/chat/ui/message-stream/context-port.ts b/src/features/chat/ui/message-stream/context-port.ts index 249e53b9..6925c016 100644 --- a/src/features/chat/ui/message-stream/context-port.ts +++ b/src/features/chat/ui/message-stream/context-port.ts @@ -1,4 +1,4 @@ -import type { ChatAction, ChatState } from "../../chat-state"; +import type { ChatAction, ChatState } from "../../state/reducer"; import type { ChatMessageStreamActionPort, ChatMessageStreamContextPort, ChatMessageStreamRequestPort } from "./context-builder"; export interface MessageStreamContextPortOptions { diff --git a/src/features/chat/ui/message-stream/context.ts b/src/features/chat/ui/message-stream/context.ts index 06c9cf5e..9fb17023 100644 --- a/src/features/chat/ui/message-stream/context.ts +++ b/src/features/chat/ui/message-stream/context.ts @@ -1,7 +1,7 @@ import type { ComponentChild as UiNode } from "preact"; -import type { ChatTurnLifecycleState } from "../../chat-state"; -import type { PendingRequestSnapshot } from "../../chat-state-selectors"; +import type { ChatTurnLifecycleState } from "../../state/reducer"; +import type { PendingRequestSnapshot } from "../../state/selectors"; import type { DisplayItem } from "../../display/types"; import type { PendingRequestMessageActions } from "../pending-request-message"; import type { ChatTurnDiffViewState } from "../turn-diff"; diff --git a/src/features/chat/ui/message-stream/message-actions.tsx b/src/features/chat/ui/message-stream/message-actions.tsx index 2f4bd394..7fb5c0b8 100644 --- a/src/features/chat/ui/message-stream/message-actions.tsx +++ b/src/features/chat/ui/message-stream/message-actions.tsx @@ -1,7 +1,7 @@ import { type ComponentChild as UiNode } from "preact"; import { useEffect, useRef } from "preact/hooks"; -import { activeTurnId } from "../../chat-state"; +import { activeTurnId } from "../../state/reducer"; import type { DisplayItem } from "../../display/types"; import { IconButton } from "../../../../shared/ui/components"; import type { MessageActionContext, RenderableTextItem } from "./context"; diff --git a/src/features/chat/ui/message-stream/render-state.ts b/src/features/chat/ui/message-stream/render-state.ts index 15ed464a..eaa9ba16 100644 --- a/src/features/chat/ui/message-stream/render-state.ts +++ b/src/features/chat/ui/message-stream/render-state.ts @@ -1,4 +1,4 @@ -import type { ChatState } from "../../chat-state"; +import type { ChatState } from "../../state/reducer"; import type { MessageStreamScrollIntent, MessageStreamVirtualizerHandle } from "../message-virtualizer"; import { messageStreamBlocks } from "./blocks"; import { createMessageStreamContext, type ChatMessageStreamContextPort } from "./context-builder"; diff --git a/src/features/chat/ui/message-stream/renderer.ts b/src/features/chat/ui/message-stream/renderer.ts index 40cae456..92c3c53a 100644 --- a/src/features/chat/ui/message-stream/renderer.ts +++ b/src/features/chat/ui/message-stream/renderer.ts @@ -2,8 +2,8 @@ import type { App, Component } from "obsidian"; import type { ComponentChild as UiNode } from "preact"; import { copyTextWithNotice } from "../../../../shared/ui/clipboard"; -import type { ChatAction, ChatState, ChatStateStore } from "../../chat-state"; -import type { ComposerBoundaryScrollAction } from "../../composer/boundary-scroll"; +import type { ChatAction, ChatState, ChatStateStore } from "../../state/reducer"; +import type { ComposerBoundaryScrollAction } from "../../conversation/composer/boundary-scroll"; import type { MessageStreamScrollIntent, MessageStreamVirtualizerHandle } from "../message-virtualizer"; import type { ChatMessageStreamActionPort, ChatMessageStreamContextPort, ChatMessageStreamRequestPort } from "./context-builder"; import { createMessageStreamContextPort } from "./context-port"; diff --git a/src/features/chat/ui/pending-request-message.tsx b/src/features/chat/ui/pending-request-message.tsx index 4be47eb1..9cb4467c 100644 --- a/src/features/chat/ui/pending-request-message.tsx +++ b/src/features/chat/ui/pending-request-message.tsx @@ -8,9 +8,9 @@ import { approvalTitle, type ApprovalAction, type PendingApproval, -} from "../requests/approval"; -import type { PendingUserInput } from "../requests/user-input"; -import { questionDefaultAnswer } from "../requests/user-input"; +} from "../protocol/requests/approval"; +import type { PendingUserInput } from "../protocol/requests/user-input"; +import { questionDefaultAnswer } from "../protocol/requests/user-input"; import { createWorkMessageClassName } from "./work-message"; type PendingUserInputRequestId = PendingUserInput["requestId"]; diff --git a/src/features/chat/ui/region-view-models.ts b/src/features/chat/ui/region-view-models.ts index e638ceef..07f6d68e 100644 --- a/src/features/chat/ui/region-view-models.ts +++ b/src/features/chat/ui/region-view-models.ts @@ -1,12 +1,12 @@ -import type { ChatState } from "../chat-state"; -import { pendingRequestsSignature as requestStateSignature } from "../requests/view-model"; +import type { ChatState } from "../state/reducer"; +import { pendingRequestsSignature as requestStateSignature } from "../pending-requests/view-model"; import { activeComposerThreadName as buildActiveComposerThreadName, composerMetaViewModel as buildComposerMetaViewModel, composerPlaceholder as buildComposerPlaceholder, runtimeComposerChoices, toolbarViewModel as buildToolbarViewModel, -} from "../panel/model"; +} from "../panel/view-model"; import type { GoalBannerActions, GoalBannerOptions } from "./goal-banner"; import type { ChatPanelComposerPorts, ChatPanelGoalPorts, ChatPanelMessagesPorts, ChatPanelToolbarPorts } from "../panel/ui-ports"; import type { ChatPanelShellState } from "./shell"; diff --git a/src/features/chat/ui/shell.tsx b/src/features/chat/ui/shell.tsx index 715e85da..48f378a0 100644 --- a/src/features/chat/ui/shell.tsx +++ b/src/features/chat/ui/shell.tsx @@ -2,7 +2,7 @@ import { createContext, type ComponentChild as UiNode } from "preact"; import { useContext } from "preact/hooks"; import { signal, type Signal } from "@preact/signals"; import { renderUiRoot, unmountUiRoot } from "../../../shared/ui/ui-root"; -import type { ChatState, ChatStateStore } from "../chat-state"; +import type { ChatState, ChatStateStore } from "../state/reducer"; export interface ChatPanelShellState { connection: Signal; diff --git a/src/features/chat/ui/toolbar.tsx b/src/features/chat/ui/toolbar.tsx index c949b04d..527e36a1 100644 --- a/src/features/chat/ui/toolbar.tsx +++ b/src/features/chat/ui/toolbar.tsx @@ -3,7 +3,7 @@ import { useLayoutEffect, useRef } from "preact/hooks"; import type { RuntimeConfigSection, RateLimitSummary } from "../runtime/status-summary"; import { IconButton } from "../../../shared/ui/components"; -import type { ToolbarDiagnosticSection, ToolbarThreadRow, ToolbarViewModel } from "../panel/model/types"; +import type { ToolbarDiagnosticSection, ToolbarThreadRow, ToolbarViewModel } from "../panel/view-model/types"; type ButtonProps = ButtonHTMLAttributes & { disabled?: boolean | undefined; diff --git a/src/features/chat/ui/work-items.tsx b/src/features/chat/ui/work-items.tsx index b4607ff0..ab02bfcd 100644 --- a/src/features/chat/ui/work-items.tsx +++ b/src/features/chat/ui/work-items.tsx @@ -13,7 +13,7 @@ import type { TaskProgressDisplayItem, } from "../display/types"; import { agentActivityMetaLabel, agentMessagePreview, agentRunSummaryLabel, taskStatusMarker } from "../display/labels"; -import { activeTurnId, type ChatTurnLifecycleState } from "../chat-state"; +import { activeTurnId, type ChatTurnLifecycleState } from "../state/reducer"; import { createWorkMessageClassName } from "./work-message"; import { shortThreadId, truncate } from "../../../utils"; diff --git a/src/features/chat/view.ts b/src/features/chat/view.ts index e8ba2546..72f43d7f 100644 --- a/src/features/chat/view.ts +++ b/src/features/chat/view.ts @@ -8,7 +8,7 @@ import type { ModelMetadata } from "../../domain/catalog/metadata"; import type { Thread } from "../../domain/threads/model"; import { collaborationModeLabel as formatCollaborationModeLabel } from "./runtime/turn-settings"; import type { RuntimeSnapshot } from "./runtime/effective-settings"; -import { chatTurnBusy, createChatStateStore, type ChatState, type ChatAction } from "./chat-state"; +import { chatTurnBusy, createChatStateStore, type ChatState, type ChatAction } from "./state/reducer"; import type { OpenCodexPanelSnapshot } from "../../workspace/open-panel-snapshot"; import type { SharedAppServerMetadata } from "../../app-server/shared-cache-state"; import type { CodexChatHost } from "./chat-host"; @@ -21,7 +21,7 @@ import { modelStatusLines as buildModelStatusLines, runtimeSnapshotForChatSlices, statusSummaryLines as buildStatusSummaryLines, -} from "./panel/model"; +} from "./panel/view-model"; import { openPanelTurnLifecycle } from "./panel/snapshot"; import { ChatConnectionWorkTracker, ChatResumeWorkTracker, ChatViewDeferredTasks } from "./panel/lifecycle"; import { ChatMessageScrollIntentController } from "./panel/message-scroll-intent-controller"; diff --git a/tests/features/chat/session/app-server-warmup-controller.test.ts b/tests/features/chat/connection/app-server-warmup-controller.test.ts similarity index 97% rename from tests/features/chat/session/app-server-warmup-controller.test.ts rename to tests/features/chat/connection/app-server-warmup-controller.test.ts index d9e2f794..7d9e4e57 100644 --- a/tests/features/chat/session/app-server-warmup-controller.test.ts +++ b/tests/features/chat/connection/app-server-warmup-controller.test.ts @@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; -import { scheduleAppServerWarmup } from "../../../../src/features/chat/session/app-server-warmup-controller"; +import { scheduleAppServerWarmup } from "../../../../src/features/chat/connection/app-server-warmup-controller"; import { ChatViewDeferredTasks } from "../../../../src/features/chat/panel/lifecycle"; function createController({ diff --git a/tests/features/chat/session/connection-controller.test.ts b/tests/features/chat/connection/connection-controller.test.ts similarity index 98% rename from tests/features/chat/session/connection-controller.test.ts rename to tests/features/chat/connection/connection-controller.test.ts index a2ba2e61..f2b69d4d 100644 --- a/tests/features/chat/session/connection-controller.test.ts +++ b/tests/features/chat/connection/connection-controller.test.ts @@ -2,13 +2,13 @@ import { describe, expect, it, vi } from "vitest"; import type { AppServerClient } from "../../../../src/app-server/client"; import { emptyRuntimeConfigSnapshot } from "../../../../src/app-server/runtime-config"; -import { createChatState, createChatStateStore } from "../../../../src/features/chat/chat-state"; +import { createChatState, createChatStateStore } from "../../../../src/features/chat/state/reducer"; import { ChatConnectionController, type ChatConnectionAdapter, type ChatConnectionDiagnosticsPort, type ChatConnectionMetadataPort, -} from "../../../../src/features/chat/session/connection-controller"; +} from "../../../../src/features/chat/connection/connection-controller"; import { ChatConnectionWorkTracker } from "../../../../src/features/chat/panel/lifecycle"; function createController({ connected = false, client = {} as AppServerClient } = {}) { diff --git a/tests/features/chat/session/reconnect-actions.test.ts b/tests/features/chat/connection/reconnect-actions.test.ts similarity index 95% rename from tests/features/chat/session/reconnect-actions.test.ts rename to tests/features/chat/connection/reconnect-actions.test.ts index a73ac62a..f4699883 100644 --- a/tests/features/chat/session/reconnect-actions.test.ts +++ b/tests/features/chat/connection/reconnect-actions.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from "vitest"; -import { createChatState, createChatStateStore } from "../../../../src/features/chat/chat-state"; -import { createChatReconnectActions, type ChatReconnectActionsHost } from "../../../../src/features/chat/session/reconnect-actions"; +import { createChatState, createChatStateStore } from "../../../../src/features/chat/state/reducer"; +import { createChatReconnectActions, type ChatReconnectActionsHost } from "../../../../src/features/chat/connection/reconnect-actions"; function createHost(overrides: Partial = {}) { const stateStore = createChatStateStore(createChatState()); diff --git a/tests/features/chat/composer/boundary-scroll.test.ts b/tests/features/chat/conversation/composer/boundary-scroll.test.ts similarity index 95% rename from tests/features/chat/composer/boundary-scroll.test.ts rename to tests/features/chat/conversation/composer/boundary-scroll.test.ts index 92c67cad..c298b94b 100644 --- a/tests/features/chat/composer/boundary-scroll.test.ts +++ b/tests/features/chat/conversation/composer/boundary-scroll.test.ts @@ -1,6 +1,9 @@ import { describe, expect, it, vi } from "vitest"; -import { composerBoundaryScrollDirection, type ComposerBoundaryScrollAction } from "../../../../src/features/chat/composer/boundary-scroll"; +import { + composerBoundaryScrollDirection, + type ComposerBoundaryScrollAction, +} from "../../../../../src/features/chat/conversation/composer/boundary-scroll"; describe("composer boundary scroll shortcuts", () => { it("scrolls up from the first composer line", () => { diff --git a/tests/features/chat/composer/composer-keys.test.ts b/tests/features/chat/conversation/composer/composer-keys.test.ts similarity index 96% rename from tests/features/chat/composer/composer-keys.test.ts rename to tests/features/chat/conversation/composer/composer-keys.test.ts index 1112ebd6..c7aa4723 100644 --- a/tests/features/chat/composer/composer-keys.test.ts +++ b/tests/features/chat/conversation/composer/composer-keys.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "vitest"; -import { isComposerSendKey, type ComposerSendKeyEvent } from "../../../../src/shared/ui/keyboard"; +import { isComposerSendKey, type ComposerSendKeyEvent } from "../../../../../src/shared/ui/keyboard"; const baseEvent: ComposerSendKeyEvent = { key: "Enter", diff --git a/tests/features/chat/composer/composer-suggestions.test.ts b/tests/features/chat/conversation/composer/composer-suggestions.test.ts similarity index 97% rename from tests/features/chat/composer/composer-suggestions.test.ts rename to tests/features/chat/conversation/composer/composer-suggestions.test.ts index 1660e314..953d21fb 100644 --- a/tests/features/chat/composer/composer-suggestions.test.ts +++ b/tests/features/chat/conversation/composer/composer-suggestions.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it } from "vitest"; -import type { ReasoningEffort } from "../../../../src/generated/app-server/ReasoningEffort"; -import type { Thread } from "../../../../src/generated/app-server/v2/Thread"; -import type { ModelMetadata } from "../../../../src/domain/catalog/metadata"; +import type { ReasoningEffort } from "../../../../../src/generated/app-server/ReasoningEffort"; +import type { Thread } from "../../../../../src/generated/app-server/v2/Thread"; +import type { ModelMetadata } from "../../../../../src/domain/catalog/metadata"; import { activeComposerSuggestions, applyComposerSuggestionInsertion, @@ -11,8 +11,8 @@ import { findWikiLinkSuggestions, nextComposerSuggestionIndex, parseSlashCommand, -} from "../../../../src/features/chat/composer/suggestions"; -import { userInputWithWikiLinkMentions } from "../../../../src/features/chat/composer/wikilink-context"; +} from "../../../../../src/features/chat/conversation/composer/suggestions"; +import { userInputWithWikiLinkMentions } from "../../../../../src/features/chat/conversation/composer/wikilink-context"; function expectPresent(value: T | null | undefined): T { if (value === null || value === undefined) throw new Error("Expected value to be present"); diff --git a/tests/features/chat/composer/controller.test.ts b/tests/features/chat/conversation/composer/controller.test.ts similarity index 96% rename from tests/features/chat/composer/controller.test.ts rename to tests/features/chat/conversation/composer/controller.test.ts index 187adc0d..2f52f196 100644 --- a/tests/features/chat/composer/controller.test.ts +++ b/tests/features/chat/conversation/composer/controller.test.ts @@ -3,11 +3,11 @@ import type { App } from "obsidian"; import { describe, expect, it, vi } from "vitest"; -import { ChatComposerController } from "../../../../src/features/chat/composer/controller"; -import { createChatStateStore } from "../../../../src/features/chat/chat-state"; -import { renderUiRoot, unmountUiRoot } from "../../../../src/shared/ui/ui-root"; -import type { SkillMetadata } from "../../../../src/generated/app-server/v2/SkillMetadata"; -import { installObsidianDomShims } from "../../../support/dom"; +import { ChatComposerController } from "../../../../../src/features/chat/conversation/composer/controller"; +import { createChatStateStore } from "../../../../../src/features/chat/state/reducer"; +import { renderUiRoot, unmountUiRoot } from "../../../../../src/shared/ui/ui-root"; +import type { SkillMetadata } from "../../../../../src/generated/app-server/v2/SkillMetadata"; +import { installObsidianDomShims } from "../../../../support/dom"; installObsidianDomShims(); diff --git a/tests/features/chat/composer/obsidian-context.test.ts b/tests/features/chat/conversation/composer/obsidian-context.test.ts similarity index 99% rename from tests/features/chat/composer/obsidian-context.test.ts rename to tests/features/chat/conversation/composer/obsidian-context.test.ts index f271e3ff..074ea037 100644 --- a/tests/features/chat/composer/obsidian-context.test.ts +++ b/tests/features/chat/conversation/composer/obsidian-context.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from "vitest"; import { TFile, type App } from "obsidian"; -import { noteCandidates, resolveWikiLinkMention } from "../../../../src/features/chat/composer/obsidian-context"; +import { noteCandidates, resolveWikiLinkMention } from "../../../../../src/features/chat/conversation/composer/obsidian-context"; describe("Obsidian composer context", () => { it("builds note candidates from markdown files", () => { diff --git a/tests/features/chat/composer/wikilink-context.test.ts b/tests/features/chat/conversation/composer/wikilink-context.test.ts similarity index 98% rename from tests/features/chat/composer/wikilink-context.test.ts rename to tests/features/chat/conversation/composer/wikilink-context.test.ts index 50c3bfa5..ca828bb1 100644 --- a/tests/features/chat/composer/wikilink-context.test.ts +++ b/tests/features/chat/conversation/composer/wikilink-context.test.ts @@ -5,7 +5,7 @@ import { parsedWikiLinks, userInputWithWikiLinkMentions, userInputWithWikiLinkMentionsAndSkills, -} from "../../../../src/features/chat/composer/wikilink-context"; +} from "../../../../../src/features/chat/conversation/composer/wikilink-context"; describe("wikilink context", () => { it("parses aliases, subpaths, and duplicate links", () => { diff --git a/tests/features/chat/turns/composer-submission-actions.test.ts b/tests/features/chat/conversation/turns/composer-submission-actions.test.ts similarity index 92% rename from tests/features/chat/turns/composer-submission-actions.test.ts rename to tests/features/chat/conversation/turns/composer-submission-actions.test.ts index 3db2ff3f..065444be 100644 --- a/tests/features/chat/turns/composer-submission-actions.test.ts +++ b/tests/features/chat/conversation/turns/composer-submission-actions.test.ts @@ -1,9 +1,9 @@ import { describe, expect, it, vi } from "vitest"; -import type { AppServerClient } from "../../../../src/app-server/client"; -import { createChatState, createChatStateStore } from "../../../../src/features/chat/chat-state"; -import { createComposerSubmissionActions } from "../../../../src/features/chat/turns/composer-submission-actions"; -import type { Thread } from "../../../../src/generated/app-server/v2/Thread"; +import type { AppServerClient } from "../../../../../src/app-server/client"; +import { createChatState, createChatStateStore } from "../../../../../src/features/chat/state/reducer"; +import { createComposerSubmissionActions } from "../../../../../src/features/chat/conversation/turns/composer-submission-actions"; +import type { Thread } from "../../../../../src/generated/app-server/v2/Thread"; function thread(id: string): Thread & { archived: boolean } { return { diff --git a/tests/features/chat/turns/plan-implementation-actions.test.ts b/tests/features/chat/conversation/turns/plan-implementation-actions.test.ts similarity index 88% rename from tests/features/chat/turns/plan-implementation-actions.test.ts rename to tests/features/chat/conversation/turns/plan-implementation-actions.test.ts index 754a85fd..4e30ed11 100644 --- a/tests/features/chat/turns/plan-implementation-actions.test.ts +++ b/tests/features/chat/conversation/turns/plan-implementation-actions.test.ts @@ -1,13 +1,13 @@ import { describe, expect, it, vi } from "vitest"; -import type { AppServerClient } from "../../../../src/app-server/client"; -import { createChatState, createChatStateStore, type ChatStateStore } from "../../../../src/features/chat/chat-state"; -import { implementPlanCandidateFromState } from "../../../../src/features/chat/display/action-candidates"; +import type { AppServerClient } from "../../../../../src/app-server/client"; +import { createChatState, createChatStateStore, type ChatStateStore } from "../../../../../src/features/chat/state/reducer"; +import { implementPlanCandidateFromState } from "../../../../../src/features/chat/display/action-candidates"; import { createPlanImplementationActions, type PlanImplementationActionsHost, -} from "../../../../src/features/chat/turns/plan-implementation-actions"; -import type { DisplayItem } from "../../../../src/features/chat/display/types"; +} from "../../../../../src/features/chat/conversation/turns/plan-implementation-actions"; +import type { DisplayItem } from "../../../../../src/features/chat/display/types"; const planItem = (id: string): DisplayItem => ({ id, diff --git a/tests/features/chat/turns/slash-command-actions.test.ts b/tests/features/chat/conversation/turns/slash-command-actions.test.ts similarity index 94% rename from tests/features/chat/turns/slash-command-actions.test.ts rename to tests/features/chat/conversation/turns/slash-command-actions.test.ts index a0381c53..54649f17 100644 --- a/tests/features/chat/turns/slash-command-actions.test.ts +++ b/tests/features/chat/conversation/turns/slash-command-actions.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it, vi } from "vitest"; -import type { AppServerClient } from "../../../../src/app-server/client"; -import type { CodexInput } from "../../../../src/app-server/request-input"; -import { createChatState, createChatStateStore } from "../../../../src/features/chat/chat-state"; +import type { AppServerClient } from "../../../../../src/app-server/client"; +import type { CodexInput } from "../../../../../src/app-server/request-input"; +import { createChatState, createChatStateStore } from "../../../../../src/features/chat/state/reducer"; import { createSlashCommandActions, type SlashCommandActionsHost, @@ -10,8 +10,8 @@ import { type SlashCommandRuntimePort, type SlashCommandStatusPort, type SlashCommandThreadPort, -} from "../../../../src/features/chat/turns/slash-command-actions"; -import type { Thread } from "../../../../src/generated/app-server/v2/Thread"; +} from "../../../../../src/features/chat/conversation/turns/slash-command-actions"; +import type { Thread } from "../../../../../src/generated/app-server/v2/Thread"; const textInput = (text: string): CodexInput => [{ type: "text", text }]; diff --git a/tests/features/chat/turns/slash-command-execution.test.ts b/tests/features/chat/conversation/turns/slash-command-execution.test.ts similarity index 98% rename from tests/features/chat/turns/slash-command-execution.test.ts rename to tests/features/chat/conversation/turns/slash-command-execution.test.ts index c367fdcd..affdd1f3 100644 --- a/tests/features/chat/turns/slash-command-execution.test.ts +++ b/tests/features/chat/conversation/turns/slash-command-execution.test.ts @@ -1,9 +1,12 @@ import { describe, expect, it, vi } from "vitest"; -import type { ThreadGoal } from "../../../../src/app-server/thread-goal"; -import { slashCommandHelpLines, slashCommandHelpSections } from "../../../../src/features/chat/composer/slash-commands"; -import type { Thread } from "../../../../src/generated/app-server/v2/Thread"; -import { executeSlashCommand, type SlashCommandExecutionContext } from "../../../../src/features/chat/turns/slash-command-execution"; +import type { ThreadGoal } from "../../../../../src/app-server/thread-goal"; +import { slashCommandHelpLines, slashCommandHelpSections } from "../../../../../src/features/chat/conversation/composer/slash-commands"; +import type { Thread } from "../../../../../src/generated/app-server/v2/Thread"; +import { + executeSlashCommand, + type SlashCommandExecutionContext, +} from "../../../../../src/features/chat/conversation/turns/slash-command-execution"; function context(overrides: Partial = {}): SlashCommandExecutionContext { return { diff --git a/tests/features/chat/turns/turn-submission-controller.test.ts b/tests/features/chat/conversation/turns/turn-submission-controller.test.ts similarity index 94% rename from tests/features/chat/turns/turn-submission-controller.test.ts rename to tests/features/chat/conversation/turns/turn-submission-controller.test.ts index 8d7dd4d3..1b9c79c9 100644 --- a/tests/features/chat/turns/turn-submission-controller.test.ts +++ b/tests/features/chat/conversation/turns/turn-submission-controller.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it, vi } from "vitest"; -import type { AppServerClient } from "../../../../src/app-server/client"; -import type { CodexInput } from "../../../../src/app-server/request-input"; -import { createChatState, createChatStateStore } from "../../../../src/features/chat/chat-state"; +import type { AppServerClient } from "../../../../../src/app-server/client"; +import type { CodexInput } from "../../../../../src/app-server/request-input"; +import { createChatState, createChatStateStore } from "../../../../../src/features/chat/state/reducer"; import { TurnSubmissionController, type TurnSubmissionControllerHost, @@ -13,8 +13,8 @@ import { type TurnSubmissionStatusPort, type TurnSubmissionThreadPort, type TurnSubmissionViewPort, -} from "../../../../src/features/chat/turns/turn-submission-controller"; -import type { Thread } from "../../../../src/generated/app-server/v2/Thread"; +} from "../../../../../src/features/chat/conversation/turns/turn-submission-controller"; +import type { Thread } from "../../../../../src/generated/app-server/v2/Thread"; const textInput = (text: string): CodexInput => [{ type: "text", text }]; diff --git a/tests/features/chat/turns/turn-submission.test.ts b/tests/features/chat/conversation/turns/turn-submission.test.ts similarity index 96% rename from tests/features/chat/turns/turn-submission.test.ts rename to tests/features/chat/conversation/turns/turn-submission.test.ts index c7bbaf7b..bdcc7f94 100644 --- a/tests/features/chat/turns/turn-submission.test.ts +++ b/tests/features/chat/conversation/turns/turn-submission.test.ts @@ -7,8 +7,8 @@ import { localUserMessageItemFromInput, optimisticTurnStart, shouldAcknowledgeTurnStart, -} from "../../../../src/features/chat/turns/turn-submission"; -import type { DisplayItem } from "../../../../src/features/chat/display/types"; +} from "../../../../../src/features/chat/conversation/turns/turn-submission"; +import type { DisplayItem } from "../../../../../src/features/chat/display/types"; describe("chat turn submission helpers", () => { it("builds local user messages without sharing mentioned file arrays", () => { diff --git a/tests/features/chat/display/display-model.test.ts b/tests/features/chat/display/display-model.test.ts index 751f4618..ff9e7465 100644 --- a/tests/features/chat/display/display-model.test.ts +++ b/tests/features/chat/display/display-model.test.ts @@ -23,7 +23,7 @@ import { patchApplyExecutionState, taskProgressExecutionState, } from "../../../../src/features/chat/display/state"; -import { displayItemFromThreadItem, displayItemsFromTurns } from "../../../../src/features/chat/display/thread-items"; +import { displayItemFromThreadItem, displayItemsFromTurns } from "../../../../src/features/chat/protocol/display-items"; import { referencedThreadPrompt } from "../../../../src/domain/threads/reference"; import type { DisplayItem } from "../../../../src/features/chat/display/types"; import type { Thread } from "../../../../src/generated/app-server/v2/Thread"; diff --git a/tests/features/chat/panel/composition.test.ts b/tests/features/chat/panel/composition.test.ts index 9d7131a4..249588aa 100644 --- a/tests/features/chat/panel/composition.test.ts +++ b/tests/features/chat/panel/composition.test.ts @@ -4,12 +4,12 @@ import { describe, expect, it, vi } from "vitest"; import type { App, Component, EventRef } from "obsidian"; import type { RuntimeSnapshot } from "../../../../src/features/chat/runtime/effective-settings"; -import { createChatStateStore } from "../../../../src/features/chat/chat-state"; +import { createChatStateStore } from "../../../../src/features/chat/state/reducer"; import { createChatViewControllers } from "../../../../src/features/chat/panel/composition"; import type { ChatControllerCompositionPorts } from "../../../../src/features/chat/panel/controller-ports"; import { ChatConnectionWorkTracker, ChatResumeWorkTracker, ChatViewDeferredTasks } from "../../../../src/features/chat/panel/lifecycle"; import { ChatMessageScrollIntentController } from "../../../../src/features/chat/panel/message-scroll-intent-controller"; -import type { ComposerMetaViewModel } from "../../../../src/features/chat/panel/model"; +import type { ComposerMetaViewModel } from "../../../../src/features/chat/panel/view-model"; import { DEFAULT_SETTINGS } from "../../../../src/settings/model"; describe("createChatViewControllers", () => { diff --git a/tests/features/chat/panel/toolbar-controller.test.ts b/tests/features/chat/panel/toolbar-controller.test.ts index d4a90173..880716d1 100644 --- a/tests/features/chat/panel/toolbar-controller.test.ts +++ b/tests/features/chat/panel/toolbar-controller.test.ts @@ -2,7 +2,7 @@ import { describe, expect, it, vi } from "vitest"; -import { createChatState, createChatStateStore } from "../../../../src/features/chat/chat-state"; +import { createChatState, createChatStateStore } from "../../../../src/features/chat/state/reducer"; import { createToolbarArchiveConfirmState } from "../../../../src/features/chat/panel/toolbar-archive-confirm-state"; import { ToolbarPanelController } from "../../../../src/features/chat/panel/toolbar-controller"; import type { ChatThreadActions } from "../../../../src/features/chat/threads/thread-actions"; diff --git a/tests/features/chat/requests/pending-request-controller.test.ts b/tests/features/chat/pending-requests/controller.test.ts similarity index 94% rename from tests/features/chat/requests/pending-request-controller.test.ts rename to tests/features/chat/pending-requests/controller.test.ts index abd9dad0..474f08a9 100644 --- a/tests/features/chat/requests/pending-request-controller.test.ts +++ b/tests/features/chat/pending-requests/controller.test.ts @@ -1,9 +1,9 @@ import { describe, expect, it, vi } from "vitest"; -import { ChatInboundController } from "../../../../src/features/chat/inbound/controller"; -import { createChatState, createChatStateStore } from "../../../../src/features/chat/chat-state"; -import { PendingRequestController } from "../../../../src/features/chat/requests/pending-request-controller"; -import { toPendingUserInput } from "../../../../src/features/chat/requests/user-input"; +import { ChatInboundController } from "../../../../src/features/chat/protocol/inbound/controller"; +import { createChatState, createChatStateStore } from "../../../../src/features/chat/state/reducer"; +import { PendingRequestController } from "../../../../src/features/chat/pending-requests/controller"; +import { toPendingUserInput } from "../../../../src/features/chat/protocol/requests/user-input"; import type { ServerRequest } from "../../../../src/generated/app-server/ServerRequest"; function expectPresent(value: T | null | undefined): T { diff --git a/tests/features/chat/chat-server-actions.test.ts b/tests/features/chat/protocol/client-actions.test.ts similarity index 91% rename from tests/features/chat/chat-server-actions.test.ts rename to tests/features/chat/protocol/client-actions.test.ts index 7872d89e..f853683e 100644 --- a/tests/features/chat/chat-server-actions.test.ts +++ b/tests/features/chat/protocol/client-actions.test.ts @@ -1,16 +1,16 @@ import { describe, expect, it, vi } from "vitest"; -import type { AppServerClient } from "../../../src/app-server/client"; -import type { RateLimitSnapshot } from "../../../src/app-server/runtime-metrics"; -import { threadFromAppServerThread } from "../../../src/app-server/thread-model"; -import { createChatServerDiagnosticsActions } from "../../../src/features/chat/server-actions/diagnostics-actions"; -import { createChatServerMetadataActions } from "../../../src/features/chat/server-actions/metadata-actions"; -import { createChatServerThreadActions } from "../../../src/features/chat/server-actions/thread-actions"; -import { createChatState, createChatStateStore } from "../../../src/features/chat/chat-state"; -import type { Model } from "../../../src/generated/app-server/v2/Model"; -import type { McpServerStatus } from "../../../src/generated/app-server/v2/McpServerStatus"; -import type { SkillMetadata } from "../../../src/generated/app-server/v2/SkillMetadata"; -import type { Thread } from "../../../src/generated/app-server/v2/Thread"; +import type { AppServerClient } from "../../../../src/app-server/client"; +import type { RateLimitSnapshot } from "../../../../src/app-server/runtime-metrics"; +import { threadFromAppServerThread } from "../../../../src/app-server/thread-model"; +import { createChatServerDiagnosticsActions } from "../../../../src/features/chat/protocol/client-actions/diagnostics-actions"; +import { createChatServerMetadataActions } from "../../../../src/features/chat/protocol/client-actions/metadata-actions"; +import { createChatServerThreadActions } from "../../../../src/features/chat/protocol/client-actions/thread-actions"; +import { createChatState, createChatStateStore } from "../../../../src/features/chat/state/reducer"; +import type { Model } from "../../../../src/generated/app-server/v2/Model"; +import type { McpServerStatus } from "../../../../src/generated/app-server/v2/McpServerStatus"; +import type { SkillMetadata } from "../../../../src/generated/app-server/v2/SkillMetadata"; +import type { Thread } from "../../../../src/generated/app-server/v2/Thread"; describe("chat server actions", () => { it("publishes newly started threads before the first turn completes", async () => { diff --git a/tests/features/chat/inbound/app-server-logs.test.ts b/tests/features/chat/protocol/inbound/app-server-logs.test.ts similarity index 94% rename from tests/features/chat/inbound/app-server-logs.test.ts rename to tests/features/chat/protocol/inbound/app-server-logs.test.ts index 77e747a1..d284b8ac 100644 --- a/tests/features/chat/inbound/app-server-logs.test.ts +++ b/tests/features/chat/protocol/inbound/app-server-logs.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "vitest"; -import { classifyAppServerLog } from "../../../../src/features/chat/inbound/app-server-logs"; +import { classifyAppServerLog } from "../../../../../src/features/chat/protocol/inbound/app-server-logs"; describe("app-server log classification", () => { it("suppresses raw MCP token refresh stderr", () => { diff --git a/tests/features/chat/inbound/controller.test.ts b/tests/features/chat/protocol/inbound/controller.test.ts similarity index 99% rename from tests/features/chat/inbound/controller.test.ts rename to tests/features/chat/protocol/inbound/controller.test.ts index d07eb359..aec848c0 100644 --- a/tests/features/chat/inbound/controller.test.ts +++ b/tests/features/chat/protocol/inbound/controller.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from "vitest"; -import { ChatInboundController } from "../../../../src/features/chat/inbound/controller"; -import { attachHookRunsToTurn } from "../../../../src/features/chat/display/hooks"; +import { ChatInboundController } from "../../../../../src/features/chat/protocol/inbound/controller"; +import { attachHookRunsToTurn } from "../../../../../src/features/chat/display/hooks"; import { activeTurnId, chatReducer, @@ -11,11 +11,11 @@ import { type ChatAction, type ChatState, type ChatStateStore, -} from "../../../../src/features/chat/chat-state"; -import type { ServerNotification } from "../../../../src/generated/app-server/ServerNotification"; -import type { ServerRequest } from "../../../../src/generated/app-server/ServerRequest"; -import type { Thread } from "../../../../src/generated/app-server/v2/Thread"; -import type { Turn } from "../../../../src/generated/app-server/v2/Turn"; +} from "../../../../../src/features/chat/state/reducer"; +import type { ServerNotification } from "../../../../../src/generated/app-server/ServerNotification"; +import type { ServerRequest } from "../../../../../src/generated/app-server/ServerRequest"; +import type { Thread } from "../../../../../src/generated/app-server/v2/Thread"; +import type { Turn } from "../../../../../src/generated/app-server/v2/Turn"; function controllerForState( state = createChatState(), diff --git a/tests/features/chat/inbound-routing.test.ts b/tests/features/chat/protocol/inbound/routing.test.ts similarity index 97% rename from tests/features/chat/inbound-routing.test.ts rename to tests/features/chat/protocol/inbound/routing.test.ts index f84171c2..eb712b49 100644 --- a/tests/features/chat/inbound-routing.test.ts +++ b/tests/features/chat/protocol/inbound/routing.test.ts @@ -6,9 +6,9 @@ import { messageTurnId, routeServerNotification, routeServerRequest, -} from "../../../src/features/chat/inbound/routing"; -import type { ServerNotification } from "../../../src/generated/app-server/ServerNotification"; -import type { ServerRequest } from "../../../src/generated/app-server/ServerRequest"; +} from "../../../../../src/features/chat/protocol/inbound/routing"; +import type { ServerNotification } from "../../../../../src/generated/app-server/ServerNotification"; +import type { ServerRequest } from "../../../../../src/generated/app-server/ServerRequest"; const activeScope = { activeThreadId: "thread-active", activeTurnId: "turn-active" }; diff --git a/tests/features/chat/requests/approval.test.ts b/tests/features/chat/protocol/requests/approval.test.ts similarity index 97% rename from tests/features/chat/requests/approval.test.ts rename to tests/features/chat/protocol/requests/approval.test.ts index b23d5673..b0066348 100644 --- a/tests/features/chat/requests/approval.test.ts +++ b/tests/features/chat/protocol/requests/approval.test.ts @@ -7,9 +7,9 @@ import { approvalSummary, approvalTitle, toPendingApproval, -} from "../../../../src/features/chat/requests/approval"; -import type { ServerRequest } from "../../../../src/generated/app-server/ServerRequest"; -import type { CommandExecutionApprovalDecision } from "../../../../src/generated/app-server/v2/CommandExecutionApprovalDecision"; +} from "../../../../../src/features/chat/protocol/requests/approval"; +import type { ServerRequest } from "../../../../../src/generated/app-server/ServerRequest"; +import type { CommandExecutionApprovalDecision } from "../../../../../src/generated/app-server/v2/CommandExecutionApprovalDecision"; function expectPresent(value: T | null | undefined): T { if (value === null || value === undefined) throw new Error("Expected value to be present"); diff --git a/tests/features/chat/requests/server-request-responder.test.ts b/tests/features/chat/protocol/requests/server-request-responder.test.ts similarity index 89% rename from tests/features/chat/requests/server-request-responder.test.ts rename to tests/features/chat/protocol/requests/server-request-responder.test.ts index 4c0612d8..a1c93c29 100644 --- a/tests/features/chat/requests/server-request-responder.test.ts +++ b/tests/features/chat/protocol/requests/server-request-responder.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from "vitest"; -import type { AppServerClient } from "../../../../src/app-server/client"; -import { rejectServerRequest, respondToServerRequest } from "../../../../src/features/chat/requests/server-request-responder"; +import type { AppServerClient } from "../../../../../src/app-server/client"; +import { rejectServerRequest, respondToServerRequest } from "../../../../../src/features/chat/protocol/requests/server-request-responder"; describe("server request responder", () => { it("responds through the current app-server client", () => { diff --git a/tests/features/chat/requests/user-input.test.ts b/tests/features/chat/protocol/requests/user-input.test.ts similarity index 93% rename from tests/features/chat/requests/user-input.test.ts rename to tests/features/chat/protocol/requests/user-input.test.ts index 82dde00c..74276ad8 100644 --- a/tests/features/chat/requests/user-input.test.ts +++ b/tests/features/chat/protocol/requests/user-input.test.ts @@ -5,9 +5,9 @@ import { questionDefaultAnswer, toPendingUserInput, userInputResponse, -} from "../../../../src/features/chat/requests/user-input"; -import { pendingRequestFocusSignature, pendingRequestsSignature } from "../../../../src/features/chat/requests/view-model"; -import type { ServerRequest } from "../../../../src/generated/app-server/ServerRequest"; +} from "../../../../../src/features/chat/protocol/requests/user-input"; +import { pendingRequestFocusSignature, pendingRequestsSignature } from "../../../../../src/features/chat/pending-requests/view-model"; +import type { ServerRequest } from "../../../../../src/generated/app-server/ServerRequest"; function expectPresent(value: T | null | undefined): T { if (value === null || value === undefined) throw new Error("Expected value to be present"); diff --git a/tests/features/chat/runtime/runtime-settings-actions.test.ts b/tests/features/chat/runtime/runtime-settings-actions.test.ts index bf02df2d..d0c4ec45 100644 --- a/tests/features/chat/runtime/runtime-settings-actions.test.ts +++ b/tests/features/chat/runtime/runtime-settings-actions.test.ts @@ -4,9 +4,9 @@ import { createChatRuntimeSettingsActions, type ChatRuntimeSettingsActions, } from "../../../../src/features/chat/runtime/runtime-settings-actions"; -import { createChatState, createChatStateStore, type ChatState } from "../../../../src/features/chat/chat-state"; -import { runtimeSnapshotForChatSlices } from "../../../../src/features/chat/panel/model"; -import type { ActiveThreadSettingsAppliedAction } from "../../../../src/features/chat/chat-state-actions"; +import { createChatState, createChatStateStore, type ChatState } from "../../../../src/features/chat/state/reducer"; +import { runtimeSnapshotForChatSlices } from "../../../../src/features/chat/panel/view-model"; +import type { ActiveThreadSettingsAppliedAction } from "../../../../src/features/chat/state/actions"; import type { AppServerClient } from "../../../../src/app-server/client"; import type { ModelMetadata } from "../../../../src/domain/catalog/metadata"; diff --git a/tests/features/chat/chat-state-reducer.test.ts b/tests/features/chat/state-reducer.test.ts similarity index 99% rename from tests/features/chat/chat-state-reducer.test.ts rename to tests/features/chat/state-reducer.test.ts index 13a51ccd..ed987952 100644 --- a/tests/features/chat/chat-state-reducer.test.ts +++ b/tests/features/chat/state-reducer.test.ts @@ -9,7 +9,7 @@ import { pendingTurnStart, transitionChatTurnLifecycleState, type ChatState, -} from "../../../src/features/chat/chat-state"; +} from "../../../src/features/chat/state/reducer"; import type { ThreadGoal } from "../../../src/app-server/thread-goal"; import type { DisplayItem } from "../../../src/features/chat/display/types"; import type { Thread } from "../../../src/generated/app-server/v2/Thread"; diff --git a/tests/features/chat/threads/restored-thread-controller.test.ts b/tests/features/chat/threads/restored-thread-controller.test.ts index 5eb9ca25..99e2515c 100644 --- a/tests/features/chat/threads/restored-thread-controller.test.ts +++ b/tests/features/chat/threads/restored-thread-controller.test.ts @@ -2,7 +2,7 @@ import { describe, expect, it, vi } from "vitest"; -import { createChatState, createChatStateStore } from "../../../../src/features/chat/chat-state"; +import { createChatState, createChatStateStore } from "../../../../src/features/chat/state/reducer"; import { RestoredThreadController } from "../../../../src/features/chat/threads/restored-thread-controller"; import { ChatViewDeferredTasks } from "../../../../src/features/chat/panel/lifecycle"; import { deferred } from "../../../support/async"; diff --git a/tests/features/chat/threads/thread-actions.test.ts b/tests/features/chat/threads/thread-actions.test.ts index 211a32e8..f78cf0e4 100644 --- a/tests/features/chat/threads/thread-actions.test.ts +++ b/tests/features/chat/threads/thread-actions.test.ts @@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import type { AppServerClient } from "../../../../src/app-server/client"; import type { ArchiveExportAdapter } from "../../../../src/domain/threads/export"; -import { createChatState, createChatStateStore } from "../../../../src/features/chat/chat-state"; +import { createChatState, createChatStateStore } from "../../../../src/features/chat/state/reducer"; import { createChatThreadActions, type ChatThreadActionsHost } from "../../../../src/features/chat/threads/thread-actions"; import type { DisplayItem } from "../../../../src/features/chat/display/types"; import type { Thread } from "../../../../src/generated/app-server/v2/Thread"; diff --git a/tests/features/chat/threads/thread-goal-actions.test.ts b/tests/features/chat/threads/thread-goal-actions.test.ts index ba640b35..63a95923 100644 --- a/tests/features/chat/threads/thread-goal-actions.test.ts +++ b/tests/features/chat/threads/thread-goal-actions.test.ts @@ -3,7 +3,7 @@ import { describe, expect, it, vi } from "vitest"; import type { AppServerClient } from "../../../../src/app-server/client"; import type { ThreadGoal } from "../../../../src/app-server/thread-goal"; import { createChatThreadGoalActions } from "../../../../src/features/chat/threads/thread-goal-actions"; -import { createChatState, createChatStateStore } from "../../../../src/features/chat/chat-state"; +import { createChatState, createChatStateStore } from "../../../../src/features/chat/state/reducer"; describe("createChatThreadGoalActions", () => { it("syncs the active thread goal into chat state", async () => { diff --git a/tests/features/chat/threads/thread-history-controller.test.ts b/tests/features/chat/threads/thread-history-controller.test.ts index a543de11..4cba568a 100644 --- a/tests/features/chat/threads/thread-history-controller.test.ts +++ b/tests/features/chat/threads/thread-history-controller.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it, vi } from "vitest"; -import { createChatState, createChatStateStore } from "../../../../src/features/chat/chat-state"; +import { createChatState, createChatStateStore } from "../../../../src/features/chat/state/reducer"; import { ThreadHistoryController } from "../../../../src/features/chat/threads/thread-history-controller"; import type { AppServerClient } from "../../../../src/app-server/client"; import type { ThreadItem } from "../../../../src/generated/app-server/v2/ThreadItem"; diff --git a/tests/features/chat/threads/thread-identity-actions.test.ts b/tests/features/chat/threads/thread-identity-actions.test.ts index 6ce29882..7360f65e 100644 --- a/tests/features/chat/threads/thread-identity-actions.test.ts +++ b/tests/features/chat/threads/thread-identity-actions.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it, vi } from "vitest"; -import { createChatState, createChatStateStore } from "../../../../src/features/chat/chat-state"; +import { createChatState, createChatStateStore } from "../../../../src/features/chat/state/reducer"; import { createThreadIdentityActions } from "../../../../src/features/chat/threads/thread-identity-actions"; import type { RestoredThreadController } from "../../../../src/features/chat/threads/restored-thread-controller"; import type { RestoredThreadPlaceholderState } from "../../../../src/features/chat/panel/lifecycle"; diff --git a/tests/features/chat/threads/thread-rename-controller.test.ts b/tests/features/chat/threads/thread-rename-controller.test.ts index a42a30f7..bc6cb95c 100644 --- a/tests/features/chat/threads/thread-rename-controller.test.ts +++ b/tests/features/chat/threads/thread-rename-controller.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it, vi } from "vitest"; -import { createChatStateStore } from "../../../../src/features/chat/chat-state"; +import { createChatStateStore } from "../../../../src/features/chat/state/reducer"; import { ThreadRenameController } from "../../../../src/features/chat/threads/thread-rename-controller"; import type { AppServerClient } from "../../../../src/app-server/client"; import type { Thread } from "../../../../src/generated/app-server/v2/Thread"; diff --git a/tests/features/chat/threads/thread-resume-controller.test.ts b/tests/features/chat/threads/thread-resume-controller.test.ts index ea69981e..91450d35 100644 --- a/tests/features/chat/threads/thread-resume-controller.test.ts +++ b/tests/features/chat/threads/thread-resume-controller.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from "vitest"; import type { AppServerClient } from "../../../../src/app-server/client"; -import { createChatState, createChatStateStore } from "../../../../src/features/chat/chat-state"; +import { createChatState, createChatStateStore } from "../../../../src/features/chat/state/reducer"; import type { RestoredThreadController } from "../../../../src/features/chat/threads/restored-thread-controller"; import { ThreadResumeController } from "../../../../src/features/chat/threads/thread-resume-controller"; import type { ThreadHistoryController } from "../../../../src/features/chat/threads/thread-history-controller"; diff --git a/tests/features/chat/threads/thread-selection-controller.test.ts b/tests/features/chat/threads/thread-selection-controller.test.ts index 830d8fa7..5379ba27 100644 --- a/tests/features/chat/threads/thread-selection-controller.test.ts +++ b/tests/features/chat/threads/thread-selection-controller.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it, vi } from "vitest"; -import { createChatState, createChatStateStore, type ChatStateStore } from "../../../../src/features/chat/chat-state"; +import { createChatState, createChatStateStore, type ChatStateStore } from "../../../../src/features/chat/state/reducer"; import { createThreadSelectionActions, type ThreadSelectionControllerHost, diff --git a/tests/features/chat/ui/message-stream/context-port.test.ts b/tests/features/chat/ui/message-stream/context-port.test.ts index 01d208a9..98b15df7 100644 --- a/tests/features/chat/ui/message-stream/context-port.test.ts +++ b/tests/features/chat/ui/message-stream/context-port.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it, vi } from "vitest"; -import { createChatState, type ChatAction } from "../../../../../src/features/chat/chat-state"; +import { createChatState, type ChatAction } from "../../../../../src/features/chat/state/reducer"; import { createMessageStreamContextPort } from "../../../../../src/features/chat/ui/message-stream"; describe("message stream context port", () => { diff --git a/tests/features/chat/ui/message-stream/pending-requests.test.tsx b/tests/features/chat/ui/message-stream/pending-requests.test.tsx index 22ac1b3c..9939d9be 100644 --- a/tests/features/chat/ui/message-stream/pending-requests.test.tsx +++ b/tests/features/chat/ui/message-stream/pending-requests.test.tsx @@ -2,9 +2,9 @@ import { describe, expect, it, vi } from "vitest"; -import type { PendingRequestSnapshot } from "../../../../../src/features/chat/chat-state-selectors"; -import type { PendingApproval } from "../../../../../src/features/chat/requests/approval"; -import type { PendingUserInput } from "../../../../../src/features/chat/requests/user-input"; +import type { PendingRequestSnapshot } from "../../../../../src/features/chat/state/selectors"; +import type { PendingApproval } from "../../../../../src/features/chat/protocol/requests/approval"; +import type { PendingUserInput } from "../../../../../src/features/chat/protocol/requests/user-input"; import type { PendingRequestBlockContext } from "../../../../../src/features/chat/ui/message-stream/context"; import type { DisplayItem } from "../../../../../src/features/chat/display/types"; import { changeInputValue } from "../../../../support/dom"; diff --git a/tests/features/chat/ui/message-stream/renderer.test.ts b/tests/features/chat/ui/message-stream/renderer.test.ts index e8f69c78..5afd0fb4 100644 --- a/tests/features/chat/ui/message-stream/renderer.test.ts +++ b/tests/features/chat/ui/message-stream/renderer.test.ts @@ -9,7 +9,7 @@ import { type ChatAction, type ChatState, type ChatStateStore, -} from "../../../../../src/features/chat/chat-state"; +} from "../../../../../src/features/chat/state/reducer"; import { ChatMessageRenderer, bindRenderedWikiLinks, diff --git a/tests/features/chat/ui/message-stream/test-helpers.tsx b/tests/features/chat/ui/message-stream/test-helpers.tsx index 36303c5f..f9ffe0d5 100644 --- a/tests/features/chat/ui/message-stream/test-helpers.tsx +++ b/tests/features/chat/ui/message-stream/test-helpers.tsx @@ -2,10 +2,10 @@ import { vi } from "vitest"; import type { ComponentChild as UiNode } from "preact"; import { act } from "preact/test-utils"; -import type { PendingApproval } from "../../../../../src/features/chat/requests/approval"; -import type { PendingUserInput } from "../../../../../src/features/chat/requests/user-input"; +import type { PendingApproval } from "../../../../../src/features/chat/protocol/requests/approval"; +import type { PendingUserInput } from "../../../../../src/features/chat/protocol/requests/user-input"; import { pendingRequestMessageNode, type PendingRequestMessageActions } from "../../../../../src/features/chat/ui/pending-request-message"; -import type { ChatTurnLifecycleState } from "../../../../../src/features/chat/chat-state"; +import type { ChatTurnLifecycleState } from "../../../../../src/features/chat/state/reducer"; import { type MessageStreamBlock, messageStreamBlocksNode, diff --git a/tests/features/chat/ui/renderers/composer.test.ts b/tests/features/chat/ui/renderers/composer.test.ts index 2eab5536..0ce747d9 100644 --- a/tests/features/chat/ui/renderers/composer.test.ts +++ b/tests/features/chat/ui/renderers/composer.test.ts @@ -8,8 +8,8 @@ import { syncComposerHeight, type ComposerCallbacks, } from "../../../../../src/features/chat/ui/composer"; -import type { ComposerSuggestion } from "../../../../../src/features/chat/composer/suggestions"; -import type { ComposerMetaViewModel } from "../../../../../src/features/chat/panel/model"; +import type { ComposerSuggestion } from "../../../../../src/features/chat/conversation/composer/suggestions"; +import type { ComposerMetaViewModel } from "../../../../../src/features/chat/panel/view-model"; import { renderUiRoot } from "../../../../../src/shared/ui/ui-root"; import { waitForAsyncWork } from "../../../../support/async"; import { changeInputValue, composerSuggestionScrollFixture, installObsidianDomShims } from "../../../../support/dom"; diff --git a/tests/features/chat/ui/renderers/toolbar.test.ts b/tests/features/chat/ui/renderers/toolbar.test.ts index 515a78dd..a31c5e90 100644 --- a/tests/features/chat/ui/renderers/toolbar.test.ts +++ b/tests/features/chat/ui/renderers/toolbar.test.ts @@ -2,7 +2,7 @@ import { describe, expect, it, vi } from "vitest"; -import type { ToolbarViewModel } from "../../../../../src/features/chat/panel/model/types"; +import type { ToolbarViewModel } from "../../../../../src/features/chat/panel/view-model/types"; import { toolbarNode } from "../../../../../src/features/chat/ui/toolbar"; import { renderUiRoot } from "../../../../../src/shared/ui/ui-root"; import { changeInputValue, installObsidianDomShims } from "../../../../support/dom"; diff --git a/tests/features/chat/ui/shell.test.tsx b/tests/features/chat/ui/shell.test.tsx index 21e9bcfc..e1a1765a 100644 --- a/tests/features/chat/ui/shell.test.tsx +++ b/tests/features/chat/ui/shell.test.tsx @@ -4,7 +4,7 @@ import { describe, expect, it, vi } from "vitest"; import { act } from "preact/test-utils"; import { useEffect } from "preact/hooks"; -import { chatTurnBusy, createChatStateStore } from "../../../../src/features/chat/chat-state"; +import { chatTurnBusy, createChatStateStore } from "../../../../src/features/chat/state/reducer"; import { renderChatPanelShell, unmountChatPanelShell, useChatPanelShellState } from "../../../../src/features/chat/ui/shell"; import { installObsidianDomShims } from "../../../support/dom"; diff --git a/tests/features/chat/ui/toolbar-archive-signal.test.tsx b/tests/features/chat/ui/toolbar-archive-signal.test.tsx index 56e3308d..ddc7f0c1 100644 --- a/tests/features/chat/ui/toolbar-archive-signal.test.tsx +++ b/tests/features/chat/ui/toolbar-archive-signal.test.tsx @@ -4,8 +4,8 @@ import { describe, expect, it, vi } from "vitest"; import { act } from "preact/test-utils"; import type { Thread } from "../../../../src/domain/threads/model"; -import { createChatStateStore } from "../../../../src/features/chat/chat-state"; -import { runtimeSnapshotForChatSlices } from "../../../../src/features/chat/panel/model"; +import { createChatStateStore } from "../../../../src/features/chat/state/reducer"; +import { runtimeSnapshotForChatSlices } from "../../../../src/features/chat/panel/view-model"; import { createToolbarArchiveConfirmState } from "../../../../src/features/chat/panel/toolbar-archive-confirm-state"; import { ToolbarPanelController } from "../../../../src/features/chat/panel/toolbar-controller"; import type { ChatPanelToolbarPorts } from "../../../../src/features/chat/panel/ui-ports"; diff --git a/tests/features/chat/view-connection.test.ts b/tests/features/chat/view-connection.test.ts index 55667fc7..90ecc6d0 100644 --- a/tests/features/chat/view-connection.test.ts +++ b/tests/features/chat/view-connection.test.ts @@ -7,7 +7,7 @@ import type { CodexChatHost } from "../../../src/features/chat/chat-host"; import { createAppServerDiagnostics } from "../../../src/app-server/diagnostics"; import { emptyRuntimeConfigSnapshot } from "../../../src/app-server/runtime-config"; import { threadFromAppServerThread } from "../../../src/app-server/thread-model"; -import type { ChatState } from "../../../src/features/chat/chat-state"; +import type { ChatState } from "../../../src/features/chat/state/reducer"; import type { ServerNotification } from "../../../src/generated/app-server/ServerNotification"; import type { Thread } from "../../../src/generated/app-server/v2/Thread"; import { notices } from "../../mocks/obsidian"; diff --git a/tests/features/chat/view-model.test.ts b/tests/features/chat/view-model.test.ts index 3f6fde57..9bb1e22b 100644 --- a/tests/features/chat/view-model.test.ts +++ b/tests/features/chat/view-model.test.ts @@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest"; import { createAppServerDiagnostics } from "../../../src/app-server/diagnostics"; import { runtimeConfigSnapshotFromAppServerConfig, type RuntimeConfigSnapshot } from "../../../src/app-server/runtime-config"; -import { createChatState } from "../../../src/features/chat/chat-state"; +import { createChatState } from "../../../src/features/chat/state/reducer"; import { activeComposerThreadName, activeThreadTitle, @@ -15,8 +15,8 @@ import { runtimeSnapshotForChatSlices, statusSummaryLines, toolbarViewModel, -} from "../../../src/features/chat/panel/model"; -import type { ChatState } from "../../../src/features/chat/chat-state"; +} from "../../../src/features/chat/panel/view-model"; +import type { ChatState } from "../../../src/features/chat/state/reducer"; import type { ModelMetadata } from "../../../src/domain/catalog/metadata"; import type { Thread } from "../../../src/generated/app-server/v2/Thread"; import type { ConfigReadResponse } from "../../../src/generated/app-server/v2/ConfigReadResponse"; diff --git a/tests/runtime/runtime-settings.test.ts b/tests/runtime/runtime-settings.test.ts index 51ef90f4..6e8c4bea 100644 --- a/tests/runtime/runtime-settings.test.ts +++ b/tests/runtime/runtime-settings.test.ts @@ -10,7 +10,7 @@ import { parseModelOverride, parseReasoningEffortOverride, reasoningEffortOverrideMessage, -} from "../../src/features/chat/turns/runtime-overrides"; +} from "../../src/features/chat/conversation/turns/runtime-overrides"; import { autoReviewActive, currentApprovalsReviewer,