diff --git a/biome.jsonc b/biome.jsonc index 13cb00ea..d00f79f8 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -22,6 +22,14 @@ "indentStyle": "space", "lineWidth": 140 }, + "assist": { + "actions": { + "source": { + "noDuplicateClasses": "on", + "organizeImports": "on" + } + } + }, "linter": { "rules": { "preset": "recommended", diff --git a/docs/development.md b/docs/development.md index 18ee8cbb..d360ef52 100644 --- a/docs/development.md +++ b/docs/development.md @@ -10,9 +10,9 @@ npm run format npm run check ``` -Run `npm run format` after edits and before `npm run check` so Biome formatting issues are fixed upfront. `npm run check` runs TypeScript type checking, unit tests, lint checks, Biome format check, CSS verification, and the production esbuild bundle. `npm run check:ci` uses the same checks with CI cache settings for TypeScript, tests, and ESLint. Use `npm run build` when you need to refresh Obsidian-loaded assets without running the full check. +Run `npm run format` after edits and before `npm run check` so Biome formatting and import organization issues are fixed upfront. `npm run check` runs TypeScript type checking, unit tests, lint checks, Biome format and assist checks, CSS verification, and the production esbuild bundle. `npm run check:ci` uses the same checks with CI cache settings for TypeScript, tests, and ESLint. Use `npm run build` when you need to refresh Obsidian-loaded assets without running the full check. -Formatting and general JavaScript/TypeScript/JSON linting and JavaScript/TypeScript/CSS/JSON formatting are handled by Biome. The Biome lint configuration explicitly uses the recommended preset, with accessibility diagnostics downgraded to info while the Obsidian-specific UI semantics are reviewed rule by rule. Biome also owns floating Promise, import cycle, and Preact hook dependency/order checks. CSS is formatted by Biome but excluded from Biome linting so CSS lint policy stays centralized in Stylelint and the project CSS usage script. ESLint remains for unsafe-any TypeScript parser-service checks, Obsidian plugin API/text policy checks, and Codex Panel responsibility-boundary checks. +Formatting, import organization, general JavaScript/TypeScript/JSON linting, and JavaScript/TypeScript/CSS/JSON formatting are handled by Biome. The Biome lint configuration explicitly uses the recommended preset, with accessibility diagnostics downgraded to info while the Obsidian-specific UI semantics are reviewed rule by rule. Biome also owns floating Promise, import cycle, and Preact hook dependency/order checks. CSS is formatted by Biome but excluded from Biome linting so CSS lint policy stays centralized in Stylelint and the project CSS usage script. ESLint remains for unsafe-any TypeScript parser-service checks, Obsidian plugin API/text policy checks, and Codex Panel responsibility-boundary checks. ## Generated and Loaded Files diff --git a/eslint.config.mjs b/eslint.config.mjs index 4152ea75..2ec67e42 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,7 +1,7 @@ import { defineConfig } from "eslint/config"; import obsidianmd from "eslint-plugin-obsidianmd"; -import codexPanelEslintPlugin from "./scripts/lint/eslint-plugin-codex-panel.mjs"; import tseslint from "typescript-eslint"; +import codexPanelEslintPlugin from "./scripts/lint/eslint-plugin-codex-panel.mjs"; const typeScriptFiles = ["src/**/*.{ts,tsx}", "tests/**/*.{ts,tsx}"]; const nodeJavaScriptFiles = ["*.mjs", "scripts/**/*.mjs"]; diff --git a/package.json b/package.json index 16b56b48..f7deecbd 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ "build:styles": "node scripts/build-styles.mjs", "check": "node scripts/check.mjs", "check:ci": "node scripts/check.mjs --ci", - "format": "biome format --write --no-errors-on-unmatched", - "format:check": "biome format --no-errors-on-unmatched", + "format": "biome check --write --linter-enabled=false --no-errors-on-unmatched", + "format:check": "biome check --linter-enabled=false --no-errors-on-unmatched", "generate:app-server-types": "node scripts/generate-app-server-types.mjs", "lint": "node scripts/check.mjs --lint", "lint:ci": "node scripts/check.mjs --ci --lint", diff --git a/scripts/api-baseline.mjs b/scripts/api-baseline.mjs index 13469f3a..2b1b3016 100644 --- a/scripts/api-baseline.mjs +++ b/scripts/api-baseline.mjs @@ -1,5 +1,5 @@ -import { readFile } from "node:fs/promises"; import { spawnSync } from "node:child_process"; +import { readFile } from "node:fs/promises"; const args = new Set(process.argv.slice(2)); const asJson = args.has("--json"); diff --git a/src/app-server/catalog.ts b/src/app-server/catalog.ts index e6d28ca7..5737b4a3 100644 --- a/src/app-server/catalog.ts +++ b/src/app-server/catalog.ts @@ -1,3 +1,4 @@ +import type { HookItem, ModelMetadata, SkillMetadata } from "../domain/catalog/metadata"; import type { AppServerClient } from "./connection/client"; import { appServerHookOperationFromHookItem, @@ -6,7 +7,6 @@ import { modelMetadataFromCatalogModels, skillMetadataFromCatalogSkills, } from "./protocol/catalog"; -import type { HookItem, ModelMetadata, SkillMetadata } from "../domain/catalog/metadata"; export interface HookData { hooks: HookItem[]; diff --git a/src/app-server/connection/client.ts b/src/app-server/connection/client.ts index c39a4f2f..f1dd13fd 100644 --- a/src/app-server/connection/client.ts +++ b/src/app-server/connection/client.ts @@ -1,16 +1,23 @@ -import type { InitializeResponse } from "../../generated/app-server/InitializeResponse"; +import { CLIENT_VERSION } from "../../constants"; +import type { CodexInput } from "../../domain/chat/input"; +import type { RuntimeServiceTierRequest, RuntimeSettingsPatch } from "../../domain/runtime/thread-settings"; +import type { ThreadGoalUpdate } from "../../domain/threads/goal"; import type { CollaborationMode } from "../../generated/app-server/CollaborationMode"; -import type { RequestId } from "../../generated/app-server/RequestId"; +import type { InitializeResponse } from "../../generated/app-server/InitializeResponse"; import type { ReasoningEffort } from "../../generated/app-server/ReasoningEffort"; +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 { JsonValue } from "../../generated/app-server/serde_json/JsonValue"; import type { ApprovalsReviewer } from "../../generated/app-server/v2/ApprovalsReviewer"; import type { AppsListParams } from "../../generated/app-server/v2/AppsListParams"; import type { AppsListResponse } from "../../generated/app-server/v2/AppsListResponse"; +import type { CollaborationModeListResponse } from "../../generated/app-server/v2/CollaborationModeListResponse"; import type { ConfigReadResponse } from "../../generated/app-server/v2/ConfigReadResponse"; import type { ConfigWriteResponse } from "../../generated/app-server/v2/ConfigWriteResponse"; import type { FsReadFileResponse } from "../../generated/app-server/v2/FsReadFileResponse"; import type { GetAccountRateLimitsResponse } from "../../generated/app-server/v2/GetAccountRateLimitsResponse"; import type { HooksListResponse } from "../../generated/app-server/v2/HooksListResponse"; -import type { CollaborationModeListResponse } from "../../generated/app-server/v2/CollaborationModeListResponse"; import type { ListMcpServerStatusParams } from "../../generated/app-server/v2/ListMcpServerStatusParams"; import type { ListMcpServerStatusResponse } from "../../generated/app-server/v2/ListMcpServerStatusResponse"; import type { ModelListResponse } from "../../generated/app-server/v2/ModelListResponse"; @@ -20,7 +27,9 @@ import type { PluginInstalledResponse } from "../../generated/app-server/v2/Plug import type { PluginReadParams } from "../../generated/app-server/v2/PluginReadParams"; import type { PluginReadResponse } from "../../generated/app-server/v2/PluginReadResponse"; import type { SkillsListResponse } from "../../generated/app-server/v2/SkillsListResponse"; +import type { SortDirection } from "../../generated/app-server/v2/SortDirection"; import type { ThreadArchiveResponse } from "../../generated/app-server/v2/ThreadArchiveResponse"; +import type { ThreadCompactStartResponse } from "../../generated/app-server/v2/ThreadCompactStartResponse"; import type { ThreadDeleteResponse } from "../../generated/app-server/v2/ThreadDeleteResponse"; import type { ThreadForkResponse } from "../../generated/app-server/v2/ThreadForkResponse"; import type { ThreadGoalClearResponse } from "../../generated/app-server/v2/ThreadGoalClearResponse"; @@ -33,30 +42,21 @@ import type { ThreadResumeResponse } from "../../generated/app-server/v2/ThreadR import type { ThreadRollbackResponse } from "../../generated/app-server/v2/ThreadRollbackResponse"; import type { ThreadSetNameResponse } from "../../generated/app-server/v2/ThreadSetNameResponse"; import type { ThreadSettingsUpdateResponse } from "../../generated/app-server/v2/ThreadSettingsUpdateResponse"; -import type { ThreadCompactStartResponse } from "../../generated/app-server/v2/ThreadCompactStartResponse"; -import type { SortDirection } from "../../generated/app-server/v2/SortDirection"; import type { ThreadStartResponse } from "../../generated/app-server/v2/ThreadStartResponse"; import type { ThreadTurnsListResponse } from "../../generated/app-server/v2/ThreadTurnsListResponse"; import type { ThreadUnarchiveResponse } from "../../generated/app-server/v2/ThreadUnarchiveResponse"; -import type { TurnItemsView } from "../../generated/app-server/v2/TurnItemsView"; import type { TurnInterruptResponse } from "../../generated/app-server/v2/TurnInterruptResponse"; +import type { TurnItemsView } from "../../generated/app-server/v2/TurnItemsView"; import type { TurnStartResponse } from "../../generated/app-server/v2/TurnStartResponse"; import type { TurnSteerResponse } from "../../generated/app-server/v2/TurnSteerResponse"; import type { UserInput } from "../../generated/app-server/v2/UserInput"; -import { CLIENT_VERSION } from "../../constants"; -import { JsonRpcClient } from "./json-rpc-client"; -import { StdioAppServerTransport, type AppServerTransport, type AppServerTransportHandlers } from "./transport"; -import type { ClientRequestMethod, ClientRequestParams, RpcOutboundMessage } from "./rpc-messages"; -import type { ServerNotification } from "../../generated/app-server/ServerNotification"; -import type { ServerRequest } from "../../generated/app-server/ServerRequest"; -import type { JsonValue } from "../../generated/app-server/serde_json/JsonValue"; -import type { CodexInput } from "../../domain/chat/input"; -import type { ThreadGoalUpdate } from "../../domain/threads/goal"; -import type { RuntimeServiceTierRequest, RuntimeSettingsPatch } from "../../domain/runtime/thread-settings"; import type { AppServerHookOperation } from "../protocol/catalog"; import { additionalContextFromCodexInput, toAppServerUserInput } from "../protocol/request-input"; import { appServerThreadGoalUpdate } from "../protocol/thread-goal"; import { appServerRuntimeSettingsPatch } from "../protocol/thread-settings"; +import { JsonRpcClient } from "./json-rpc-client"; +import type { ClientRequestMethod, ClientRequestParams, RpcOutboundMessage } from "./rpc-messages"; +import { type AppServerTransport, type AppServerTransportHandlers, StdioAppServerTransport } from "./transport"; const DEFAULT_REQUEST_TIMEOUT_MS = 120_000; diff --git a/src/app-server/connection/connection-manager.ts b/src/app-server/connection/connection-manager.ts index 736ab7b5..948bd652 100644 --- a/src/app-server/connection/connection-manager.ts +++ b/src/app-server/connection/connection-manager.ts @@ -1,8 +1,8 @@ +import type { ServerInitialization } from "../../domain/server/initialization"; import type { ServerNotification } from "../../generated/app-server/ServerNotification"; import type { ServerRequest } from "../../generated/app-server/ServerRequest"; -import type { ServerInitialization } from "../../domain/server/initialization"; -import { AppServerClient, type AppServerClientHandlers } from "./client"; import { appServerInitializationFromResponse } from "../protocol/initialization"; +import { AppServerClient, type AppServerClientHandlers } from "./client"; export interface ConnectionManagerHandlers { onNotification: (notification: ServerNotification) => void; diff --git a/src/app-server/connection/json-rpc-client.ts b/src/app-server/connection/json-rpc-client.ts index 04d2baa3..8ae9f752 100644 --- a/src/app-server/connection/json-rpc-client.ts +++ b/src/app-server/connection/json-rpc-client.ts @@ -1,3 +1,4 @@ +import type { RequestId } from "../../generated/app-server/RequestId"; import type { ClientRequestMethod, ClientRequestParams, @@ -5,9 +6,9 @@ import type { RpcError, RpcInboundMessage, RpcOutboundMessage, + ServerNotification, + ServerRequest, } from "./rpc-messages"; -import type { ServerNotification, ServerRequest } from "./rpc-messages"; -import type { RequestId } from "../../generated/app-server/RequestId"; const MAX_SUPPRESSED_ORPHAN_RESPONSES = 256; diff --git a/src/app-server/connection/transport.ts b/src/app-server/connection/transport.ts index cfd57db0..2f9255bb 100644 --- a/src/app-server/connection/transport.ts +++ b/src/app-server/connection/transport.ts @@ -1,4 +1,4 @@ -import { spawn, type ChildProcessWithoutNullStreams } from "child_process"; +import { type ChildProcessWithoutNullStreams, spawn } from "child_process"; import * as readline from "readline"; import type { RpcOutboundMessage } from "./rpc-messages"; diff --git a/src/app-server/protocol/runtime-config.ts b/src/app-server/protocol/runtime-config.ts index 9e981b7a..790565e0 100644 --- a/src/app-server/protocol/runtime-config.ts +++ b/src/app-server/protocol/runtime-config.ts @@ -1,6 +1,6 @@ import { normalizeReasoningEffort } from "../../domain/catalog/metadata"; -import { approvalsReviewerOrNull, parseServiceTier } from "../../domain/runtime/policy"; import type { ReasoningSummary, RuntimeConfigSnapshot, Verbosity } from "../../domain/runtime/config"; +import { approvalsReviewerOrNull, parseServiceTier } from "../../domain/runtime/policy"; interface ConfigLayerRecord { name: { type: string; profile?: unknown; [key: string]: unknown }; diff --git a/src/app-server/protocol/server-requests.ts b/src/app-server/protocol/server-requests.ts index 3c387933..0cd153bd 100644 --- a/src/app-server/protocol/server-requests.ts +++ b/src/app-server/protocol/server-requests.ts @@ -1,4 +1,3 @@ -import type { ServerRequest } from "../../generated/app-server/ServerRequest"; import type { ApprovalAction, ApprovalActionIntent, @@ -12,6 +11,7 @@ import type { PendingMcpElicitationOption, PendingUserInput, } from "../../domain/pending-requests/model"; +import type { ServerRequest } from "../../generated/app-server/ServerRequest"; import { pathRelativeToRoot } from "../../shared/path/file-paths"; import { jsonPreview } from "../../shared/text/preview"; diff --git a/src/app-server/protocol/turn.ts b/src/app-server/protocol/turn.ts index c936c63b..8bbca11b 100644 --- a/src/app-server/protocol/turn.ts +++ b/src/app-server/protocol/turn.ts @@ -1,10 +1,10 @@ -import type { ThreadItem as GeneratedTurnItem } from "../../generated/app-server/v2/ThreadItem"; import { conversationSummaryFromTranscriptEntries, nonEmptyConversationSummaries, type ThreadConversationSummary, type ThreadTranscriptEntry, } from "../../domain/threads/transcript"; +import type { ThreadItem as GeneratedTurnItem } from "../../generated/app-server/v2/ThreadItem"; export type TurnItem = GeneratedTurnItem; diff --git a/src/app-server/query/cache.ts b/src/app-server/query/cache.ts index d7937e0d..617ca1a1 100644 --- a/src/app-server/query/cache.ts +++ b/src/app-server/query/cache.ts @@ -1,26 +1,25 @@ import { QueryClient, QueryObserver, type QueryObserverResult } from "@tanstack/query-core"; - -import type { AppServerClient } from "../connection/client"; -import type { AppServerClientAccessOptions } from "../connection/client-access"; -import { listModelMetadata } from "../catalog"; -import { readRateLimitMetadataProbe, readSkillMetadataProbe } from "./metadata-probes"; -import { runtimeConfigSnapshotFromAppServerConfig } from "../protocol/runtime-config"; -import { listThreads } from "../threads"; import type { ModelMetadata } from "../../domain/catalog/metadata"; import type { ObservedDataListener, ObservedDataResult } from "../../domain/observed-data"; import { createServerDiagnostics, diagnosticProbeError, diagnosticProbeOk, diagnosticsWithProbe } from "../../domain/server/diagnostics"; import type { SharedServerMetadata } from "../../domain/server/metadata"; import type { Thread } from "../../domain/threads/model"; +import { listModelMetadata } from "../catalog"; +import type { AppServerClient } from "../connection/client"; +import type { AppServerClientAccessOptions } from "../connection/client-access"; +import { runtimeConfigSnapshotFromAppServerConfig } from "../protocol/runtime-config"; +import { listThreads } from "../threads"; import { + type AppServerQueryContext, activeThreadsQueryKey, - archivedThreadsQueryKey, appServerMetadataQueryKey, appServerModelsQueryKey, appServerQueriesFilter, appServerQueryContextIsComplete, + archivedThreadsQueryKey, cloneAppServerQueryContext, - type AppServerQueryContext, } from "./keys"; +import { readRateLimitMetadataProbe, readSkillMetadataProbe } from "./metadata-probes"; import { cloneModelMetadata, cloneSharedServerMetadata, cloneThreads } from "./snapshots"; const THREAD_LIST_STALE_TIME_MS = 10_000; diff --git a/src/app-server/query/metadata-probes.ts b/src/app-server/query/metadata-probes.ts index 8e6d6aa9..3b925f65 100644 --- a/src/app-server/query/metadata-probes.ts +++ b/src/app-server/query/metadata-probes.ts @@ -1,9 +1,9 @@ -import type { AppServerClient } from "../connection/client"; -import { accountRateLimitsSummaryFromResponse, rateLimitSnapshotFromAccountRateLimitsResponse } from "../protocol/runtime-metrics"; -import { listSkillCatalog } from "../catalog"; -import { diagnosticProbeError, diagnosticProbeOk, type Diagnostics } from "../../domain/server/diagnostics"; import type { SkillMetadata } from "../../domain/catalog/metadata"; import type { RateLimitSnapshot } from "../../domain/runtime/metrics"; +import { type Diagnostics, diagnosticProbeError, diagnosticProbeOk } from "../../domain/server/diagnostics"; +import { listSkillCatalog } from "../catalog"; +import type { AppServerClient } from "../connection/client"; +import { accountRateLimitsSummaryFromResponse, rateLimitSnapshotFromAccountRateLimitsResponse } from "../protocol/runtime-metrics"; interface MetadataProbeResult { data: T; diff --git a/src/app-server/query/shared-queries.ts b/src/app-server/query/shared-queries.ts index 7a45fe17..78a7a22f 100644 --- a/src/app-server/query/shared-queries.ts +++ b/src/app-server/query/shared-queries.ts @@ -4,10 +4,10 @@ import type { SharedServerMetadata } from "../../domain/server/metadata"; import type { Thread } from "../../domain/threads/model"; import type { AppServerQueryCache } from "./cache"; import { + type AppServerQueryContext, appServerQueryContextMatches, appServerQueryContextRawEquals, cloneAppServerQueryContext, - type AppServerQueryContext, } from "./keys"; export interface AppServerSharedQueriesOptions { diff --git a/src/app-server/services/ephemeral-structured-turn.ts b/src/app-server/services/ephemeral-structured-turn.ts index fb4bc913..3d9814cf 100644 --- a/src/app-server/services/ephemeral-structured-turn.ts +++ b/src/app-server/services/ephemeral-structured-turn.ts @@ -1,3 +1,4 @@ +import type { ModelMetadataClient } from "../catalog"; import { AppServerClient, type AppServerClientHandlers, @@ -6,7 +7,6 @@ import { } from "../connection/client"; import type { AppServerClientRequestPolicy } from "../connection/client-access"; import type { RequestId, ServerNotification } from "../connection/rpc-messages"; -import type { ModelMetadataClient } from "../catalog"; import { lastAgentMessageTextFromTurnRecord, type TurnItem, type TurnRecord } from "../protocol/turn"; import { abortableOperation, throwIfSignalAborted } from "./abortable-operation"; diff --git a/src/app-server/services/thread-archive-markdown.ts b/src/app-server/services/thread-archive-markdown.ts index 012097db..bf5bf3b2 100644 --- a/src/app-server/services/thread-archive-markdown.ts +++ b/src/app-server/services/thread-archive-markdown.ts @@ -1,9 +1,9 @@ import { - archivedThreadMarkdown, - archivedThreadTitle, type ArchiveExportAdapter, type ArchiveExportSettings, type ArchiveThreadInput, + archivedThreadMarkdown, + archivedThreadTitle, } from "../../domain/threads/archive-markdown"; import { shortThreadId } from "../../shared/id/thread-id"; diff --git a/src/app-server/services/thread-archive.ts b/src/app-server/services/thread-archive.ts index e02a0b40..d2c96fb6 100644 --- a/src/app-server/services/thread-archive.ts +++ b/src/app-server/services/thread-archive.ts @@ -1,7 +1,7 @@ import type { ArchiveExportAdapter, ArchiveExportSettings } from "../../domain/threads/archive-markdown"; import type { AppServerClient } from "../connection/client"; -import { exportArchivedThreadMarkdown } from "./thread-archive-markdown"; import { readThreadForArchiveExport } from "../threads"; +import { exportArchivedThreadMarkdown } from "./thread-archive-markdown"; export interface ArchiveThreadOptions { settings: ArchiveExportSettings; diff --git a/src/app-server/services/thread-title-generation.ts b/src/app-server/services/thread-title-generation.ts index 3455d011..816437ab 100644 --- a/src/app-server/services/thread-title-generation.ts +++ b/src/app-server/services/thread-title-generation.ts @@ -1,18 +1,18 @@ -import { - runEphemeralStructuredTurn, - type EphemeralStructuredTurnClientFactory, - type StructuredTurnOutputSchema, -} from "./ephemeral-structured-turn"; -import type { ModelMetadataClient } from "../catalog"; -import { resolvedRuntimeOverrideForClient } from "./runtime-overrides"; -import { conversationAssistantTextFromTurnRecord, type TurnRecord } from "../protocol/turn"; import type { ReasoningEffort } from "../../domain/catalog/metadata"; import { THREAD_TITLE_MAX_CHARS, + type ThreadTitleContext, threadTitleFromGeneratedText, threadTitlePrompt, - type ThreadTitleContext, } from "../../domain/threads/title-generation-model"; +import type { ModelMetadataClient } from "../catalog"; +import { conversationAssistantTextFromTurnRecord, type TurnRecord } from "../protocol/turn"; +import { + type EphemeralStructuredTurnClientFactory, + runEphemeralStructuredTurn, + type StructuredTurnOutputSchema, +} from "./ephemeral-structured-turn"; +import { resolvedRuntimeOverrideForClient } from "./runtime-overrides"; const THREAD_TITLE_SERVICE_NAME = "codex-panel-naming"; const THREAD_TITLE_TIMEOUT_MS = 60_000; diff --git a/src/app-server/threads.ts b/src/app-server/threads.ts index 292eee44..081d00fd 100644 --- a/src/app-server/threads.ts +++ b/src/app-server/threads.ts @@ -1,21 +1,21 @@ -import type { AppServerClient } from "./connection/client"; -import { appServerThreadGoalUserHistoryItem, threadGoalFromAppServerGoal } from "./protocol/thread-goal"; -import { threadFromThreadRecord, threadsFromThreadRecords, type ThreadRecord } from "./protocol/thread"; -import { - chronologicalConversationSummariesFromTurnRecords, - completedConversationSummariesFromTurnRecords, - transcriptEntriesFromTurnRecords, -} from "./protocol/turn"; import { normalizeReasoningEffort } from "../domain/catalog/metadata"; import type { ApprovalsReviewer, ServiceTier } from "../domain/runtime/policy"; import { parseServiceTier } from "../domain/runtime/policy"; -import type { ArchiveThreadInput } from "../domain/threads/archive-markdown"; import type { ThreadActivationSnapshot } from "../domain/threads/activation"; +import type { ArchiveThreadInput } from "../domain/threads/archive-markdown"; import type { ThreadGoal, ThreadGoalUpdate } from "../domain/threads/goal"; import type { HistoricalTurn } from "../domain/threads/history"; import type { Thread } from "../domain/threads/model"; import { REFERENCED_THREAD_TURN_LIMIT } from "../domain/threads/reference"; import type { ThreadConversationSummary } from "../domain/threads/transcript"; +import type { AppServerClient } from "./connection/client"; +import { type ThreadRecord, threadFromThreadRecord, threadsFromThreadRecords } from "./protocol/thread"; +import { appServerThreadGoalUserHistoryItem, threadGoalFromAppServerGoal } from "./protocol/thread-goal"; +import { + chronologicalConversationSummariesFromTurnRecords, + completedConversationSummariesFromTurnRecords, + transcriptEntriesFromTurnRecords, +} from "./protocol/turn"; const THREAD_LIST_PAGE_LIMIT = 100; diff --git a/src/app-server/tool-inventory.ts b/src/app-server/tool-inventory.ts index 9dbdbfc3..b1eaacec 100644 --- a/src/app-server/tool-inventory.ts +++ b/src/app-server/tool-inventory.ts @@ -1,12 +1,12 @@ +import type { SkillMetadata } from "../domain/catalog/metadata"; import { + type DiagnosticProbeResult, diagnosticProbeError, diagnosticProbeOk, - mcpServerStatusSummariesFromStatuses, - type DiagnosticProbeResult, type McpServerDiagnostic, type McpServerStatusSummary, + mcpServerStatusSummariesFromStatuses, } from "../domain/server/diagnostics"; -import type { SkillMetadata } from "../domain/catalog/metadata"; import type { ToolInventoryApp, ToolInventoryMarketplaceError, diff --git a/src/domain/threads/archive-markdown.ts b/src/domain/threads/archive-markdown.ts index b61250e2..46cb3fff 100644 --- a/src/domain/threads/archive-markdown.ts +++ b/src/domain/threads/archive-markdown.ts @@ -1,7 +1,3 @@ -import type { Thread } from "./model"; -import { referencedThreadMetadataFromPrompt } from "./reference"; -import { threadArchiveTitle } from "./title"; -import type { ThreadTranscriptEntry } from "./transcript"; import { isExternalFileHref, isFilesystemAbsolutePath, @@ -10,6 +6,10 @@ import { parseFileHref, vaultRelativePath, } from "../../shared/path/file-paths"; +import type { Thread } from "./model"; +import { referencedThreadMetadataFromPrompt } from "./reference"; +import { threadArchiveTitle } from "./title"; +import type { ThreadTranscriptEntry } from "./transcript"; interface ParsedMarkdownLink { raw: string; diff --git a/src/domain/threads/title-generation-model.ts b/src/domain/threads/title-generation-model.ts index 10e0edcb..16d46646 100644 --- a/src/domain/threads/title-generation-model.ts +++ b/src/domain/threads/title-generation-model.ts @@ -1,5 +1,5 @@ -import type { ThreadConversationSummary } from "./transcript"; import { truncate } from "../../shared/text/preview"; +import type { ThreadConversationSummary } from "./transcript"; const THREAD_TITLE_CONTEXT_MAX_CHARS = 4_000; const DEFAULT_CONTEXT_PAGE_LIMIT = 20; diff --git a/src/features/chat/app-server/actions/diagnostics.ts b/src/features/chat/app-server/actions/diagnostics.ts index 06b364f9..20a7cfeb 100644 --- a/src/features/chat/app-server/actions/diagnostics.ts +++ b/src/features/chat/app-server/actions/diagnostics.ts @@ -1,18 +1,18 @@ import type { AppServerClient } from "../../../../app-server/connection/client"; +import { readRateLimitMetadataProbe } from "../../../../app-server/query/metadata-probes"; +import { readToolInventory } from "../../../../app-server/tool-inventory"; import { cloneServerDiagnostics, - diagnosticsWithToolInventory, - diagnosticsWithProbe, + type DiagnosticProbeMethod, + type Diagnostics, diagnosticProbeError, diagnosticProbeOk, + diagnosticsWithProbe, + diagnosticsWithToolInventory, upsertMcpServerStatusDiagnostics, - type Diagnostics, - type DiagnosticProbeMethod, } from "../../../../domain/server/diagnostics"; -import { readToolInventory } from "../../../../app-server/tool-inventory"; -import { readRateLimitMetadataProbe } from "../../../../app-server/query/metadata-probes"; import type { SharedServerMetadata } from "../../../../domain/server/metadata"; -import { captureChatServerActionClientScope, type ChatServerActionHost } from "./host"; +import { type ChatServerActionHost, captureChatServerActionClientScope } from "./host"; interface RefreshServerDiagnosticsOptions { appServerMetadataSnapshot?: boolean; diff --git a/src/features/chat/app-server/actions/metadata.ts b/src/features/chat/app-server/actions/metadata.ts index 68010352..4560f740 100644 --- a/src/features/chat/app-server/actions/metadata.ts +++ b/src/features/chat/app-server/actions/metadata.ts @@ -1,17 +1,17 @@ import { + type RateLimitMetadataProbeResult, readRateLimitMetadataProbe, readSkillMetadataProbe, - type RateLimitMetadataProbeResult, } from "../../../../app-server/query/metadata-probes"; import { isStaleAppServerSharedQueryContextError } from "../../../../app-server/query/shared-queries"; import { cloneServerDiagnostics, diagnosticsWithProbe, - upsertMcpServerDiagnostic, type McpServerStartupStatus, + upsertMcpServerDiagnostic, } from "../../../../domain/server/diagnostics"; import type { SharedServerMetadata } from "../../../../domain/server/metadata"; -import { captureChatServerActionClientScope, type ChatServerActionHost } from "./host"; +import { type ChatServerActionHost, captureChatServerActionClientScope } from "./host"; export type AppServerResourceEvent = | { type: "skills-changed"; forceReload: boolean } diff --git a/src/features/chat/app-server/actions/threads.ts b/src/features/chat/app-server/actions/threads.ts index 85b6d280..ec3645a6 100644 --- a/src/features/chat/app-server/actions/threads.ts +++ b/src/features/chat/app-server/actions/threads.ts @@ -1,12 +1,12 @@ +import { threadActivationSnapshotFromAppServerResponse } from "../../../../app-server/threads"; import type { Thread } from "../../../../domain/threads/model"; import type { ThreadCatalogEvent } from "../../../../workspace/thread-catalog"; -import { threadActivationSnapshotFromAppServerResponse } from "../../../../app-server/threads"; -import type { RuntimeSnapshot } from "../../domain/runtime/snapshot"; -import { runtimeConfigOrDefault } from "../../domain/runtime/effective"; -import { serviceTierRequestForThreadStart } from "../runtime/thread-settings-update"; import { resumedThreadAction } from "../../application/state/actions"; -import { captureChatServerActionClientScope, type ChatServerActionHost } from "./host"; import type { ChatState } from "../../application/state/root-reducer"; +import { runtimeConfigOrDefault } from "../../domain/runtime/effective"; +import type { RuntimeSnapshot } from "../../domain/runtime/snapshot"; +import { serviceTierRequestForThreadStart } from "../runtime/thread-settings-update"; +import { type ChatServerActionHost, captureChatServerActionClientScope } from "./host"; interface StartedThreadSummary { threadId: string; diff --git a/src/features/chat/app-server/inbound/handler.ts b/src/features/chat/app-server/inbound/handler.ts index 46648ece..4be2a84a 100644 --- a/src/features/chat/app-server/inbound/handler.ts +++ b/src/features/chat/app-server/inbound/handler.ts @@ -4,31 +4,31 @@ import { appServerMcpElicitationResponse, appServerUserInputResponse, } from "../../../../app-server/protocol/server-requests"; -import type { ThreadConversationSummary } from "../../../../domain/threads/transcript"; -import type { ThreadCatalogEvent } from "../../../../workspace/thread-catalog"; -import type { AppServerResourceEvent } from "../actions/metadata"; -import type { LocalIdSource } from "../../../../shared/id/local-id"; -import { classifyAppServerLog } from "./app-server-logs"; -import { activeTurnId } from "../../application/conversation/turn-state"; -import type { ChatAction, ChatState } from "../../application/state/root-reducer"; -import type { ChatStateStore } from "../../application/state/store"; -import type { MessageStreamNoticeSection } from "../../domain/message-stream/items"; -import { createStructuredSystemItem, createSystemItem } from "../../domain/message-stream/factories/system-items"; import { - contentForPendingMcpElicitation, type ApprovalAction, + contentForPendingMcpElicitation, type McpElicitationAction, type PendingApproval, type PendingMcpElicitation, type PendingRequestId, type PendingUserInput, } from "../../../../domain/pending-requests/model"; +import type { ThreadConversationSummary } from "../../../../domain/threads/transcript"; +import type { LocalIdSource } from "../../../../shared/id/local-id"; +import type { ThreadCatalogEvent } from "../../../../workspace/thread-catalog"; +import { activeTurnId } from "../../application/conversation/turn-state"; +import type { ChatAction, ChatState } from "../../application/state/root-reducer"; +import type { ChatStateStore } from "../../application/state/store"; +import { createStructuredSystemItem, createSystemItem } from "../../domain/message-stream/factories/system-items"; +import type { MessageStreamNoticeSection } from "../../domain/message-stream/items"; import { createApprovalResultItem, createMcpElicitationResultItem, createUserInputResultItem, } from "../../domain/pending-requests/result-items"; -import { planChatNotification, type ChatNotificationEffect } from "./notification-plan"; +import type { AppServerResourceEvent } from "../actions/metadata"; +import { classifyAppServerLog } from "./app-server-logs"; +import { type ChatNotificationEffect, planChatNotification } from "./notification-plan"; import { routeServerRequest } from "./routing"; function cannotSendApprovalResponseMessage(): string { diff --git a/src/features/chat/app-server/inbound/notification-plan.ts b/src/features/chat/app-server/inbound/notification-plan.ts index 89efaa4f..adad3c6c 100644 --- a/src/features/chat/app-server/inbound/notification-plan.ts +++ b/src/features/chat/app-server/inbound/notification-plan.ts @@ -1,44 +1,43 @@ -import { activeThreadSettingsAppliedAction } from "../../application/state/actions"; -import { threadTokenUsageFromRuntimeUsage } from "../../../../domain/runtime/metrics"; -import { threadFromAppServerRecord } from "../../../../app-server/threads"; -import { completedConversationSummaryFromTurnRecord, type TurnItem } from "../../../../app-server/protocol/turn"; import type { ServerNotification } from "../../../../app-server/connection/rpc-messages"; +import { completedConversationSummaryFromTurnRecord, type TurnItem } from "../../../../app-server/protocol/turn"; +import { threadFromAppServerRecord } from "../../../../app-server/threads"; +import { threadTokenUsageFromRuntimeUsage } from "../../../../domain/runtime/metrics"; import { normalizeExplicitThreadName } from "../../../../domain/threads/model"; import type { ThreadConversationSummary } from "../../../../domain/threads/transcript"; -import type { ThreadCatalogEvent } from "../../../../workspace/thread-catalog"; import { jsonPreview } from "../../../../shared/text/preview"; +import type { ThreadCatalogEvent } from "../../../../workspace/thread-catalog"; import { activeTurnId, pendingTurnStart as pendingTurnStartForState } from "../../application/conversation/turn-state"; +import { activeThreadSettingsAppliedAction } from "../../application/state/actions"; +import { messageStreamItems } from "../../application/state/message-stream"; import type { ChatAction, ChatState } from "../../application/state/root-reducer"; -import { completeReasoningItems, upsertMessageStreamItemById } from "../../domain/message-stream/updates"; +import { reconcileCompletedTurnItems } from "../../domain/message-stream/completed-turn-reconciliation"; +import { goalChangeItem } from "../../domain/message-stream/factories/goal-items"; +import { + STREAMED_COMMAND_RUNNING_TEXT, + STREAMED_FILE_CHANGE_IN_PROGRESS_TEXT, + STREAMED_MCP_PROGRESS_LABEL, +} from "../../domain/message-stream/factories/streaming-items"; +import { createSystemItem } from "../../domain/message-stream/factories/system-items"; +import type { MessageStreamItem, MessageStreamItemKind } from "../../domain/message-stream/items"; +import { attachHookRunsToTurn, completeReasoningItems, upsertMessageStreamItemById } from "../../domain/message-stream/updates"; +import type { AppServerResourceEvent } from "../actions/metadata"; +import { + type AppServerFileChange, + normalizeFileChanges, + streamingFileChangeMessageStreamItem, +} from "../mappers/message-stream/file-changes"; +import { hookRunMessageStreamItem } from "../mappers/message-stream/hook-run-items"; +import { createAutoReviewResultItem, createReviewResultItem } from "../mappers/message-stream/review-result-items"; +import { taskProgressMessageStreamItem } from "../mappers/message-stream/task-progress"; import { messageStreamItemFromTurnItem, messageStreamItemsFromTurns, shouldSuppressLifecycleItem, } from "../mappers/message-stream/turn-items"; import { - normalizeFileChanges, - streamingFileChangeMessageStreamItem, - type AppServerFileChange, -} from "../mappers/message-stream/file-changes"; -import { taskProgressMessageStreamItem } from "../mappers/message-stream/task-progress"; -import type { MessageStreamItem, MessageStreamItemKind } from "../../domain/message-stream/items"; -import { goalChangeItem } from "../../domain/message-stream/factories/goal-items"; -import { hookRunMessageStreamItem } from "../mappers/message-stream/hook-run-items"; -import { createAutoReviewResultItem, createReviewResultItem } from "../mappers/message-stream/review-result-items"; -import { createSystemItem } from "../../domain/message-stream/factories/system-items"; -import { - STREAMED_COMMAND_RUNNING_TEXT, - STREAMED_FILE_CHANGE_IN_PROGRESS_TEXT, - STREAMED_MCP_PROGRESS_LABEL, -} from "../../domain/message-stream/factories/streaming-items"; -import { attachHookRunsToTurn } from "../../domain/message-stream/updates"; -import { messageStreamItems } from "../../application/state/message-stream"; -import { reconcileCompletedTurnItems } from "../../domain/message-stream/completed-turn-reconciliation"; -import type { AppServerResourceEvent } from "../actions/metadata"; -import { - routeServerNotification, type DiagnosticStatusNotification, type DiagnosticStatusNotificationMethod, + routeServerNotification, type StreamUpdateNotification, type StreamUpdateNotificationMethod, type ThreadLifecycleNotification, diff --git a/src/features/chat/app-server/mappers/message-stream/agent-items.ts b/src/features/chat/app-server/mappers/message-stream/agent-items.ts index db4e1f9e..b33e14cb 100644 --- a/src/features/chat/app-server/mappers/message-stream/agent-items.ts +++ b/src/features/chat/app-server/mappers/message-stream/agent-items.ts @@ -1,10 +1,10 @@ -import type { AgentMessageStreamItem, AgentStateSummary, ExecutionState } from "../../../domain/message-stream/items"; import { collabAgentStateExecutionState, + type ExecutionStateByStatus, executionStateFromStatus, RUNNING_EXECUTION_STATE, - type ExecutionStateByStatus, } from "../../../domain/message-stream/execution-state"; +import type { AgentMessageStreamItem, AgentStateSummary, ExecutionState } from "../../../domain/message-stream/items"; const STANDARD_TOOL_STATES: ExecutionStateByStatus = { inProgress: RUNNING_EXECUTION_STATE, diff --git a/src/features/chat/app-server/mappers/message-stream/file-changes.ts b/src/features/chat/app-server/mappers/message-stream/file-changes.ts index d91654af..2ec217af 100644 --- a/src/features/chat/app-server/mappers/message-stream/file-changes.ts +++ b/src/features/chat/app-server/mappers/message-stream/file-changes.ts @@ -1,5 +1,5 @@ -import type { MessageStreamFileChange, MessageStreamItem } from "../../../domain/message-stream/items"; import { patchApplyExecutionState } from "../../../domain/message-stream/execution-state"; +import type { MessageStreamFileChange, MessageStreamItem } from "../../../domain/message-stream/items"; export interface AppServerFileChange { readonly path: string; diff --git a/src/features/chat/app-server/mappers/message-stream/hook-run-items.ts b/src/features/chat/app-server/mappers/message-stream/hook-run-items.ts index 92f39a99..0bad8919 100644 --- a/src/features/chat/app-server/mappers/message-stream/hook-run-items.ts +++ b/src/features/chat/app-server/mappers/message-stream/hook-run-items.ts @@ -1,9 +1,9 @@ -import type { ExecutionState, HookMessageStreamItem } from "../../../domain/message-stream/items"; import { + type ExecutionStateByStatus, executionStateFromStatus, RUNNING_EXECUTION_STATE, - type ExecutionStateByStatus, } from "../../../domain/message-stream/execution-state"; +import type { ExecutionState, HookMessageStreamItem } from "../../../domain/message-stream/items"; interface MessageStreamHookRun { id: string; diff --git a/src/features/chat/app-server/mappers/message-stream/review-result-items.ts b/src/features/chat/app-server/mappers/message-stream/review-result-items.ts index 5255385a..12908493 100644 --- a/src/features/chat/app-server/mappers/message-stream/review-result-items.ts +++ b/src/features/chat/app-server/mappers/message-stream/review-result-items.ts @@ -1,11 +1,11 @@ -import type { ExecutionState, MessageStreamAuditFact, MessageStreamItem } from "../../../domain/message-stream/items"; +import { pathRelativeToRoot } from "../../../../../shared/path/file-paths"; import { + type ExecutionStateByStatus, executionStateFromStatus, RUNNING_EXECUTION_STATE, - type ExecutionStateByStatus, } from "../../../domain/message-stream/execution-state"; import { permissionRows } from "../../../domain/message-stream/format/permission-rows"; -import { pathRelativeToRoot } from "../../../../../shared/path/file-paths"; +import type { ExecutionState, MessageStreamAuditFact, MessageStreamItem } from "../../../domain/message-stream/items"; const AUTO_REVIEW_STATES: ExecutionStateByStatus = { inProgress: RUNNING_EXECUTION_STATE, diff --git a/src/features/chat/app-server/mappers/message-stream/task-progress.ts b/src/features/chat/app-server/mappers/message-stream/task-progress.ts index bcd58026..5f42b638 100644 --- a/src/features/chat/app-server/mappers/message-stream/task-progress.ts +++ b/src/features/chat/app-server/mappers/message-stream/task-progress.ts @@ -1,9 +1,9 @@ -import type { ExecutionState, MessageStreamItem } from "../../../domain/message-stream/items"; import { + type ExecutionStateByStatus, executionStateFromStatus, RUNNING_EXECUTION_STATE, - type ExecutionStateByStatus, } from "../../../domain/message-stream/execution-state"; +import type { ExecutionState, MessageStreamItem } from "../../../domain/message-stream/items"; const TASK_STATES = { pending: RUNNING_EXECUTION_STATE, diff --git a/src/features/chat/app-server/mappers/message-stream/turn-items.ts b/src/features/chat/app-server/mappers/message-stream/turn-items.ts index 82895881..b3a07fd6 100644 --- a/src/features/chat/app-server/mappers/message-stream/turn-items.ts +++ b/src/features/chat/app-server/mappers/message-stream/turn-items.ts @@ -1,14 +1,8 @@ -import type { CommandMessageStreamTarget, MessageStreamDiagnosticSection, MessageStreamItem } from "../../../domain/message-stream/items"; -import type { MessageStreamItemProvenance } from "../../../domain/message-stream/provenance"; -import type { HistoricalTurn } from "../../../../../domain/threads/history"; import type { TurnItem } from "../../../../../app-server/protocol/turn"; -import { jsonPreview } from "../../../../../shared/text/preview"; -import { referencedThreadMetadataFromPrompt } from "../../../../../domain/threads/reference"; import { turnUserItemText } from "../../../../../app-server/protocol/turn"; -import { agentMessageStreamItem } from "./agent-items"; -import { fileMentionsFromInput } from "../../../domain/message-stream/format/file-mentions"; -import { normalizeProposedPlanMarkdown } from "../../../domain/message-stream/format/proposed-plan"; -import { userMessageDisplayText } from "../../../domain/message-stream/format/user-message-text"; +import type { HistoricalTurn } from "../../../../../domain/threads/history"; +import { referencedThreadMetadataFromPrompt } from "../../../../../domain/threads/reference"; +import { jsonPreview } from "../../../../../shared/text/preview"; import { commandExecutionState, dynamicToolCallExecutionState, @@ -17,6 +11,12 @@ import { mcpToolCallExecutionState, patchApplyExecutionState, } from "../../../domain/message-stream/execution-state"; +import { fileMentionsFromInput } from "../../../domain/message-stream/format/file-mentions"; +import { normalizeProposedPlanMarkdown } from "../../../domain/message-stream/format/proposed-plan"; +import { userMessageDisplayText } from "../../../domain/message-stream/format/user-message-text"; +import type { CommandMessageStreamTarget, MessageStreamDiagnosticSection, MessageStreamItem } from "../../../domain/message-stream/items"; +import type { MessageStreamItemProvenance } from "../../../domain/message-stream/provenance"; +import { agentMessageStreamItem } from "./agent-items"; import { normalizeFileChanges } from "./file-changes"; type UserMessageItem = Extract; diff --git a/src/features/chat/app-server/runtime/thread-settings-update.ts b/src/features/chat/app-server/runtime/thread-settings-update.ts index 3ebb8b80..e1b06749 100644 --- a/src/features/chat/app-server/runtime/thread-settings-update.ts +++ b/src/features/chat/app-server/runtime/thread-settings-update.ts @@ -1,12 +1,12 @@ +import type { RuntimeConfigSnapshot } from "../../../../domain/runtime/config"; import { applyRuntimeSettingsPatchValue, - runtimeCollaborationModeSettings, type RuntimeServiceTierRequest, type RuntimeSettingsPatch, + runtimeCollaborationModeSettings, } from "../../../../domain/runtime/thread-settings"; -import type { RuntimeConfigSnapshot } from "../../../../domain/runtime/config"; -import { resolveRuntimeControls, type RuntimeControlsResolution } from "../../domain/runtime/resolution"; import type { PendingRuntimeIntent } from "../../domain/runtime/intent"; +import { type RuntimeControlsResolution, resolveRuntimeControls } from "../../domain/runtime/resolution"; import type { RuntimeSnapshot } from "../../domain/runtime/snapshot"; type TurnCollaborationModeWarning = "missing-model"; diff --git a/src/features/chat/application/composer/suggestions.ts b/src/features/chat/application/composer/suggestions.ts index caf90249..a58a3574 100644 --- a/src/features/chat/application/composer/suggestions.ts +++ b/src/features/chat/application/composer/suggestions.ts @@ -1,11 +1,10 @@ -import type { Thread } from "../../../../domain/threads/model"; +import { prepareFuzzySearch, type SearchResult, sortSearchResults } from "obsidian"; import type { ModelMetadata, SkillMetadata } from "../../../../domain/catalog/metadata"; -import { prepareFuzzySearch, sortSearchResults, type SearchResult } from "obsidian"; -import { findModelMetadataByIdOrName, sortedModelMetadata } from "../../../../domain/catalog/metadata"; -import { supportedEffortsForModelMetadata } from "../../../../domain/catalog/metadata"; -import { SLASH_COMMANDS, slashCommandSubcommands, type SlashCommandName } from "./slash-commands"; +import { findModelMetadataByIdOrName, sortedModelMetadata, supportedEffortsForModelMetadata } from "../../../../domain/catalog/metadata"; +import type { Thread } from "../../../../domain/threads/model"; import { threadDisplayTitle } from "../../../../domain/threads/title"; import { shortThreadId } from "../../../../shared/id/thread-id"; +import { SLASH_COMMANDS, type SlashCommandName, slashCommandSubcommands } from "./slash-commands"; export interface ComposerSuggestion { display: string; diff --git a/src/features/chat/application/composer/wikilink-context.ts b/src/features/chat/application/composer/wikilink-context.ts index 81de22c6..3d5a9afd 100644 --- a/src/features/chat/application/composer/wikilink-context.ts +++ b/src/features/chat/application/composer/wikilink-context.ts @@ -1,7 +1,6 @@ import { parseLinktext } from "obsidian"; - -import { codexTextInputWithMentions, type RequestAdditionalContext, type RequestMention } from "../../../../domain/chat/input"; import type { SkillMetadata } from "../../../../domain/catalog/metadata"; +import { codexTextInputWithMentions, type RequestAdditionalContext, type RequestMention } from "../../../../domain/chat/input"; export interface ParsedWikiLink { raw: string; diff --git a/src/features/chat/application/connection/connection-controller.ts b/src/features/chat/application/connection/connection-controller.ts index e531934f..be13f8cd 100644 --- a/src/features/chat/application/connection/connection-controller.ts +++ b/src/features/chat/application/connection/connection-controller.ts @@ -1,5 +1,5 @@ -import { StaleConnectionError } from "../../../../app-server/connection/connection-manager"; import type { AppServerClient } from "../../../../app-server/connection/client"; +import { StaleConnectionError } from "../../../../app-server/connection/connection-manager"; import { isStaleAppServerSharedQueryContextError } from "../../../../app-server/query/shared-queries"; import type { ServerInitialization } from "../../../../domain/server/initialization"; import type { ActiveConnectionWork, ConnectionWorkTracker } from "../../../../shared/lifecycle/connection-work"; diff --git a/src/features/chat/application/connection/diagnostics-display.ts b/src/features/chat/application/connection/diagnostics-display.ts index c4801246..d2caeb18 100644 --- a/src/features/chat/application/connection/diagnostics-display.ts +++ b/src/features/chat/application/connection/diagnostics-display.ts @@ -1,8 +1,8 @@ -import { serverIdentity, serverPlatform, type DiagnosticProbeMethod } from "../../../../domain/server/diagnostics"; import { CLIENT_VERSION } from "../../../../constants"; -import type { ChatState } from "../state/root-reducer"; +import type { DiagnosticProbeResult, Diagnostics } from "../../../../domain/server/diagnostics"; +import { type DiagnosticProbeMethod, serverIdentity, serverPlatform } from "../../../../domain/server/diagnostics"; import type { ServerInitialization } from "../../../../domain/server/initialization"; -import type { Diagnostics, DiagnosticProbeResult } from "../../../../domain/server/diagnostics"; +import type { ChatState } from "../state/root-reducer"; const RUNTIME_CHECK_PROBE_METHODS: readonly DiagnosticProbeMethod[] = ["model/list", "account/rateLimits/read"]; diff --git a/src/features/chat/application/conversation/composer-submit-actions.ts b/src/features/chat/application/conversation/composer-submit-actions.ts index 9d338a52..56c34ccd 100644 --- a/src/features/chat/application/conversation/composer-submit-actions.ts +++ b/src/features/chat/application/conversation/composer-submit-actions.ts @@ -1,11 +1,11 @@ import type { AppServerClient } from "../../../../app-server/connection/client"; import type { CodexInput } from "../../../../domain/chat/input"; -import { submissionStateSnapshot } from "./submission-state"; -import type { ChatStateStore } from "../state/store"; -import { parseSlashCommand } from "../composer/suggestions"; -import type { SlashCommandExecutionResult } from "./slash-command-execution"; -import { slashCommandRequiresConnection, type SlashCommandName } from "../composer/slash-commands"; import type { ReferencedThreadMetadata } from "../../../../domain/threads/reference"; +import { type SlashCommandName, slashCommandRequiresConnection } from "../composer/slash-commands"; +import { parseSlashCommand } from "../composer/suggestions"; +import type { ChatStateStore } from "../state/store"; +import type { SlashCommandExecutionResult } from "./slash-command-execution"; +import { submissionStateSnapshot } from "./submission-state"; const STATUS_INTERRUPT_REQUESTED = "Interrupt requested."; diff --git a/src/features/chat/application/conversation/composition.ts b/src/features/chat/application/conversation/composition.ts index b72e72df..69376faa 100644 --- a/src/features/chat/application/conversation/composition.ts +++ b/src/features/chat/application/conversation/composition.ts @@ -1,15 +1,15 @@ import type { AppServerClient } from "../../../../app-server/connection/client"; import type { CodexInput } from "../../../../domain/chat/input"; -import type { MessageStreamNoticeSection } from "../../domain/message-stream/items"; import type { LocalIdSource } from "../../../../shared/id/local-id"; +import type { MessageStreamNoticeSection } from "../../domain/message-stream/items"; import type { ChatRuntimeSettingsActions } from "../runtime/settings-actions"; import type { ChatStateStore } from "../state/store"; -import type { ThreadManagementActions } from "../threads/thread-management-actions"; import type { GoalActions } from "../threads/goal-actions"; -import { submitComposer, type ComposerSubmitActions, type ComposerSubmitActionsHost } from "./composer-submit-actions"; +import type { ThreadManagementActions } from "../threads/thread-management-actions"; +import { type ComposerSubmitActions, type ComposerSubmitActionsHost, submitComposer } from "./composer-submit-actions"; +import { implementPlan, type PlanImplementationHost } from "./plan-implementation"; import { executeSlashCommandWithState, type SlashCommandExecutorHost } from "./slash-command-executor"; import { createTurnSubmissionActions } from "./turn-submission-actions"; -import { implementPlan, type PlanImplementationHost } from "./plan-implementation"; export interface ConversationTurnActionsContext { vaultPath: string; diff --git a/src/features/chat/application/conversation/optimistic-turn-start.ts b/src/features/chat/application/conversation/optimistic-turn-start.ts index eb12095d..44cf16e8 100644 --- a/src/features/chat/application/conversation/optimistic-turn-start.ts +++ b/src/features/chat/application/conversation/optimistic-turn-start.ts @@ -1,11 +1,11 @@ -import type { PendingTurnStart } from "./turn-state"; -import type { MessageStreamFileMention, MessageStreamItem, MessageStreamMessageItem } from "../../domain/message-stream/items"; -import type { MessageStreamItemProvenance } from "../../domain/message-stream/provenance"; +import type { CodexInput } from "../../../../domain/chat/input"; +import { isLocalSteerMessageClientId } from "../../domain/local-message-ids"; import { fileMentionsFromInput } from "../../domain/message-stream/format/file-mentions"; import { userMessageDisplayText } from "../../domain/message-stream/format/user-message-text"; +import type { MessageStreamFileMention, MessageStreamItem, MessageStreamMessageItem } from "../../domain/message-stream/items"; +import type { MessageStreamItemProvenance } from "../../domain/message-stream/provenance"; import { attachHookRunsToTurn } from "../../domain/message-stream/updates"; -import { isLocalSteerMessageClientId } from "../../domain/local-message-ids"; -import type { CodexInput } from "../../../../domain/chat/input"; +import type { PendingTurnStart } from "./turn-state"; interface LocalUserMessageParams { id: string; diff --git a/src/features/chat/application/conversation/plan-implementation.ts b/src/features/chat/application/conversation/plan-implementation.ts index b2d7cae9..0859b19a 100644 --- a/src/features/chat/application/conversation/plan-implementation.ts +++ b/src/features/chat/application/conversation/plan-implementation.ts @@ -1,10 +1,10 @@ import type { AppServerClient } from "../../../../app-server/connection/client"; import { latestImplementablePlanTargetFromItems, type PlanImplementationTarget } from "../../domain/message-stream/selectors"; import type { ChatRuntimeState } from "../../domain/runtime/state"; -import type { ChatStateStore } from "../state/store"; -import { chatTurnBusy, type ChatTurnState } from "./turn-state"; +import { type ChatMessageStreamState, messageStreamItems } from "../state/message-stream"; import type { ChatActiveThreadState, ChatState } from "../state/root-reducer"; -import { messageStreamItems, type ChatMessageStreamState } from "../state/message-stream"; +import type { ChatStateStore } from "../state/store"; +import { type ChatTurnState, chatTurnBusy } from "./turn-state"; const IMPLEMENT_PLAN_PROMPT = "Please implement this plan."; diff --git a/src/features/chat/application/conversation/slash-command-execution.ts b/src/features/chat/application/conversation/slash-command-execution.ts index 8e7ab8b1..e901d1d4 100644 --- a/src/features/chat/application/conversation/slash-command-execution.ts +++ b/src/features/chat/application/conversation/slash-command-execution.ts @@ -1,24 +1,24 @@ -import type { CodexInput } from "../../../../domain/chat/input"; -import type { ThreadGoal } from "../../../../domain/threads/goal"; import type { ReasoningEffort } from "../../../../domain/catalog/metadata"; import { normalizeReasoningEffort } from "../../../../domain/catalog/metadata"; +import type { CodexInput } from "../../../../domain/chat/input"; +import type { ThreadGoal } from "../../../../domain/threads/goal"; import type { Thread } from "../../../../domain/threads/model"; -import { threadDisplayTitle } from "../../../../domain/threads/title"; import type { ReferencedThreadMetadata } from "../../../../domain/threads/reference"; +import { threadDisplayTitle } from "../../../../domain/threads/title"; import { shortThreadId } from "../../../../shared/id/thread-id"; -import type { ChatRuntimeSettingsActions } from "../runtime/settings-actions"; -import type { GoalActions } from "../threads/goal-actions"; -import type { ThreadManagementActions } from "../threads/thread-management-actions"; +import type { MessageStreamAuditFact, MessageStreamNoticeSection } from "../../domain/message-stream/items"; +import { modelOverrideMessage, reasoningEffortOverrideMessage } from "../../domain/runtime/labels"; import { + type SlashCommandName, + type SlashCommandSubcommandDefinition, slashCommandDefinition, slashCommandHelpSections, slashCommandSubcommandDefinition, slashCommandSubcommands, - type SlashCommandName, - type SlashCommandSubcommandDefinition, } from "../composer/slash-commands"; -import type { MessageStreamAuditFact, MessageStreamNoticeSection } from "../../domain/message-stream/items"; -import { modelOverrideMessage, reasoningEffortOverrideMessage } from "../../domain/runtime/labels"; +import type { ChatRuntimeSettingsActions } from "../runtime/settings-actions"; +import type { GoalActions } from "../threads/goal-actions"; +import type { ThreadManagementActions } from "../threads/thread-management-actions"; const DEFAULT_RUNTIME_SETTING_ALIASES = new Set(["default", "reset", "clear", "off"]); diff --git a/src/features/chat/application/conversation/slash-command-executor.ts b/src/features/chat/application/conversation/slash-command-executor.ts index 967e9c80..b799ae36 100644 --- a/src/features/chat/application/conversation/slash-command-executor.ts +++ b/src/features/chat/application/conversation/slash-command-executor.ts @@ -1,22 +1,22 @@ import type { AppServerClient } from "../../../../app-server/connection/client"; -import { codexTextInputWithAttachments, type CodexInput } from "../../../../domain/chat/input"; import { readReferencedThreadConversationSummaries } from "../../../../app-server/threads"; -import { referencedThreadPromptBundle, REFERENCED_THREAD_TURN_LIMIT } from "../../../../domain/threads/reference"; +import type { ReasoningEffort } from "../../../../domain/catalog/metadata"; +import { findModelMetadataByIdOrName, supportedEffortsForModelMetadata } from "../../../../domain/catalog/metadata"; +import { type CodexInput, codexTextInputWithAttachments } from "../../../../domain/chat/input"; import type { Thread } from "../../../../domain/threads/model"; +import { REFERENCED_THREAD_TURN_LIMIT, referencedThreadPromptBundle } from "../../../../domain/threads/reference"; import { shortThreadId } from "../../../../shared/id/thread-id"; +import { runtimeConfigOrDefault } from "../../domain/runtime/effective"; +import { resolveRuntimeControls } from "../../domain/runtime/resolution"; +import type { SlashCommandName } from "../composer/slash-commands"; +import { runtimeSnapshotForChatState } from "../runtime/snapshot"; +import type { ChatStateStore } from "../state/store"; import { executeSlashCommand as runSlashCommand, type SlashCommandExecutionPorts, type SlashCommandExecutionResult, type ThreadReferenceInput, } from "./slash-command-execution"; -import type { SlashCommandName } from "../composer/slash-commands"; -import type { ReasoningEffort } from "../../../../domain/catalog/metadata"; -import { findModelMetadataByIdOrName, supportedEffortsForModelMetadata } from "../../../../domain/catalog/metadata"; -import type { ChatStateStore } from "../state/store"; -import { runtimeConfigOrDefault } from "../../domain/runtime/effective"; -import { resolveRuntimeControls } from "../../domain/runtime/resolution"; -import { runtimeSnapshotForChatState } from "../runtime/snapshot"; import { submissionStateSnapshot } from "./submission-state"; export interface SlashCommandExecutorHost extends SlashCommandExecutionPorts { diff --git a/src/features/chat/application/conversation/submission-state.ts b/src/features/chat/application/conversation/submission-state.ts index f1ef20e2..014c1f71 100644 --- a/src/features/chat/application/conversation/submission-state.ts +++ b/src/features/chat/application/conversation/submission-state.ts @@ -1,8 +1,8 @@ import type { Thread } from "../../../../domain/threads/model"; import type { MessageStreamItem } from "../../domain/message-stream/items"; -import { activeTurnId, chatTurnBusy, pendingTurnStart, type PendingTurnStart } from "./turn-state"; -import type { ChatState } from "../state/root-reducer"; import { messageStreamItems } from "../state/message-stream"; +import type { ChatState } from "../state/root-reducer"; +import { activeTurnId, chatTurnBusy, type PendingTurnStart, pendingTurnStart } from "./turn-state"; export interface SubmissionStateSnapshot { activeThreadId: string | null; diff --git a/src/features/chat/application/conversation/turn-submission-actions.ts b/src/features/chat/application/conversation/turn-submission-actions.ts index f1c91dfd..2bad77f6 100644 --- a/src/features/chat/application/conversation/turn-submission-actions.ts +++ b/src/features/chat/application/conversation/turn-submission-actions.ts @@ -3,7 +3,6 @@ import type { CodexInput } from "../../../../domain/chat/input"; import type { ReferencedThreadMetadata } from "../../../../domain/threads/reference"; import type { LocalIdSource } from "../../../../shared/id/local-id"; import type { ChatStateStore } from "../state/store"; -import { STATUS_TURN_RUNNING } from "./turn-state"; import { acknowledgeOptimisticTurnStart, cleanupFailedTurnStart, @@ -12,6 +11,7 @@ import { shouldAcknowledgeTurnStart, } from "./optimistic-turn-start"; import { submissionStateSnapshot } from "./submission-state"; +import { STATUS_TURN_RUNNING } from "./turn-state"; const STATUS_STEERED_CURRENT_TURN = "Steered current turn."; diff --git a/src/features/chat/application/pending-requests/block.ts b/src/features/chat/application/pending-requests/block.ts index 6c4edf29..ae66962a 100644 --- a/src/features/chat/application/pending-requests/block.ts +++ b/src/features/chat/application/pending-requests/block.ts @@ -6,8 +6,8 @@ import type { PendingRequestId, PendingUserInput, } from "../../../../domain/pending-requests/model"; -import type { ChatRequestState } from "./state"; import type { ChatUiState } from "../state/ui-state"; +import type { ChatRequestState } from "./state"; export interface PendingRequestBlockState { approvals: readonly PendingApproval[]; diff --git a/src/features/chat/application/pending-requests/pending-request-actions.ts b/src/features/chat/application/pending-requests/pending-request-actions.ts index 6eaffec1..40d42ca2 100644 --- a/src/features/chat/application/pending-requests/pending-request-actions.ts +++ b/src/features/chat/application/pending-requests/pending-request-actions.ts @@ -1,8 +1,6 @@ -import type { ChatStateStore } from "../state/store"; -import { pendingRequestFocusSignature } from "../../domain/pending-requests/signatures"; import { - answersForPendingUserInput, type ApprovalAction, + answersForPendingUserInput, type McpElicitationAction, type PendingApproval, type PendingMcpElicitation, @@ -10,7 +8,9 @@ import { type PendingUserInput, } from "../../../../domain/pending-requests/model"; import { approvalDetailsDisclosureId } from "../../domain/pending-requests/disclosure-ids"; -import { pendingRequestBlockStateFromChatState, type PendingRequestBlockActions, type PendingRequestBlockState } from "./block"; +import { pendingRequestFocusSignature } from "../../domain/pending-requests/signatures"; +import type { ChatStateStore } from "../state/store"; +import { type PendingRequestBlockActions, type PendingRequestBlockState, pendingRequestBlockStateFromChatState } from "./block"; interface PendingRequestResponder { resolveApproval: (requestId: PendingRequestId, action: ApprovalAction) => void; diff --git a/src/features/chat/application/pending-requests/state.ts b/src/features/chat/application/pending-requests/state.ts index 6c6c1bf6..ec962cd3 100644 --- a/src/features/chat/application/pending-requests/state.ts +++ b/src/features/chat/application/pending-requests/state.ts @@ -1,11 +1,11 @@ import { mcpElicitationDraftKey, - userInputDraftKey, - userInputOtherDraftKey, type PendingApproval, type PendingMcpElicitation, type PendingRequestId, type PendingUserInput, + userInputDraftKey, + userInputOtherDraftKey, } from "../../../../domain/pending-requests/model"; import { patchObject } from "../state/patch"; diff --git a/src/features/chat/application/runtime/settings-actions.ts b/src/features/chat/application/runtime/settings-actions.ts index 32c83595..95e09b3b 100644 --- a/src/features/chat/application/runtime/settings-actions.ts +++ b/src/features/chat/application/runtime/settings-actions.ts @@ -1,18 +1,18 @@ import type { AppServerClient } from "../../../../app-server/connection/client"; +import type { ReasoningEffort } from "../../../../domain/catalog/metadata"; import type { RuntimeConfigSnapshot } from "../../../../domain/runtime/config"; import type { ApprovalsReviewer } from "../../../../domain/runtime/policy"; import type { RuntimeSettingsPatch } from "../../../../domain/runtime/thread-settings"; -import type { ReasoningEffort } from "../../../../domain/catalog/metadata"; -import { autoReviewActive, fastModeActive, runtimeConfigOrDefault } from "../../domain/runtime/effective"; import { pendingRuntimeSettingsPatch as buildPendingRuntimeSettingsPatch, type PendingRuntimeSettingsPatch, } from "../../app-server/runtime/thread-settings-update"; +import { autoReviewActive, fastModeActive, runtimeConfigOrDefault } from "../../domain/runtime/effective"; +import { type CollaborationModeSelection, nextCollaborationMode, type RequestedFastMode } from "../../domain/runtime/intent"; +import { modelOverrideMessage, reasoningEffortOverrideMessage } from "../../domain/runtime/labels"; import type { RuntimeSnapshot } from "../../domain/runtime/snapshot"; -import { nextCollaborationMode, type CollaborationModeSelection, type RequestedFastMode } from "../../domain/runtime/intent"; import type { ChatAction, ChatState } from "../state/root-reducer"; import type { ChatStateStore } from "../state/store"; -import { modelOverrideMessage, reasoningEffortOverrideMessage } from "../../domain/runtime/labels"; interface RuntimeSettingsCommitResult { ok: boolean; diff --git a/src/features/chat/application/runtime/snapshot.ts b/src/features/chat/application/runtime/snapshot.ts index fc087bdc..5029cf64 100644 --- a/src/features/chat/application/runtime/snapshot.ts +++ b/src/features/chat/application/runtime/snapshot.ts @@ -1,8 +1,8 @@ -import type { ChatState } from "../state/root-reducer"; import type { MessageStreamItem } from "../../domain/message-stream/items"; import type { RuntimeSnapshot } from "../../domain/runtime/snapshot"; import { activeThreadRuntimeState, pendingRuntimeIntentState } from "../../domain/runtime/state"; import { messageStreamItems } from "../state/message-stream"; +import type { ChatState } from "../state/root-reducer"; interface RuntimeSnapshotInput { runtimeConfig: ChatState["connection"]["runtimeConfig"]; diff --git a/src/features/chat/application/state/actions.ts b/src/features/chat/application/state/actions.ts index d4ae25af..5cc17c79 100644 --- a/src/features/chat/application/state/actions.ts +++ b/src/features/chat/application/state/actions.ts @@ -1,11 +1,11 @@ +import { normalizeReasoningEffort, type ReasoningEffort } from "../../../../domain/catalog/metadata"; +import { parseServiceTier, type ServiceTier } from "../../../../domain/runtime/policy"; import type { ServerInitialization } from "../../../../domain/server/initialization"; import type { ThreadActivationSnapshot } from "../../../../domain/threads/activation"; -import { upsertThread, type Thread } from "../../../../domain/threads/model"; -import { parseServiceTier, type ServiceTier } from "../../../../domain/runtime/policy"; -import { normalizeReasoningEffort, type ReasoningEffort } from "../../../../domain/catalog/metadata"; -import type { ActiveThreadRuntimeState } from "../../domain/runtime/state"; -import type { CollaborationModeSelection } from "../../domain/runtime/intent"; +import { type Thread, upsertThread } from "../../../../domain/threads/model"; import type { MessageStreamItem } from "../../domain/message-stream/items"; +import type { CollaborationModeSelection } from "../../domain/runtime/intent"; +import type { ActiveThreadRuntimeState } from "../../domain/runtime/state"; import type { PendingTurnStart } from "../conversation/turn-state"; interface ResumedThreadActionParams { diff --git a/src/features/chat/application/state/message-stream.ts b/src/features/chat/application/state/message-stream.ts index 784555c6..0b206b5b 100644 --- a/src/features/chat/application/state/message-stream.ts +++ b/src/features/chat/application/state/message-stream.ts @@ -1,13 +1,13 @@ -import { completeReasoningItems, upsertMessageStreamItemById } from "../../domain/message-stream/updates"; -import type { MessageStreamItem, MessageStreamMessageItem } from "../../domain/message-stream/items"; -import { normalizeProposedPlanMarkdown } from "../../domain/message-stream/format/proposed-plan"; -import { messageStreamSemanticClassifications } from "../../domain/message-stream/semantics/classify"; -import { messageStreamIsTurnInitiator } from "../../domain/message-stream/semantics/predicates"; import { streamedItemOutputMessageStreamItem, streamedTextMessageStreamItem, streamedToolOutputMessageStreamItem, } from "../../domain/message-stream/factories/streaming-items"; +import { normalizeProposedPlanMarkdown } from "../../domain/message-stream/format/proposed-plan"; +import type { MessageStreamItem, MessageStreamMessageItem } from "../../domain/message-stream/items"; +import { messageStreamSemanticClassifications } from "../../domain/message-stream/semantics/classify"; +import { messageStreamIsTurnInitiator } from "../../domain/message-stream/semantics/predicates"; +import { completeReasoningItems, upsertMessageStreamItemById } from "../../domain/message-stream/updates"; import { definedPatch, patchObject } from "./patch"; export interface ChatMessageStreamActiveSegment { diff --git a/src/features/chat/application/state/root-reducer.ts b/src/features/chat/application/state/root-reducer.ts index 62161b86..2d46e2a4 100644 --- a/src/features/chat/application/state/root-reducer.ts +++ b/src/features/chat/application/state/root-reducer.ts @@ -1,34 +1,47 @@ -import type { ServerInitialization } from "../../../../domain/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 "../../../../domain/threads/goal"; -import type { Diagnostics } from "../../../../domain/server/diagnostics"; -import { createServerDiagnostics } from "../../../../domain/server/diagnostics"; +import type { ModelMetadata, ReasoningEffort, SkillMetadata } from "../../../../domain/catalog/metadata"; +import type { PendingRequestId } from "../../../../domain/pending-requests/model"; import type { RuntimeConfigSnapshot } from "../../../../domain/runtime/config"; import type { RateLimitSnapshot, ThreadTokenUsage } from "../../../../domain/runtime/metrics"; import type { ApprovalsReviewer } from "../../../../domain/runtime/policy"; import type { RuntimeSettingsPatch } from "../../../../domain/runtime/thread-settings"; -import type { CollaborationModeSelection } from "../../domain/runtime/intent"; +import type { Diagnostics } from "../../../../domain/server/diagnostics"; +import { createServerDiagnostics } from "../../../../domain/server/diagnostics"; +import type { ServerInitialization } from "../../../../domain/server/initialization"; +import type { ThreadGoal } from "../../../../domain/threads/goal"; +import type { Thread } from "../../../../domain/threads/model"; +import type { MessageStreamItem } from "../../domain/message-stream/items"; +import type { CollaborationModeSelection, RequestedFastMode } from "../../domain/runtime/intent"; import { - commitAppliedRuntimeSettingsPatchState, + type ChatRuntimeState, clearRequestedApprovalsReviewerRuntimeState, clearRequestedFastModeRuntimeState, + commitAppliedRuntimeSettingsPatchState, initialActiveChatRuntimeState, initialChatRuntimeState, requestApprovalsReviewerRuntimeState, + requestFastModeRuntimeState, requestModelRuntimeState, requestReasoningEffortRuntimeState, - requestFastModeRuntimeState, resetModelToConfigRuntimeState, resetReasoningEffortToConfigRuntimeState, setSelectedCollaborationModeRuntimeState, - type ChatRuntimeState, } from "../../domain/runtime/state"; -import type { RequestedFastMode } from "../../domain/runtime/intent"; -import type { PendingRequestId } from "../../../../domain/pending-requests/model"; import type { ComposerSuggestion } from "../composer/suggestions"; -import type { MessageStreamItem } from "../../domain/message-stream/items"; +import { + type ChatTurnState, + initialChatTurnState, + type PendingTurnStart, + STATUS_TURN_RUNNING, + transitionChatTurnLifecycleState, +} from "../conversation/turn-state"; +import { + type ChatRequestState, + initialChatRequestState, + isRequestAction, + type RequestAction, + reduceRequestSlice, + resolveChatRequest, +} from "../pending-requests/state"; import type { ActiveThreadResumedAction, ActiveThreadSettingsAppliedAction, @@ -42,42 +55,27 @@ import type { TurnStartFailedAction, } from "./actions"; import { + type ChatMessageStreamState, initialChatMessageStreamState, isMessageStreamAction, + type MessageStreamAction, messageStreamItems, messageStreamStartActiveSegment, messageStreamWithActiveTurnItems, messageStreamWithItems, reduceMessageStreamSlice, - type ChatMessageStreamState, - type MessageStreamAction, } from "./message-stream"; +import { definedPatch, patchObject } from "./patch"; import { - initialChatRequestState, - isRequestAction, - reduceRequestSlice, - resolveChatRequest, - type ChatRequestState, - type RequestAction, -} from "../pending-requests/state"; -import { - STATUS_TURN_RUNNING, - initialChatTurnState, - transitionChatTurnLifecycleState, - type ChatTurnState, - type PendingTurnStart, -} from "../conversation/turn-state"; -import { + type ChatUiState, clearAllRequestDisclosures, clearResolvedRequestDisclosures, initialUiState, isUiAction, maybeClearGoalObjectiveExpansion, reduceUiSlice, - type ChatUiState, type UiAction, } from "./ui-state"; -import { definedPatch, patchObject } from "./patch"; export type ChatConnectionPhase = | { kind: "idle" } diff --git a/src/features/chat/application/state/store.ts b/src/features/chat/application/state/store.ts index f166ee37..cfaed870 100644 --- a/src/features/chat/application/state/store.ts +++ b/src/features/chat/application/state/store.ts @@ -1,6 +1,6 @@ -import { cloneDisclosureUiState } from "./ui-state"; import type { ChatMessageStreamActiveSegment, ChatMessageStreamState } from "./message-stream"; -import { chatReducer, createChatState, type ChatAction, type ChatState } from "./root-reducer"; +import { type ChatAction, type ChatState, chatReducer, createChatState } from "./root-reducer"; +import { cloneDisclosureUiState } from "./ui-state"; export interface ChatStateStore { getState(): ChatState; diff --git a/src/features/chat/application/state/ui-state.ts b/src/features/chat/application/state/ui-state.ts index 144a3448..d6dd430a 100644 --- a/src/features/chat/application/state/ui-state.ts +++ b/src/features/chat/application/state/ui-state.ts @@ -1,12 +1,12 @@ +import { type PendingRequestId, pendingRequestDerivedKeyPrefix } from "../../../../domain/pending-requests/model"; import type { ThreadGoal } from "../../../../domain/threads/goal"; -import { pendingRequestDerivedKeyPrefix, type PendingRequestId } from "../../../../domain/pending-requests/model"; import { - threadRenameGenerationStillActive, - transitionThreadRenameLifecycleState, type ThreadRenameActiveState, type ThreadRenameGeneratingState, type ThreadRenameLifecycleEvent, type ThreadRenameLifecycleState, + threadRenameGenerationStillActive, + transitionThreadRenameLifecycleState, } from "../../../threads/rename-lifecycle"; import type { DisclosureSetAction } from "./actions"; import { patchObject } from "./patch"; diff --git a/src/features/chat/application/threads/active-thread-identity-sync.ts b/src/features/chat/application/threads/active-thread-identity-sync.ts index f9e7bee5..d62265bb 100644 --- a/src/features/chat/application/threads/active-thread-identity-sync.ts +++ b/src/features/chat/application/threads/active-thread-identity-sync.ts @@ -1,5 +1,5 @@ -import type { RestorationController } from "./restoration-controller"; import type { ChatStateStore } from "../state/store"; +import type { RestorationController } from "./restoration-controller"; import { activeThreadId } from "./state-selectors"; export interface ActiveThreadIdentitySyncHost { diff --git a/src/features/chat/application/threads/auto-title-coordinator.ts b/src/features/chat/application/threads/auto-title-coordinator.ts index 9bd8697e..beb18a34 100644 --- a/src/features/chat/application/threads/auto-title-coordinator.ts +++ b/src/features/chat/application/threads/auto-title-coordinator.ts @@ -1,6 +1,6 @@ import type { Thread } from "../../../../domain/threads/model"; -import type { ThreadConversationSummary } from "../../../../domain/threads/transcript"; import type { ThreadTitleContext } from "../../../../domain/threads/title-generation-model"; +import type { ThreadConversationSummary } from "../../../../domain/threads/transcript"; import type { ThreadTitleService } from "../../../threads/thread-title-service"; import type { ChatState } from "../state/root-reducer"; import type { ChatStateStore } from "../state/store"; diff --git a/src/features/chat/application/threads/goal-actions.ts b/src/features/chat/application/threads/goal-actions.ts index 1486709d..c2324e29 100644 --- a/src/features/chat/application/threads/goal-actions.ts +++ b/src/features/chat/application/threads/goal-actions.ts @@ -2,9 +2,9 @@ import type { AppServerClient } from "../../../../app-server/connection/client"; import { readThreadGoal, recordThreadGoalUserMessage, setThreadGoal } from "../../../../app-server/threads"; import type { ThreadGoal, ThreadGoalStatus, ThreadGoalUpdate } from "../../../../domain/threads/goal"; import type { LocalIdSource } from "../../../../shared/id/local-id"; -import type { ChatStateStore } from "../state/store"; -import type { GoalMessageStreamItem } from "../../domain/message-stream/items"; import { goalChangeItem } from "../../domain/message-stream/factories/goal-items"; +import type { GoalMessageStreamItem } from "../../domain/message-stream/items"; +import type { ChatStateStore } from "../state/store"; export interface ThreadGoalSyncHost { stateStore: ChatStateStore; diff --git a/src/features/chat/application/threads/history-controller.ts b/src/features/chat/application/threads/history-controller.ts index ec3f27d9..dd52c2b9 100644 --- a/src/features/chat/application/threads/history-controller.ts +++ b/src/features/chat/application/threads/history-controller.ts @@ -1,8 +1,8 @@ import type { AppServerClient } from "../../../../app-server/connection/client"; -import { readChatThreadHistoryPage, type ChatThreadHistoryPage } from "../../app-server/threads/projection"; +import { type ChatThreadHistoryPage, readChatThreadHistoryPage } from "../../app-server/threads/projection"; +import { messageStreamItems } from "../state/message-stream"; import type { ChatAction, ChatState } from "../state/root-reducer"; import type { ChatStateStore } from "../state/store"; -import { messageStreamItems } from "../state/message-stream"; export interface HistoryControllerHost { stateStore: ChatStateStore; diff --git a/src/features/chat/application/threads/lifecycle-parts.ts b/src/features/chat/application/threads/lifecycle-parts.ts index d49bb49a..de119244 100644 --- a/src/features/chat/application/threads/lifecycle-parts.ts +++ b/src/features/chat/application/threads/lifecycle-parts.ts @@ -2,11 +2,11 @@ import type { AppServerClient } from "../../../../app-server/connection/client"; import { recoverRolloutTokenUsage } from "../../../../app-server/services/rollout-token-usage"; import type { ChatResumeWorkTracker } from "../lifecycle"; import type { ChatStateStore } from "../state/store"; +import { createActiveThreadIdentitySync } from "./active-thread-identity-sync"; import type { GoalActions } from "./goal-actions"; import type { HistoryController } from "./history-controller"; -import { createActiveThreadIdentitySync } from "./active-thread-identity-sync"; -import { createResumeActions, type ResumeActions } from "./resume-actions"; import { RestorationController } from "./restoration-controller"; +import { createResumeActions, type ResumeActions } from "./resume-actions"; export interface ThreadLifecyclePartsContext { settingsRef: { readonly vaultPath: string }; diff --git a/src/features/chat/application/threads/rename-editor-actions.ts b/src/features/chat/application/threads/rename-editor-actions.ts index 84bf67e9..5ff5731e 100644 --- a/src/features/chat/application/threads/rename-editor-actions.ts +++ b/src/features/chat/application/threads/rename-editor-actions.ts @@ -3,10 +3,10 @@ import { threadRenameDraftTitle } from "../../../../domain/threads/title"; import type { ThreadTitleContext } from "../../../../domain/threads/title-generation-model"; import type { ThreadOperations } from "../../../threads/thread-operations"; import type { ThreadTitleService } from "../../../threads/thread-title-service"; -import type { ChatAction, ChatState } from "../state/root-reducer"; -import { renameGenerationStillActive, type ChatRenameGeneratingUiState, type ChatRenameUiState } from "../state/ui-state"; -import type { ChatStateStore } from "../state/store"; import { messageStreamItems } from "../state/message-stream"; +import type { ChatAction, ChatState } from "../state/root-reducer"; +import type { ChatStateStore } from "../state/store"; +import { type ChatRenameGeneratingUiState, type ChatRenameUiState, renameGenerationStillActive } from "../state/ui-state"; import { firstThreadTitleContextFromMessageStreamItems } from "./title-context"; interface RenameEditState { diff --git a/src/features/chat/application/threads/restoration-controller.ts b/src/features/chat/application/threads/restoration-controller.ts index ece1f8c6..a2c4a683 100644 --- a/src/features/chat/application/threads/restoration-controller.ts +++ b/src/features/chat/application/threads/restoration-controller.ts @@ -1,8 +1,8 @@ import { - transitionRestoredThreadLifecycle, type RestoredThreadLifecycleState, type RestoredThreadPlaceholderState, type RestoredThreadState, + transitionRestoredThreadLifecycle, } from "../lifecycle"; const STATUS_THREAD_READY_TO_RESUME = "Thread ready to resume."; diff --git a/src/features/chat/application/threads/resume-actions.ts b/src/features/chat/application/threads/resume-actions.ts index 148651ad..5b9e0b2e 100644 --- a/src/features/chat/application/threads/resume-actions.ts +++ b/src/features/chat/application/threads/resume-actions.ts @@ -1,11 +1,11 @@ import type { AppServerClient } from "../../../../app-server/connection/client"; import type { ThreadTokenUsage } from "../../../../domain/runtime/metrics"; -import { resumeChatThread, type ChatThreadResumeSnapshot } from "../../app-server/threads/projection"; +import { type ChatThreadResumeSnapshot, resumeChatThread } from "../../app-server/threads/projection"; +import type { ActiveChatResume, ChatResumeWorkTracker } from "../lifecycle"; import { resumedThreadAction } from "../state/actions"; import type { ChatStateStore } from "../state/store"; -import type { RestorationController } from "./restoration-controller"; import type { HistoryController } from "./history-controller"; -import type { ChatResumeWorkTracker, ActiveChatResume } from "../lifecycle"; +import type { RestorationController } from "./restoration-controller"; import { activeThreadId, canSwitchToThread, listedThreads, messageStreamItemsEmpty } from "./state-selectors"; export interface ResumeActionsHost { diff --git a/src/features/chat/application/threads/start-new-thread-actions.ts b/src/features/chat/application/threads/start-new-thread-actions.ts index f7be9dbf..33b4efee 100644 --- a/src/features/chat/application/threads/start-new-thread-actions.ts +++ b/src/features/chat/application/threads/start-new-thread-actions.ts @@ -1,6 +1,6 @@ -import type { ActiveThreadIdentitySync } from "./active-thread-identity-sync"; import { chatTurnBusy } from "../conversation/turn-state"; import type { ChatStateStore } from "../state/store"; +import type { ActiveThreadIdentitySync } from "./active-thread-identity-sync"; export interface StartNewThreadActions { startNewThread(): Promise; diff --git a/src/features/chat/application/threads/state-selectors.ts b/src/features/chat/application/threads/state-selectors.ts index be0bd991..f079b385 100644 --- a/src/features/chat/application/threads/state-selectors.ts +++ b/src/features/chat/application/threads/state-selectors.ts @@ -1,7 +1,7 @@ import type { Thread } from "../../../../domain/threads/model"; import { chatTurnBusy } from "../conversation/turn-state"; -import type { ChatState } from "../state/root-reducer"; import { messageStreamIsEmpty } from "../state/message-stream"; +import type { ChatState } from "../state/root-reducer"; export function activeThreadId(state: ChatState): string | null { return state.activeThread.id; diff --git a/src/features/chat/application/threads/thread-management-actions.ts b/src/features/chat/application/threads/thread-management-actions.ts index 684f7ccc..edeba23e 100644 --- a/src/features/chat/application/threads/thread-management-actions.ts +++ b/src/features/chat/application/threads/thread-management-actions.ts @@ -5,9 +5,9 @@ import type { ThreadCatalogEvent } from "../../../../workspace/thread-catalog"; import type { ThreadOperations } from "../../../threads/thread-operations"; import { messageStreamItemsFromTurns } from "../../app-server/mappers/message-stream/turn-items"; import { activeThreadRuntimeState } from "../../domain/runtime/state"; +import { chatTurnBusy } from "../conversation/turn-state"; import { resumedThreadActionFromActiveRuntime } from "../state/actions"; import { messageStreamRollbackCandidate, messageStreamTurnsAfterTurnId } from "../state/message-stream"; -import { chatTurnBusy } from "../conversation/turn-state"; import type { ChatAction, ChatState } from "../state/root-reducer"; import type { ChatStateStore } from "../state/store"; diff --git a/src/features/chat/application/threads/title-context.ts b/src/features/chat/application/threads/title-context.ts index 12287374..5693d80a 100644 --- a/src/features/chat/application/threads/title-context.ts +++ b/src/features/chat/application/threads/title-context.ts @@ -1,6 +1,6 @@ -import { threadTitleContextPromptText, type ThreadTitleContext } from "../../../../domain/threads/title-generation-model"; -import { isCompletedTurnOutcomeMessage } from "../../domain/message-stream/selectors"; +import { type ThreadTitleContext, threadTitleContextPromptText } from "../../../../domain/threads/title-generation-model"; import type { MessageStreamItem, MessageStreamMessageItem } from "../../domain/message-stream/items"; +import { isCompletedTurnOutcomeMessage } from "../../domain/message-stream/selectors"; export function threadTitleContextFromMessageStreamItems(turnId: string, items: readonly MessageStreamItem[]): ThreadTitleContext | null { const turnItems = items.filter((item) => item.turnId === turnId); diff --git a/src/features/chat/domain/message-stream/factories/streaming-items.ts b/src/features/chat/domain/message-stream/factories/streaming-items.ts index b3da0c60..58ac4ec8 100644 --- a/src/features/chat/domain/message-stream/factories/streaming-items.ts +++ b/src/features/chat/domain/message-stream/factories/streaming-items.ts @@ -1,5 +1,5 @@ -import type { MessageStreamItem, MessageStreamItemKind } from "../items"; import { RUNNING_EXECUTION_STATE } from "../execution-state"; +import type { MessageStreamItem, MessageStreamItemKind } from "../items"; export const STREAMED_COMMAND_RUNNING_TEXT = "Command running"; export const STREAMED_FILE_CHANGE_IN_PROGRESS_TEXT = "File change inProgress"; diff --git a/src/features/chat/domain/message-stream/semantics/classify.ts b/src/features/chat/domain/message-stream/semantics/classify.ts index 3810f339..c9fb5675 100644 --- a/src/features/chat/domain/message-stream/semantics/classify.ts +++ b/src/features/chat/domain/message-stream/semantics/classify.ts @@ -1,5 +1,5 @@ -import type { MessageStreamItem } from "../items"; import { isLocalSteerMessageClientId } from "../../local-message-ids"; +import type { MessageStreamItem } from "../items"; import type { MessageStreamLifecycle, MessageStreamMeaning, diff --git a/src/features/chat/domain/message-stream/updates.ts b/src/features/chat/domain/message-stream/updates.ts index 2935bf17..afe34cdc 100644 --- a/src/features/chat/domain/message-stream/updates.ts +++ b/src/features/chat/domain/message-stream/updates.ts @@ -1,6 +1,6 @@ +import type { MessageStreamFileChange, MessageStreamItem } from "./items"; import { messageStreamSemanticClassifications } from "./semantics/classify"; import { messageStreamIsTurnInitiator } from "./semantics/predicates"; -import type { MessageStreamFileChange, MessageStreamItem } from "./items"; export function upsertMessageStreamItemById(items: readonly MessageStreamItem[], next: MessageStreamItem): MessageStreamItem[] { const index = items.findIndex((item) => item.id === next.id); diff --git a/src/features/chat/domain/pending-requests/disclosure-ids.ts b/src/features/chat/domain/pending-requests/disclosure-ids.ts index ca99107b..b131b14e 100644 --- a/src/features/chat/domain/pending-requests/disclosure-ids.ts +++ b/src/features/chat/domain/pending-requests/disclosure-ids.ts @@ -1,4 +1,4 @@ -import { pendingRequestDerivedKeyPrefix, type PendingRequestId } from "../../../../domain/pending-requests/model"; +import { type PendingRequestId, pendingRequestDerivedKeyPrefix } from "../../../../domain/pending-requests/model"; export function approvalDetailsDisclosureId(requestId: PendingRequestId): string { return `${pendingRequestDerivedKeyPrefix(requestId)}details`; diff --git a/src/features/chat/domain/pending-requests/result-items.ts b/src/features/chat/domain/pending-requests/result-items.ts index 41a30b5e..b0e9da2a 100644 --- a/src/features/chat/domain/pending-requests/result-items.ts +++ b/src/features/chat/domain/pending-requests/result-items.ts @@ -1,6 +1,6 @@ import { - approvalActionKind, type ApprovalAction, + approvalActionKind, type McpElicitationAction, type McpElicitationContentValue, type PendingApproval, diff --git a/src/features/chat/domain/pending-requests/signatures.ts b/src/features/chat/domain/pending-requests/signatures.ts index 6d255844..a87b6cd0 100644 --- a/src/features/chat/domain/pending-requests/signatures.ts +++ b/src/features/chat/domain/pending-requests/signatures.ts @@ -1,5 +1,5 @@ -import type { PendingApproval, PendingMcpElicitation, PendingUserInput } from "../../../../domain/pending-requests/model"; import { hasPendingRequests, pendingRequestCountsFromQueues } from "../../../../domain/pending-requests/aggregate"; +import type { PendingApproval, PendingMcpElicitation, PendingUserInput } from "../../../../domain/pending-requests/model"; export function pendingRequestsSignature( approvals: readonly PendingApproval[], diff --git a/src/features/chat/domain/runtime/effective.ts b/src/features/chat/domain/runtime/effective.ts index 91f56f1e..23e52a70 100644 --- a/src/features/chat/domain/runtime/effective.ts +++ b/src/features/chat/domain/runtime/effective.ts @@ -1,7 +1,7 @@ -import { cloneRuntimeConfigSnapshot, emptyRuntimeConfigSnapshot, type RuntimeConfigSnapshot } from "../../../../domain/runtime/config"; import type { ReasoningEffort } from "../../../../domain/catalog/metadata"; -import type { RuntimeSnapshot } from "./snapshot"; +import { cloneRuntimeConfigSnapshot, emptyRuntimeConfigSnapshot, type RuntimeConfigSnapshot } from "../../../../domain/runtime/config"; import { resolveRuntimeControls } from "./resolution"; +import type { RuntimeSnapshot } from "./snapshot"; export function runtimeConfigOrDefault(runtimeConfig: RuntimeConfigSnapshot | null): RuntimeConfigSnapshot { return runtimeConfig ? cloneRuntimeConfigSnapshot(runtimeConfig) : emptyRuntimeConfigSnapshot(); diff --git a/src/features/chat/domain/runtime/resolution.ts b/src/features/chat/domain/runtime/resolution.ts index 022f3550..e1c99b9d 100644 --- a/src/features/chat/domain/runtime/resolution.ts +++ b/src/features/chat/domain/runtime/resolution.ts @@ -1,5 +1,5 @@ -import { findModelMetadataByIdOrName, supportedEffortsForModelMetadata, type ModelMetadata } from "../../../../domain/catalog/metadata"; import type { ReasoningEffort } from "../../../../domain/catalog/metadata"; +import { findModelMetadataByIdOrName, type ModelMetadata, supportedEffortsForModelMetadata } from "../../../../domain/catalog/metadata"; import type { RuntimeConfigSnapshot } from "../../../../domain/runtime/config"; import type { ApprovalsReviewer, ServiceTier } from "../../../../domain/runtime/policy"; import { effectiveCollaborationMode, type PendingRuntimeIntent, type RequestedFastMode } from "./intent"; diff --git a/src/features/chat/domain/runtime/state.ts b/src/features/chat/domain/runtime/state.ts index d17d5f41..29b9d860 100644 --- a/src/features/chat/domain/runtime/state.ts +++ b/src/features/chat/domain/runtime/state.ts @@ -1,14 +1,14 @@ -import { parseServiceTier, type ApprovalsReviewer, type ServiceTier } from "../../../../domain/runtime/policy"; -import type { RuntimeSettingsPatch } from "../../../../domain/runtime/thread-settings"; import { normalizeReasoningEffort, type ReasoningEffort } from "../../../../domain/catalog/metadata"; +import { type ApprovalsReviewer, parseServiceTier, type ServiceTier } from "../../../../domain/runtime/policy"; +import type { RuntimeSettingsPatch } from "../../../../domain/runtime/thread-settings"; import { - resetRuntimeIntentToConfig, - setRuntimeIntentValue, - unchangedRuntimeIntent, type ActiveCollaborationMode, type CollaborationModeSelection, type PendingRuntimeIntent, type RequestedFastMode, + resetRuntimeIntentToConfig, + setRuntimeIntentValue, + unchangedRuntimeIntent, } from "./intent"; export interface ChatRuntimeState { diff --git a/src/features/chat/host/connection-bundle.ts b/src/features/chat/host/connection-bundle.ts index 585f8534..23a0a294 100644 --- a/src/features/chat/host/connection-bundle.ts +++ b/src/features/chat/host/connection-bundle.ts @@ -3,23 +3,23 @@ import { Notice } from "obsidian"; import type { AppServerClient } from "../../../app-server/connection/client"; import type { ConnectionManager } from "../../../app-server/connection/connection-manager"; import { isStaleAppServerSharedQueryContextError } from "../../../app-server/query/shared-queries"; -import type { ConnectionWorkTracker } from "../../../shared/lifecycle/connection-work"; import type { LocalIdSource } from "../../../shared/id/local-id"; +import type { ConnectionWorkTracker } from "../../../shared/lifecycle/connection-work"; +import { type ChatServerDiagnosticsActions, createChatServerDiagnosticsActions } from "../app-server/actions/diagnostics"; +import { type ChatServerMetadataActions, createChatServerMetadataActions } from "../app-server/actions/metadata"; +import { type ChatServerThreadActions, createChatServerThreadActions } from "../app-server/actions/threads"; +import { type ChatInboundHandler, createChatInboundHandler } from "../app-server/inbound/handler"; import { + type ChatConnectionController, createChatConnectionController, handleChatConnectionExit, - type ChatConnectionController, } from "../application/connection/connection-controller"; import type { ChatViewDeferredTasks } from "../application/lifecycle"; +import { runtimeSnapshotForChatState } from "../application/runtime/snapshot"; import type { ChatConnectionPhase } from "../application/state/root-reducer"; import type { ChatStateStore } from "../application/state/store"; -import type { createThreadGoalSyncActions } from "../application/threads/goal-actions"; import type { AutoTitleCoordinator } from "../application/threads/auto-title-coordinator"; -import { runtimeSnapshotForChatState } from "../application/runtime/snapshot"; -import { createChatServerDiagnosticsActions, type ChatServerDiagnosticsActions } from "../app-server/actions/diagnostics"; -import { createChatServerMetadataActions, type ChatServerMetadataActions } from "../app-server/actions/metadata"; -import { createChatServerThreadActions, type ChatServerThreadActions } from "../app-server/actions/threads"; -import { createChatInboundHandler, type ChatInboundHandler } from "../app-server/inbound/handler"; +import type { createThreadGoalSyncActions } from "../application/threads/goal-actions"; import type { ChatPanelEnvironment } from "./runtime"; export type CurrentAppServerClient = () => AppServerClient | null; diff --git a/src/features/chat/host/session-graph.ts b/src/features/chat/host/session-graph.ts index d3fe1a5b..766331e0 100644 --- a/src/features/chat/host/session-graph.ts +++ b/src/features/chat/host/session-graph.ts @@ -1,31 +1,39 @@ import { Notice } from "obsidian"; - -import { ConnectionManager } from "../../../app-server/connection/connection-manager"; import type { AppServerClientAccess } from "../../../app-server/connection/client-access"; -import type { ObservedDataResult } from "../../../domain/observed-data"; -import { observedData } from "../../../domain/observed-data"; +import { ConnectionManager } from "../../../app-server/connection/connection-manager"; import { isStaleAppServerSharedQueryContextError } from "../../../app-server/query/shared-queries"; import type { ModelMetadata } from "../../../domain/catalog/metadata"; -import type { MessageStreamNoticeSection } from "../domain/message-stream/items"; +import type { ObservedDataResult } from "../../../domain/observed-data"; +import { observedData } from "../../../domain/observed-data"; +import type { SharedServerMetadata } from "../../../domain/server/metadata"; +import { normalizeExplicitThreadName, type Thread } from "../../../domain/threads/model"; +import { createLocalIdSource, type LocalIdSource } from "../../../shared/id/local-id"; +import type { ConnectionWorkTracker } from "../../../shared/lifecycle/connection-work"; import { createThreadOperations, type ThreadOperations } from "../../threads/thread-operations"; import { createThreadTitleService, type ThreadTitleService } from "../../threads/thread-title-service"; -import { createPendingRequestActions, type PendingRequestActions } from "../application/pending-requests/pending-request-actions"; -import { - createConversationTurnActions, - type ConversationTurnActions as ChatPanelConversationTurnActions, -} from "../application/conversation/composition"; +import type { ChatServerDiagnosticsActions } from "../app-server/actions/diagnostics"; +import type { ChatServerMetadataActions } from "../app-server/actions/metadata"; +import type { ChatServerThreadActions } from "../app-server/actions/threads"; +import type { ChatInboundHandler } from "../app-server/inbound/handler"; +import { connectionDiagnosticSectionsModel } from "../application/connection/diagnostics-display"; +import { type ChatReconnectActionsHost, reconnectPanel } from "../application/connection/reconnect-actions"; +import { toolInventoryDiagnosticSections } from "../application/connection/tool-inventory-display"; import type { ComposerSubmitActions } from "../application/conversation/composer-submit-actions"; -import { reconnectPanel, type ChatReconnectActionsHost } from "../application/connection/reconnect-actions"; -import { runtimeSnapshotForChatState } from "../application/runtime/snapshot"; -import { createChatRuntimeSettingsActions } from "../application/runtime/settings-actions"; -import type { ChatAction, ChatConnectionPhase } from "../application/state/root-reducer"; -import { messageStreamItems } from "../application/state/message-stream"; -import type { ChatStateStore } from "../application/state/store"; +import { + type ConversationTurnActions as ChatPanelConversationTurnActions, + createConversationTurnActions, +} from "../application/conversation/composition"; import type { ChatResumeWorkTracker, ChatViewDeferredTasks } from "../application/lifecycle"; -import { createGoalActions, createThreadGoalSyncActions } from "../application/threads/goal-actions"; -import { createAutoTitleCoordinator, type AutoTitleCoordinator } from "../application/threads/auto-title-coordinator"; -import { HistoryController } from "../application/threads/history-controller"; +import { createPendingRequestActions, type PendingRequestActions } from "../application/pending-requests/pending-request-actions"; +import { createChatRuntimeSettingsActions } from "../application/runtime/settings-actions"; +import { runtimeSnapshotForChatState } from "../application/runtime/snapshot"; +import { messageStreamItems } from "../application/state/message-stream"; +import type { ChatAction, ChatConnectionPhase } from "../application/state/root-reducer"; +import type { ChatStateStore } from "../application/state/store"; import type { ActiveThreadIdentitySync } from "../application/threads/active-thread-identity-sync"; +import { type AutoTitleCoordinator, createAutoTitleCoordinator } from "../application/threads/auto-title-coordinator"; +import { createGoalActions, createThreadGoalSyncActions } from "../application/threads/goal-actions"; +import { HistoryController } from "../application/threads/history-controller"; import { createThreadLifecycleParts } from "../application/threads/lifecycle-parts"; import { activeThreadRenameTitleContext, @@ -37,37 +45,28 @@ import type { ResumeActions } from "../application/threads/resume-actions"; import { createSelectionActions } from "../application/threads/selection-actions"; import { createStartNewThreadActions } from "../application/threads/start-new-thread-actions"; import { createThreadManagementActions, type ThreadManagementActionsHost } from "../application/threads/thread-management-actions"; -import type { ChatServerDiagnosticsActions } from "../app-server/actions/diagnostics"; -import type { ChatServerMetadataActions } from "../app-server/actions/metadata"; -import type { ChatServerThreadActions } from "../app-server/actions/threads"; -import type { ChatInboundHandler } from "../app-server/inbound/handler"; +import { threadTitleContextFromMessageStreamItems } from "../application/threads/title-context"; +import { createStructuredSystemItem, createSystemItem } from "../domain/message-stream/factories/system-items"; +import type { MessageStreamNoticeSection } from "../domain/message-stream/items"; +import { currentModel, runtimeConfigOrDefault } from "../domain/runtime/effective"; +import { collaborationModeLabel as formatCollaborationModeLabel } from "../domain/runtime/labels"; +import type { RuntimeSnapshot } from "../domain/runtime/snapshot"; import { ChatComposerController } from "../panel/composer-controller"; -import { chatPanelComposerProjection, type ChatPanelComposerSurface } from "../panel/surface/composer-projection"; -import { createChatPanelGoalSurface, type ChatPanelGoalSurface } from "../panel/surface/goal-projection"; +import { type ChatPanelComposerSurface, chatPanelComposerProjection } from "../panel/surface/composer-projection"; +import { type ChatPanelGoalSurface, createChatPanelGoalSurface } from "../panel/surface/goal-projection"; import { MessageStreamPresenter } from "../panel/surface/message-stream-presenter"; import type { ChatMessageScrollController } from "../panel/surface/message-stream-scroll"; import type { ChatPanelToolbarSurface } from "../panel/surface/toolbar-projection"; import { createChatPanelToolbarActions, createToolbarPanelActions, type ToolbarPanelActions } from "../panel/toolbar-actions"; -import type { ToolbarActions } from "../ui/toolbar"; -import { currentModel, runtimeConfigOrDefault } from "../domain/runtime/effective"; -import { threadTitleContextFromMessageStreamItems } from "../application/threads/title-context"; -import { normalizeExplicitThreadName, type Thread } from "../../../domain/threads/model"; -import type { SharedServerMetadata } from "../../../domain/server/metadata"; -import type { ConnectionWorkTracker } from "../../../shared/lifecycle/connection-work"; -import { collaborationModeLabel as formatCollaborationModeLabel } from "../domain/runtime/labels"; +import { VaultNoteCandidateProvider } from "../panel/vault-note-candidate-provider"; import { effortStatusLines as buildEffortStatusLines, modelStatusLines as buildModelStatusLines, statusSummaryLines as buildStatusSummaryLines, } from "../presentation/runtime/status"; -import { connectionDiagnosticSectionsModel } from "../application/connection/diagnostics-display"; -import { toolInventoryDiagnosticSections } from "../application/connection/tool-inventory-display"; -import { createStructuredSystemItem, createSystemItem } from "../domain/message-stream/factories/system-items"; -import { createLocalIdSource, type LocalIdSource } from "../../../shared/id/local-id"; -import type { RuntimeSnapshot } from "../domain/runtime/snapshot"; +import type { ToolbarActions } from "../ui/toolbar"; +import { type ChatPanelConnectionBundle, type CurrentAppServerClient, createConnectionBundle } from "./connection-bundle"; import type { ChatPanelEnvironment } from "./runtime"; -import { createConnectionBundle, type ChatPanelConnectionBundle, type CurrentAppServerClient } from "./connection-bundle"; -import { VaultNoteCandidateProvider } from "../panel/vault-note-candidate-provider"; export interface ChatPanelSessionGraph { connection: { diff --git a/src/features/chat/host/session.ts b/src/features/chat/host/session.ts index 35d443de..d2845203 100644 --- a/src/features/chat/host/session.ts +++ b/src/features/chat/host/session.ts @@ -1,19 +1,18 @@ import type { AppServerClient } from "../../../app-server/connection/client"; -import { appServerQueryContextMatches, appServerQueryContextRawEquals, type AppServerQueryContext } from "../../../app-server/query/keys"; - +import { type AppServerQueryContext, appServerQueryContextMatches, appServerQueryContextRawEquals } from "../../../app-server/query/keys"; +import { pendingRequestCountsFromQueues } from "../../../domain/pending-requests/aggregate"; import { threadMeaningfulTitle, threadWindowTitle } from "../../../domain/threads/title"; import { ConnectionWorkTracker } from "../../../shared/lifecycle/connection-work"; -import { createChatViewDeferredTasks } from "./lifecycle"; import { ChatResumeWorkTracker, type ChatViewDeferredTasks, type RestoredThreadPlaceholderState } from "../application/lifecycle"; -import { openPanelTurnLifecycle, parseRestoredThreadState, type ChatPanelSnapshot } from "../panel/snapshot"; import type { ChatState } from "../application/state/root-reducer"; -import { pendingRequestCountsFromQueues } from "../../../domain/pending-requests/aggregate"; +import { type ChatStateStore, createChatStateStore } from "../application/state/store"; import { renderChatPanelShell, unmountChatPanelShell } from "../panel/shell"; -import { createChatStateStore, type ChatStateStore } from "../application/state/store"; -import { createChatMessageScrollController, type ChatMessageScrollController } from "../panel/surface/message-stream-scroll"; -import type { ChatSurfaceHandle } from "./surface-handle"; +import { type ChatPanelSnapshot, openPanelTurnLifecycle, parseRestoredThreadState } from "../panel/snapshot"; +import { type ChatMessageScrollController, createChatMessageScrollController } from "../panel/surface/message-stream-scroll"; +import { createChatViewDeferredTasks } from "./lifecycle"; import type { ChatPanelEnvironment } from "./runtime"; -import { createChatPanelSessionGraph, type ChatPanelSessionGraph } from "./session-graph"; +import { type ChatPanelSessionGraph, createChatPanelSessionGraph } from "./session-graph"; +import type { ChatSurfaceHandle } from "./surface-handle"; export class ChatPanelSession implements ChatSurfaceHandle { private readonly stateStore: ChatStateStore = createChatStateStore(); diff --git a/src/features/chat/panel/composer-controller.ts b/src/features/chat/panel/composer-controller.ts index 56f1e447..bb2f8c8d 100644 --- a/src/features/chat/panel/composer-controller.ts +++ b/src/features/chat/panel/composer-controller.ts @@ -1,23 +1,23 @@ import type { CodexInput } from "../../../domain/chat/input"; import { isComposerSendKey, type SendShortcut } from "../../../shared/ui/keyboard"; import { textareaCursorAtVisualBoundary } from "../../../shared/ui/textarea-caret"; -import type { ChatAction, ChatState } from "../application/state/root-reducer"; -import type { ChatStateStore } from "../application/state/store"; -import type { ComposerShellProps } from "../ui/composer"; -import { syncComposerHeight, type ComposerCallbacks } from "../ui/composer"; -import type { ChatPanelComposerShellState } from "./shell-state"; -import { composerBoundaryScrollDirection, type ComposerBoundaryScrollAction } from "../application/composer/boundary-scroll"; +import { type ComposerBoundaryScrollAction, composerBoundaryScrollDirection } from "../application/composer/boundary-scroll"; import type { NoteCandidateProvider } from "../application/composer/note-context"; import { activeComposerSuggestions, applyComposerSuggestionInsertion, + type ComposerSuggestion, composerSuggestionNavigationDirection, composerSuggestionSignature, - nextComposerSuggestionIndex, - type ComposerSuggestion, type NoteCandidate, + nextComposerSuggestionIndex, } from "../application/composer/suggestions"; import { userInputWithWikiLinkMentionsAndSkills } from "../application/composer/wikilink-context"; +import type { ChatAction, ChatState } from "../application/state/root-reducer"; +import type { ChatStateStore } from "../application/state/store"; +import type { ComposerShellProps } from "../ui/composer"; +import { type ComposerCallbacks, syncComposerHeight } from "../ui/composer"; +import type { ChatPanelComposerShellState } from "./shell-state"; import type { ChatPanelComposerProjection } from "./surface/composer-projection"; export interface ChatComposerControllerOptions { diff --git a/src/features/chat/panel/shell-state.tsx b/src/features/chat/panel/shell-state.tsx index b7b950df..140026b1 100644 --- a/src/features/chat/panel/shell-state.tsx +++ b/src/features/chat/panel/shell-state.tsx @@ -1,21 +1,20 @@ +import { batch, computed, type ReadonlySignal, type Signal, signal } from "@preact/signals"; import { createContext } from "preact"; import { useContext } from "preact/hooks"; -import { batch, computed, signal, type ReadonlySignal, type Signal } from "@preact/signals"; - -import type { RuntimeSnapshot } from "../domain/runtime/snapshot"; -import { messageItemsHaveThreadTurns, runtimeSnapshotForChatSlices } from "../application/runtime/snapshot"; import { implementPlanTargetFromState } from "../application/conversation/plan-implementation"; import { activeTurnId, chatTurnBusy } from "../application/conversation/turn-state"; -import type { ChatState } from "../application/state/root-reducer"; +import { messageItemsHaveThreadTurns, runtimeSnapshotForChatSlices } from "../application/runtime/snapshot"; import { + type MessageStreamRollbackCandidate, messageStreamActiveItems, messageStreamItems, messageStreamRollbackCandidateFromItems, messageStreamStableItems, - type MessageStreamRollbackCandidate, } from "../application/state/message-stream"; +import type { ChatState } from "../application/state/root-reducer"; import type { MessageStreamItem } from "../domain/message-stream/items"; -import { forkCandidatesFromItems, type ForkCandidate, type PlanImplementationTarget } from "../domain/message-stream/selectors"; +import { type ForkCandidate, forkCandidatesFromItems, type PlanImplementationTarget } from "../domain/message-stream/selectors"; +import type { RuntimeSnapshot } from "../domain/runtime/snapshot"; export interface ChatPanelShellState { connection: Signal; diff --git a/src/features/chat/panel/shell.tsx b/src/features/chat/panel/shell.tsx index 55e5040f..0b245dc7 100644 --- a/src/features/chat/panel/shell.tsx +++ b/src/features/chat/panel/shell.tsx @@ -1,12 +1,12 @@ import type { ComponentChild as UiNode } from "preact"; import { renderUiRoot, unmountUiRoot } from "../../../shared/ui/ui-root"; import type { ChatStateStore } from "../application/state/store"; -import { ChatPanelToolbar, type ChatPanelToolbarSurface } from "./surface/toolbar-projection"; import type { ToolbarActions } from "../ui/toolbar"; +import { type ChatPanelShellState, ChatPanelShellStateContext, createChatPanelShellState, syncChatPanelShellState } from "./shell-state"; +import { ChatPanelComposer, type ChatPanelComposerActions, type ChatPanelComposerRenderer } from "./surface/composer-projection"; import { ChatPanelGoal, type ChatPanelGoalSurface } from "./surface/goal-projection"; import { ChatPanelMessageStream, type ChatPanelMessageStreamPresenter } from "./surface/message-stream-presenter"; -import { ChatPanelComposer, type ChatPanelComposerActions, type ChatPanelComposerRenderer } from "./surface/composer-projection"; -import { ChatPanelShellStateContext, createChatPanelShellState, syncChatPanelShellState, type ChatPanelShellState } from "./shell-state"; +import { ChatPanelToolbar, type ChatPanelToolbarSurface } from "./surface/toolbar-projection"; export interface ChatPanelShellParts { toolbar: { diff --git a/src/features/chat/panel/snapshot.ts b/src/features/chat/panel/snapshot.ts index 60af446d..e06da864 100644 --- a/src/features/chat/panel/snapshot.ts +++ b/src/features/chat/panel/snapshot.ts @@ -1,5 +1,5 @@ -import type { ChatState } from "../application/state/root-reducer"; import type { RestoredThreadState } from "../application/lifecycle"; +import type { ChatState } from "../application/state/root-reducer"; type OpenCodexPanelTurnLifecycle = { kind: "idle" } | { kind: "starting" } | { kind: "running"; turnId: string }; diff --git a/src/features/chat/panel/surface/composer-projection.tsx b/src/features/chat/panel/surface/composer-projection.tsx index 1ee33655..771c32eb 100644 --- a/src/features/chat/panel/surface/composer-projection.tsx +++ b/src/features/chat/panel/surface/composer-projection.tsx @@ -1,16 +1,15 @@ import type { ComponentChild as UiNode } from "preact"; import { h } from "preact"; - -import { runtimeConfigOrDefault } from "../../domain/runtime/effective"; -import { resolveRuntimeControls } from "../../domain/runtime/resolution"; -import { contextSummary } from "../../presentation/runtime/status"; -import { compactReasoningEffortLabel } from "../../domain/runtime/labels"; -import { sortedModelMetadata } from "../../../../domain/catalog/metadata"; import type { ReasoningEffort } from "../../../../domain/catalog/metadata"; -import type { RuntimeSnapshot } from "../../domain/runtime/snapshot"; -import { ComposerShell, type ComposerShellProps } from "../../ui/composer"; -import { composerStateFromShellState, useChatPanelShellState, type ChatPanelComposerShellState } from "../shell-state"; +import { sortedModelMetadata } from "../../../../domain/catalog/metadata"; import { explicitThreadName } from "../../../../domain/threads/model"; +import { runtimeConfigOrDefault } from "../../domain/runtime/effective"; +import { compactReasoningEffortLabel } from "../../domain/runtime/labels"; +import { resolveRuntimeControls } from "../../domain/runtime/resolution"; +import type { RuntimeSnapshot } from "../../domain/runtime/snapshot"; +import { contextSummary } from "../../presentation/runtime/status"; +import { ComposerShell, type ComposerShellProps } from "../../ui/composer"; +import { type ChatPanelComposerShellState, composerStateFromShellState, useChatPanelShellState } from "../shell-state"; interface RestoredThreadTitleSnapshot { threadId: string; diff --git a/src/features/chat/panel/surface/goal-projection.tsx b/src/features/chat/panel/surface/goal-projection.tsx index ad7bae55..7d5c33a2 100644 --- a/src/features/chat/panel/surface/goal-projection.tsx +++ b/src/features/chat/panel/surface/goal-projection.tsx @@ -1,10 +1,10 @@ -import type { GoalActions } from "../../application/threads/goal-actions"; import type { ComponentChild as UiNode } from "preact"; import { h } from "preact"; import type { SendShortcut } from "../../../../shared/ui/keyboard"; +import type { GoalActions } from "../../application/threads/goal-actions"; import type { GoalPanelActions, GoalPanelDisplayState, GoalPanelEditorState, GoalPanelOptions } from "../../ui/goal"; import { GoalPanel } from "../../ui/goal"; -import { goalStateFromShellState, useChatPanelShellState, type ChatPanelGoalShellState } from "../shell-state"; +import { type ChatPanelGoalShellState, goalStateFromShellState, useChatPanelShellState } from "../shell-state"; interface ChatPanelGoalActions { saveObjective: (objective: string, tokenBudget: number | null) => Promise; diff --git a/src/features/chat/panel/surface/message-stream-presenter.ts b/src/features/chat/panel/surface/message-stream-presenter.ts index c52352eb..b568b19e 100644 --- a/src/features/chat/panel/surface/message-stream-presenter.ts +++ b/src/features/chat/panel/surface/message-stream-presenter.ts @@ -1,19 +1,19 @@ +import type { App, Component } from "obsidian"; import type { ComponentChild as UiNode } from "preact"; import { h } from "preact"; -import type { App, Component } from "obsidian"; import { copyTextWithNotice } from "../../../../shared/ui/clipboard"; +import type { PendingRequestBlockActions } from "../../application/pending-requests/block"; import type { ChatAction } from "../../application/state/root-reducer"; import type { ChatStateStore } from "../../application/state/store"; +import type { ChatTurnDiffViewState } from "../../domain/turn-diff"; import type { MessageStreamScrollControllerBinding } from "../../ui/message-stream/flow-scroll"; import { MarkdownMessageRenderer, renderStreamMarkdown } from "../../ui/message-stream/markdown-renderer"; import { MessageStreamViewport, type MessageStreamViewportState } from "../../ui/message-stream/stream-blocks"; -import { messageStreamStateFromShellState, useChatPanelShellState, type ChatPanelMessageStreamShellState } from "../shell-state"; -import type { PendingRequestBlockActions } from "../../application/pending-requests/block"; -import type { ChatTurnDiffViewState } from "../../domain/turn-diff"; +import { type ChatPanelMessageStreamShellState, messageStreamStateFromShellState, useChatPanelShellState } from "../shell-state"; import { + type ChatMessageStreamSurfaceContext, createMessageStreamSurfaceContext, messageStreamSurfaceProjectionFromState, - type ChatMessageStreamSurfaceContext, } from "./message-stream-projection"; export interface ChatPanelMessageStreamPresenter { diff --git a/src/features/chat/panel/surface/message-stream-projection.ts b/src/features/chat/panel/surface/message-stream-projection.ts index 76192d2e..9a4fb7d0 100644 --- a/src/features/chat/panel/surface/message-stream-projection.ts +++ b/src/features/chat/panel/surface/message-stream-projection.ts @@ -1,15 +1,15 @@ +import { type PendingRequestBlockActions, pendingRequestBlockStateFromChatState } from "../../application/pending-requests/block"; +import type { MessageStreamRollbackCandidate } from "../../application/state/message-stream"; import type { ChatAction } from "../../application/state/root-reducer"; import type { ChatDisclosureBucket, ChatDisclosureUiState } from "../../application/state/ui-state"; -import { messageStreamViewBlocks, type MessageStreamViewBlock } from "../../presentation/message-stream/view-model"; -import { messageStreamSegmentsEmpty, type ForkCandidate, type PlanImplementationTarget } from "../../domain/message-stream/selectors"; -import type { MessageStreamRollbackCandidate } from "../../application/state/message-stream"; -import type { MessageStreamContext } from "../../ui/message-stream/context"; -import type { ChatPanelMessageStreamShellState } from "../shell-state"; -import { pendingRequestBlockSnapshotFromState, type PendingRequestBlockSnapshot } from "../../presentation/pending-requests/view-model"; -import { pendingRequestBlockStateFromChatState, type PendingRequestBlockActions } from "../../application/pending-requests/block"; +import { type ForkCandidate, messageStreamSegmentsEmpty, type PlanImplementationTarget } from "../../domain/message-stream/selectors"; +import { pendingRequestsSignature } from "../../domain/pending-requests/signatures"; import type { ChatTurnDiffViewState } from "../../domain/turn-diff"; import type { MessageStreamTextActionTargets } from "../../presentation/message-stream/text-view"; -import { pendingRequestsSignature } from "../../domain/pending-requests/signatures"; +import { type MessageStreamViewBlock, messageStreamViewBlocks } from "../../presentation/message-stream/view-model"; +import { type PendingRequestBlockSnapshot, pendingRequestBlockSnapshotFromState } from "../../presentation/pending-requests/view-model"; +import type { MessageStreamContext } from "../../ui/message-stream/context"; +import type { ChatPanelMessageStreamShellState } from "../shell-state"; interface ChatMessageStreamActions { rollbackThread: (threadId: string) => void; diff --git a/src/features/chat/panel/surface/toolbar-projection.tsx b/src/features/chat/panel/surface/toolbar-projection.tsx index 232c4d88..96107fab 100644 --- a/src/features/chat/panel/surface/toolbar-projection.tsx +++ b/src/features/chat/panel/surface/toolbar-projection.tsx @@ -4,12 +4,12 @@ import { h } from "preact"; import { CLIENT_VERSION } from "../../../../constants"; import type { Thread } from "../../../../domain/threads/model"; import { threadRowCoreProjection } from "../../../threads/row-projection"; -import { rateLimitSummary } from "../../presentation/runtime/status"; import { connectionDiagnosticSectionsModel } from "../../application/connection/diagnostics-display"; import { toolInventoryDiagnosticSections } from "../../application/connection/tool-inventory-display"; import type { RuntimeSnapshot } from "../../domain/runtime/snapshot"; -import { toolbarStateFromShellState, useChatPanelShellState, type ChatPanelToolbarShellState } from "../shell-state"; +import { rateLimitSummary } from "../../presentation/runtime/status"; import { Toolbar, type ToolbarActions, type ToolbarThreadRow, type ToolbarViewModel } from "../../ui/toolbar"; +import { type ChatPanelToolbarShellState, toolbarStateFromShellState, useChatPanelShellState } from "../shell-state"; export interface ChatPanelToolbarSurface { state: { diff --git a/src/features/chat/panel/toolbar-actions.ts b/src/features/chat/panel/toolbar-actions.ts index 05c17254..b5cdfd60 100644 --- a/src/features/chat/panel/toolbar-actions.ts +++ b/src/features/chat/panel/toolbar-actions.ts @@ -1,12 +1,12 @@ -import type { ThreadManagementActions } from "../application/threads/thread-management-actions"; +import { copyTextWithNotice } from "../../../shared/ui/clipboard"; +import type { ChatConnectionController } from "../application/connection/connection-controller"; import type { ChatAction, ChatState } from "../application/state/root-reducer"; import type { ChatStateStore } from "../application/state/store"; -import type { ChatConnectionController } from "../application/connection/connection-controller"; import type { GoalActions } from "../application/threads/goal-actions"; import type { ThreadRenameEditorActions } from "../application/threads/rename-editor-actions"; import type { SelectionActions } from "../application/threads/selection-actions"; +import type { ThreadManagementActions } from "../application/threads/thread-management-actions"; import type { ToolbarActions } from "../ui/toolbar"; -import { copyTextWithNotice } from "../../../shared/ui/clipboard"; export interface ToolbarPanelActionsHost { stateStore: ChatStateStore; diff --git a/src/features/chat/presentation/message-stream/detail-view.ts b/src/features/chat/presentation/message-stream/detail-view.ts index 4b797940..24614c06 100644 --- a/src/features/chat/presentation/message-stream/detail-view.ts +++ b/src/features/chat/presentation/message-stream/detail-view.ts @@ -1,7 +1,7 @@ import { shortThreadId } from "../../../../shared/id/thread-id"; +import { pathRelativeToRoot } from "../../../../shared/path/file-paths"; import { truncate } from "../../../../shared/text/preview"; import { failedStatusLabel } from "../../domain/message-stream/execution-state"; -import { pathRelativeToRoot } from "../../../../shared/path/file-paths"; import type { AgentMessageStreamItem, ApprovalResultMessageStreamItem, diff --git a/src/features/chat/presentation/message-stream/layout.ts b/src/features/chat/presentation/message-stream/layout.ts index 5ea8d0f9..ad7581af 100644 --- a/src/features/chat/presentation/message-stream/layout.ts +++ b/src/features/chat/presentation/message-stream/layout.ts @@ -1,5 +1,5 @@ -import type { MessageStreamItem } from "../../domain/message-stream/items"; import { pathRelativeToRoot } from "../../../../shared/path/file-paths"; +import type { MessageStreamItem } from "../../domain/message-stream/items"; import { messageStreamSemanticClassifications } from "../../domain/message-stream/semantics/classify"; import { messageStreamIsAutoReviewDecision, diff --git a/src/features/chat/presentation/message-stream/status-view.ts b/src/features/chat/presentation/message-stream/status-view.ts index 5e3442e2..dde2e614 100644 --- a/src/features/chat/presentation/message-stream/status-view.ts +++ b/src/features/chat/presentation/message-stream/status-view.ts @@ -1,5 +1,4 @@ import { shortThreadId } from "../../../../shared/id/thread-id"; -import { messageStreamReasoningIsActive } from "../../domain/message-stream/semantics/active-turn"; import type { AgentRunSummary, AgentRunSummaryAgent, @@ -8,6 +7,7 @@ import type { ReasoningMessageStreamItem, TaskProgressMessageStreamItem, } from "../../domain/message-stream/items"; +import { messageStreamReasoningIsActive } from "../../domain/message-stream/semantics/active-turn"; export type StatusChecklistItem = TaskProgressMessageStreamItem["steps"][number]; diff --git a/src/features/chat/presentation/message-stream/view-model.ts b/src/features/chat/presentation/message-stream/view-model.ts index dad4bc4c..949592a9 100644 --- a/src/features/chat/presentation/message-stream/view-model.ts +++ b/src/features/chat/presentation/message-stream/view-model.ts @@ -1,12 +1,12 @@ -import type { MessageStreamSemanticClassification } from "../../domain/message-stream/semantics/types"; import type { AgentRunSummary, MessageStreamItem, TaskProgressMessageStreamItem } from "../../domain/message-stream/items"; import { messageStreamItemsEmpty } from "../../domain/message-stream/selectors"; import { activeTurnLiveItems, messageStreamItemsWithoutActiveTaskProgress } from "../../domain/message-stream/semantics/active-turn"; -import { messageStreamLayoutBlocks, type MessageStreamItemAnnotations, type MessageStreamLayoutBlock } from "./layout"; -import { detailView, type DetailView } from "./detail-view"; -import { messageStreamTextView, type MessageStreamTextActionTargets, type MessageStreamTextView } from "./text-view"; -import { agentRunSummaryView, messageStreamStatusView, type AgentRunSummaryView, type MessageStreamStatusView } from "./status-view"; +import type { MessageStreamSemanticClassification } from "../../domain/message-stream/semantics/types"; import type { PendingRequestBlockSnapshot } from "../pending-requests/view-model"; +import { type DetailView, detailView } from "./detail-view"; +import { type MessageStreamItemAnnotations, type MessageStreamLayoutBlock, messageStreamLayoutBlocks } from "./layout"; +import { type AgentRunSummaryView, agentRunSummaryView, type MessageStreamStatusView, messageStreamStatusView } from "./status-view"; +import { type MessageStreamTextActionTargets, type MessageStreamTextView, messageStreamTextView } from "./text-view"; interface PendingRequestMessageStreamBlockInput { signature: string; diff --git a/src/features/chat/presentation/pending-requests/view-model.ts b/src/features/chat/presentation/pending-requests/view-model.ts index 1ef78923..5e55769e 100644 --- a/src/features/chat/presentation/pending-requests/view-model.ts +++ b/src/features/chat/presentation/pending-requests/view-model.ts @@ -1,14 +1,14 @@ import { - approvalActionKind, - defaultPendingApprovalOptions, type ApprovalAction, + approvalActionKind, + type PendingRequestId as DomainPendingRequestId, + defaultPendingApprovalOptions, + mcpElicitationDraftKey, + mcpElicitationFieldDefaultDraft, type PendingApproval, type PendingMcpElicitation, type PendingMcpElicitationField, - type PendingRequestId as DomainPendingRequestId, type PendingUserInput, - mcpElicitationDraftKey, - mcpElicitationFieldDefaultDraft, questionDefaultAnswer, userInputDraftKey, userInputOtherDraftKey, diff --git a/src/features/chat/presentation/runtime/status.ts b/src/features/chat/presentation/runtime/status.ts index 4f642cd7..16db5b03 100644 --- a/src/features/chat/presentation/runtime/status.ts +++ b/src/features/chat/presentation/runtime/status.ts @@ -2,9 +2,9 @@ import type { RuntimeConfigSnapshot } from "../../../../domain/runtime/config"; import type { RateLimitWindow, SpendControlLimitSnapshot, ThreadTokenUsage } from "../../../../domain/runtime/metrics"; import { jsonPreview } from "../../../../shared/text/preview"; import { currentServiceTier, runtimeConfigOrDefault } from "../../domain/runtime/effective"; -import type { RuntimeSnapshot } from "../../domain/runtime/snapshot"; -import { pendingRuntimeSettingLabel, serviceTierLabel as formatServiceTierLabel } from "../../domain/runtime/labels"; +import { serviceTierLabel as formatServiceTierLabel, pendingRuntimeSettingLabel } from "../../domain/runtime/labels"; import { resolveRuntimeControls } from "../../domain/runtime/resolution"; +import type { RuntimeSnapshot } from "../../domain/runtime/snapshot"; export interface ContextSummary { label: string; diff --git a/src/features/chat/ui/composer.tsx b/src/features/chat/ui/composer.tsx index 526c644d..9cd37cb5 100644 --- a/src/features/chat/ui/composer.tsx +++ b/src/features/chat/ui/composer.tsx @@ -1,4 +1,4 @@ -import type { ButtonHTMLAttributes, ComponentChild as UiNode, Ref } from "preact"; +import type { ButtonHTMLAttributes, Ref, ComponentChild as UiNode } from "preact"; import { useLayoutEffect, useRef, useState } from "preact/hooks"; import { IconButton } from "../../../shared/ui/components"; diff --git a/src/features/chat/ui/goal.tsx b/src/features/chat/ui/goal.tsx index e6e6becc..6785bdf9 100644 --- a/src/features/chat/ui/goal.tsx +++ b/src/features/chat/ui/goal.tsx @@ -2,9 +2,9 @@ import type { ComponentChild as UiNode } from "preact"; import { useEffect, useLayoutEffect, useRef, useState } from "preact/hooks"; import type { ThreadGoal, ThreadGoalStatus } from "../../../domain/threads/goal"; -import { isComposerSendKey, type SendShortcut } from "../../../shared/ui/keyboard"; import { IconButton } from "../../../shared/ui/components"; import { disposeDomListeners, listenDomEvent } from "../../../shared/ui/dom-events"; +import { isComposerSendKey, type SendShortcut } from "../../../shared/ui/keyboard"; import { syncTextareaHeight } from "../../../shared/ui/textarea-autogrow"; export interface GoalPanelActions { diff --git a/src/features/chat/ui/message-stream/context.ts b/src/features/chat/ui/message-stream/context.ts index 0df7793d..33b8bcae 100644 --- a/src/features/chat/ui/message-stream/context.ts +++ b/src/features/chat/ui/message-stream/context.ts @@ -1,8 +1,8 @@ import type { ApprovalAction, McpElicitationAction, PendingRequestId } from "../../../../domain/pending-requests/model"; -import type { PendingRequestBlockSnapshot } from "../../presentation/pending-requests/view-model"; -import type { MessageStreamForkTarget } from "../../presentation/message-stream/text-view"; import type { PlanImplementationTarget } from "../../domain/message-stream/selectors"; import type { ChatTurnDiffViewState } from "../../domain/turn-diff"; +import type { MessageStreamForkTarget } from "../../presentation/message-stream/text-view"; +import type { PendingRequestBlockSnapshot } from "../../presentation/pending-requests/view-model"; type MessageStreamDisclosureBucket = | "details" diff --git a/src/features/chat/ui/message-stream/markdown-renderer.ts b/src/features/chat/ui/message-stream/markdown-renderer.ts index c8635a03..77044ebb 100644 --- a/src/features/chat/ui/message-stream/markdown-renderer.ts +++ b/src/features/chat/ui/message-stream/markdown-renderer.ts @@ -1,5 +1,5 @@ -import { MarkdownRenderer, Notice, type App, type Component } from "obsidian"; import { micromark } from "micromark"; +import { type App, type Component, MarkdownRenderer, Notice } from "obsidian"; import { isAbsoluteFileHref, vaultFileLinkTarget, vaultRelativeFileLinkTarget } from "../../../../shared/obsidian/file-links"; import { notifyMessageContentRendered } from "./content-events"; diff --git a/src/features/chat/ui/message-stream/stream-blocks.tsx b/src/features/chat/ui/message-stream/stream-blocks.tsx index 0ae3c3a1..5ea9417c 100644 --- a/src/features/chat/ui/message-stream/stream-blocks.tsx +++ b/src/features/chat/ui/message-stream/stream-blocks.tsx @@ -5,11 +5,11 @@ import { type MessageStreamRenderedItemView, type MessageStreamViewBlock, } from "../../presentation/message-stream/view-model"; +import type { MessageStreamContext, PendingRequestBlockContext } from "./context"; +import { detailNode } from "./detail"; import { MessageStreamFlowFrame, type MessageStreamScrollControllerBinding } from "./flow-scroll"; import { pendingRequestBlockNode } from "./pending-request-block"; -import { detailNode } from "./detail"; import { agentRunSummaryNode, statusNode } from "./status"; -import type { MessageStreamContext, PendingRequestBlockContext } from "./context"; import { textNode } from "./text"; export interface MessageStreamViewportState { diff --git a/src/features/chat/ui/message-stream/text-content.tsx b/src/features/chat/ui/message-stream/text-content.tsx index 0fa2bc6a..711d87b7 100644 --- a/src/features/chat/ui/message-stream/text-content.tsx +++ b/src/features/chat/ui/message-stream/text-content.tsx @@ -1,4 +1,4 @@ -import { type ComponentChild as UiNode, type Ref } from "preact"; +import { type Ref, type ComponentChild as UiNode } from "preact"; import { useEffect, useLayoutEffect, useRef, useState } from "preact/hooks"; import type { MessageStreamTextView } from "../../presentation/message-stream/text-view"; diff --git a/src/features/chat/ui/message-stream/text.tsx b/src/features/chat/ui/message-stream/text.tsx index 1e190140..839482cb 100644 --- a/src/features/chat/ui/message-stream/text.tsx +++ b/src/features/chat/ui/message-stream/text.tsx @@ -1,6 +1,7 @@ import { Fragment, type ComponentChild as UiNode } from "preact"; import { useEffect, useRef } from "preact/hooks"; - +import { IconButton } from "../../../../shared/ui/components"; +import { listenDomEvent } from "../../../../shared/ui/dom-events"; import type { EditedFilesTextView, MentionedFileTextView, @@ -8,8 +9,6 @@ import type { ReferencedThreadTextView, TextItemDetailSectionView, } from "../../presentation/message-stream/text-view"; -import { IconButton } from "../../../../shared/ui/components"; -import { listenDomEvent } from "../../../../shared/ui/dom-events"; import type { TextItemActionContext, TextItemContext, TextItemDetailStateContext, TextItemMetadataContext } from "./context"; import { CollapsibleTextContent, TextContent } from "./text-content"; diff --git a/src/features/chat/ui/toolbar.tsx b/src/features/chat/ui/toolbar.tsx index e9f6e893..1eb154f2 100644 --- a/src/features/chat/ui/toolbar.tsx +++ b/src/features/chat/ui/toolbar.tsx @@ -1,8 +1,7 @@ -import type { ButtonHTMLAttributes, ComponentChild as UiNode, TargetedKeyboardEvent } from "preact"; +import type { ButtonHTMLAttributes, TargetedKeyboardEvent, ComponentChild as UiNode } from "preact"; import { useLayoutEffect, useRef } from "preact/hooks"; - -import type { RateLimitSummary } from "../presentation/runtime/status"; import { IconButton } from "../../../shared/ui/components"; +import type { RateLimitSummary } from "../presentation/runtime/status"; type ButtonProps = ButtonHTMLAttributes & { disabled?: boolean | undefined; diff --git a/src/features/chat/ui/turn-diff/render.tsx b/src/features/chat/ui/turn-diff/render.tsx index 387b07be..5a3e84fe 100644 --- a/src/features/chat/ui/turn-diff/render.tsx +++ b/src/features/chat/ui/turn-diff/render.tsx @@ -3,9 +3,9 @@ import { useLayoutEffect, useRef } from "preact/hooks"; import { renderDisplayDiffLines } from "../../../../shared/diff/render"; import { displayDiffLines } from "../../../../shared/diff/unified"; +import { shortThreadId } from "../../../../shared/id/thread-id"; import { IconButton } from "../../../../shared/ui/components"; import { renderUiRoot } from "../../../../shared/ui/ui-root"; -import { shortThreadId } from "../../../../shared/id/thread-id"; import type { ChatTurnDiffViewState, PersistedChatTurnDiffViewState } from "../../domain/turn-diff"; export interface ChatTurnDiffViewActions { diff --git a/src/features/chat/ui/turn-diff/view.ts b/src/features/chat/ui/turn-diff/view.ts index 14d1b089..b81ce504 100644 --- a/src/features/chat/ui/turn-diff/view.ts +++ b/src/features/chat/ui/turn-diff/view.ts @@ -4,10 +4,10 @@ import { VIEW_TYPE_CODEX_TURN_DIFF } from "../../../../constants"; import { copyTextWithNotice } from "../../../../shared/ui/clipboard"; import { unmountUiRoot } from "../../../../shared/ui/ui-root"; import { - isPersistedChatTurnDiffViewState, - persistedChatTurnDiffViewState, - type PersistedChatTurnDiffViewState, type ChatTurnDiffViewState, + isPersistedChatTurnDiffViewState, + type PersistedChatTurnDiffViewState, + persistedChatTurnDiffViewState, } from "../../domain/turn-diff"; import { renderChatTurnDiffView } from "./render"; diff --git a/src/features/selection-rewrite/command.ts b/src/features/selection-rewrite/command.ts index 4ab548fa..92b10321 100644 --- a/src/features/selection-rewrite/command.ts +++ b/src/features/selection-rewrite/command.ts @@ -1,8 +1,7 @@ -import { MarkdownView, Notice, type Editor, type Plugin } from "obsidian"; - +import { type Editor, MarkdownView, Notice, type Plugin } from "obsidian"; +import type { SendShortcut } from "../../shared/ui/keyboard"; import type { SelectionRewriteRuntimeSettings, SelectionRewriteState } from "./model"; import { SelectionRewritePopover } from "./popover"; -import type { SendShortcut } from "../../shared/ui/keyboard"; export interface SelectionRewriteCommandHost extends Plugin { settings: { diff --git a/src/features/selection-rewrite/popover.tsx b/src/features/selection-rewrite/popover.tsx index fd833aec..d9a6d16d 100644 --- a/src/features/selection-rewrite/popover.tsx +++ b/src/features/selection-rewrite/popover.tsx @@ -1,14 +1,14 @@ -import { Notice, type Editor } from "obsidian"; -import type { ComponentChild as UiNode, TargetedKeyboardEvent } from "preact"; +import { type Editor, Notice } from "obsidian"; +import type { TargetedKeyboardEvent, ComponentChild as UiNode } from "preact"; import { useLayoutEffect, useRef } from "preact/hooks"; import { renderDisplayDiffLines } from "../../shared/diff/render"; import { displayDiffLines } from "../../shared/diff/unified"; -import { isComposerSendKey, type SendShortcut } from "../../shared/ui/keyboard"; import { IconButton } from "../../shared/ui/components"; -import { textareaCursorAtVisualBoundary, type TextareaCaretBoundaryDirection } from "../../shared/ui/textarea-caret"; -import { renderUiRoot, unmountUiRoot } from "../../shared/ui/ui-root"; +import { isComposerSendKey, type SendShortcut } from "../../shared/ui/keyboard"; import { syncTextareaHeight } from "../../shared/ui/textarea-autogrow"; +import { type TextareaCaretBoundaryDirection, textareaCursorAtVisualBoundary } from "../../shared/ui/textarea-caret"; +import { renderUiRoot, unmountUiRoot } from "../../shared/ui/ui-root"; import { buildSelectionUnifiedDiff } from "./diff"; import { canApplySelectionRewrite, type SelectionRewriteRuntimeSettings, type SelectionRewriteState } from "./model"; diff --git a/src/features/selection-rewrite/prompt.ts b/src/features/selection-rewrite/prompt.ts index 466a1224..50c09f86 100644 --- a/src/features/selection-rewrite/prompt.ts +++ b/src/features/selection-rewrite/prompt.ts @@ -1,4 +1,4 @@ -import { selectionRewriteTextRangeOffsets, type SelectionRewriteState } from "./model"; +import { type SelectionRewriteState, selectionRewriteTextRangeOffsets } from "./model"; const MAX_NOTE_CONTEXT_CHARS = 20_000; diff --git a/src/features/selection-rewrite/runner.ts b/src/features/selection-rewrite/runner.ts index 4975feb1..140dfd07 100644 --- a/src/features/selection-rewrite/runner.ts +++ b/src/features/selection-rewrite/runner.ts @@ -1,14 +1,14 @@ +import type { ModelMetadataClient } from "../../app-server/catalog"; +import type { AppServerClientHandlers } from "../../app-server/connection/client"; import { type EphemeralStructuredTurnClient, runEphemeralStructuredTurnForLastAgentText, type StructuredTurnOutputSchema, } from "../../app-server/services/ephemeral-structured-turn"; -import type { ModelMetadataClient } from "../../app-server/catalog"; -import type { AppServerClientHandlers } from "../../app-server/connection/client"; import { resolvedRuntimeOverrideForClient } from "../../app-server/services/runtime-overrides"; import type { SelectionRewriteRuntimeSettings } from "./model"; +import { type SelectionRewriteOutput, SelectionRewriteOutputError, selectionRewriteOutputParseResultFromText } from "./output"; import { SELECTION_REWRITE_DEVELOPER_INSTRUCTIONS, SELECTION_REWRITE_SERVICE_NAME } from "./prompt"; -import { SelectionRewriteOutputError, selectionRewriteOutputParseResultFromText, type SelectionRewriteOutput } from "./output"; const SELECTION_REWRITE_TIMEOUT_MS = 120_000; diff --git a/src/features/selection-rewrite/session.ts b/src/features/selection-rewrite/session.ts index 3456748c..9d4ac7d7 100644 --- a/src/features/selection-rewrite/session.ts +++ b/src/features/selection-rewrite/session.ts @@ -1,9 +1,9 @@ import type { TextareaCaretBoundaryDirection } from "../../shared/ui/textarea-caret"; import { - transitionSelectionRewriteState, type SelectionRewriteLifecycleEvent, type SelectionRewriteRuntimeSettings, type SelectionRewriteState, + transitionSelectionRewriteState, } from "./model"; import { SelectionRewriteOutputError } from "./output"; import { buildSelectionRewritePrompt } from "./prompt"; diff --git a/src/features/thread-picker/modal.ts b/src/features/thread-picker/modal.ts index 839b3e55..611d86ba 100644 --- a/src/features/thread-picker/modal.ts +++ b/src/features/thread-picker/modal.ts @@ -1,6 +1,6 @@ -import { Notice, Platform, SuggestModal, type App } from "obsidian"; +import { type App, Notice, Platform, SuggestModal } from "obsidian"; -import { threadRecencyAt, type Thread } from "../../domain/threads/model"; +import { type Thread, threadRecencyAt } from "../../domain/threads/model"; import { threadDisplayTitle } from "../../domain/threads/title"; import { shortThreadId } from "../../shared/id/thread-id"; import type { ThreadCatalogActiveReader } from "../../workspace/thread-catalog"; diff --git a/src/features/threads-view/renderer.tsx b/src/features/threads-view/renderer.tsx index 36a20391..7ce8a02e 100644 --- a/src/features/threads-view/renderer.tsx +++ b/src/features/threads-view/renderer.tsx @@ -1,5 +1,4 @@ -import type { ButtonHTMLAttributes, TargetedKeyboardEvent } from "preact"; -import type { ComponentChild as UiNode } from "preact"; +import type { ButtonHTMLAttributes, TargetedKeyboardEvent, ComponentChild as UiNode } from "preact"; import { useLayoutEffect, useRef } from "preact/hooks"; import { IconButton } from "../../shared/ui/components"; diff --git a/src/features/threads-view/session.ts b/src/features/threads-view/session.ts index 29689314..5d21097b 100644 --- a/src/features/threads-view/session.ts +++ b/src/features/threads-view/session.ts @@ -5,26 +5,26 @@ import { isStaleAppServerSharedQueryContextError } from "../../app-server/query/ import type { ReasoningEffort } from "../../domain/catalog/metadata"; import type { ObservedDataResult } from "../../domain/observed-data"; import { observedData, observedInitialError, observedInitialLoading } from "../../domain/observed-data"; +import type { ArchiveExportAdapter, ArchiveExportSettings } from "../../domain/threads/archive-markdown"; import type { Thread } from "../../domain/threads/model"; import type { OpenCodexPanelSnapshot } from "../../workspace/panel-coordinator"; import type { ThreadCatalogActiveReader, ThreadCatalogEventSink } from "../../workspace/thread-catalog"; -import type { ArchiveExportAdapter, ArchiveExportSettings } from "../../domain/threads/archive-markdown"; import { createThreadOperations, type ThreadOperations } from "../threads/thread-operations"; import { createThreadTitleService, type ThreadTitleService } from "../threads/thread-title-service"; import { renderThreadsView, unmountThreadsView } from "./renderer"; import { - threadRows, - transitionThreadsRenameState, type ThreadsGeneratingRenameState, type ThreadsRenameLifecycleEvent, type ThreadsRenameState, + threadRows, + transitionThreadsRenameState, } from "./state"; import { - createThreadsViewDeferredTasks, - transitionThreadsViewRefreshLifecycle, type ActiveThreadsViewRefresh, + createThreadsViewDeferredTasks, type ThreadsViewDeferredTasks, type ThreadsViewRefreshLifecycleState, + transitionThreadsViewRefreshLifecycle, } from "./view-lifecycle"; export interface CodexThreadsHost { diff --git a/src/features/threads-view/state.ts b/src/features/threads-view/state.ts index 150faccb..561951b0 100644 --- a/src/features/threads-view/state.ts +++ b/src/features/threads-view/state.ts @@ -1,15 +1,15 @@ -import { threadRecencyAt, type Thread } from "../../domain/threads/model"; -import type { OpenCodexPanelSnapshot } from "../../workspace/panel-coordinator"; import { hasPendingRequests, pendingRequestCounts } from "../../domain/pending-requests/aggregate"; -import { threadRowCoreProjection, type ThreadRowCoreProjection } from "../threads/row-projection"; +import { type Thread, threadRecencyAt } from "../../domain/threads/model"; +import type { OpenCodexPanelSnapshot } from "../../workspace/panel-coordinator"; import { initialThreadRenameLifecycleState, - transitionThreadRenameLifecycleState, - type ThreadRenameActiveState, - type ThreadRenameGeneratingState, type ThreadRenameLifecycleEvent as SharedThreadRenameLifecycleEvent, type ThreadRenameLifecycleState as SharedThreadRenameLifecycleState, + type ThreadRenameActiveState, + type ThreadRenameGeneratingState, + transitionThreadRenameLifecycleState, } from "../threads/rename-lifecycle"; +import { type ThreadRowCoreProjection, threadRowCoreProjection } from "../threads/row-projection"; type ThreadsLiveStatus = "pending" | "running" | "open"; diff --git a/src/features/threads-view/view.ts b/src/features/threads-view/view.ts index c46559c1..ceade8ed 100644 --- a/src/features/threads-view/view.ts +++ b/src/features/threads-view/view.ts @@ -1,7 +1,7 @@ import { ItemView, type WorkspaceLeaf } from "obsidian"; import { VIEW_TYPE_CODEX_THREADS } from "../../constants"; -import { CodexThreadsSession, type CodexThreadsHost } from "./session"; +import { type CodexThreadsHost, CodexThreadsSession } from "./session"; export class CodexThreadsView extends ItemView { private readonly session: CodexThreadsSession; diff --git a/src/features/threads/thread-operations.ts b/src/features/threads/thread-operations.ts index 265086f7..ef0778ae 100644 --- a/src/features/threads/thread-operations.ts +++ b/src/features/threads/thread-operations.ts @@ -1,5 +1,5 @@ import type { AppServerClientAccess } from "../../app-server/connection/client-access"; -import { archiveThreadOnAppServer, type ArchiveThreadResult } from "../../app-server/services/thread-archive"; +import { type ArchiveThreadResult, archiveThreadOnAppServer } from "../../app-server/services/thread-archive"; import type { ArchiveExportAdapter, ArchiveExportSettings } from "../../domain/threads/archive-markdown"; import { normalizeExplicitThreadName } from "../../domain/threads/model"; import type { ThreadCatalogEventSink } from "../../workspace/thread-catalog"; diff --git a/src/features/threads/thread-title-service.ts b/src/features/threads/thread-title-service.ts index fc1d39af..4e4ab829 100644 --- a/src/features/threads/thread-title-service.ts +++ b/src/features/threads/thread-title-service.ts @@ -1,14 +1,14 @@ import type { AppServerClientAccess } from "../../app-server/connection/client-access"; import { generateThreadTitleWithCodex } from "../../app-server/services/thread-title-generation"; import { readCompletedConversationSummariesPage } from "../../app-server/threads"; -import type { ThreadConversationSummary } from "../../domain/threads/transcript"; +import type { ReasoningEffort } from "../../domain/catalog/metadata"; import { findThreadTitleContext, THREAD_TITLE_CONTEXT_UNAVAILABLE_MESSAGE, - threadTitleContextFromConversationSummary, type ThreadTitleContext, + threadTitleContextFromConversationSummary, } from "../../domain/threads/title-generation-model"; -import type { ReasoningEffort } from "../../domain/catalog/metadata"; +import type { ThreadConversationSummary } from "../../domain/threads/transcript"; export interface ThreadTitleServiceHost { codexPath: () => string; diff --git a/src/main.ts b/src/main.ts index 85705071..b3436e46 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,13 +1,13 @@ import { Plugin } from "obsidian"; import { VIEW_TYPE_CODEX_PANEL, VIEW_TYPE_CODEX_THREADS, VIEW_TYPE_CODEX_TURN_DIFF } from "./constants"; -import { registerSelectionRewriteCommand } from "./features/selection-rewrite/command"; import { CodexChatView } from "./features/chat/host/view"; import { CodexChatTurnDiffView } from "./features/chat/ui/turn-diff/view"; +import { registerSelectionRewriteCommand } from "./features/selection-rewrite/command"; import { CodexThreadsView } from "./features/threads-view/view"; -import { DEFAULT_SETTINGS, getVaultPath, normalizeSettings, settingsMatchNormalizedData, type CodexPanelSettings } from "./settings/model"; -import { CodexPanelSettingTab } from "./settings/tab"; import { CodexPanelRuntime } from "./plugin-runtime"; +import { type CodexPanelSettings, DEFAULT_SETTINGS, getVaultPath, normalizeSettings, settingsMatchNormalizedData } from "./settings/model"; +import { CodexPanelSettingTab } from "./settings/tab"; export default class CodexPanelPlugin extends Plugin { settings: CodexPanelSettings = DEFAULT_SETTINGS; diff --git a/src/plugin-runtime.ts b/src/plugin-runtime.ts index 57833a05..b355ab55 100644 --- a/src/plugin-runtime.ts +++ b/src/plugin-runtime.ts @@ -1,13 +1,13 @@ import type { App } from "obsidian"; - -import { VIEW_TYPE_CODEX_THREADS, VIEW_TYPE_CODEX_TURN_DIFF } from "./constants"; -import { AppServerQueryCache } from "./app-server/query/cache"; -import { AppServerSharedQueries } from "./app-server/query/shared-queries"; import type { AppServerClient } from "./app-server/connection/client"; import type { AppServerClientAccess, AppServerClientAccessOptions } from "./app-server/connection/client-access"; import { withShortLivedAppServerClient } from "./app-server/connection/short-lived-client"; -import { appServerQueryContextIsComplete, type AppServerQueryContext } from "./app-server/query/keys"; +import { AppServerQueryCache } from "./app-server/query/cache"; +import { type AppServerQueryContext, appServerQueryContextIsComplete } from "./app-server/query/keys"; +import { AppServerSharedQueries } from "./app-server/query/shared-queries"; +import { VIEW_TYPE_CODEX_THREADS, VIEW_TYPE_CODEX_TURN_DIFF } from "./constants"; import type { ChatTurnDiffViewState } from "./features/chat/domain/turn-diff"; +import { persistedChatTurnDiffViewState } from "./features/chat/domain/turn-diff"; import type { CodexChatHost, PluginSettingsRef } from "./features/chat/host/runtime"; import type { ChatPanelClientSurface, @@ -15,7 +15,6 @@ import type { ChatViewLifecycleSurface, ChatWorkspacePanelSurface, } from "./features/chat/host/surface-handle"; -import { persistedChatTurnDiffViewState } from "./features/chat/domain/turn-diff"; import { CodexChatTurnDiffView } from "./features/chat/ui/turn-diff/view"; import { openThreadPicker, type ThreadPickerHost } from "./features/thread-picker/modal"; import type { CodexThreadsHost, CodexThreadsSettingsAccess } from "./features/threads-view/session"; diff --git a/src/settings/archived-section.tsx b/src/settings/archived-section.tsx index 5bc1ac59..1f012e9e 100644 --- a/src/settings/archived-section.tsx +++ b/src/settings/archived-section.tsx @@ -2,8 +2,8 @@ import type { ComponentChild as UiNode } from "preact"; import type { Thread } from "../domain/threads/model"; import { threadArchiveDisplayTitle } from "../domain/threads/title"; -import { ObsidianExtraButton, ObsidianTextInput, ObsidianToggle } from "../shared/ui/components"; import { shortThreadId } from "../shared/id/thread-id"; +import { ObsidianExtraButton, ObsidianTextInput, ObsidianToggle } from "../shared/ui/components"; import type { ArchivedThreadSectionState } from "./section-state"; import { SettingRow, SettingsGroup, SettingsHeading, SettingsItems, SettingsStatusRow } from "./setting-components"; diff --git a/src/settings/dynamic-data-controller.ts b/src/settings/dynamic-data-controller.ts index 6de78b9e..eccc5d03 100644 --- a/src/settings/dynamic-data-controller.ts +++ b/src/settings/dynamic-data-controller.ts @@ -1,6 +1,6 @@ +import { type HookData, listHookData, setHookItemEnabled, trustHookItem } from "../app-server/catalog"; import type { AppServerClient } from "../app-server/connection/client"; import { isStaleAppServerSharedQueryContextError } from "../app-server/query/shared-queries"; -import { listHookData, setHookItemEnabled, trustHookItem, type HookData } from "../app-server/catalog"; import { restoreArchivedThread as restoreArchivedThreadOnAppServer } from "../app-server/threads"; import type { HookItem, ModelMetadata, ReasoningEffort } from "../domain/catalog/metadata"; import { findModelMetadataByIdOrName, sortedModelMetadata, supportedEffortsForModelMetadata } from "../domain/catalog/metadata"; @@ -11,8 +11,8 @@ import { threadArchiveDisplayTitle } from "../domain/threads/title"; import type { SettingsDynamicDataHost } from "./host"; import { createSettingsDynamicSectionLifecycle, - transitionSettingsDynamicSectionLifecycle, type SettingsDynamicSectionLifecycleState, + transitionSettingsDynamicSectionLifecycle, } from "./lifecycle"; function archivedThreadTitleForStatus(thread: Thread | undefined, threadId: string): string { diff --git a/src/settings/host.ts b/src/settings/host.ts index 30b7fa33..70dac2d9 100644 --- a/src/settings/host.ts +++ b/src/settings/host.ts @@ -1,8 +1,8 @@ import type { AppServerClientAccess } from "../app-server/connection/client-access"; import type { ModelMetadata } from "../domain/catalog/metadata"; import type { ObservedDataListener } from "../domain/observed-data"; -import type { CodexPanelSettings } from "./model"; import type { ThreadCatalogArchivedReader, ThreadCatalogEventSink } from "../workspace/thread-catalog"; +import type { CodexPanelSettings } from "./model"; interface SettingsAppServerData { modelsSnapshot(): readonly ModelMetadata[] | null; diff --git a/src/settings/model.ts b/src/settings/model.ts index d184e357..6825566f 100644 --- a/src/settings/model.ts +++ b/src/settings/model.ts @@ -1,4 +1,4 @@ -import { FileSystemAdapter, type App } from "obsidian"; +import { type App, FileSystemAdapter } from "obsidian"; import { DEFAULT_CODEX_PATH } from "../constants"; import type { ReasoningEffort } from "../domain/catalog/metadata"; diff --git a/src/settings/tab.tsx b/src/settings/tab.tsx index 61bc93c5..89e8e1da 100644 --- a/src/settings/tab.tsx +++ b/src/settings/tab.tsx @@ -6,8 +6,8 @@ import { renderUiRoot, unmountUiRoot } from "../shared/ui/ui-root"; import { ArchivedThreadSection } from "./archived-section"; import { SettingsDynamicDataController, type SettingsDynamicDataDisplayTarget } from "./dynamic-data-controller"; import { HelperSettingsSection } from "./helper-section"; -import type { CodexPanelSettingTabHost } from "./host"; import { HookSection } from "./hook-section"; +import type { CodexPanelSettingTabHost } from "./host"; import type { SettingsSectionsState } from "./section-state"; const SETTINGS_INTRO_TEXT = "Codex Panel stores panel preferences only. Runtime settings still come from Codex."; diff --git a/src/shared/diff/render.ts b/src/shared/diff/render.ts index be19226b..cfad7140 100644 --- a/src/shared/diff/render.ts +++ b/src/shared/diff/render.ts @@ -1,4 +1,4 @@ -import { diffLineClass, diffLineClassFromText, displayDiffLineText, type DiffLineClass, type DisplayDiffLine } from "./unified"; +import { type DiffLineClass, type DisplayDiffLine, diffLineClass, diffLineClassFromText, displayDiffLineText } from "./unified"; const MAX_INLINE_DIFF_CHARS = 4000; const MAX_INLINE_DIFF_TOKENS = 500; diff --git a/src/shared/obsidian/file-links.ts b/src/shared/obsidian/file-links.ts index df39721e..f924fdc0 100644 --- a/src/shared/obsidian/file-links.ts +++ b/src/shared/obsidian/file-links.ts @@ -1,4 +1,4 @@ -import { TFile, type App } from "obsidian"; +import { type App, TFile } from "obsidian"; import { isFilesystemAbsolutePath, isVaultConfigPath, normalizeFilePath, parseFileHref, vaultRelativePath } from "../path/file-paths"; diff --git a/src/shared/ui/components.tsx b/src/shared/ui/components.tsx index f72166b4..9955bfcb 100644 --- a/src/shared/ui/components.tsx +++ b/src/shared/ui/components.tsx @@ -1,5 +1,5 @@ -import { ButtonComponent, DropdownComponent, ExtraButtonComponent, TextComponent, ToggleComponent, setIcon } from "obsidian"; -import type { ButtonHTMLAttributes, ComponentChild as UiNode, Ref } from "preact"; +import { ButtonComponent, DropdownComponent, ExtraButtonComponent, setIcon, TextComponent, ToggleComponent } from "obsidian"; +import type { ButtonHTMLAttributes, Ref, ComponentChild as UiNode } from "preact"; import { useLayoutEffect, useRef } from "preact/hooks"; interface ObsidianIconProps { diff --git a/src/workspace/panel-coordinator.ts b/src/workspace/panel-coordinator.ts index 3990cb72..e959d7ee 100644 --- a/src/workspace/panel-coordinator.ts +++ b/src/workspace/panel-coordinator.ts @@ -1,10 +1,10 @@ import type { App, WorkspaceLeaf } from "obsidian"; import { VIEW_TYPE_CODEX_PANEL } from "../constants"; -import { CodexChatView } from "../features/chat/host/view"; -import type { ChatWorkspacePanelSurface } from "../features/chat/host/surface-handle"; -import type { ChatPanelSnapshot } from "../features/chat/panel/snapshot"; import { hasPendingRequests, pendingRequestCounts } from "../domain/pending-requests/aggregate"; +import type { ChatWorkspacePanelSurface } from "../features/chat/host/surface-handle"; +import { CodexChatView } from "../features/chat/host/view"; +import type { ChatPanelSnapshot } from "../features/chat/panel/snapshot"; type ThreadPanelTarget = | { diff --git a/tests/app-server/app-server-client.test.ts b/tests/app-server/app-server-client.test.ts index e817b249..e6dc6f5c 100644 --- a/tests/app-server/app-server-client.test.ts +++ b/tests/app-server/app-server-client.test.ts @@ -1,12 +1,11 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - -import { AppServerClient } from "../../src/app-server/connection/client"; +import manifest from "../../manifest.json"; import type { AppServerStartStructuredTurnOptions, AppServerStartTurnOptions } from "../../src/app-server/connection/client"; -import type { AppServerTransport, AppServerTransportHandlers } from "../../src/app-server/connection/transport"; +import { AppServerClient } from "../../src/app-server/connection/client"; import type { RpcOutboundMessage } from "../../src/app-server/connection/rpc-messages"; +import type { AppServerTransport, AppServerTransportHandlers } from "../../src/app-server/connection/transport"; import type { InitializeResponse } from "../../src/generated/app-server/InitializeResponse"; import type { ServerRequest } from "../../src/generated/app-server/ServerRequest"; -import manifest from "../../manifest.json"; class FakeTransport implements AppServerTransport { readonly sent: RpcOutboundMessage[] = []; diff --git a/tests/app-server/app-server-diagnostics.test.ts b/tests/app-server/app-server-diagnostics.test.ts index 997609cb..72febf45 100644 --- a/tests/app-server/app-server-diagnostics.test.ts +++ b/tests/app-server/app-server-diagnostics.test.ts @@ -1,12 +1,12 @@ import { describe, expect, it } from "vitest"; import { + createServerDiagnostics, DIAGNOSTIC_PROBE_METHODS, - serverIdentity, - serverPlatform, diagnosticProbeError, diagnosticProbeOk, - createServerDiagnostics, + serverIdentity, + serverPlatform, upsertMcpServerDiagnostic, } from "../../src/domain/server/diagnostics"; import type { ServerInitialization } from "../../src/domain/server/initialization"; diff --git a/tests/app-server/catalog.test.ts b/tests/app-server/catalog.test.ts index c4b90a26..c2341081 100644 --- a/tests/app-server/catalog.test.ts +++ b/tests/app-server/catalog.test.ts @@ -1,7 +1,6 @@ import { describe, expect, it, vi } from "vitest"; - -import type { AppServerClient } from "../../src/app-server/connection/client"; import { listHookData, listSkillCatalog } from "../../src/app-server/catalog"; +import type { AppServerClient } from "../../src/app-server/connection/client"; import { appServerHookOperationFromHookItem, hookItemsFromCatalogHooks, diff --git a/tests/app-server/connection-manager.test.ts b/tests/app-server/connection-manager.test.ts index db0fa267..e9275827 100644 --- a/tests/app-server/connection-manager.test.ts +++ b/tests/app-server/connection-manager.test.ts @@ -6,8 +6,8 @@ import { type ConnectionManagerHandlers, StaleConnectionError, } from "../../src/app-server/connection/connection-manager"; -import type { AppServerTransport, AppServerTransportHandlers } from "../../src/app-server/connection/transport"; import type { RpcOutboundMessage } from "../../src/app-server/connection/rpc-messages"; +import type { AppServerTransport, AppServerTransportHandlers } from "../../src/app-server/connection/transport"; class SilentTransport implements AppServerTransport { readonly sent: RpcOutboundMessage[] = []; diff --git a/tests/app-server/ephemeral-structured-turn.test.ts b/tests/app-server/ephemeral-structured-turn.test.ts index 6ee8ba1c..d1be41d7 100644 --- a/tests/app-server/ephemeral-structured-turn.test.ts +++ b/tests/app-server/ephemeral-structured-turn.test.ts @@ -1,17 +1,17 @@ // @vitest-environment jsdom import { describe, expect, it, vi } from "vitest"; - -import { - runEphemeralStructuredTurn, - type EphemeralStructuredTurnClient, - type EphemeralStructuredTurnClientFactory, -} from "../../src/app-server/services/ephemeral-structured-turn"; import type { AppServerClientHandlers, AppServerStartEphemeralThreadOptions, AppServerStartStructuredTurnOptions, } from "../../src/app-server/connection/client"; +import type { TurnItem, TurnRecord } from "../../src/app-server/protocol/turn"; +import { + type EphemeralStructuredTurnClient, + type EphemeralStructuredTurnClientFactory, + runEphemeralStructuredTurn, +} from "../../src/app-server/services/ephemeral-structured-turn"; import type { InitializeResponse } from "../../src/generated/app-server/InitializeResponse"; import type { RequestId } from "../../src/generated/app-server/RequestId"; import type { ServerNotification } from "../../src/generated/app-server/ServerNotification"; @@ -20,7 +20,6 @@ import type { ModelListResponse } from "../../src/generated/app-server/v2/ModelL import type { Thread as ThreadRecord } from "../../src/generated/app-server/v2/Thread"; import type { ThreadStartResponse } from "../../src/generated/app-server/v2/ThreadStartResponse"; import type { TurnStartResponse } from "../../src/generated/app-server/v2/TurnStartResponse"; -import type { TurnItem, TurnRecord } from "../../src/app-server/protocol/turn"; describe("runEphemeralStructuredTurn", () => { it("fills completed turn items from item completion notifications", async () => { diff --git a/tests/app-server/query-cache.test.ts b/tests/app-server/query-cache.test.ts index 4f4254f8..9b5008d9 100644 --- a/tests/app-server/query-cache.test.ts +++ b/tests/app-server/query-cache.test.ts @@ -1,18 +1,17 @@ import { describe, expect, it, vi } from "vitest"; - +import type { CatalogModel, CatalogSkillMetadata } from "../../src/app-server/protocol/catalog"; +import { AppServerQueryCache } from "../../src/app-server/query/cache"; +import type { AppServerQueryContext } from "../../src/app-server/query/keys"; +import type { ModelMetadata, SkillMetadata } from "../../src/domain/catalog/metadata"; +import { emptyRuntimeConfigSnapshot, type RuntimeConfigSnapshot } from "../../src/domain/runtime/config"; +import type { RateLimitSnapshot } from "../../src/domain/runtime/metrics"; import { createServerDiagnostics, diagnosticProbeError, diagnosticProbeOk, diagnosticsWithProbe, } from "../../src/domain/server/diagnostics"; -import { AppServerQueryCache } from "../../src/app-server/query/cache"; -import type { AppServerQueryContext } from "../../src/app-server/query/keys"; -import { emptyRuntimeConfigSnapshot, type RuntimeConfigSnapshot } from "../../src/domain/runtime/config"; -import type { RateLimitSnapshot } from "../../src/domain/runtime/metrics"; import type { SharedServerMetadata } from "../../src/domain/server/metadata"; -import type { ModelMetadata, SkillMetadata } from "../../src/domain/catalog/metadata"; -import type { CatalogModel, CatalogSkillMetadata } from "../../src/app-server/protocol/catalog"; describe("AppServerQueryCache", () => { it("stores metadata snapshots without replacing failed resource values with stale data", () => { diff --git a/tests/app-server/request-input.test.ts b/tests/app-server/request-input.test.ts index c18c981b..5e4d3eec 100644 --- a/tests/app-server/request-input.test.ts +++ b/tests/app-server/request-input.test.ts @@ -1,7 +1,6 @@ import { describe, expect, it } from "vitest"; - -import { codexTextInputWithAttachments, codexTextInputWithMentions, type CodexInput } from "../../src/domain/chat/input"; import { additionalContextFromCodexInput, toAppServerUserInput } from "../../src/app-server/protocol/request-input"; +import { type CodexInput, codexTextInputWithAttachments, codexTextInputWithMentions } from "../../src/domain/chat/input"; describe("app-server request input", () => { it("builds text input with mentions and skills", () => { diff --git a/tests/app-server/shared-queries.test.ts b/tests/app-server/shared-queries.test.ts index b0325903..8dc12a4b 100644 --- a/tests/app-server/shared-queries.test.ts +++ b/tests/app-server/shared-queries.test.ts @@ -2,8 +2,8 @@ import { describe, expect, it, vi } from "vitest"; import type { AppServerQueryCache } from "../../src/app-server/query/cache"; import { AppServerSharedQueries, StaleAppServerSharedQueryContextError } from "../../src/app-server/query/shared-queries"; -import type { ObservedDataResult } from "../../src/domain/observed-data"; import type { ModelMetadata } from "../../src/domain/catalog/metadata"; +import type { ObservedDataResult } from "../../src/domain/observed-data"; import { createServerDiagnostics, diagnosticProbeOk, diagnosticsWithProbe } from "../../src/domain/server/diagnostics"; import type { SharedServerMetadata } from "../../src/domain/server/metadata"; import type { Thread } from "../../src/domain/threads/model"; diff --git a/tests/app-server/thread-activation.test.ts b/tests/app-server/thread-activation.test.ts index 4f3fc035..8cf7769b 100644 --- a/tests/app-server/thread-activation.test.ts +++ b/tests/app-server/thread-activation.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it } from "vitest"; import { threadActivationSnapshotFromAppServerResponse } from "../../src/app-server/threads"; -import type { ThreadResumeResponse } from "../../src/generated/app-server/v2/ThreadResumeResponse"; import type { Thread as ThreadRecord } from "../../src/generated/app-server/v2/Thread"; +import type { ThreadResumeResponse } from "../../src/generated/app-server/v2/ThreadResumeResponse"; describe("app-server thread activation", () => { it("maps app-server activation responses into panel-owned snapshots", () => { diff --git a/tests/app-server/thread-archive.test.ts b/tests/app-server/thread-archive.test.ts index bf89a6e6..6ce008ff 100644 --- a/tests/app-server/thread-archive.test.ts +++ b/tests/app-server/thread-archive.test.ts @@ -2,8 +2,8 @@ import { describe, expect, it, vi } from "vitest"; import type { AppServerClient } from "../../src/app-server/connection/client"; import type { ThreadRecord } from "../../src/app-server/protocol/thread"; -import type { ArchiveExportAdapter } from "../../src/domain/threads/archive-markdown"; import { archiveThreadOnAppServer } from "../../src/app-server/services/thread-archive"; +import type { ArchiveExportAdapter } from "../../src/domain/threads/archive-markdown"; import { DEFAULT_SETTINGS } from "../../src/settings/model"; describe("thread archive operation", () => { diff --git a/tests/app-server/thread-settings.test.ts b/tests/app-server/thread-settings.test.ts index 916dfbc5..76e29924 100644 --- a/tests/app-server/thread-settings.test.ts +++ b/tests/app-server/thread-settings.test.ts @@ -1,12 +1,12 @@ import { describe, expect, it } from "vitest"; import { appServerRuntimeSettingsPatch } from "../../src/app-server/protocol/thread-settings"; +import { approvalsReviewerOrNull, parseServiceTier } from "../../src/domain/runtime/policy"; import { applyRuntimeSettingsPatchValue, - runtimeCollaborationModeSettings, type RuntimeSettingsPatch, + runtimeCollaborationModeSettings, } from "../../src/domain/runtime/thread-settings"; -import { approvalsReviewerOrNull, parseServiceTier } from "../../src/domain/runtime/policy"; describe("app-server thread settings", () => { it("applies defined thread setting values and omits undefined values", () => { diff --git a/tests/app-server/thread-title-generation.test.ts b/tests/app-server/thread-title-generation.test.ts index 98fb9670..e550f6fb 100644 --- a/tests/app-server/thread-title-generation.test.ts +++ b/tests/app-server/thread-title-generation.test.ts @@ -3,17 +3,17 @@ import { describe, expect, it } from "vitest"; import type { AppServerClient, AppServerClientHandlers, AppServerStartStructuredTurnOptions } from "../../src/app-server/connection/client"; -import type { TurnItem, TurnRecord } from "../../src/app-server/protocol/turn"; import type { RequestId, ServerNotification } from "../../src/app-server/connection/rpc-messages"; -import type { ServerInitialization } from "../../src/domain/server/initialization"; -import { generateThreadTitleWithCodex } from "../../src/app-server/services/thread-title-generation"; +import type { TurnItem, TurnRecord } from "../../src/app-server/protocol/turn"; import type { EphemeralStructuredTurnClient, EphemeralStructuredTurnClientFactory, } from "../../src/app-server/services/ephemeral-structured-turn"; +import { generateThreadTitleWithCodex } from "../../src/app-server/services/thread-title-generation"; +import type { ServerInitialization } from "../../src/domain/server/initialization"; import { - THREAD_TITLE_MAX_CHARS, findThreadTitleContext, + THREAD_TITLE_MAX_CHARS, threadTitleContextFromConversationSummary, threadTitleFromGeneratedText, threadTitlePrompt, diff --git a/tests/app-server/transport.test.ts b/tests/app-server/transport.test.ts index 2954b84d..66ec97f9 100644 --- a/tests/app-server/transport.test.ts +++ b/tests/app-server/transport.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it, vi } from "vitest"; -import { StdioAppServerTransport, type AppServerTransportHandlers } from "../../src/app-server/connection/transport"; +import { type AppServerTransportHandlers, StdioAppServerTransport } from "../../src/app-server/connection/transport"; interface TestableTransport { handleStderr(text: string): void; diff --git a/tests/app-server/turn.test.ts b/tests/app-server/turn.test.ts index 65f95723..d91ec83a 100644 --- a/tests/app-server/turn.test.ts +++ b/tests/app-server/turn.test.ts @@ -6,9 +6,9 @@ import { completedConversationSummaryFromTurnRecord, conversationAssistantTextFromTurnRecord, lastAgentMessageTextFromTurnRecord, - transcriptEntriesFromTurnRecords, type TurnItem, type TurnRecord, + transcriptEntriesFromTurnRecords, } from "../../src/app-server/protocol/turn"; describe("app-server turn records", () => { diff --git a/tests/domain/threads/archive-markdown.test.ts b/tests/domain/threads/archive-markdown.test.ts index c31f2f13..6b7337aa 100644 --- a/tests/domain/threads/archive-markdown.test.ts +++ b/tests/domain/threads/archive-markdown.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "vitest"; -import { archivedThreadMarkdown, type ArchiveExportSettings } from "../../../src/domain/threads/archive-markdown"; +import { type ArchiveExportSettings, archivedThreadMarkdown } from "../../../src/domain/threads/archive-markdown"; import type { Thread } from "../../../src/domain/threads/model"; import { referencedThreadPromptBundle } from "../../../src/domain/threads/reference"; import type { ThreadTranscriptEntry } from "../../../src/domain/threads/transcript"; diff --git a/tests/domain/threads/threads.test.ts b/tests/domain/threads/threads.test.ts index 25b9b460..da504855 100644 --- a/tests/domain/threads/threads.test.ts +++ b/tests/domain/threads/threads.test.ts @@ -4,9 +4,9 @@ import { explicitThreadName, inheritedForkThreadName, normalizeExplicitThreadName, + type Thread, threadRecencyAt, upsertThread, - type Thread, } from "../../../src/domain/threads/model"; import { threadArchiveDisplayTitle, diff --git a/tests/features/chat/connection/connection-controller.test.ts b/tests/features/chat/connection/connection-controller.test.ts index b57dcc7a..9a1f2224 100644 --- a/tests/features/chat/connection/connection-controller.test.ts +++ b/tests/features/chat/connection/connection-controller.test.ts @@ -2,16 +2,16 @@ import { describe, expect, it, vi } from "vitest"; import type { AppServerClient } from "../../../../src/app-server/connection/client"; import { emptyRuntimeConfigSnapshot } from "../../../../src/domain/runtime/config"; -import { createChatState } from "../../../../src/features/chat/application/state/root-reducer"; -import { createChatStateStore } from "../../../../src/features/chat/application/state/store"; -import { ConnectionWorkTracker } from "../../../../src/shared/lifecycle/connection-work"; import { - createChatConnectionController, type ChatConnectionAdapter, type ChatConnectionControllerHost, type ChatConnectionDiagnosticsActions, type ChatConnectionMetadataActions, + createChatConnectionController, } from "../../../../src/features/chat/application/connection/connection-controller"; +import { createChatState } from "../../../../src/features/chat/application/state/root-reducer"; +import { createChatStateStore } from "../../../../src/features/chat/application/state/store"; +import { ConnectionWorkTracker } from "../../../../src/shared/lifecycle/connection-work"; function createController({ connected = false, client = {} as AppServerClient } = {}) { const stateStore = createChatStateStore(createChatState()); diff --git a/tests/features/chat/connection/reconnect-actions.test.ts b/tests/features/chat/connection/reconnect-actions.test.ts index 51579a0b..4fa3f828 100644 --- a/tests/features/chat/connection/reconnect-actions.test.ts +++ b/tests/features/chat/connection/reconnect-actions.test.ts @@ -1,8 +1,7 @@ import { describe, expect, it, vi } from "vitest"; - +import { type ChatReconnectActionsHost, reconnectPanel } from "../../../../src/features/chat/application/connection/reconnect-actions"; import { createChatState } from "../../../../src/features/chat/application/state/root-reducer"; import { createChatStateStore } from "../../../../src/features/chat/application/state/store"; -import { reconnectPanel, type ChatReconnectActionsHost } from "../../../../src/features/chat/application/connection/reconnect-actions"; function createHost(overrides: Partial = {}) { const stateStore = createChatStateStore(createChatState()); diff --git a/tests/features/chat/connection/server-actions/server-actions.test.ts b/tests/features/chat/connection/server-actions/server-actions.test.ts index f3cf3513..f221e858 100644 --- a/tests/features/chat/connection/server-actions/server-actions.test.ts +++ b/tests/features/chat/connection/server-actions/server-actions.test.ts @@ -1,7 +1,15 @@ import { describe, expect, it, vi } from "vitest"; import type { AppServerClient } from "../../../../../src/app-server/connection/client"; +import { + type CatalogModel, + type CatalogSkillMetadata, + modelMetadataFromCatalogModels, +} from "../../../../../src/app-server/protocol/catalog"; +import { threadFromThreadRecord } from "../../../../../src/app-server/protocol/thread"; import { StaleAppServerSharedQueryContextError } from "../../../../../src/app-server/query/shared-queries"; +import { emptyRuntimeConfigSnapshot } from "../../../../../src/domain/runtime/config"; +import type { RateLimitSnapshot } from "../../../../../src/domain/runtime/metrics"; import { createServerDiagnostics, diagnosticProbeError, @@ -10,20 +18,12 @@ import { type McpServerStatus, } from "../../../../../src/domain/server/diagnostics"; import type { SharedServerMetadata } from "../../../../../src/domain/server/metadata"; -import { emptyRuntimeConfigSnapshot } from "../../../../../src/domain/runtime/config"; -import type { RateLimitSnapshot } from "../../../../../src/domain/runtime/metrics"; -import { threadFromThreadRecord } from "../../../../../src/app-server/protocol/thread"; import { createChatServerDiagnosticsActions } from "../../../../../src/features/chat/app-server/actions/diagnostics"; import { createChatServerMetadataActions } from "../../../../../src/features/chat/app-server/actions/metadata"; import { createChatServerThreadActions } from "../../../../../src/features/chat/app-server/actions/threads"; import { toolInventoryDiagnosticSections } from "../../../../../src/features/chat/application/connection/tool-inventory-display"; import { runtimeSnapshotForChatState } from "../../../../../src/features/chat/application/runtime/snapshot"; import { createChatStateStore } from "../../../../../src/features/chat/application/state/store"; -import { - modelMetadataFromCatalogModels, - type CatalogModel, - type CatalogSkillMetadata, -} from "../../../../../src/app-server/protocol/catalog"; import { chatStateFixture, chatStateWith } from "../../support/state"; type ThreadStartResponse = Awaited>; diff --git a/tests/features/chat/conversation/composer/boundary-scroll.test.ts b/tests/features/chat/conversation/composer/boundary-scroll.test.ts index ff4a6061..5353ea07 100644 --- a/tests/features/chat/conversation/composer/boundary-scroll.test.ts +++ b/tests/features/chat/conversation/composer/boundary-scroll.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it, vi } from "vitest"; import { - composerBoundaryScrollDirection, type ComposerBoundaryScrollAction, + composerBoundaryScrollDirection, } from "../../../../../src/features/chat/application/composer/boundary-scroll"; describe("composer boundary scroll shortcuts", () => { diff --git a/tests/features/chat/conversation/composer/composer-keys.test.ts b/tests/features/chat/conversation/composer/composer-keys.test.ts index e2e17965..618700f8 100644 --- a/tests/features/chat/conversation/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 { type ComposerSendKeyEvent, isComposerSendKey } from "../../../../../src/shared/ui/keyboard"; const baseEvent: ComposerSendKeyEvent = { key: "Enter", diff --git a/tests/features/chat/conversation/composer/composer-suggestions.test.ts b/tests/features/chat/conversation/composer/composer-suggestions.test.ts index 619acb23..7454558a 100644 --- a/tests/features/chat/conversation/composer/composer-suggestions.test.ts +++ b/tests/features/chat/conversation/composer/composer-suggestions.test.ts @@ -1,12 +1,11 @@ import { describe, expect, it } from "vitest"; - -import type { Thread } from "../../../../../src/domain/threads/model"; import type { ModelMetadata, ReasoningEffort } from "../../../../../src/domain/catalog/metadata"; +import type { Thread } from "../../../../../src/domain/threads/model"; import { activeComposerSuggestions, applyComposerSuggestionInsertion, - composerSuggestionSignature, composerSuggestionNavigationDirection, + composerSuggestionSignature, nextComposerSuggestionIndex, parseSlashCommand, } from "../../../../../src/features/chat/application/composer/suggestions"; diff --git a/tests/features/chat/conversation/composer/controller.test.ts b/tests/features/chat/conversation/composer/controller.test.ts index 12f0dae2..3396faa6 100644 --- a/tests/features/chat/conversation/composer/controller.test.ts +++ b/tests/features/chat/conversation/composer/controller.test.ts @@ -1,17 +1,16 @@ // @vitest-environment jsdom -import { describe, expect, it, vi } from "vitest"; import { h } from "preact"; - -import { ChatComposerController, type ChatComposerRenderActions } from "../../../../../src/features/chat/panel/composer-controller"; -import { ComposerShell } from "../../../../../src/features/chat/ui/composer"; -import { createChatStateStore } from "../../../../../src/features/chat/application/state/store"; -import type { ChatStateStore } from "../../../../../src/features/chat/application/state/store"; -import { renderUiRoot, unmountUiRoot } from "../../../../../src/shared/ui/ui-root"; +import { describe, expect, it, vi } from "vitest"; import type { SkillMetadata } from "../../../../../src/domain/catalog/metadata"; -import { installObsidianDomShims } from "../../../../support/dom"; -import type { ChatPanelComposerShellState } from "../../../../../src/features/chat/panel/shell-state"; import type { NoteCandidateProvider } from "../../../../../src/features/chat/application/composer/note-context"; +import type { ChatStateStore } from "../../../../../src/features/chat/application/state/store"; +import { createChatStateStore } from "../../../../../src/features/chat/application/state/store"; +import { ChatComposerController, type ChatComposerRenderActions } from "../../../../../src/features/chat/panel/composer-controller"; +import type { ChatPanelComposerShellState } from "../../../../../src/features/chat/panel/shell-state"; +import { ComposerShell } from "../../../../../src/features/chat/ui/composer"; +import { renderUiRoot, unmountUiRoot } from "../../../../../src/shared/ui/ui-root"; +import { installObsidianDomShims } from "../../../../support/dom"; import { composerShellStateFromChatState } from "../../support/shell-state"; installObsidianDomShims(); diff --git a/tests/features/chat/conversation/pending-requests/pending-request-actions.test.ts b/tests/features/chat/conversation/pending-requests/pending-request-actions.test.ts index 5d689de3..85b48305 100644 --- a/tests/features/chat/conversation/pending-requests/pending-request-actions.test.ts +++ b/tests/features/chat/conversation/pending-requests/pending-request-actions.test.ts @@ -1,10 +1,9 @@ import { describe, expect, it, vi } from "vitest"; - +import type { ServerRequest } from "../../../../../src/app-server/connection/rpc-messages"; import { appServerUserInputRequest as toPendingUserInput } from "../../../../../src/app-server/protocol/server-requests"; +import { createPendingRequestActions } from "../../../../../src/features/chat/application/pending-requests/pending-request-actions"; import { createChatState } from "../../../../../src/features/chat/application/state/root-reducer"; import { createChatStateStore } from "../../../../../src/features/chat/application/state/store"; -import { createPendingRequestActions } from "../../../../../src/features/chat/application/pending-requests/pending-request-actions"; -import type { ServerRequest } from "../../../../../src/app-server/connection/rpc-messages"; 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/conversation/pending-requests/state.test.ts b/tests/features/chat/conversation/pending-requests/state.test.ts index c8cffe04..5400a595 100644 --- a/tests/features/chat/conversation/pending-requests/state.test.ts +++ b/tests/features/chat/conversation/pending-requests/state.test.ts @@ -1,9 +1,9 @@ import { describe, expect, it } from "vitest"; import { + type ChatRequestState, initialChatRequestState, resolveChatRequest, - type ChatRequestState, } from "../../../../../src/features/chat/application/pending-requests/state"; describe("chat pending request state", () => { diff --git a/tests/features/chat/conversation/turns/composer-submit-actions.test.ts b/tests/features/chat/conversation/turns/composer-submit-actions.test.ts index 49b15b1a..0b6a7978 100644 --- a/tests/features/chat/conversation/turns/composer-submit-actions.test.ts +++ b/tests/features/chat/conversation/turns/composer-submit-actions.test.ts @@ -1,10 +1,10 @@ import { describe, expect, it, vi } from "vitest"; import type { AppServerClient } from "../../../../../src/app-server/connection/client"; +import type { Thread } from "../../../../../src/domain/threads/model"; +import { submitComposer } from "../../../../../src/features/chat/application/conversation/composer-submit-actions"; import { createChatState } from "../../../../../src/features/chat/application/state/root-reducer"; import { createChatStateStore } from "../../../../../src/features/chat/application/state/store"; -import { submitComposer } from "../../../../../src/features/chat/application/conversation/composer-submit-actions"; -import type { Thread } from "../../../../../src/domain/threads/model"; function thread(id: string): Thread { return { diff --git a/tests/features/chat/conversation/turns/plan-implementation.test.ts b/tests/features/chat/conversation/turns/plan-implementation.test.ts index 2dad75f1..d4fd5086 100644 --- a/tests/features/chat/conversation/turns/plan-implementation.test.ts +++ b/tests/features/chat/conversation/turns/plan-implementation.test.ts @@ -1,13 +1,13 @@ import { describe, expect, it, vi } from "vitest"; import type { AppServerClient } from "../../../../../src/app-server/connection/client"; -import { createChatState } from "../../../../../src/features/chat/application/state/root-reducer"; -import { createChatStateStore, type ChatStateStore } from "../../../../../src/features/chat/application/state/store"; import { implementPlan, implementPlanTargetFromState, type PlanImplementationHost, } from "../../../../../src/features/chat/application/conversation/plan-implementation"; +import { createChatState } from "../../../../../src/features/chat/application/state/root-reducer"; +import { type ChatStateStore, createChatStateStore } from "../../../../../src/features/chat/application/state/store"; import type { MessageStreamItem } from "../../../../../src/features/chat/domain/message-stream/items"; const planItem = (id: string): MessageStreamItem => ({ diff --git a/tests/features/chat/conversation/turns/slash-command-execution.test.ts b/tests/features/chat/conversation/turns/slash-command-execution.test.ts index 3e1e3e8f..9c948c7b 100644 --- a/tests/features/chat/conversation/turns/slash-command-execution.test.ts +++ b/tests/features/chat/conversation/turns/slash-command-execution.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it, vi } from "vitest"; import type { ThreadGoal } from "../../../../../src/domain/threads/goal"; -import { slashCommandHelpSections } from "../../../../../src/features/chat/application/composer/slash-commands"; import type { Thread } from "../../../../../src/domain/threads/model"; +import { slashCommandHelpSections } from "../../../../../src/features/chat/application/composer/slash-commands"; import { executeSlashCommand, type SlashCommandExecutionContext, diff --git a/tests/features/chat/conversation/turns/slash-command-executor.test.ts b/tests/features/chat/conversation/turns/slash-command-executor.test.ts index 6a2b0ba9..5eff26e1 100644 --- a/tests/features/chat/conversation/turns/slash-command-executor.test.ts +++ b/tests/features/chat/conversation/turns/slash-command-executor.test.ts @@ -1,15 +1,15 @@ import { describe, expect, it, vi } from "vitest"; import type { AppServerClient } from "../../../../../src/app-server/connection/client"; -import type { CodexInput } from "../../../../../src/domain/chat/input"; import type { TurnItem, TurnRecord } from "../../../../../src/app-server/protocol/turn"; -import { createChatState } from "../../../../../src/features/chat/application/state/root-reducer"; -import { createChatStateStore } from "../../../../../src/features/chat/application/state/store"; +import type { CodexInput } from "../../../../../src/domain/chat/input"; +import type { Thread } from "../../../../../src/domain/threads/model"; import { executeSlashCommandWithState, type SlashCommandExecutorHost, } from "../../../../../src/features/chat/application/conversation/slash-command-executor"; -import type { Thread } from "../../../../../src/domain/threads/model"; +import { createChatState } from "../../../../../src/features/chat/application/state/root-reducer"; +import { createChatStateStore } from "../../../../../src/features/chat/application/state/store"; const textInput = (text: string): CodexInput => [{ type: "text", text }]; diff --git a/tests/features/chat/conversation/turns/turn-state.test.ts b/tests/features/chat/conversation/turns/turn-state.test.ts index a51ad62c..dcb60b7e 100644 --- a/tests/features/chat/conversation/turns/turn-state.test.ts +++ b/tests/features/chat/conversation/turns/turn-state.test.ts @@ -1,10 +1,10 @@ import { describe, expect, it } from "vitest"; import { - transitionChatTurnLifecycleState, type ChatTurnLifecycleEvent, type ChatTurnLifecycleState, type PendingTurnStart, + transitionChatTurnLifecycleState, } from "../../../../../src/features/chat/application/conversation/turn-state"; describe("chat turn lifecycle state machine", () => { diff --git a/tests/features/chat/conversation/turns/turn-submission-actions.test.ts b/tests/features/chat/conversation/turns/turn-submission-actions.test.ts index f308ec52..c68d4a94 100644 --- a/tests/features/chat/conversation/turns/turn-submission-actions.test.ts +++ b/tests/features/chat/conversation/turns/turn-submission-actions.test.ts @@ -2,14 +2,14 @@ import { describe, expect, it, vi } from "vitest"; import type { AppServerClient } from "../../../../../src/app-server/connection/client"; import type { CodexInput } from "../../../../../src/domain/chat/input"; -import { createChatState } from "../../../../../src/features/chat/application/state/root-reducer"; -import { createChatStateStore } from "../../../../../src/features/chat/application/state/store"; +import type { Thread } from "../../../../../src/domain/threads/model"; +import { optimisticTurnStart } from "../../../../../src/features/chat/application/conversation/optimistic-turn-start"; import { createTurnSubmissionActions, type TurnSubmissionActionsHost, } from "../../../../../src/features/chat/application/conversation/turn-submission-actions"; -import { optimisticTurnStart } from "../../../../../src/features/chat/application/conversation/optimistic-turn-start"; -import type { Thread } from "../../../../../src/domain/threads/model"; +import { createChatState } from "../../../../../src/features/chat/application/state/root-reducer"; +import { createChatStateStore } from "../../../../../src/features/chat/application/state/store"; import { createLocalIdSource } from "../../../../../src/shared/id/local-id"; import { chatStateMessageStreamItems } from "../../support/message-stream"; diff --git a/tests/features/chat/diagnostics.test.ts b/tests/features/chat/diagnostics.test.ts index d89342c6..296f3b47 100644 --- a/tests/features/chat/diagnostics.test.ts +++ b/tests/features/chat/diagnostics.test.ts @@ -1,10 +1,10 @@ import { describe, expect, it } from "vitest"; import { + createServerDiagnostics, diagnosticProbeError, diagnosticProbeOk, diagnosticsWithProbe, - createServerDiagnostics, upsertMcpServerDiagnostic, upsertMcpServerStatusDiagnostics, } from "../../../src/domain/server/diagnostics"; diff --git a/tests/features/chat/host/session-graph.test.ts b/tests/features/chat/host/session-graph.test.ts index 31cf7c08..0a866bd4 100644 --- a/tests/features/chat/host/session-graph.test.ts +++ b/tests/features/chat/host/session-graph.test.ts @@ -3,18 +3,18 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { StaleAppServerSharedQueryContextError } from "../../../../src/app-server/query/shared-queries"; -import { createChatStateStore, type ChatStateStore } from "../../../../src/features/chat/application/state/store"; +import type { ModelMetadata } from "../../../../src/domain/catalog/metadata"; +import type { Thread } from "../../../../src/domain/threads/model"; import { ChatResumeWorkTracker } from "../../../../src/features/chat/application/lifecycle"; +import { type ChatStateStore, createChatStateStore } from "../../../../src/features/chat/application/state/store"; +import { createChatViewDeferredTasks } from "../../../../src/features/chat/host/lifecycle"; +import type { ChatPanelEnvironment } from "../../../../src/features/chat/host/runtime"; +import { createChatPanelSessionGraph } from "../../../../src/features/chat/host/session-graph"; import { ChatComposerController } from "../../../../src/features/chat/panel/composer-controller"; import { MessageStreamPresenter } from "../../../../src/features/chat/panel/surface/message-stream-presenter"; -import { createChatViewDeferredTasks } from "../../../../src/features/chat/host/lifecycle"; import { createChatMessageScrollController } from "../../../../src/features/chat/panel/surface/message-stream-scroll"; -import { createChatPanelSessionGraph } from "../../../../src/features/chat/host/session-graph"; import { DEFAULT_SETTINGS } from "../../../../src/settings/model"; import { ConnectionWorkTracker } from "../../../../src/shared/lifecycle/connection-work"; -import type { Thread } from "../../../../src/domain/threads/model"; -import type { ModelMetadata } from "../../../../src/domain/catalog/metadata"; -import type { ChatPanelEnvironment } from "../../../../src/features/chat/host/runtime"; import { installObsidianDomShims } from "../../../support/dom"; installObsidianDomShims(); diff --git a/tests/features/chat/markdown-file-links.test.ts b/tests/features/chat/markdown-file-links.test.ts index 7282d601..776c8914 100644 --- a/tests/features/chat/markdown-file-links.test.ts +++ b/tests/features/chat/markdown-file-links.test.ts @@ -1,5 +1,5 @@ +import { type App, TFile } from "obsidian"; import { describe, expect, it } from "vitest"; -import { TFile, type App } from "obsidian"; import { isAbsoluteFileHref, vaultFileLinkTarget, vaultRelativeFileLinkTarget } from "../../../src/shared/obsidian/file-links"; diff --git a/tests/features/chat/message-stream/model.test.ts b/tests/features/chat/message-stream/model.test.ts index 1b2ae144..a22a0b5c 100644 --- a/tests/features/chat/message-stream/model.test.ts +++ b/tests/features/chat/message-stream/model.test.ts @@ -1,25 +1,24 @@ import { describe, expect, it } from "vitest"; - -import { collabAgentStateExecutionState } from "../../../../src/features/chat/domain/message-stream/execution-state"; -import { activeTurnLiveItems } from "../../../../src/features/chat/domain/message-stream/semantics/active-turn"; -import { messageStreamLayoutBlocks } from "../../../../src/features/chat/presentation/message-stream/layout"; -import { upsertMessageStreamItemById } from "../../../../src/features/chat/domain/message-stream/updates"; -import { taskProgressMessageStreamItem } from "../../../../src/features/chat/app-server/mappers/message-stream/task-progress"; -import { pathRelativeToRoot } from "../../../../src/shared/path/file-paths"; -import { permissionRows } from "../../../../src/features/chat/domain/message-stream/format/permission-rows"; +import type { TurnItem, TurnRecord } from "../../../../src/app-server/protocol/turn"; +import type { Thread } from "../../../../src/domain/threads/model"; +import { referencedThreadPromptBundle } from "../../../../src/domain/threads/reference"; +import { hookRunMessageStreamItem } from "../../../../src/features/chat/app-server/mappers/message-stream/hook-run-items"; import { createAutoReviewResultItem, createReviewResultItem, } from "../../../../src/features/chat/app-server/mappers/message-stream/review-result-items"; -import { hookRunMessageStreamItem } from "../../../../src/features/chat/app-server/mappers/message-stream/hook-run-items"; +import { taskProgressMessageStreamItem } from "../../../../src/features/chat/app-server/mappers/message-stream/task-progress"; import { messageStreamItemFromTurnItem, messageStreamItemsFromTurns, } from "../../../../src/features/chat/app-server/mappers/message-stream/turn-items"; -import { referencedThreadPromptBundle } from "../../../../src/domain/threads/reference"; +import { collabAgentStateExecutionState } from "../../../../src/features/chat/domain/message-stream/execution-state"; +import { permissionRows } from "../../../../src/features/chat/domain/message-stream/format/permission-rows"; import type { MessageStreamItem } from "../../../../src/features/chat/domain/message-stream/items"; -import type { Thread } from "../../../../src/domain/threads/model"; -import type { TurnItem, TurnRecord } from "../../../../src/app-server/protocol/turn"; +import { activeTurnLiveItems } from "../../../../src/features/chat/domain/message-stream/semantics/active-turn"; +import { upsertMessageStreamItemById } from "../../../../src/features/chat/domain/message-stream/updates"; +import { messageStreamLayoutBlocks } from "../../../../src/features/chat/presentation/message-stream/layout"; +import { pathRelativeToRoot } from "../../../../src/shared/path/file-paths"; function commandItem(id: string, text: string, turnId: string): MessageStreamItem { return { diff --git a/tests/features/chat/message-stream/presentation/blocks.test.ts b/tests/features/chat/message-stream/presentation/blocks.test.ts index 09b6926b..8ece5c28 100644 --- a/tests/features/chat/message-stream/presentation/blocks.test.ts +++ b/tests/features/chat/message-stream/presentation/blocks.test.ts @@ -1,7 +1,6 @@ import { describe, expect, it } from "vitest"; - -import { messageStreamViewBlocks } from "../../../../../src/features/chat/presentation/message-stream/view-model"; import type { MessageStreamItem } from "../../../../../src/features/chat/domain/message-stream/items"; +import { messageStreamViewBlocks } from "../../../../../src/features/chat/presentation/message-stream/view-model"; describe("message stream presentation blocks", () => { it("keeps the empty state after the history affordance", () => { diff --git a/tests/features/chat/message-stream/selectors.test.ts b/tests/features/chat/message-stream/selectors.test.ts index a034d16c..6b1062d2 100644 --- a/tests/features/chat/message-stream/selectors.test.ts +++ b/tests/features/chat/message-stream/selectors.test.ts @@ -1,7 +1,6 @@ import { describe, expect, it } from "vitest"; - -import { forkCandidatesFromItems } from "../../../../src/features/chat/domain/message-stream/selectors"; import type { MessageStreamItem } from "../../../../src/features/chat/domain/message-stream/items"; +import { forkCandidatesFromItems } from "../../../../src/features/chat/domain/message-stream/selectors"; describe("message stream item selectors", () => { it("selects final assistant messages as fork candidates", () => { diff --git a/tests/features/chat/message-stream/semantics.test.ts b/tests/features/chat/message-stream/semantics.test.ts index 286b0250..c86efe8f 100644 --- a/tests/features/chat/message-stream/semantics.test.ts +++ b/tests/features/chat/message-stream/semantics.test.ts @@ -1,12 +1,11 @@ import { describe, expect, it } from "vitest"; - +import type { TurnItem } from "../../../../src/app-server/protocol/turn"; import { streamingFileChangeMessageStreamItem } from "../../../../src/features/chat/app-server/mappers/message-stream/file-changes"; import { messageStreamItemFromTurnItem } from "../../../../src/features/chat/app-server/mappers/message-stream/turn-items"; +import type { MessageStreamItem } from "../../../../src/features/chat/domain/message-stream/items"; import { messageStreamReasoningIsActive } from "../../../../src/features/chat/domain/message-stream/semantics/active-turn"; import { messageStreamSemanticClassifications } from "../../../../src/features/chat/domain/message-stream/semantics/classify"; import { messageStreamIsAutoReviewDecision } from "../../../../src/features/chat/domain/message-stream/semantics/predicates"; -import type { MessageStreamItem } from "../../../../src/features/chat/domain/message-stream/items"; -import type { TurnItem } from "../../../../src/app-server/protocol/turn"; describe("message stream semantic classification", () => { it("separates dialogue meaning from turn placement", () => { diff --git a/tests/features/chat/panel/shell.test.tsx b/tests/features/chat/panel/shell.test.tsx index a17df5d8..9eced4fb 100644 --- a/tests/features/chat/panel/shell.test.tsx +++ b/tests/features/chat/panel/shell.test.tsx @@ -1,17 +1,16 @@ // @vitest-environment jsdom -import { describe, expect, it, vi } from "vitest"; import { act } from "preact/test-utils"; - -import { createChatStateStore } from "../../../../src/features/chat/application/state/store"; +import { describe, expect, it, vi } from "vitest"; import { messageStreamItems } from "../../../../src/features/chat/application/state/message-stream"; -import { renderChatPanelShell, unmountChatPanelShell, type ChatPanelShellParts } from "../../../../src/features/chat/panel/shell"; +import { createChatStateStore } from "../../../../src/features/chat/application/state/store"; +import { type ChatPanelShellParts, renderChatPanelShell, unmountChatPanelShell } from "../../../../src/features/chat/panel/shell"; import type { ChatPanelComposerSurface } from "../../../../src/features/chat/panel/surface/composer-projection"; import type { ChatPanelGoalSurface } from "../../../../src/features/chat/panel/surface/goal-projection"; import type { ChatPanelToolbarSurface } from "../../../../src/features/chat/panel/surface/toolbar-projection"; -import type { MessageStreamScrollControllerBinding } from "../../../../src/features/chat/ui/message-stream/flow-scroll"; -import type { MessageStreamContext } from "../../../../src/features/chat/ui/message-stream/context"; import { messageStreamViewBlocks } from "../../../../src/features/chat/presentation/message-stream/view-model"; +import type { MessageStreamContext } from "../../../../src/features/chat/ui/message-stream/context"; +import type { MessageStreamScrollControllerBinding } from "../../../../src/features/chat/ui/message-stream/flow-scroll"; import { installObsidianDomShims } from "../../../support/dom"; installObsidianDomShims(); diff --git a/tests/features/chat/panel/surface/message-stream-presenter.test.ts b/tests/features/chat/panel/surface/message-stream-presenter.test.ts index 1fc73e00..77937be2 100644 --- a/tests/features/chat/panel/surface/message-stream-presenter.test.ts +++ b/tests/features/chat/panel/surface/message-stream-presenter.test.ts @@ -1,30 +1,30 @@ // @vitest-environment jsdom -import { beforeEach, describe, expect, it, vi } from "vitest"; import { MarkdownRenderer, TFile } from "obsidian"; import { h } from "preact"; +import { beforeEach, describe, expect, it, vi } from "vitest"; -import { chatReducer, type ChatAction, type ChatState } from "../../../../../src/features/chat/application/state/root-reducer"; -import { createChatStateStore, type ChatStateStore } from "../../../../../src/features/chat/application/state/store"; +import { type ChatAction, type ChatState, chatReducer } from "../../../../../src/features/chat/application/state/root-reducer"; +import { type ChatStateStore, createChatStateStore } from "../../../../../src/features/chat/application/state/store"; import { MessageStreamPresenter } from "../../../../../src/features/chat/panel/surface/message-stream-presenter"; import { type ChatMessageStreamSurfaceContext, messageStreamSurfaceProjectionFromState, } from "../../../../../src/features/chat/panel/surface/message-stream-projection"; import { - createChatMessageScrollController, type ChatMessageScrollController, + createChatMessageScrollController, } from "../../../../../src/features/chat/panel/surface/message-stream-scroll"; -import { MessageStreamViewport } from "../../../../../src/features/chat/ui/message-stream/stream-blocks"; -import { MarkdownMessageRenderer } from "../../../../../src/features/chat/ui/message-stream/markdown-renderer"; import { MESSAGE_CONTENT_RENDERED_EVENT } from "../../../../../src/features/chat/ui/message-stream/content-events"; +import { MarkdownMessageRenderer } from "../../../../../src/features/chat/ui/message-stream/markdown-renderer"; +import { MessageStreamViewport } from "../../../../../src/features/chat/ui/message-stream/stream-blocks"; import { renderUiRoot, unmountUiRoot } from "../../../../../src/shared/ui/ui-root"; import { notices } from "../../../../mocks/obsidian"; import { installObsidianDomShims } from "../../../../support/dom"; -import { installMessageViewportMetrics, pendingApproval } from "../../ui/message-stream/test-helpers"; import { withChatStateMessageStreamItems } from "../../support/message-stream"; -import { chatStateFixture, chatStateWith } from "../../support/state"; import { messageStreamShellStateFromChatState } from "../../support/shell-state"; +import { chatStateFixture, chatStateWith } from "../../support/state"; +import { installMessageViewportMetrics, pendingApproval } from "../../ui/message-stream/test-helpers"; const ESTIMATED_MESSAGE_BLOCK_HEIGHT = 96; diff --git a/tests/features/chat/panel/surface/projection.test.ts b/tests/features/chat/panel/surface/projection.test.ts index 20a91d79..baae78d5 100644 --- a/tests/features/chat/panel/surface/projection.test.ts +++ b/tests/features/chat/panel/surface/projection.test.ts @@ -1,28 +1,27 @@ // @vitest-environment jsdom +import { type ComponentChild, h } from "preact"; import { describe, expect, it, vi } from "vitest"; -import { h, type ComponentChild } from "preact"; - -import { createServerDiagnostics } from "../../../../../src/domain/server/diagnostics"; -import { runtimeConfigSnapshotFromAppServerConfig, type ConfigReadResult } from "../../../../../src/app-server/protocol/runtime-config"; -import type { RuntimeConfigSnapshot } from "../../../../../src/domain/runtime/config"; -import { chatPanelComposerProjection } from "../../../../../src/features/chat/panel/surface/composer-projection"; -import { effortStatusLines, modelStatusLines, statusSummaryLines } from "../../../../../src/features/chat/presentation/runtime/status"; -import { runtimeSnapshotForChatState } from "../../../../../src/features/chat/application/runtime/snapshot"; -import { ChatPanelToolbar } from "../../../../../src/features/chat/panel/surface/toolbar-projection"; -import type { ChatState } from "../../../../../src/features/chat/application/state/root-reducer"; +import { type ConfigReadResult, runtimeConfigSnapshotFromAppServerConfig } from "../../../../../src/app-server/protocol/runtime-config"; import type { ModelMetadata } from "../../../../../src/domain/catalog/metadata"; -import type { Thread } from "../../../../../src/domain/threads/model"; -import type { ChatPanelComposerSurface } from "../../../../../src/features/chat/panel/surface/composer-projection"; -import { ChatPanelGoal, type ChatPanelGoalSurface } from "../../../../../src/features/chat/panel/surface/goal-projection"; +import type { RuntimeConfigSnapshot } from "../../../../../src/domain/runtime/config"; +import { createServerDiagnostics } from "../../../../../src/domain/server/diagnostics"; import type { ThreadGoal } from "../../../../../src/domain/threads/goal"; -import { withChatStateMessageStreamItems } from "../../support/message-stream"; -import { chatStateFixture, chatStateWith } from "../../support/state"; +import type { Thread } from "../../../../../src/domain/threads/model"; +import { runtimeSnapshotForChatState } from "../../../../../src/features/chat/application/runtime/snapshot"; +import type { ChatState } from "../../../../../src/features/chat/application/state/root-reducer"; import { ChatPanelShellStateContext, createChatPanelShellState } from "../../../../../src/features/chat/panel/shell-state"; +import type { ChatPanelComposerSurface } from "../../../../../src/features/chat/panel/surface/composer-projection"; +import { chatPanelComposerProjection } from "../../../../../src/features/chat/panel/surface/composer-projection"; +import { ChatPanelGoal, type ChatPanelGoalSurface } from "../../../../../src/features/chat/panel/surface/goal-projection"; +import { ChatPanelToolbar } from "../../../../../src/features/chat/panel/surface/toolbar-projection"; +import { effortStatusLines, modelStatusLines, statusSummaryLines } from "../../../../../src/features/chat/presentation/runtime/status"; import type { ToolbarActions } from "../../../../../src/features/chat/ui/toolbar"; import { renderUiRoot, unmountUiRoot } from "../../../../../src/shared/ui/ui-root"; import { installObsidianDomShims } from "../../../../support/dom"; +import { withChatStateMessageStreamItems } from "../../support/message-stream"; import { composerShellStateFromChatState } from "../../support/shell-state"; +import { chatStateFixture, chatStateWith } from "../../support/state"; installObsidianDomShims(); diff --git a/tests/features/chat/panel/toolbar-actions.test.ts b/tests/features/chat/panel/toolbar-actions.test.ts index 349e9733..98771b6b 100644 --- a/tests/features/chat/panel/toolbar-actions.test.ts +++ b/tests/features/chat/panel/toolbar-actions.test.ts @@ -4,8 +4,8 @@ import { describe, expect, it, vi } from "vitest"; import { createChatState } from "../../../../src/features/chat/application/state/root-reducer"; import { createChatStateStore } from "../../../../src/features/chat/application/state/store"; -import { createChatPanelToolbarActions, createToolbarPanelActions } from "../../../../src/features/chat/panel/toolbar-actions"; import type { ThreadManagementActions } from "../../../../src/features/chat/application/threads/thread-management-actions"; +import { createChatPanelToolbarActions, createToolbarPanelActions } from "../../../../src/features/chat/panel/toolbar-actions"; describe("createToolbarPanelActions", () => { it("tracks archive confirmation and delegates archive actions", async () => { diff --git a/tests/features/chat/panel/toolbar-archive-state.test.tsx b/tests/features/chat/panel/toolbar-archive-state.test.tsx index 185833c9..012a4f90 100644 --- a/tests/features/chat/panel/toolbar-archive-state.test.tsx +++ b/tests/features/chat/panel/toolbar-archive-state.test.tsx @@ -1,18 +1,18 @@ // @vitest-environment jsdom -import { describe, expect, it, vi } from "vitest"; import { act } from "preact/test-utils"; +import { describe, expect, it, vi } from "vitest"; import type { Thread } from "../../../../src/domain/threads/model"; import { createChatStateStore } from "../../../../src/features/chat/application/state/store"; -import { createToolbarPanelActions, type ToolbarPanelActions } from "../../../../src/features/chat/panel/toolbar-actions"; +import type { ThreadManagementActions } from "../../../../src/features/chat/application/threads/thread-management-actions"; +import { type ChatPanelShellParts, renderChatPanelShell, unmountChatPanelShell } from "../../../../src/features/chat/panel/shell"; import type { ChatPanelComposerSurface } from "../../../../src/features/chat/panel/surface/composer-projection"; import type { ChatPanelGoalSurface } from "../../../../src/features/chat/panel/surface/goal-projection"; import type { ChatPanelToolbarSurface } from "../../../../src/features/chat/panel/surface/toolbar-projection"; -import type { ThreadManagementActions } from "../../../../src/features/chat/application/threads/thread-management-actions"; -import { renderChatPanelShell, unmountChatPanelShell, type ChatPanelShellParts } from "../../../../src/features/chat/panel/shell"; -import type { MessageStreamScrollControllerBinding } from "../../../../src/features/chat/ui/message-stream/flow-scroll"; +import { createToolbarPanelActions, type ToolbarPanelActions } from "../../../../src/features/chat/panel/toolbar-actions"; import type { MessageStreamContext } from "../../../../src/features/chat/ui/message-stream/context"; +import type { MessageStreamScrollControllerBinding } from "../../../../src/features/chat/ui/message-stream/flow-scroll"; import { installObsidianDomShims } from "../../../support/dom"; installObsidianDomShims(); diff --git a/tests/features/chat/panel/vault-note-candidate-provider.test.ts b/tests/features/chat/panel/vault-note-candidate-provider.test.ts index 87c97a00..efe05089 100644 --- a/tests/features/chat/panel/vault-note-candidate-provider.test.ts +++ b/tests/features/chat/panel/vault-note-candidate-provider.test.ts @@ -1,5 +1,5 @@ +import { type App, type EventRef, TFile } from "obsidian"; import { describe, expect, it, vi } from "vitest"; -import { TFile, type App, type EventRef } from "obsidian"; import { VaultNoteCandidateProvider } from "../../../../src/features/chat/panel/vault-note-candidate-provider"; diff --git a/tests/features/chat/protocol/inbound/handler.test.ts b/tests/features/chat/protocol/inbound/handler.test.ts index 12c0d5d8..70d79d57 100644 --- a/tests/features/chat/protocol/inbound/handler.test.ts +++ b/tests/features/chat/protocol/inbound/handler.test.ts @@ -1,20 +1,19 @@ import { describe, expect, it, vi } from "vitest"; - -import { - createChatInboundHandler, - type ChatInboundHandler, - type ChatInboundHandlerActions, -} from "../../../../../src/features/chat/app-server/inbound/handler"; -import { attachHookRunsToTurn } from "../../../../../src/features/chat/domain/message-stream/updates"; -import { chatReducer, type ChatAction, type ChatState } from "../../../../../src/features/chat/application/state/root-reducer"; -import { pendingTurnStart } from "../../../../../src/features/chat/application/conversation/turn-state"; -import type { ChatStateStore } from "../../../../../src/features/chat/application/state/store"; import type { ServerNotification, ServerRequest } from "../../../../../src/app-server/connection/rpc-messages"; import { appServerApprovalRequest, appServerUserInputRequest } from "../../../../../src/app-server/protocol/server-requests"; -import type { Thread as PanelThread } from "../../../../../src/domain/threads/model"; import type { TurnRecord } from "../../../../../src/app-server/protocol/turn"; -import type { ThreadCatalogEvent } from "../../../../../src/workspace/thread-catalog"; +import type { Thread as PanelThread } from "../../../../../src/domain/threads/model"; +import { + type ChatInboundHandler, + type ChatInboundHandlerActions, + createChatInboundHandler, +} from "../../../../../src/features/chat/app-server/inbound/handler"; +import { pendingTurnStart } from "../../../../../src/features/chat/application/conversation/turn-state"; +import { type ChatAction, type ChatState, chatReducer } from "../../../../../src/features/chat/application/state/root-reducer"; +import type { ChatStateStore } from "../../../../../src/features/chat/application/state/store"; +import { attachHookRunsToTurn } from "../../../../../src/features/chat/domain/message-stream/updates"; import { createLocalIdSource } from "../../../../../src/shared/id/local-id"; +import type { ThreadCatalogEvent } from "../../../../../src/workspace/thread-catalog"; import { chatStateMessageStreamItems, withChatStateMessageStreamItems } from "../../support/message-stream"; import { chatStateFixture, chatStateWith } from "../../support/state"; diff --git a/tests/features/chat/protocol/inbound/routing.test.ts b/tests/features/chat/protocol/inbound/routing.test.ts index ef51f3d9..7b257c1c 100644 --- a/tests/features/chat/protocol/inbound/routing.test.ts +++ b/tests/features/chat/protocol/inbound/routing.test.ts @@ -1,15 +1,14 @@ import { describe, expect, it } from "vitest"; - +import type { ServerNotification, ServerRequest } from "../../../../../src/app-server/connection/rpc-messages"; +import { + PLANNED_SERVER_NOTIFICATION_METHODS_BY_ROUTE_KIND, + planChatNotification, +} from "../../../../../src/features/chat/app-server/inbound/notification-plan"; import { ROUTED_SERVER_NOTIFICATION_METHODS_BY_ROUTE_KIND, routeServerNotification, routeServerRequest, } from "../../../../../src/features/chat/app-server/inbound/routing"; -import { - PLANNED_SERVER_NOTIFICATION_METHODS_BY_ROUTE_KIND, - planChatNotification, -} from "../../../../../src/features/chat/app-server/inbound/notification-plan"; -import type { ServerNotification, ServerRequest } from "../../../../../src/app-server/connection/rpc-messages"; import { chatStateFixture, chatStateWith } from "../../support/state"; const activeScope = { activeThreadId: "thread-active", activeTurnId: "turn-active" }; diff --git a/tests/features/chat/protocol/server-requests/approval.test.ts b/tests/features/chat/protocol/server-requests/approval.test.ts index 701544bc..67cbee54 100644 --- a/tests/features/chat/protocol/server-requests/approval.test.ts +++ b/tests/features/chat/protocol/server-requests/approval.test.ts @@ -1,12 +1,11 @@ import { describe, expect, it } from "vitest"; - +import type { ServerRequest } from "../../../../../src/app-server/connection/rpc-messages"; import { - appServerApprovalRequest as toPendingApproval, appServerApprovalResponse as approvalResponse, + appServerApprovalRequest as toPendingApproval, } from "../../../../../src/app-server/protocol/server-requests"; import { createApprovalResultItem } from "../../../../../src/features/chat/domain/pending-requests/result-items"; import { pendingRequestBlockSnapshotFromState } from "../../../../../src/features/chat/presentation/pending-requests/view-model"; -import type { ServerRequest } from "../../../../../src/app-server/connection/rpc-messages"; 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/protocol/server-requests/mcp-elicitation.test.ts b/tests/features/chat/protocol/server-requests/mcp-elicitation.test.ts index 948301db..825bb292 100644 --- a/tests/features/chat/protocol/server-requests/mcp-elicitation.test.ts +++ b/tests/features/chat/protocol/server-requests/mcp-elicitation.test.ts @@ -1,10 +1,9 @@ import { describe, expect, it } from "vitest"; - -import { - appServerMcpElicitationRequest as toPendingMcpElicitation, - appServerMcpElicitationResponse as mcpElicitationResponse, -} from "../../../../../src/app-server/protocol/server-requests"; import type { ServerRequest } from "../../../../../src/app-server/connection/rpc-messages"; +import { + appServerMcpElicitationResponse as mcpElicitationResponse, + appServerMcpElicitationRequest as toPendingMcpElicitation, +} from "../../../../../src/app-server/protocol/server-requests"; import { contentForPendingMcpElicitation, mcpElicitationDraftKey } from "../../../../../src/domain/pending-requests/model"; function expectPresent(value: T | null | undefined): T { diff --git a/tests/features/chat/protocol/server-requests/user-input.test.ts b/tests/features/chat/protocol/server-requests/user-input.test.ts index 0a62ac5d..ae590c08 100644 --- a/tests/features/chat/protocol/server-requests/user-input.test.ts +++ b/tests/features/chat/protocol/server-requests/user-input.test.ts @@ -1,15 +1,14 @@ import { describe, expect, it } from "vitest"; - +import type { ServerRequest } from "../../../../../src/app-server/connection/rpc-messages"; import { - appServerUserInputRequest as toPendingUserInput, appServerUserInputResponse, + appServerUserInputRequest as toPendingUserInput, } from "../../../../../src/app-server/protocol/server-requests"; import { answersForPendingUserInput, questionDefaultAnswer } from "../../../../../src/domain/pending-requests/model"; import { pendingRequestFocusSignature, pendingRequestsSignature, } from "../../../../../src/features/chat/domain/pending-requests/signatures"; -import type { ServerRequest } from "../../../../../src/app-server/connection/rpc-messages"; 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/settings-actions.test.ts b/tests/features/chat/runtime/settings-actions.test.ts index 98f0a1a2..8626bd16 100644 --- a/tests/features/chat/runtime/settings-actions.test.ts +++ b/tests/features/chat/runtime/settings-actions.test.ts @@ -1,16 +1,15 @@ import { describe, expect, it, vi } from "vitest"; - +import type { AppServerClient } from "../../../../src/app-server/connection/client"; +import type { ModelMetadata } from "../../../../src/domain/catalog/metadata"; +import { emptyRuntimeConfigSnapshot } from "../../../../src/domain/runtime/config"; import { - createChatRuntimeSettingsActions, type ChatRuntimeSettingsActions, + createChatRuntimeSettingsActions, } from "../../../../src/features/chat/application/runtime/settings-actions"; -import type { ChatState } from "../../../../src/features/chat/application/state/root-reducer"; -import { createChatStateStore } from "../../../../src/features/chat/application/state/store"; import { runtimeSnapshotForChatState } from "../../../../src/features/chat/application/runtime/snapshot"; import type { ActiveThreadSettingsAppliedAction } from "../../../../src/features/chat/application/state/actions"; -import type { AppServerClient } from "../../../../src/app-server/connection/client"; -import { emptyRuntimeConfigSnapshot } from "../../../../src/domain/runtime/config"; -import type { ModelMetadata } from "../../../../src/domain/catalog/metadata"; +import type { ChatState } from "../../../../src/features/chat/application/state/root-reducer"; +import { createChatStateStore } from "../../../../src/features/chat/application/state/store"; import { chatStateFixture, chatStateWith } from "../support/state"; describe("createChatRuntimeSettingsActions", () => { diff --git a/tests/features/chat/state-actions.test.ts b/tests/features/chat/state-actions.test.ts index 24a3aeaa..1ad4183f 100644 --- a/tests/features/chat/state-actions.test.ts +++ b/tests/features/chat/state-actions.test.ts @@ -1,8 +1,7 @@ import { describe, expect, it } from "vitest"; - -import { resumedThreadActionFromActiveRuntime, resumedThreadAction } from "../../../src/features/chat/application/state/actions"; import type { ThreadActivationSnapshot } from "../../../src/domain/threads/activation"; import type { Thread } from "../../../src/domain/threads/model"; +import { resumedThreadAction, resumedThreadActionFromActiveRuntime } from "../../../src/features/chat/application/state/actions"; describe("chat thread resume helpers", () => { it("builds thread resumed actions from response snapshots", () => { diff --git a/tests/features/chat/state-reducer.test.ts b/tests/features/chat/state-reducer.test.ts index 27fc8c3b..51d31b0a 100644 --- a/tests/features/chat/state-reducer.test.ts +++ b/tests/features/chat/state-reducer.test.ts @@ -1,17 +1,16 @@ import { describe, expect, it } from "vitest"; - +import type { ThreadGoal } from "../../../src/domain/threads/goal"; +import type { Thread } from "../../../src/domain/threads/model"; import { activeTurnId, chatTurnBusy, pendingTurnStart, transitionChatTurnLifecycleState, } from "../../../src/features/chat/application/conversation/turn-state"; -import { chatReducer, type ChatState } from "../../../src/features/chat/application/state/root-reducer"; -import { createChatStateStore } from "../../../src/features/chat/application/state/store"; import { messageStreamItems } from "../../../src/features/chat/application/state/message-stream"; -import type { ThreadGoal } from "../../../src/domain/threads/goal"; +import { type ChatState, chatReducer } from "../../../src/features/chat/application/state/root-reducer"; +import { createChatStateStore } from "../../../src/features/chat/application/state/store"; import type { MessageStreamItem } from "../../../src/features/chat/domain/message-stream/items"; -import type { Thread } from "../../../src/domain/threads/model"; import { chatStateMessageStreamItems, withChatStateMessageStreamItems } from "./support/message-stream"; import { chatStateFixture, chatStateWith } from "./support/state"; diff --git a/tests/features/chat/state/message-stream-selectors.test.ts b/tests/features/chat/state/message-stream-selectors.test.ts index f36e9898..5c4503e6 100644 --- a/tests/features/chat/state/message-stream-selectors.test.ts +++ b/tests/features/chat/state/message-stream-selectors.test.ts @@ -1,12 +1,11 @@ import { describe, expect, it } from "vitest"; - -import type { MessageStreamItem } from "../../../../src/features/chat/domain/message-stream/items"; import { initialChatMessageStreamState, messageStreamRollbackCandidate, messageStreamTurnsAfterTurnId, messageStreamWithActiveTurnItems, } from "../../../../src/features/chat/application/state/message-stream"; +import type { MessageStreamItem } from "../../../../src/features/chat/domain/message-stream/items"; describe("message stream selectors", () => { it("counts turns after a turn id from message stream state", () => { diff --git a/tests/features/chat/support/message-stream.ts b/tests/features/chat/support/message-stream.ts index f593bfd8..9c58fbc7 100644 --- a/tests/features/chat/support/message-stream.ts +++ b/tests/features/chat/support/message-stream.ts @@ -1,6 +1,6 @@ -import type { MessageStreamItem } from "../../../../src/features/chat/domain/message-stream/items"; import { messageStreamItems, messageStreamWithItems } from "../../../../src/features/chat/application/state/message-stream"; import type { ChatState } from "../../../../src/features/chat/application/state/root-reducer"; +import type { MessageStreamItem } from "../../../../src/features/chat/domain/message-stream/items"; import { chatStateWith } from "./state"; export function chatStateMessageStreamItems(state: Pick): readonly MessageStreamItem[] { diff --git a/tests/features/chat/support/shell-state.ts b/tests/features/chat/support/shell-state.ts index 313219cd..c961520b 100644 --- a/tests/features/chat/support/shell-state.ts +++ b/tests/features/chat/support/shell-state.ts @@ -1,12 +1,12 @@ -import { runtimeSnapshotForChatState } from "../../../../src/features/chat/application/runtime/snapshot"; import { activeTurnId, chatTurnBusy } from "../../../../src/features/chat/application/conversation/turn-state"; -import type { ChatState } from "../../../../src/features/chat/application/state/root-reducer"; +import { runtimeSnapshotForChatState } from "../../../../src/features/chat/application/runtime/snapshot"; import { messageStreamActiveItems, messageStreamItems, messageStreamRollbackCandidateFromItems, messageStreamStableItems, } from "../../../../src/features/chat/application/state/message-stream"; +import type { ChatState } from "../../../../src/features/chat/application/state/root-reducer"; import { forkCandidatesFromItems, latestImplementablePlanTargetFromItems, diff --git a/tests/features/chat/support/state.ts b/tests/features/chat/support/state.ts index 0c158a7d..88d8e146 100644 --- a/tests/features/chat/support/state.ts +++ b/tests/features/chat/support/state.ts @@ -1,4 +1,4 @@ -import { createChatState, type ChatState } from "../../../../src/features/chat/application/state/root-reducer"; +import { type ChatState, createChatState } from "../../../../src/features/chat/application/state/root-reducer"; interface RuntimePatch { active?: Partial; diff --git a/tests/features/chat/threads/active-thread-identity-sync.test.ts b/tests/features/chat/threads/active-thread-identity-sync.test.ts index 751d9a0d..9f4b42bc 100644 --- a/tests/features/chat/threads/active-thread-identity-sync.test.ts +++ b/tests/features/chat/threads/active-thread-identity-sync.test.ts @@ -1,11 +1,10 @@ import { describe, expect, it, vi } from "vitest"; - +import type { Thread } from "../../../../src/domain/threads/model"; +import type { RestoredThreadPlaceholderState } from "../../../../src/features/chat/application/lifecycle"; import { createChatState } from "../../../../src/features/chat/application/state/root-reducer"; import { createChatStateStore } from "../../../../src/features/chat/application/state/store"; import { createActiveThreadIdentitySync } from "../../../../src/features/chat/application/threads/active-thread-identity-sync"; import type { RestorationController } from "../../../../src/features/chat/application/threads/restoration-controller"; -import type { RestoredThreadPlaceholderState } from "../../../../src/features/chat/application/lifecycle"; -import type { Thread } from "../../../../src/domain/threads/model"; function thread(id: string, name: string | null = null): Thread { return { diff --git a/tests/features/chat/threads/auto-title-coordinator.test.ts b/tests/features/chat/threads/auto-title-coordinator.test.ts index 3ccf98aa..1fd9893e 100644 --- a/tests/features/chat/threads/auto-title-coordinator.test.ts +++ b/tests/features/chat/threads/auto-title-coordinator.test.ts @@ -1,17 +1,17 @@ import { describe, expect, it, vi } from "vitest"; import type { AppServerClient } from "../../../../src/app-server/connection/client"; -import { createChatStateStore } from "../../../../src/features/chat/application/state/store"; +import type { Thread } from "../../../../src/domain/threads/model"; +import type { ThreadTitleContext } from "../../../../src/domain/threads/title-generation-model"; import { messageStreamItems } from "../../../../src/features/chat/application/state/message-stream"; +import { createChatStateStore } from "../../../../src/features/chat/application/state/store"; import { - createAutoTitleCoordinator, type AutoTitleCoordinator, type AutoTitleCoordinatorHost, + createAutoTitleCoordinator, } from "../../../../src/features/chat/application/threads/auto-title-coordinator"; import { threadTitleContextFromMessageStreamItems } from "../../../../src/features/chat/application/threads/title-context"; import { createThreadTitleService } from "../../../../src/features/threads/thread-title-service"; -import type { Thread } from "../../../../src/domain/threads/model"; -import type { ThreadTitleContext } from "../../../../src/domain/threads/title-generation-model"; import { DEFAULT_SETTINGS } from "../../../../src/settings/model"; import { deferred } from "../../../support/async"; diff --git a/tests/features/chat/threads/goal-actions.test.ts b/tests/features/chat/threads/goal-actions.test.ts index 6f41ed46..75b41695 100644 --- a/tests/features/chat/threads/goal-actions.test.ts +++ b/tests/features/chat/threads/goal-actions.test.ts @@ -2,8 +2,8 @@ import { describe, expect, it, vi } from "vitest"; import type { AppServerClient } from "../../../../src/app-server/connection/client"; import type { ThreadGoal } from "../../../../src/domain/threads/goal"; -import { createGoalActions } from "../../../../src/features/chat/application/threads/goal-actions"; import { createChatStateStore } from "../../../../src/features/chat/application/state/store"; +import { createGoalActions } from "../../../../src/features/chat/application/threads/goal-actions"; import { createLocalIdSource } from "../../../../src/shared/id/local-id"; import { deferred } from "../../../support/async"; import { chatStateFixture, chatStateWith } from "../support/state"; diff --git a/tests/features/chat/threads/history-controller.test.ts b/tests/features/chat/threads/history-controller.test.ts index 1d728094..a90979ae 100644 --- a/tests/features/chat/threads/history-controller.test.ts +++ b/tests/features/chat/threads/history-controller.test.ts @@ -1,9 +1,8 @@ import { describe, expect, it, vi } from "vitest"; - -import { createChatStateStore } from "../../../../src/features/chat/application/state/store"; -import { HistoryController, type HistoryControllerHost } from "../../../../src/features/chat/application/threads/history-controller"; import type { AppServerClient } from "../../../../src/app-server/connection/client"; import type { ChatThreadHistoryPage } from "../../../../src/features/chat/app-server/threads/projection"; +import { createChatStateStore } from "../../../../src/features/chat/application/state/store"; +import { HistoryController, type HistoryControllerHost } from "../../../../src/features/chat/application/threads/history-controller"; import type { MessageStreamItem } from "../../../../src/features/chat/domain/message-stream/items"; import { deferred } from "../../../support/async"; import { chatStateMessageStreamItems } from "../support/message-stream"; diff --git a/tests/features/chat/threads/rename-editor-actions.test.ts b/tests/features/chat/threads/rename-editor-actions.test.ts index 876ea216..d1283666 100644 --- a/tests/features/chat/threads/rename-editor-actions.test.ts +++ b/tests/features/chat/threads/rename-editor-actions.test.ts @@ -1,14 +1,13 @@ import { describe, expect, it, vi } from "vitest"; - +import type { AppServerClient } from "../../../../src/app-server/connection/client"; +import type { TurnItem, TurnRecord } from "../../../../src/app-server/protocol/turn"; +import { normalizeExplicitThreadName, type Thread } from "../../../../src/domain/threads/model"; import { createChatStateStore } from "../../../../src/features/chat/application/state/store"; import { createThreadRenameEditorActions, type ThreadRenameEditorActions, type ThreadRenameEditorActionsHost, } from "../../../../src/features/chat/application/threads/rename-editor-actions"; -import type { AppServerClient } from "../../../../src/app-server/connection/client"; -import { normalizeExplicitThreadName, type Thread } from "../../../../src/domain/threads/model"; -import type { TurnItem, TurnRecord } from "../../../../src/app-server/protocol/turn"; import { deferred } from "../../../support/async"; describe("ThreadRenameEditorActions", () => { diff --git a/tests/features/chat/threads/resume-actions.test.ts b/tests/features/chat/threads/resume-actions.test.ts index 50503944..cd37b1b8 100644 --- a/tests/features/chat/threads/resume-actions.test.ts +++ b/tests/features/chat/threads/resume-actions.test.ts @@ -1,15 +1,15 @@ import { describe, expect, it, vi } from "vitest"; import type { AppServerClient } from "../../../../src/app-server/connection/client"; +import type { ThreadTokenUsage } from "../../../../src/domain/runtime/metrics"; +import type { Thread as PanelThread } from "../../../../src/domain/threads/model"; +import type { ChatThreadHistoryPage, ChatThreadResumeSnapshot } from "../../../../src/features/chat/app-server/threads/projection"; +import { ChatResumeWorkTracker } from "../../../../src/features/chat/application/lifecycle"; import { createChatState } from "../../../../src/features/chat/application/state/root-reducer"; import { createChatStateStore } from "../../../../src/features/chat/application/state/store"; +import type { HistoryController } from "../../../../src/features/chat/application/threads/history-controller"; import type { RestorationController } from "../../../../src/features/chat/application/threads/restoration-controller"; import { createResumeActions, type ResumeActionsHost } from "../../../../src/features/chat/application/threads/resume-actions"; -import type { HistoryController } from "../../../../src/features/chat/application/threads/history-controller"; -import { ChatResumeWorkTracker } from "../../../../src/features/chat/application/lifecycle"; -import type { Thread as PanelThread } from "../../../../src/domain/threads/model"; -import type { ThreadTokenUsage } from "../../../../src/domain/runtime/metrics"; -import type { ChatThreadHistoryPage, ChatThreadResumeSnapshot } from "../../../../src/features/chat/app-server/threads/projection"; import type { MessageStreamItem } from "../../../../src/features/chat/domain/message-stream/items"; function activation(threadId: string, overrides: Partial = {}): ChatThreadResumeSnapshot { diff --git a/tests/features/chat/threads/selection-actions.test.ts b/tests/features/chat/threads/selection-actions.test.ts index e5aec52f..a9769565 100644 --- a/tests/features/chat/threads/selection-actions.test.ts +++ b/tests/features/chat/threads/selection-actions.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from "vitest"; import { createChatState } from "../../../../src/features/chat/application/state/root-reducer"; -import { createChatStateStore, type ChatStateStore } from "../../../../src/features/chat/application/state/store"; +import { type ChatStateStore, createChatStateStore } from "../../../../src/features/chat/application/state/store"; import { createSelectionActions, type SelectionActionsHost } from "../../../../src/features/chat/application/threads/selection-actions"; function resumeThreadState(stateStore: ChatStateStore, threadId: string): void { diff --git a/tests/features/chat/ui/message-stream/blocks-and-messages.test.tsx b/tests/features/chat/ui/message-stream/blocks-and-messages.test.tsx index 0b812398..b7fe49af 100644 --- a/tests/features/chat/ui/message-stream/blocks-and-messages.test.tsx +++ b/tests/features/chat/ui/message-stream/blocks-and-messages.test.tsx @@ -1,11 +1,10 @@ // @vitest-environment jsdom -import { describe, expect, it, vi } from "vitest"; -import { act } from "preact/test-utils"; import { MarkdownRenderer } from "obsidian"; - -import type { MessageStreamItem } from "../../../../../src/features/chat/domain/message-stream/items"; +import { act } from "preact/test-utils"; +import { describe, expect, it, vi } from "vitest"; import { implementPlanTargetFromState } from "../../../../../src/features/chat/application/conversation/plan-implementation"; +import type { MessageStreamItem } from "../../../../../src/features/chat/domain/message-stream/items"; import { MESSAGE_CONTENT_RENDERED_EVENT } from "../../../../../src/features/chat/ui/message-stream/content-events"; import { MarkdownMessageRenderer } from "../../../../../src/features/chat/ui/message-stream/markdown-renderer"; import { deferred } from "../../../../support/async"; diff --git a/tests/features/chat/ui/message-stream/flow-scroll.test.ts b/tests/features/chat/ui/message-stream/flow-scroll.test.ts index 55f817cf..cdda6fea 100644 --- a/tests/features/chat/ui/message-stream/flow-scroll.test.ts +++ b/tests/features/chat/ui/message-stream/flow-scroll.test.ts @@ -1,16 +1,15 @@ // @vitest-environment jsdom -import { afterEach, beforeEach, describe, expect, it } from "vitest"; import { h, type ComponentChild as UiNode } from "preact"; import { act } from "preact/test-utils"; - +import { afterEach, beforeEach, describe, expect, it } from "vitest"; +import { MESSAGE_CONTENT_RENDERED_EVENT } from "../../../../../src/features/chat/ui/message-stream/content-events"; import { MessageStreamFlowFrame, type MessageStreamScrollCommand, type MessageStreamScrollControllerBinding, type MessageStreamScrollPort, } from "../../../../../src/features/chat/ui/message-stream/flow-scroll"; -import { MESSAGE_CONTENT_RENDERED_EVENT } from "../../../../../src/features/chat/ui/message-stream/content-events"; import { renderUiRoot } from "../../../../../src/shared/ui/ui-root"; import { installObsidianDomShims } from "../../../../support/dom"; 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 2befd768..9ffe3513 100644 --- a/tests/features/chat/ui/message-stream/pending-requests.test.tsx +++ b/tests/features/chat/ui/message-stream/pending-requests.test.tsx @@ -1,14 +1,13 @@ // @vitest-environment jsdom import { describe, expect, it, vi } from "vitest"; - -import { - pendingRequestBlockSnapshotFromState, - type PendingRequestBlockSnapshot, -} from "../../../../../src/features/chat/presentation/pending-requests/view-model"; import type { PendingApproval, PendingMcpElicitation, PendingUserInput } from "../../../../../src/domain/pending-requests/model"; -import type { PendingRequestBlockContext } from "../../../../../src/features/chat/ui/message-stream/context"; import type { MessageStreamItem } from "../../../../../src/features/chat/domain/message-stream/items"; +import { + type PendingRequestBlockSnapshot, + pendingRequestBlockSnapshotFromState, +} from "../../../../../src/features/chat/presentation/pending-requests/view-model"; +import type { PendingRequestBlockContext } from "../../../../../src/features/chat/ui/message-stream/context"; import { changeInputValue, textContents } from "../../../../support/dom"; import "./setup"; import { diff --git a/tests/features/chat/ui/message-stream/setup.ts b/tests/features/chat/ui/message-stream/setup.ts index 790b1fa5..5cd5cc16 100644 --- a/tests/features/chat/ui/message-stream/setup.ts +++ b/tests/features/chat/ui/message-stream/setup.ts @@ -1,5 +1,5 @@ -import { installObsidianDomShims } from "../../../../support/dom"; import { beforeEach } from "vitest"; +import { installObsidianDomShims } from "../../../../support/dom"; (globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true; diff --git a/tests/features/chat/ui/message-stream/stream-markdown-renderer.test.ts b/tests/features/chat/ui/message-stream/stream-markdown-renderer.test.ts index 25d0cdd2..c4691655 100644 --- a/tests/features/chat/ui/message-stream/stream-markdown-renderer.test.ts +++ b/tests/features/chat/ui/message-stream/stream-markdown-renderer.test.ts @@ -1,7 +1,7 @@ // @vitest-environment jsdom -import { beforeEach, describe, expect, it, vi } from "vitest"; import { TFile } from "obsidian"; +import { beforeEach, describe, expect, it, vi } from "vitest"; import { renderStreamMarkdown } from "../../../../../src/features/chat/ui/message-stream/markdown-renderer"; import { notices } from "../../../../mocks/obsidian"; diff --git a/tests/features/chat/ui/message-stream/test-helpers.tsx b/tests/features/chat/ui/message-stream/test-helpers.tsx index 677fcf74..53283ffe 100644 --- a/tests/features/chat/ui/message-stream/test-helpers.tsx +++ b/tests/features/chat/ui/message-stream/test-helpers.tsx @@ -1,24 +1,24 @@ -import { vi } from "vitest"; import type { ComponentChild as UiNode } from "preact"; import { act } from "preact/test-utils"; +import { vi } from "vitest"; import type { PendingApproval, PendingUserInput } from "../../../../../src/domain/pending-requests/model"; +import type { MessageStreamItem } from "../../../../../src/features/chat/domain/message-stream/items"; +import type { MessageStreamTextActionTargets } from "../../../../../src/features/chat/presentation/message-stream/text-view"; +import { + type MessageStreamViewBlock, + messageStreamViewBlocks, +} from "../../../../../src/features/chat/presentation/message-stream/view-model"; import { pendingRequestBlockSnapshotFromState } from "../../../../../src/features/chat/presentation/pending-requests/view-model"; -import { pendingRequestBlockNode } from "../../../../../src/features/chat/ui/message-stream/pending-request-block"; import type { MessageStreamContext, MessageStreamDisclosureState, PendingRequestBlockActions, PendingRequestBlockContext, } from "../../../../../src/features/chat/ui/message-stream/context"; -import type { MessageStreamItem } from "../../../../../src/features/chat/domain/message-stream/items"; -import { - messageStreamViewBlocks, - type MessageStreamViewBlock, -} from "../../../../../src/features/chat/presentation/message-stream/view-model"; -import type { MessageStreamTextActionTargets } from "../../../../../src/features/chat/presentation/message-stream/text-view"; -import { MessageStreamViewport } from "../../../../../src/features/chat/ui/message-stream/stream-blocks"; import type { MessageStreamScrollControllerBinding } from "../../../../../src/features/chat/ui/message-stream/flow-scroll"; +import { pendingRequestBlockNode } from "../../../../../src/features/chat/ui/message-stream/pending-request-block"; +import { MessageStreamViewport } from "../../../../../src/features/chat/ui/message-stream/stream-blocks"; import { renderUiRoot, unmountUiRoot } from "../../../../../src/shared/ui/ui-root"; export function messageStreamBlocks(context: TestMessageStreamContext): [MessageStreamViewBlock, ...MessageStreamViewBlock[]] { diff --git a/tests/features/chat/ui/renderers/composer.test.ts b/tests/features/chat/ui/renderers/composer.test.ts index 3ae4a0a0..f2cb6a57 100644 --- a/tests/features/chat/ui/renderers/composer.test.ts +++ b/tests/features/chat/ui/renderers/composer.test.ts @@ -1,16 +1,15 @@ // @vitest-environment jsdom -import { describe, expect, it, vi } from "vitest"; import { h } from "preact"; - +import { describe, expect, it, vi } from "vitest"; +import type { ComposerMetaViewModel } from "../../../../../src/features/chat/ui/composer"; import { - ComposerShell, - syncComposerHeight, type ComposerCallbacks, + ComposerShell, type ComposerSuggestion, + syncComposerHeight, } from "../../../../../src/features/chat/ui/composer"; import { scrollComposerSuggestionIntoView } from "../../../../../src/features/chat/ui/composer-dom"; -import type { ComposerMetaViewModel } from "../../../../../src/features/chat/ui/composer"; 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/goal.test.tsx b/tests/features/chat/ui/renderers/goal.test.tsx index c7066eb8..58e73993 100644 --- a/tests/features/chat/ui/renderers/goal.test.tsx +++ b/tests/features/chat/ui/renderers/goal.test.tsx @@ -1,8 +1,8 @@ // @vitest-environment jsdom -import { describe, expect, it, vi } from "vitest"; -import { act } from "preact/test-utils"; import { useState } from "preact/hooks"; +import { act } from "preact/test-utils"; +import { describe, expect, it, vi } from "vitest"; import type { ThreadGoal } from "../../../../../src/domain/threads/goal"; import { GoalPanel, type GoalPanelActions, type GoalPanelEditorState } from "../../../../../src/features/chat/ui/goal"; diff --git a/tests/features/chat/ui/renderers/toolbar.test.ts b/tests/features/chat/ui/renderers/toolbar.test.ts index 050412fd..c18b3286 100644 --- a/tests/features/chat/ui/renderers/toolbar.test.ts +++ b/tests/features/chat/ui/renderers/toolbar.test.ts @@ -1,7 +1,7 @@ // @vitest-environment jsdom -import { describe, expect, it, vi } from "vitest"; import { h } from "preact"; +import { describe, expect, it, vi } from "vitest"; import { Toolbar, type ToolbarActions, type ToolbarViewModel } from "../../../../../src/features/chat/ui/toolbar"; import { renderUiRoot } from "../../../../../src/shared/ui/ui-root"; diff --git a/tests/features/chat/ui/renderers/turn-diff.test.ts b/tests/features/chat/ui/renderers/turn-diff.test.ts index ad6075ae..159d817d 100644 --- a/tests/features/chat/ui/renderers/turn-diff.test.ts +++ b/tests/features/chat/ui/renderers/turn-diff.test.ts @@ -1,7 +1,7 @@ // @vitest-environment jsdom -import { describe, expect, it, vi } from "vitest"; import type { WorkspaceLeaf } from "obsidian"; +import { describe, expect, it, vi } from "vitest"; import { persistedChatTurnDiffViewState } from "../../../../../src/features/chat/domain/turn-diff"; import { renderChatTurnDiffView } from "../../../../../src/features/chat/ui/turn-diff/render"; diff --git a/tests/features/chat/ui/ui-root.test.tsx b/tests/features/chat/ui/ui-root.test.tsx index 5806c9e1..fe638d43 100644 --- a/tests/features/chat/ui/ui-root.test.tsx +++ b/tests/features/chat/ui/ui-root.test.tsx @@ -1,7 +1,7 @@ // @vitest-environment jsdom -import { describe, expect, it, vi } from "vitest"; import { useLayoutEffect } from "preact/hooks"; +import { describe, expect, it, vi } from "vitest"; import { renderUiRoot, unmountUiRoot } from "../../../../src/shared/ui/ui-root"; diff --git a/tests/features/chat/view-connection.test.ts b/tests/features/chat/view-connection.test.ts index 58db9381..0ff15c54 100644 --- a/tests/features/chat/view-connection.test.ts +++ b/tests/features/chat/view-connection.test.ts @@ -1,19 +1,18 @@ // @vitest-environment jsdom import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - -import { DEFAULT_SETTINGS } from "../../../src/settings/model"; -import type { CodexChatHost } from "../../../src/features/chat/host/runtime"; -import { StaleAppServerSharedQueryContextError } from "../../../src/app-server/query/shared-queries"; -import { modelMetadataFromCatalogModels } from "../../../src/app-server/protocol/catalog"; -import type { ObservedDataResult } from "../../../src/domain/observed-data"; -import { createServerDiagnostics } from "../../../src/domain/server/diagnostics"; -import type { Thread } from "../../../src/domain/threads/model"; -import type { ModelMetadata } from "../../../src/domain/catalog/metadata"; -import type { SharedServerMetadata } from "../../../src/domain/server/metadata"; -import { emptyRuntimeConfigSnapshot } from "../../../src/domain/runtime/config"; -import type { ThreadRecord } from "../../../src/app-server/protocol/thread"; import type { ServerNotification } from "../../../src/app-server/connection/rpc-messages"; +import { modelMetadataFromCatalogModels } from "../../../src/app-server/protocol/catalog"; +import type { ThreadRecord } from "../../../src/app-server/protocol/thread"; +import { StaleAppServerSharedQueryContextError } from "../../../src/app-server/query/shared-queries"; +import type { ModelMetadata } from "../../../src/domain/catalog/metadata"; +import type { ObservedDataResult } from "../../../src/domain/observed-data"; +import { emptyRuntimeConfigSnapshot } from "../../../src/domain/runtime/config"; +import { createServerDiagnostics } from "../../../src/domain/server/diagnostics"; +import type { SharedServerMetadata } from "../../../src/domain/server/metadata"; +import type { Thread } from "../../../src/domain/threads/model"; +import type { CodexChatHost } from "../../../src/features/chat/host/runtime"; +import { DEFAULT_SETTINGS } from "../../../src/settings/model"; import type { ThreadCatalogEvent } from "../../../src/workspace/thread-catalog"; import { notices } from "../../mocks/obsidian"; import { deferred, waitForAsyncWork } from "../../support/async"; diff --git a/tests/features/chat/view-lifecycle.test.ts b/tests/features/chat/view-lifecycle.test.ts index e6ad3ff8..e5e69b7c 100644 --- a/tests/features/chat/view-lifecycle.test.ts +++ b/tests/features/chat/view-lifecycle.test.ts @@ -1,10 +1,9 @@ // @vitest-environment jsdom import { beforeEach, describe, expect, it, vi } from "vitest"; - -import { ConnectionWorkTracker } from "../../../src/shared/lifecycle/connection-work"; import { ChatResumeWorkTracker, transitionRestoredThreadLifecycle } from "../../../src/features/chat/application/lifecycle"; import { createChatViewDeferredTasks } from "../../../src/features/chat/host/lifecycle"; +import { ConnectionWorkTracker } from "../../../src/shared/lifecycle/connection-work"; describe("createChatViewDeferredTasks", () => { beforeEach(() => { diff --git a/tests/features/selection-rewrite/selection-rewrite-command.test.ts b/tests/features/selection-rewrite/selection-rewrite-command.test.ts index e3cf7e5c..ae9a4531 100644 --- a/tests/features/selection-rewrite/selection-rewrite-command.test.ts +++ b/tests/features/selection-rewrite/selection-rewrite-command.test.ts @@ -1,7 +1,7 @@ // @vitest-environment jsdom -import { describe, expect, it, vi } from "vitest"; import { MarkdownView, TFile } from "obsidian"; +import { describe, expect, it, vi } from "vitest"; import { registerSelectionRewriteCommand } from "../../../src/features/selection-rewrite/command"; import type { SelectionRewritePopoverOptions } from "../../../src/features/selection-rewrite/popover"; diff --git a/tests/features/selection-rewrite/selection-rewrite.test.ts b/tests/features/selection-rewrite/selection-rewrite.test.ts index 33707906..422019df 100644 --- a/tests/features/selection-rewrite/selection-rewrite.test.ts +++ b/tests/features/selection-rewrite/selection-rewrite.test.ts @@ -2,20 +2,6 @@ import { act } from "preact/test-utils"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - -import { buildSelectionUnifiedDiff } from "../../../src/features/selection-rewrite/diff"; -import { - canApplySelectionRewrite, - transitionSelectionRewriteState, - type SelectionRewriteLifecycleEvent, - type SelectionRewriteState, -} from "../../../src/features/selection-rewrite/model"; -import { selectionRewriteOutputParseResultFromText } from "../../../src/features/selection-rewrite/output"; -import { SelectionRewritePopover } from "../../../src/features/selection-rewrite/popover"; -import { positionSelectionRewritePopover } from "../../../src/features/selection-rewrite/position"; -import { buildSelectionRewritePrompt } from "../../../src/features/selection-rewrite/prompt"; -import * as selectionRewriteRunner from "../../../src/features/selection-rewrite/runner"; -import { runSelectionRewrite } from "../../../src/features/selection-rewrite/runner"; import type { AppServerClient, AppServerClientHandlers, @@ -25,6 +11,19 @@ import type { RequestId, ServerNotification } from "../../../src/app-server/conn import type { TurnItem, TurnRecord } from "../../../src/app-server/protocol/turn"; import type { ModelMetadata, ReasoningEffort } from "../../../src/domain/catalog/metadata"; import type { ServerInitialization } from "../../../src/domain/server/initialization"; +import { buildSelectionUnifiedDiff } from "../../../src/features/selection-rewrite/diff"; +import { + canApplySelectionRewrite, + type SelectionRewriteLifecycleEvent, + type SelectionRewriteState, + transitionSelectionRewriteState, +} from "../../../src/features/selection-rewrite/model"; +import { selectionRewriteOutputParseResultFromText } from "../../../src/features/selection-rewrite/output"; +import { SelectionRewritePopover } from "../../../src/features/selection-rewrite/popover"; +import { positionSelectionRewritePopover } from "../../../src/features/selection-rewrite/position"; +import { buildSelectionRewritePrompt } from "../../../src/features/selection-rewrite/prompt"; +import * as selectionRewriteRunner from "../../../src/features/selection-rewrite/runner"; +import { runSelectionRewrite } from "../../../src/features/selection-rewrite/runner"; import { deferred } from "../../support/async"; import { installObsidianDomShims } from "../../support/dom"; diff --git a/tests/features/thread-picker/modal.test.ts b/tests/features/thread-picker/modal.test.ts index 7fb0ab11..953bf513 100644 --- a/tests/features/thread-picker/modal.test.ts +++ b/tests/features/thread-picker/modal.test.ts @@ -1,7 +1,7 @@ // @vitest-environment jsdom -import { describe, expect, it } from "vitest"; import { SuggestModal } from "obsidian"; +import { describe, expect, it } from "vitest"; import type { Thread } from "../../../src/domain/threads/model"; import { openThreadPicker, type ThreadPickerHost } from "../../../src/features/thread-picker/modal"; diff --git a/tests/features/threads-view/renderer.test.ts b/tests/features/threads-view/renderer.test.ts index faef7210..e5510242 100644 --- a/tests/features/threads-view/renderer.test.ts +++ b/tests/features/threads-view/renderer.test.ts @@ -1,10 +1,9 @@ // @vitest-environment jsdom import { describe, expect, it, vi } from "vitest"; - -import { renderThreadsView } from "../../../src/features/threads-view/renderer"; -import { threadRows, type ThreadsRowModel } from "../../../src/features/threads-view/state"; import type { Thread } from "../../../src/domain/threads/model"; +import { renderThreadsView } from "../../../src/features/threads-view/renderer"; +import { type ThreadsRowModel, threadRows } from "../../../src/features/threads-view/state"; import type { OpenCodexPanelSnapshot } from "../../../src/workspace/panel-coordinator"; import { changeInputValue, installObsidianDomShims } from "../../support/dom"; diff --git a/tests/features/threads-view/state.test.ts b/tests/features/threads-view/state.test.ts index 51e23af1..deb278f5 100644 --- a/tests/features/threads-view/state.test.ts +++ b/tests/features/threads-view/state.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from "vitest"; import type { Thread } from "../../../src/domain/threads/model"; -import { threadRows, transitionThreadsRenameState, type ThreadsRenameState } from "../../../src/features/threads-view/state"; +import { type ThreadsRenameState, threadRows, transitionThreadsRenameState } from "../../../src/features/threads-view/state"; import type { OpenCodexPanelSnapshot } from "../../../src/workspace/panel-coordinator"; describe("threads view rename state", () => { diff --git a/tests/features/threads-view/view-lifecycle.test.ts b/tests/features/threads-view/view-lifecycle.test.ts index b6c6b6f8..7d48cc71 100644 --- a/tests/features/threads-view/view-lifecycle.test.ts +++ b/tests/features/threads-view/view-lifecycle.test.ts @@ -3,9 +3,9 @@ import { describe, expect, it, vi } from "vitest"; import { + type ActiveThreadsViewRefresh, createThreadsViewDeferredTasks, transitionThreadsViewRefreshLifecycle, - type ActiveThreadsViewRefresh, } from "../../../src/features/threads-view/view-lifecycle"; describe("createThreadsViewDeferredTasks", () => { diff --git a/tests/features/threads-view/view.test.ts b/tests/features/threads-view/view.test.ts index 6ab45970..1ff9c340 100644 --- a/tests/features/threads-view/view.test.ts +++ b/tests/features/threads-view/view.test.ts @@ -1,12 +1,11 @@ // @vitest-environment jsdom import { beforeEach, describe, expect, it, vi } from "vitest"; - -import { DEFAULT_SETTINGS } from "../../../src/settings/model"; -import type { ObservedDataResult } from "../../../src/domain/observed-data"; import type { TurnRecord } from "../../../src/app-server/protocol/turn"; -import type { Thread } from "../../../src/domain/threads/model"; import type * as ThreadTitleGeneratorModule from "../../../src/app-server/services/thread-title-generation"; +import type { ObservedDataResult } from "../../../src/domain/observed-data"; +import type { Thread } from "../../../src/domain/threads/model"; +import { DEFAULT_SETTINGS } from "../../../src/settings/model"; import { deferred, waitForAsyncWork } from "../../support/async"; import { changeInputValue, installObsidianDomShims } from "../../support/dom"; diff --git a/tests/features/threads/rename-lifecycle.test.ts b/tests/features/threads/rename-lifecycle.test.ts index afb56a13..8ef027a2 100644 --- a/tests/features/threads/rename-lifecycle.test.ts +++ b/tests/features/threads/rename-lifecycle.test.ts @@ -2,9 +2,9 @@ import { describe, expect, it } from "vitest"; import { initialThreadRenameLifecycleState, - transitionThreadRenameLifecycleState, type ThreadRenameGeneratingState, type ThreadRenameLifecycleState, + transitionThreadRenameLifecycleState, } from "../../../src/features/threads/rename-lifecycle"; describe("thread rename lifecycle", () => { diff --git a/tests/features/threads/thread-operations.test.ts b/tests/features/threads/thread-operations.test.ts index 9bcadf9b..45d75d8f 100644 --- a/tests/features/threads/thread-operations.test.ts +++ b/tests/features/threads/thread-operations.test.ts @@ -3,8 +3,8 @@ import { describe, expect, it, vi } from "vitest"; import type { AppServerClient } from "../../../src/app-server/connection/client"; import type { ArchiveThreadResult } from "../../../src/app-server/services/thread-archive"; import type { ArchiveExportAdapter } from "../../../src/domain/threads/archive-markdown"; -import { DEFAULT_SETTINGS } from "../../../src/settings/model"; import { createThreadOperations, type ThreadOperationsHost } from "../../../src/features/threads/thread-operations"; +import { DEFAULT_SETTINGS } from "../../../src/settings/model"; const archiveMock = vi.hoisted(() => ({ archiveThreadOnAppServer: vi.fn(), diff --git a/tests/features/threads/thread-title-service.test.ts b/tests/features/threads/thread-title-service.test.ts index e3bd3243..af747ce6 100644 --- a/tests/features/threads/thread-title-service.test.ts +++ b/tests/features/threads/thread-title-service.test.ts @@ -1,12 +1,12 @@ import { describe, expect, it, vi } from "vitest"; import { THREAD_TITLE_CONTEXT_UNAVAILABLE_MESSAGE, type ThreadTitleContext } from "../../../src/domain/threads/title-generation-model"; -import { DEFAULT_SETTINGS } from "../../../src/settings/model"; import { createThreadTitleService, type ThreadTitleService, type ThreadTitleServiceHost, } from "../../../src/features/threads/thread-title-service"; +import { DEFAULT_SETTINGS } from "../../../src/settings/model"; describe("ThreadTitleService", () => { it("generates a title from visible context without saving it", async () => { diff --git a/tests/main.test.ts b/tests/main.test.ts index 5243d1a1..5cdb6663 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -1,17 +1,17 @@ // @vitest-environment jsdom -import { beforeEach, describe, expect, it, vi } from "vitest"; import { FileSystemAdapter } from "obsidian"; +import { beforeEach, describe, expect, it, vi } from "vitest"; import { VIEW_TYPE_CODEX_PANEL, VIEW_TYPE_CODEX_THREADS } from "../src/constants"; -import { DEFAULT_SETTINGS } from "../src/settings/model"; -import type CodexPanelPlugin from "../src/main"; -import type { CodexChatView } from "../src/features/chat/host/view"; -import type { CodexChatHost } from "../src/features/chat/host/runtime"; import type { Thread } from "../src/domain/threads/model"; +import type { CodexChatHost } from "../src/features/chat/host/runtime"; +import type { CodexChatView } from "../src/features/chat/host/view"; +import type CodexPanelPlugin from "../src/main"; +import { DEFAULT_SETTINGS } from "../src/settings/model"; import { WorkspacePanelCoordinator } from "../src/workspace/panel-coordinator"; -import { installObsidianDomShims } from "./support/dom"; import { waitForAsyncWork } from "./support/async"; +import { installObsidianDomShims } from "./support/dom"; installObsidianDomShims(); diff --git a/tests/runtime/runtime-settings.test.ts b/tests/runtime/runtime-settings.test.ts index 431c19dd..2f329cfe 100644 --- a/tests/runtime/runtime-settings.test.ts +++ b/tests/runtime/runtime-settings.test.ts @@ -1,13 +1,12 @@ import { describe, expect, it } from "vitest"; -import { runtimeConfigSnapshotFromAppServerConfig, type ConfigReadResult } from "../../src/app-server/protocol/runtime-config"; -import type { RuntimeConfigSnapshot } from "../../src/domain/runtime/config"; +import { type ConfigReadResult, runtimeConfigSnapshotFromAppServerConfig } from "../../src/app-server/protocol/runtime-config"; import type { ModelMetadata } from "../../src/domain/catalog/metadata"; +import type { RuntimeConfigSnapshot } from "../../src/domain/runtime/config"; import { - compactReasoningEffortLabel, - modelOverrideMessage, - reasoningEffortOverrideMessage, -} from "../../src/features/chat/domain/runtime/labels"; + pendingRuntimeSettingsPatch, + serviceTierRequestForThreadStart, +} from "../../src/features/chat/app-server/runtime/thread-settings-update"; import { autoReviewActive, currentModel, @@ -18,13 +17,14 @@ import { runtimeConfigOrDefault, supportedReasoningEfforts, } from "../../src/features/chat/domain/runtime/effective"; -import type { RuntimeSnapshot } from "../../src/features/chat/domain/runtime/snapshot"; import { resetRuntimeIntentToConfig, setRuntimeIntentValue } from "../../src/features/chat/domain/runtime/intent"; -import { resolveRuntimeControls } from "../../src/features/chat/domain/runtime/resolution"; import { - pendingRuntimeSettingsPatch, - serviceTierRequestForThreadStart, -} from "../../src/features/chat/app-server/runtime/thread-settings-update"; + compactReasoningEffortLabel, + modelOverrideMessage, + reasoningEffortOverrideMessage, +} from "../../src/features/chat/domain/runtime/labels"; +import { resolveRuntimeControls } from "../../src/features/chat/domain/runtime/resolution"; +import type { RuntimeSnapshot } from "../../src/features/chat/domain/runtime/snapshot"; import { contextSummary, rateLimitSummary } from "../../src/features/chat/presentation/runtime/status"; describe("runtime settings", () => { diff --git a/tests/runtime/service-tier-state.test.ts b/tests/runtime/service-tier-state.test.ts index 850de81b..f35059e9 100644 --- a/tests/runtime/service-tier-state.test.ts +++ b/tests/runtime/service-tier-state.test.ts @@ -1,7 +1,6 @@ import { describe, expect, it } from "vitest"; - -import { emptyRuntimeConfigSnapshot, type RuntimeConfigSnapshot } from "../../src/domain/runtime/config"; import type { ModelMetadata } from "../../src/domain/catalog/metadata"; +import { emptyRuntimeConfigSnapshot, type RuntimeConfigSnapshot } from "../../src/domain/runtime/config"; import { fastModeActive } from "../../src/features/chat/domain/runtime/effective"; import type { RuntimeSnapshot } from "../../src/features/chat/domain/runtime/snapshot"; diff --git a/tests/settings/settings-lifecycle.test.ts b/tests/settings/settings-lifecycle.test.ts index 7dbd64a9..eb7955ed 100644 --- a/tests/settings/settings-lifecycle.test.ts +++ b/tests/settings/settings-lifecycle.test.ts @@ -1,7 +1,6 @@ import { describe, expect, it, vi } from "vitest"; - -import type { AppServerClient } from "../../src/app-server/connection/client"; import { listHookData } from "../../src/app-server/catalog"; +import type { AppServerClient } from "../../src/app-server/connection/client"; import { createSettingsDynamicSectionLifecycle, transitionSettingsDynamicSectionLifecycle } from "../../src/settings/lifecycle"; describe("settings lifecycle", () => { diff --git a/tests/settings/settings-tab.test.ts b/tests/settings/settings-tab.test.ts index 4f114a96..2e07ceb9 100644 --- a/tests/settings/settings-tab.test.ts +++ b/tests/settings/settings-tab.test.ts @@ -1,18 +1,17 @@ // @vitest-environment jsdom import { beforeEach, describe, expect, it, vi } from "vitest"; - -import type { CatalogHookMetadata, CatalogModel } from "../../src/app-server/protocol/catalog"; -import type { ObservedDataResult } from "../../src/domain/observed-data"; import type { AppServerClientAccessOptions } from "../../src/app-server/connection/client-access"; +import type { CatalogHookMetadata, CatalogModel } from "../../src/app-server/protocol/catalog"; +import { modelMetadataFromCatalogModels } from "../../src/app-server/protocol/catalog"; import type { ThreadRecord } from "../../src/app-server/protocol/thread"; import type { ModelMetadata, ReasoningEffort } from "../../src/domain/catalog/metadata"; -import { modelMetadataFromCatalogModels } from "../../src/app-server/protocol/catalog"; -import { SettingsDynamicDataController, type SettingsDynamicDataSnapshot } from "../../src/settings/dynamic-data-controller"; -import { CodexPanelSettingTab } from "../../src/settings/tab"; -import type { CodexPanelSettingTabHost } from "../../src/settings/host"; +import type { ObservedDataResult } from "../../src/domain/observed-data"; import type { Thread } from "../../src/domain/threads/model"; import { threadArchiveDisplayTitle } from "../../src/domain/threads/title"; +import { SettingsDynamicDataController, type SettingsDynamicDataSnapshot } from "../../src/settings/dynamic-data-controller"; +import type { CodexPanelSettingTabHost } from "../../src/settings/host"; +import { CodexPanelSettingTab } from "../../src/settings/tab"; import { notices } from "../mocks/obsidian"; import { deferred } from "../support/async"; import { installObsidianDomShims } from "../support/dom"; diff --git a/tests/settings/settings.test.ts b/tests/settings/settings.test.ts index 24cdc9ac..a3c17a72 100644 --- a/tests/settings/settings.test.ts +++ b/tests/settings/settings.test.ts @@ -1,12 +1,12 @@ +import { type App, FileSystemAdapter } from "obsidian"; import { describe, expect, it } from "vitest"; -import { FileSystemAdapter, type App } from "obsidian"; import { + type CodexPanelSettings, DEFAULT_SETTINGS, getVaultPath, normalizeSettings, settingsMatchNormalizedData, - type CodexPanelSettings, } from "../../src/settings/model"; describe("settings", () => { diff --git a/tests/workspace/thread-catalog.test.ts b/tests/workspace/thread-catalog.test.ts index a30af893..32b2f90a 100644 --- a/tests/workspace/thread-catalog.test.ts +++ b/tests/workspace/thread-catalog.test.ts @@ -1,4 +1,4 @@ -import { describe, expect, it, vi, type Mock } from "vitest"; +import { describe, expect, it, type Mock, vi } from "vitest"; import { AppServerQueryCache } from "../../src/app-server/query/cache"; import { AppServerSharedQueries } from "../../src/app-server/query/shared-queries"; diff --git a/vitest.config.ts b/vitest.config.ts index aae38b3d..f4026bef 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from "vitest/config"; import { fileURLToPath } from "node:url"; +import { defineConfig } from "vitest/config"; export default defineConfig({ resolve: {