From 6bfc6828aef6c8c2a80196caba369f0708108d86 Mon Sep 17 00:00:00 2001 From: murashit Date: Thu, 18 Jun 2026 09:47:22 +0900 Subject: [PATCH] Inline trivial local helper wrappers --- src/app-server/protocol/runtime-config.ts | 8 +------- .../app-server/mappers/message-stream/agent-items.ts | 10 +++------- .../mappers/message-stream/hook-run-items.ts | 10 +++------- .../mappers/message-stream/review-result-items.ts | 10 +++------- 4 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/app-server/protocol/runtime-config.ts b/src/app-server/protocol/runtime-config.ts index 3f562c9a..a54c6a85 100644 --- a/src/app-server/protocol/runtime-config.ts +++ b/src/app-server/protocol/runtime-config.ts @@ -16,7 +16,7 @@ export interface ConfigReadResult { } export function runtimeConfigSnapshotFromAppServerConfig(response: ConfigReadResult): RuntimeConfigSnapshot { - const config = asConfigRecord(response.config); + const config = asRecord(response.config); const tools = asRecordOrNull(config["tools"]); const workspaceWrite = asRecordOrNull(config["sandbox_workspace_write"]); const effort = config["model_reasoning_effort"]; @@ -42,8 +42,6 @@ export function runtimeConfigSnapshotFromAppServerConfig(response: ConfigReadRes }; } -type ConfigProjectionRecord = Record; - function asRecord(value: unknown): Record { return value && typeof value === "object" ? (value as Record) : {}; } @@ -52,10 +50,6 @@ function asRecordOrNull(value: unknown): Record | null { return value && typeof value === "object" ? (value as Record) : null; } -function asConfigRecord(value: unknown): ConfigProjectionRecord { - return asRecord(value); -} - function selectedConfigProfile(layers: ConfigReadResult["layers"]): string | null { let selected: string | null = null; if (!layers) return null; 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 89a7cd6a..abd5473c 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 @@ -5,11 +5,11 @@ import { collabAgentStateExecutionState } from "../../../domain/message-stream/a type MessageStreamExecutionState = Exclude; type ExecutionStateByStatus = Readonly>; -const STANDARD_TOOL_STATES = { +const STANDARD_TOOL_STATES: ExecutionStateByStatus = { inProgress: "running", completed: "completed", failed: "failed", -} as const satisfies ExecutionStateByStatus; +}; interface MessageStreamCollabAgentToolCall { id: string; @@ -72,9 +72,5 @@ function collabAgentExecutionState(tool: string, status: string, receiverThreadI } function collabAgentToolCallExecutionState(status: string): ExecutionState { - return executionStateFromStatus(status, STANDARD_TOOL_STATES); -} - -function executionStateFromStatus(status: string, states: ExecutionStateByStatus): ExecutionState { - return states[status] ?? null; + return STANDARD_TOOL_STATES[status] ?? null; } 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 9b12e175..258dc983 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 @@ -13,13 +13,13 @@ interface MessageStreamHookRun { type MessageStreamExecutionState = Exclude; type ExecutionStateByStatus = Readonly>; -const HOOK_RUN_STATES = { +const HOOK_RUN_STATES: ExecutionStateByStatus = { running: "running", completed: "completed", failed: "failed", blocked: "failed", stopped: "failed", -} as const satisfies ExecutionStateByStatus; +}; export function hookRunMessageStreamItem(run: MessageStreamHookRun, turnId: string | null, status: string): HookMessageStreamItem | null { if (run.id.length === 0) return null; @@ -48,11 +48,7 @@ export function hookRunMessageStreamItem(run: MessageStreamHookRun, turnId: stri } function hookRunExecutionState(status: string): ExecutionState { - return executionStateFromStatus(status, HOOK_RUN_STATES); -} - -function executionStateFromStatus(status: string, states: ExecutionStateByStatus): ExecutionState { - return states[status] ?? null; + return HOOK_RUN_STATES[status] ?? null; } function hookRunDisplayId(run: MessageStreamHookRun): 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 94eaeaa8..25a3885a 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 @@ -5,13 +5,13 @@ import { permissionRows } from "../../../domain/message-stream/format/permission type MessageStreamExecutionState = Exclude; type ExecutionStateByStatus = Readonly>; -const AUTO_REVIEW_STATES = { +const AUTO_REVIEW_STATES: ExecutionStateByStatus = { inProgress: "running", approved: "completed", denied: "failed", timedOut: "failed", aborted: "failed", -} as const satisfies ExecutionStateByStatus; +}; type AutoReviewNotification = AutoReviewStartedNotification | AutoReviewCompletedNotification; @@ -187,9 +187,5 @@ function autoReviewActionLabel(action: AutoReviewAction): string { } function autoReviewExecutionState(status: string): ExecutionState { - return executionStateFromStatus(status, AUTO_REVIEW_STATES); -} - -function executionStateFromStatus(status: string, states: ExecutionStateByStatus): ExecutionState { - return states[status] ?? null; + return AUTO_REVIEW_STATES[status] ?? null; }