fix: deduplicate toProviderModelOptions and store SQL NULL for absent model options
- Extract toProviderModelOptions into @t3tools/shared/model to eliminate duplicate definitions in ChatView.tsx and ProviderCommandReactor.ts - Fix ProjectionProjects.ts and ProjectionThreads.ts to store SQL NULL instead of JSON string "null" when model options are absent
This commit is contained in:
5 files changed
+17
-23
No files matched your search
@@ -16,6 +16,7 @@ import {
|
||||
} from "@t3tools/contracts";
|
||||
import { Cache, Cause, Duration, Effect, Layer, Option, Schema, Stream } from "effect";
|
||||
import { makeDrainableWorker } from "@t3tools/shared/DrainableWorker";
|
||||
import { toProviderModelOptions } from "@t3tools/shared/model";
|
||||
|
||||
import { resolveThreadWorkspaceCwd } from "../../checkpointing/Utils.ts";
|
||||
import { GitCore } from "../../git/Services/GitCore.ts";
|
||||
@@ -81,17 +82,6 @@ const sameModelOptions = (
|
||||
right: ProviderModelOptions | undefined,
|
||||
): boolean => JSON.stringify(left ?? null) === JSON.stringify(right ?? null);
|
||||
|
||||
function toProviderModelOptions(
|
||||
modelSelection: ModelSelection | undefined,
|
||||
): ProviderModelOptions | undefined {
|
||||
if (!modelSelection?.options) {
|
||||
return undefined;
|
||||
}
|
||||
return modelSelection.provider === "codex"
|
||||
? { codex: modelSelection.options }
|
||||
: { claudeAgent: modelSelection.options };
|
||||
}
|
||||
|
||||
function isUnknownPendingApprovalRequestError(cause: Cause.Cause<ProviderServiceError>): boolean {
|
||||
const error = Cause.squash(cause);
|
||||
if (Schema.is(ProviderAdapterRequestError)(error)) {
|
||||
|
||||
@@ -77,7 +77,7 @@ const makeProjectionProjectRepository = Effect.gen(function* () {
|
||||
${row.workspaceRoot},
|
||||
${row.defaultModelSelection?.provider ?? null},
|
||||
${row.defaultModelSelection?.model ?? null},
|
||||
${JSON.stringify(row.defaultModelSelection?.options ?? null)},
|
||||
${row.defaultModelSelection?.options != null ? JSON.stringify(row.defaultModelSelection.options) : null},
|
||||
${JSON.stringify(row.scripts)},
|
||||
${row.createdAt},
|
||||
${row.updatedAt},
|
||||
|
||||
@@ -89,7 +89,7 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
${row.title},
|
||||
${row.modelSelection.provider},
|
||||
${row.modelSelection.model},
|
||||
${JSON.stringify(row.modelSelection.options ?? null)},
|
||||
${row.modelSelection.options != null ? JSON.stringify(row.modelSelection.options) : null},
|
||||
${row.runtimeMode},
|
||||
${row.interactionMode},
|
||||
${row.branch},
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
getDefaultModel,
|
||||
normalizeModelSlug,
|
||||
resolveModelSlugForProvider,
|
||||
toProviderModelOptions,
|
||||
} from "@t3tools/shared/model";
|
||||
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
@@ -211,16 +212,6 @@ function extractModelSelectionOptions(
|
||||
return provider === "codex" ? modelOptions?.codex : modelOptions?.claudeAgent;
|
||||
}
|
||||
|
||||
function toProviderModelOptions(
|
||||
modelSelection: ModelSelection | null | undefined,
|
||||
): ProviderModelOptions | undefined {
|
||||
if (!modelSelection?.options) {
|
||||
return undefined;
|
||||
}
|
||||
return modelSelection.provider === "codex"
|
||||
? { codex: modelSelection.options }
|
||||
: { claudeAgent: modelSelection.options };
|
||||
}
|
||||
const COMPOSER_PATH_QUERY_DEBOUNCE_MS = 120;
|
||||
const SCRIPT_TERMINAL_COLS = 120;
|
||||
const SCRIPT_TERMINAL_ROWS = 30;
|
||||
|
||||
@@ -10,7 +10,9 @@ import {
|
||||
type ClaudeCodeEffort,
|
||||
type CodexModelOptions,
|
||||
type CodexReasoningEffort,
|
||||
type ModelSelection,
|
||||
type ModelSlug,
|
||||
type ProviderModelOptions,
|
||||
type ProviderReasoningEffort,
|
||||
type ProviderKind,
|
||||
} from "@t3tools/contracts";
|
||||
@@ -266,4 +268,15 @@ export function applyClaudePromptEffortPrefix(
|
||||
return `Ultrathink:\n${trimmed}`;
|
||||
}
|
||||
|
||||
export function toProviderModelOptions(
|
||||
modelSelection: ModelSelection | null | undefined,
|
||||
): ProviderModelOptions | undefined {
|
||||
if (!modelSelection?.options) {
|
||||
return undefined;
|
||||
}
|
||||
return modelSelection.provider === "codex"
|
||||
? { codex: modelSelection.options }
|
||||
: { claudeAgent: modelSelection.options };
|
||||
}
|
||||
|
||||
export { CLAUDE_CODE_EFFORT_OPTIONS, CODEX_REASONING_EFFORT_OPTIONS };
|
||||
Reference in new issue
Block a user