Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de26297249 | ||
|
|
0288ac4599 | ||
|
|
f928ba2c65 | ||
|
|
8d271c0e85 | ||
|
|
d6585f6314 |
No files matched your search
@@ -37,7 +37,6 @@ import {
|
||||
import { type OpenCodeAdapterShape } from "../Services/OpenCodeAdapter.ts";
|
||||
import {
|
||||
buildOpenCodePermissionRules,
|
||||
isOpenCodeRuntimeError,
|
||||
OpenCodeRuntime,
|
||||
OpenCodeRuntimeError,
|
||||
openCodeQuestionId,
|
||||
@@ -131,7 +130,7 @@ const toProcessError = (threadId: ThreadId, cause: unknown): ProviderAdapterProc
|
||||
new ProviderAdapterProcessError({
|
||||
provider: PROVIDER,
|
||||
threadId,
|
||||
detail: isOpenCodeRuntimeError(cause) ? cause.detail : openCodeRuntimeErrorDetail(cause),
|
||||
detail: OpenCodeRuntimeError.is(cause) ? cause.detail : openCodeRuntimeErrorDetail(cause),
|
||||
cause,
|
||||
});
|
||||
|
||||
|
||||
@@ -13,13 +13,14 @@ import {
|
||||
} from "@opencode-ai/sdk/v2";
|
||||
import * as Cause from "effect/Cause";
|
||||
import * as Context from "effect/Context";
|
||||
import * as Data from "effect/Data";
|
||||
import * as Deferred from "effect/Deferred";
|
||||
import * as Duration from "effect/Duration";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Exit from "effect/Exit";
|
||||
import * as Fiber from "effect/Fiber";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
import * as P from "effect/Predicate";
|
||||
import * as Ref from "effect/Ref";
|
||||
import * as Result from "effect/Result";
|
||||
import * as Scope from "effect/Scope";
|
||||
@@ -34,7 +35,7 @@ const encodeUnknownJsonStringExit = Schema.encodeUnknownExit(Schema.UnknownFromJ
|
||||
const OPENCODE_EMPTY_CONFIG_CONTENT = "{}";
|
||||
|
||||
const OPENCODE_SERVER_READY_PREFIX = "opencode server listening";
|
||||
const DEFAULT_OPENCODE_SERVER_TIMEOUT = Duration.seconds(5);
|
||||
const DEFAULT_OPENCODE_SERVER_TIMEOUT_MS = 5_000;
|
||||
const DEFAULT_HOSTNAME = "127.0.0.1";
|
||||
export interface OpenCodeServerProcess {
|
||||
readonly url: string;
|
||||
@@ -47,19 +48,15 @@ export interface OpenCodeServerConnection {
|
||||
readonly external: boolean;
|
||||
}
|
||||
|
||||
export class OpenCodeRuntimeError extends Schema.TaggedErrorClass<OpenCodeRuntimeError>()(
|
||||
"OpenCodeRuntimeError",
|
||||
{
|
||||
operation: Schema.String,
|
||||
detail: Schema.String,
|
||||
cause: Schema.optional(Schema.Defect),
|
||||
},
|
||||
) {
|
||||
override get message() {
|
||||
return this.detail;
|
||||
}
|
||||
const OPENCODE_RUNTIME_ERROR_TAG = "OpenCodeRuntimeError";
|
||||
export class OpenCodeRuntimeError extends Data.TaggedError(OPENCODE_RUNTIME_ERROR_TAG)<{
|
||||
readonly operation: string;
|
||||
readonly cause?: unknown;
|
||||
readonly detail: string;
|
||||
}> {
|
||||
static readonly is = (u: unknown): u is OpenCodeRuntimeError =>
|
||||
P.isTagged(u, OPENCODE_RUNTIME_ERROR_TAG);
|
||||
}
|
||||
export const isOpenCodeRuntimeError = Schema.is(OpenCodeRuntimeError);
|
||||
|
||||
function encodeJsonStringForDiagnostics(input: unknown): string | undefined {
|
||||
const result = encodeUnknownJsonStringExit(input);
|
||||
@@ -67,7 +64,7 @@ function encodeJsonStringForDiagnostics(input: unknown): string | undefined {
|
||||
}
|
||||
|
||||
export function openCodeRuntimeErrorDetail(cause: unknown): string {
|
||||
if (isOpenCodeRuntimeError(cause)) return cause.detail;
|
||||
if (OpenCodeRuntimeError.is(cause)) return cause.detail;
|
||||
if (cause instanceof Error && cause.message.trim().length > 0) return cause.message.trim();
|
||||
if (cause && typeof cause === "object") {
|
||||
// SDK v2 throws { response, request, error? } shapes — extract what's useful
|
||||
@@ -120,7 +117,7 @@ export interface OpenCodeRuntimeShape {
|
||||
readonly environment?: NodeJS.ProcessEnv;
|
||||
readonly port?: number;
|
||||
readonly hostname?: string;
|
||||
readonly timeout?: Duration.Input;
|
||||
readonly timeoutMs?: number;
|
||||
}) => Effect.Effect<OpenCodeServerProcess, OpenCodeRuntimeError, Scope.Scope>;
|
||||
/**
|
||||
* Returns a handle to either an externally-managed OpenCode server (when
|
||||
@@ -133,7 +130,7 @@ export interface OpenCodeRuntimeShape {
|
||||
readonly environment?: NodeJS.ProcessEnv;
|
||||
readonly port?: number;
|
||||
readonly hostname?: string;
|
||||
readonly timeout?: Duration.Input;
|
||||
readonly timeoutMs?: number;
|
||||
}) => Effect.Effect<OpenCodeServerConnection, OpenCodeRuntimeError, Scope.Scope>;
|
||||
readonly runOpenCodeCommand: (input: {
|
||||
readonly binaryPath: string;
|
||||
@@ -271,7 +268,7 @@ function ensureRuntimeError(
|
||||
detail: string,
|
||||
cause: unknown,
|
||||
): OpenCodeRuntimeError {
|
||||
return isOpenCodeRuntimeError(cause)
|
||||
return OpenCodeRuntimeError.is(cause)
|
||||
? cause
|
||||
: new OpenCodeRuntimeError({ operation, detail, cause });
|
||||
}
|
||||
@@ -335,7 +332,7 @@ const makeOpenCodeRuntime = Effect.gen(function* () {
|
||||
}),
|
||||
),
|
||||
));
|
||||
const timeout = Duration.fromInputUnsafe(input.timeout ?? DEFAULT_OPENCODE_SERVER_TIMEOUT);
|
||||
const timeoutMs = input.timeoutMs ?? DEFAULT_OPENCODE_SERVER_TIMEOUT_MS;
|
||||
const args = ["serve", `--hostname=${hostname}`, `--port=${port}`];
|
||||
|
||||
const child = yield* spawner
|
||||
@@ -434,7 +431,7 @@ const makeOpenCodeRuntime = Effect.gen(function* () {
|
||||
);
|
||||
|
||||
const readyExit = yield* Effect.exit(
|
||||
Deferred.await(readyDeferred).pipe(Effect.timeoutOption(timeout)),
|
||||
Deferred.await(readyDeferred).pipe(Effect.timeoutOption(timeoutMs)),
|
||||
);
|
||||
|
||||
// Startup-time fibers are no longer needed once ready has resolved (either
|
||||
@@ -458,7 +455,7 @@ const makeOpenCodeRuntime = Effect.gen(function* () {
|
||||
yield* Fiber.interrupt(exitFiber).pipe(Effect.ignore);
|
||||
return yield* new OpenCodeRuntimeError({
|
||||
operation: "startOpenCodeServerProcess",
|
||||
detail: `Timed out waiting for OpenCode server start after ${Duration.format(timeout)}.`,
|
||||
detail: `Timed out waiting for OpenCode server start after ${timeoutMs}ms.`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -487,7 +484,7 @@ const makeOpenCodeRuntime = Effect.gen(function* () {
|
||||
...(input.environment !== undefined ? { environment: input.environment } : {}),
|
||||
...(input.port !== undefined ? { port: input.port } : {}),
|
||||
...(input.hostname !== undefined ? { hostname: input.hostname } : {}),
|
||||
...(input.timeout !== undefined ? { timeout: input.timeout } : {}),
|
||||
...(input.timeoutMs !== undefined ? { timeoutMs: input.timeoutMs } : {}),
|
||||
}).pipe(
|
||||
Effect.map((server) => ({
|
||||
url: server.url,
|
||||
|
||||
@@ -50,13 +50,6 @@ it.layer(NodeServices.layer)("providerStatusCache", (it) => {
|
||||
const claudeProvider = makeProvider(CLAUDE_AGENT_DRIVER, {
|
||||
status: "warning",
|
||||
auth: { status: "unknown" },
|
||||
updateState: {
|
||||
status: "queued",
|
||||
startedAt: null,
|
||||
finishedAt: null,
|
||||
message: null,
|
||||
output: null,
|
||||
},
|
||||
});
|
||||
const openCodeProvider = makeProvider(OPENCODE_DRIVER, {
|
||||
status: "warning",
|
||||
@@ -88,13 +81,9 @@ it.layer(NodeServices.layer)("providerStatusCache", (it) => {
|
||||
provider: openCodeProvider,
|
||||
});
|
||||
|
||||
const { updateState: _updateState, ...cacheableClaudeProvider } = claudeProvider;
|
||||
assert.deepStrictEqual(yield* readProviderStatusCache(codexPath), codexProvider);
|
||||
assert.deepStrictEqual(yield* readProviderStatusCache(claudePath), cacheableClaudeProvider);
|
||||
assert.deepStrictEqual(yield* readProviderStatusCache(claudePath), claudeProvider);
|
||||
assert.deepStrictEqual(yield* readProviderStatusCache(openCodePath), openCodeProvider);
|
||||
|
||||
const claudeCacheContents = yield* fs.readFileString(claudePath);
|
||||
assert.strictEqual(claudeCacheContents.includes("updateState"), false);
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -9,15 +9,12 @@ import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
import * as Path from "effect/Path";
|
||||
import * as Schema from "effect/Schema";
|
||||
import { fromJsonStringPretty } from "@t3tools/shared/schemaJson";
|
||||
|
||||
import { writeFileStringAtomically } from "../atomicWrite.ts";
|
||||
|
||||
const decodeProviderStatusCache = Schema.decodeUnknownEffect(
|
||||
Schema.fromJsonString(ServerProviderSchema),
|
||||
);
|
||||
const ProviderStatusCacheJson = fromJsonStringPretty(ServerProviderSchema);
|
||||
const encodeProviderStatusCache = Schema.encodeEffect(ProviderStatusCacheJson);
|
||||
|
||||
const mergeProviderModels = (
|
||||
fallbackModels: ReadonlyArray<ServerProvider["models"][number]>,
|
||||
@@ -149,11 +146,8 @@ export const writeProviderStatusCache = (input: {
|
||||
readonly provider: ServerProvider;
|
||||
}) => {
|
||||
const { updateState: _updateState, ...cacheableProvider } = input.provider;
|
||||
return Effect.gen(function* () {
|
||||
const contents = yield* encodeProviderStatusCache(cacheableProvider);
|
||||
yield* writeFileStringAtomically({
|
||||
filePath: input.filePath,
|
||||
contents: `${contents}\n`,
|
||||
});
|
||||
return writeFileStringAtomically({
|
||||
filePath: input.filePath,
|
||||
contents: `${JSON.stringify(cacheableProvider, null, 2)}\n`,
|
||||
});
|
||||
};
|
||||
@@ -208,6 +208,44 @@ type EnvironmentUnavailableState = {
|
||||
readonly connectionState: "connecting" | "disconnected" | "error";
|
||||
};
|
||||
|
||||
function modelSelectionOptionsEqual(
|
||||
left: ModelSelection["options"] | undefined,
|
||||
right: ModelSelection["options"] | undefined,
|
||||
): boolean {
|
||||
if (left === right) return true;
|
||||
if (left === undefined || right === undefined) return false;
|
||||
return JSON.stringify(left) === JSON.stringify(right);
|
||||
}
|
||||
|
||||
function modelSelectionsEqual(
|
||||
left: ModelSelection | null | undefined,
|
||||
right: ModelSelection | null | undefined,
|
||||
): boolean {
|
||||
if (left === right) return true;
|
||||
if (left == null || right == null) return left === right;
|
||||
return (
|
||||
left.instanceId === right.instanceId &&
|
||||
left.model === right.model &&
|
||||
modelSelectionOptionsEqual(left.options, right.options)
|
||||
);
|
||||
}
|
||||
|
||||
function useStableModelSelection<T extends ModelSelection | null | undefined>(selection: T): T {
|
||||
const stableSelectionRef = useRef<T>(selection);
|
||||
if (!modelSelectionsEqual(stableSelectionRef.current, selection)) {
|
||||
stableSelectionRef.current = selection;
|
||||
}
|
||||
return stableSelectionRef.current;
|
||||
}
|
||||
|
||||
function useEventCallback<TArgs extends unknown[], TResult>(
|
||||
callback: (...args: TArgs) => TResult,
|
||||
): (...args: TArgs) => TResult {
|
||||
const callbackRef = useRef(callback);
|
||||
callbackRef.current = callback;
|
||||
return useCallback((...args: TArgs) => callbackRef.current(...args), []);
|
||||
}
|
||||
|
||||
type ThreadPlanCatalogEntry = Pick<Thread, "id" | "proposedPlans">;
|
||||
|
||||
function useThreadPlanCatalog(threadIds: readonly ThreadId[]): ThreadPlanCatalogEntry[] {
|
||||
@@ -962,6 +1000,8 @@ export default function ChatView(props: ChatViewProps) {
|
||||
);
|
||||
const isServerThread = routeKind === "server" && serverThread !== undefined;
|
||||
const activeThread = isServerThread ? serverThread : localDraftThread;
|
||||
const activeThreadModelSelection = useStableModelSelection(activeThread?.modelSelection);
|
||||
const activeThreadProviderInstanceId = activeThread?.session?.providerInstanceId;
|
||||
const runtimeMode = composerRuntimeMode ?? activeThread?.runtimeMode ?? DEFAULT_RUNTIME_MODE;
|
||||
const interactionMode =
|
||||
composerInteractionMode ?? activeThread?.interactionMode ?? DEFAULT_INTERACTION_MODE;
|
||||
@@ -1327,7 +1367,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
|
||||
const selectedProviderByThreadId = composerActiveProvider ?? null;
|
||||
const threadProvider =
|
||||
activeThread?.modelSelection.instanceId ??
|
||||
activeThreadModelSelection?.instanceId ??
|
||||
activeProject?.defaultModelSelection?.instanceId ??
|
||||
null;
|
||||
const lockedProvider = deriveLockedProvider({
|
||||
@@ -1467,7 +1507,14 @@ export default function ChatView(props: ChatViewProps) {
|
||||
);
|
||||
const selectedProvider: ProviderDriverKind = lockedProvider ?? unlockedSelectedProvider;
|
||||
const phase = derivePhase(activeThread?.session ?? null);
|
||||
const threadActivities = activeThread?.activities ?? EMPTY_ACTIVITIES;
|
||||
const threadActivities =
|
||||
activeThread?.activities && activeThread.activities.length > 0
|
||||
? activeThread.activities
|
||||
: EMPTY_ACTIVITIES;
|
||||
const proposedPlans =
|
||||
activeThread?.proposedPlans && activeThread.proposedPlans.length > 0
|
||||
? activeThread.proposedPlans
|
||||
: EMPTY_PROPOSED_PLANS;
|
||||
const workLogEntries = useMemo(
|
||||
() => deriveWorkLogEntries(threadActivities, activeLatestTurn?.turnId ?? undefined),
|
||||
[activeLatestTurn?.turnId, threadActivities],
|
||||
@@ -1521,11 +1568,8 @@ export default function ChatView(props: ChatViewProps) {
|
||||
if (!latestTurnSettled) {
|
||||
return null;
|
||||
}
|
||||
return findLatestProposedPlan(
|
||||
activeThread?.proposedPlans ?? [],
|
||||
activeLatestTurn?.turnId ?? null,
|
||||
);
|
||||
}, [activeLatestTurn?.turnId, activeThread?.proposedPlans, latestTurnSettled]);
|
||||
return findLatestProposedPlan(proposedPlans, activeLatestTurn?.turnId ?? null);
|
||||
}, [activeLatestTurn?.turnId, latestTurnSettled, proposedPlans]);
|
||||
const sidebarProposedPlan = useMemo(
|
||||
() =>
|
||||
findSidebarProposedPlan({
|
||||
@@ -1763,9 +1807,8 @@ export default function ChatView(props: ChatViewProps) {
|
||||
return [...serverMessagesWithPreviewHandoff, ...pendingMessages];
|
||||
}, [serverMessages, attachmentPreviewHandoffByMessageId, optimisticUserMessages]);
|
||||
const timelineEntries = useMemo(
|
||||
() =>
|
||||
deriveTimelineEntries(timelineMessages, activeThread?.proposedPlans ?? [], workLogEntries),
|
||||
[activeThread?.proposedPlans, timelineMessages, workLogEntries],
|
||||
() => deriveTimelineEntries(timelineMessages, proposedPlans, workLogEntries),
|
||||
[proposedPlans, timelineMessages, workLogEntries],
|
||||
);
|
||||
const { turnDiffSummaries, inferredCheckpointTurnCountByTurnId } =
|
||||
useTurnDiffSummaries(activeThread);
|
||||
@@ -1843,8 +1886,8 @@ export default function ChatView(props: ChatViewProps) {
|
||||
// than the default Codex's. Falls back to first-match-by-kind when no
|
||||
// saved instance id is available or the instance no longer exists.
|
||||
const activeProviderInstanceId =
|
||||
activeThread?.session?.providerInstanceId ??
|
||||
activeThread?.modelSelection.instanceId ??
|
||||
activeThreadProviderInstanceId ??
|
||||
activeThreadModelSelection?.instanceId ??
|
||||
activeProject?.defaultModelSelection?.instanceId ??
|
||||
null;
|
||||
const activeProviderStatus = useMemo(() => {
|
||||
@@ -2832,7 +2875,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
],
|
||||
);
|
||||
|
||||
const onSend = async (e?: { preventDefault: () => void }) => {
|
||||
const onSend = useEventCallback(async (e?: { preventDefault: () => void }) => {
|
||||
e?.preventDefault();
|
||||
const api = readEnvironmentApi(environmentId);
|
||||
if (
|
||||
@@ -3133,9 +3176,9 @@ export default function ChatView(props: ChatViewProps) {
|
||||
if (!turnStartSucceeded) {
|
||||
resetLocalDispatch();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
const onInterrupt = async () => {
|
||||
const onInterrupt = useEventCallback(async () => {
|
||||
const api = readEnvironmentApi(environmentId);
|
||||
if (!api || !activeThread) return;
|
||||
await api.orchestration.dispatchCommand({
|
||||
@@ -3144,7 +3187,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
threadId: activeThread.id,
|
||||
createdAt: new Date().toISOString(),
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
const onRespondToApproval = useCallback(
|
||||
async (requestId: ApprovalRequestId, decision: ProviderApprovalDecision) => {
|
||||
@@ -3715,6 +3758,27 @@ export default function ChatView(props: ChatViewProps) {
|
||||
void onRevertToTurnCountRef.current(targetTurnCount);
|
||||
}, []);
|
||||
|
||||
const onImplementPlanInNewThreadForComposer = useEventCallback(onImplementPlanInNewThread);
|
||||
const onRespondToApprovalForComposer = useEventCallback(onRespondToApproval);
|
||||
const onSelectActivePendingUserInputOptionForComposer = useEventCallback(
|
||||
onSelectActivePendingUserInputOption,
|
||||
);
|
||||
const onAdvanceActivePendingUserInputForComposer = useEventCallback(
|
||||
onAdvanceActivePendingUserInput,
|
||||
);
|
||||
const onPreviousActivePendingUserInputQuestionForComposer = useEventCallback(
|
||||
onPreviousActivePendingUserInputQuestion,
|
||||
);
|
||||
const onChangeActivePendingUserInputCustomAnswerForComposer = useEventCallback(
|
||||
onChangeActivePendingUserInputCustomAnswer,
|
||||
);
|
||||
const onProviderModelSelectForComposer = useEventCallback(onProviderModelSelect);
|
||||
const toggleInteractionModeForComposer = useEventCallback(toggleInteractionMode);
|
||||
const handleRuntimeModeChangeForComposer = useEventCallback(handleRuntimeModeChange);
|
||||
const handleInteractionModeChangeForComposer = useEventCallback(handleInteractionModeChange);
|
||||
const togglePlanSidebarForComposer = useEventCallback(togglePlanSidebar);
|
||||
const setThreadErrorForComposer = useEventCallback(setThreadError);
|
||||
|
||||
// Empty state: no active thread
|
||||
if (!activeThread) {
|
||||
return <NoActiveThreadState />;
|
||||
@@ -3839,7 +3903,6 @@ export default function ChatView(props: ChatViewProps) {
|
||||
draftId={draftId}
|
||||
activeThreadId={activeThreadId}
|
||||
activeThreadEnvironmentId={activeThread?.environmentId}
|
||||
activeThread={activeThread}
|
||||
isServerThread={isServerThread}
|
||||
isLocalDraftThread={isLocalDraftThread}
|
||||
phase={phase}
|
||||
@@ -3867,8 +3930,9 @@ export default function ChatView(props: ChatViewProps) {
|
||||
lockedProvider={lockedProvider}
|
||||
providerStatuses={providerStatuses as ServerProvider[]}
|
||||
activeProjectDefaultModelSelection={activeProject?.defaultModelSelection}
|
||||
activeThreadModelSelection={activeThread?.modelSelection}
|
||||
activeThreadActivities={activeThread?.activities}
|
||||
activeThreadModelSelection={activeThreadModelSelection}
|
||||
activeThreadProviderInstanceId={activeThreadProviderInstanceId}
|
||||
activeThreadActivities={threadActivities}
|
||||
resolvedTheme={resolvedTheme}
|
||||
settings={settings}
|
||||
keybindings={keybindings}
|
||||
@@ -3881,24 +3945,26 @@ export default function ChatView(props: ChatViewProps) {
|
||||
scheduleStickToBottom={scrollToEnd}
|
||||
onSend={onSend}
|
||||
onInterrupt={onInterrupt}
|
||||
onImplementPlanInNewThread={onImplementPlanInNewThread}
|
||||
onRespondToApproval={onRespondToApproval}
|
||||
onSelectActivePendingUserInputOption={onSelectActivePendingUserInputOption}
|
||||
onAdvanceActivePendingUserInput={onAdvanceActivePendingUserInput}
|
||||
onImplementPlanInNewThread={onImplementPlanInNewThreadForComposer}
|
||||
onRespondToApproval={onRespondToApprovalForComposer}
|
||||
onSelectActivePendingUserInputOption={
|
||||
onSelectActivePendingUserInputOptionForComposer
|
||||
}
|
||||
onAdvanceActivePendingUserInput={onAdvanceActivePendingUserInputForComposer}
|
||||
onPreviousActivePendingUserInputQuestion={
|
||||
onPreviousActivePendingUserInputQuestion
|
||||
onPreviousActivePendingUserInputQuestionForComposer
|
||||
}
|
||||
onChangeActivePendingUserInputCustomAnswer={
|
||||
onChangeActivePendingUserInputCustomAnswer
|
||||
onChangeActivePendingUserInputCustomAnswerForComposer
|
||||
}
|
||||
onProviderModelSelect={onProviderModelSelect}
|
||||
toggleInteractionMode={toggleInteractionMode}
|
||||
handleRuntimeModeChange={handleRuntimeModeChange}
|
||||
handleInteractionModeChange={handleInteractionModeChange}
|
||||
togglePlanSidebar={togglePlanSidebar}
|
||||
onProviderModelSelect={onProviderModelSelectForComposer}
|
||||
toggleInteractionMode={toggleInteractionModeForComposer}
|
||||
handleRuntimeModeChange={handleRuntimeModeChangeForComposer}
|
||||
handleInteractionModeChange={handleInteractionModeChangeForComposer}
|
||||
togglePlanSidebar={togglePlanSidebarForComposer}
|
||||
focusComposer={focusComposer}
|
||||
scheduleComposerFocus={scheduleComposerFocus}
|
||||
setThreadError={setThreadError}
|
||||
setThreadError={setThreadErrorForComposer}
|
||||
onExpandImage={onExpandTimelineImage}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -380,7 +380,6 @@ export interface ChatComposerProps {
|
||||
// Thread context
|
||||
activeThreadId: ThreadId | null;
|
||||
activeThreadEnvironmentId: EnvironmentId | undefined;
|
||||
activeThread: Thread | undefined;
|
||||
isServerThread: boolean;
|
||||
isLocalDraftThread: boolean;
|
||||
|
||||
@@ -428,6 +427,7 @@ export interface ChatComposerProps {
|
||||
providerStatuses: ServerProvider[];
|
||||
activeProjectDefaultModelSelection: ModelSelection | null | undefined;
|
||||
activeThreadModelSelection: ModelSelection | null | undefined;
|
||||
activeThreadProviderInstanceId: ProviderInstanceId | undefined;
|
||||
|
||||
// Context window
|
||||
activeThreadActivities: Thread["activities"] | undefined;
|
||||
@@ -493,7 +493,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
draftId,
|
||||
activeThreadId,
|
||||
activeThreadEnvironmentId: _activeThreadEnvironmentId,
|
||||
activeThread,
|
||||
isServerThread: _isServerThread,
|
||||
isLocalDraftThread: _isLocalDraftThread,
|
||||
phase,
|
||||
@@ -522,6 +521,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
providerStatuses,
|
||||
activeProjectDefaultModelSelection,
|
||||
activeThreadModelSelection,
|
||||
activeThreadProviderInstanceId,
|
||||
activeThreadActivities,
|
||||
resolvedTheme,
|
||||
settings,
|
||||
@@ -595,7 +595,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
);
|
||||
const selectedProviderByThreadId = composerDraft.activeProvider ?? null;
|
||||
const threadProvider =
|
||||
activeThread?.session?.providerInstanceId ??
|
||||
activeThreadProviderInstanceId ??
|
||||
activeThreadModelSelection?.instanceId ??
|
||||
activeProjectDefaultModelSelection?.instanceId ??
|
||||
null;
|
||||
@@ -609,16 +609,16 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
) ?? ProviderDriverKind.make("codex");
|
||||
const selectedProvider: ProviderDriverKind = lockedProvider ?? unlockedSelectedProvider;
|
||||
const lockedContinuationGroupKey = useMemo((): string | null => {
|
||||
if (!lockedProvider || !activeThread) return null;
|
||||
if (!lockedProvider) return null;
|
||||
const lockedInstanceId =
|
||||
activeThread.session?.providerInstanceId ?? activeThreadModelSelection?.instanceId;
|
||||
activeThreadProviderInstanceId ?? activeThreadModelSelection?.instanceId;
|
||||
if (!lockedInstanceId) return null;
|
||||
return (
|
||||
providerInstanceEntries.find((entry) => entry.instanceId === lockedInstanceId)
|
||||
?.continuationGroupKey ?? null
|
||||
);
|
||||
}, [
|
||||
activeThread,
|
||||
activeThreadProviderInstanceId,
|
||||
activeThreadModelSelection?.instanceId,
|
||||
lockedProvider,
|
||||
providerInstanceEntries,
|
||||
@@ -637,7 +637,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
const selectedInstanceId = useMemo<ProviderInstanceId>(() => {
|
||||
const candidates: Array<string | null | undefined> = [
|
||||
composerDraft.activeProvider,
|
||||
activeThread?.session?.providerInstanceId,
|
||||
activeThreadProviderInstanceId,
|
||||
activeThreadModelSelection?.instanceId,
|
||||
activeProjectDefaultModelSelection?.instanceId,
|
||||
];
|
||||
@@ -679,7 +679,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
);
|
||||
}, [
|
||||
activeProjectDefaultModelSelection?.instanceId,
|
||||
activeThread?.session?.providerInstanceId,
|
||||
activeThreadProviderInstanceId,
|
||||
activeThreadModelSelection?.instanceId,
|
||||
composerDraft.activeProvider,
|
||||
explicitSelectedInstanceId,
|
||||
@@ -1863,7 +1863,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
);
|
||||
},
|
||||
addTerminalContext: (selection: TerminalContextSelection) => {
|
||||
if (!activeThread) return;
|
||||
if (!activeThreadId) return;
|
||||
const snapshot = composerEditorRef.current?.readSnapshot() ?? {
|
||||
value: promptRef.current,
|
||||
cursor: composerCursor,
|
||||
@@ -1883,7 +1883,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
insertion.prompt,
|
||||
{
|
||||
id: randomUUID(),
|
||||
threadId: activeThread.id,
|
||||
threadId: activeThreadId,
|
||||
createdAt: new Date().toISOString(),
|
||||
...selection,
|
||||
},
|
||||
@@ -1910,7 +1910,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
}),
|
||||
}),
|
||||
[
|
||||
activeThread,
|
||||
activeThreadId,
|
||||
composerDraftTarget,
|
||||
composerCursor,
|
||||
composerTerminalContexts,
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user