Skip to content

Commit ea0f9bc

Browse files
PR Batch Testerclaude
andcommitted
fix(web): the side chat edit switch says what its provider can't do
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 296ea4c commit ea0f9bc

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

‎apps/web/src/components/chat/SideChatHeader.tsx‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
resolveLatestMergeBackRun,
55
} from "@t3tools/client-runtime/state/thread-workflows";
66
import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
7+
import { useAtomValue } from "@effect/atom-react";
78
import { useNavigate } from "@tanstack/react-router";
89
import { ArrowUpFromLineIcon, MoreHorizontalIcon, PenLineIcon, Trash2Icon } from "lucide-react";
910
import { useState } from "react";
@@ -13,7 +14,7 @@ import {
1314
SIDE_CHAT_EDITABLE_RUNTIME_MODE,
1415
useSideChatActions,
1516
} from "../../hooks/useSideChatActions";
16-
import { useEnvironmentProviders } from "../../state/environments";
17+
import { serverEnvironment } from "../../state/server";
1718
import { useThreadProjection, useThreadShell } from "../../state/entities";
1819
import { buildThreadRouteParams } from "../../threadRoutes";
1920
import { Badge } from "../ui/badge";
@@ -42,20 +43,23 @@ export function SideChatHeader(props: { environmentId: EnvironmentId; threadId:
4243
const composerRuntimeMode = useComposerDraftStore(
4344
(store) => store.getComposerDraft(childRef)?.runtimeMode ?? null,
4445
);
45-
const providers = useEnvironmentProviders().get(props.environmentId);
46+
// A provider without auto-accept-edits would fall back to asking, so the
47+
// switch must not claim edits are allowed there.
48+
const providerInstanceId = shell?.runtime?.providerInstanceId ?? shell?.modelSelection.instanceId;
49+
const canAllowEdits = useAtomValue(
50+
serverEnvironment.providersValueAtom(props.environmentId),
51+
(providers) => {
52+
const modes = providers?.find(
53+
(provider) => provider.instanceId === providerInstanceId,
54+
)?.supportedRuntimeModes;
55+
return (
56+
modes === undefined || modes.length === 0 || modes.includes(SIDE_CHAT_EDITABLE_RUNTIME_MODE)
57+
);
58+
},
59+
);
4660

4761
if (shell === null) return null;
4862
const allowEdits = (composerRuntimeMode ?? shell.runtimeMode) !== "approval-required";
49-
// A provider without auto-accept-edits would fall back to asking, so the
50-
// switch must not claim edits are allowed there.
51-
const providerInstanceId = shell.runtime?.providerInstanceId ?? shell.modelSelection.instanceId;
52-
const supportedRuntimeModes = providers?.find(
53-
(provider) => provider.instanceId === providerInstanceId,
54-
)?.supportedRuntimeModes;
55-
const canAllowEdits =
56-
supportedRuntimeModes === undefined ||
57-
supportedRuntimeModes.length === 0 ||
58-
supportedRuntimeModes.includes(SIDE_CHAT_EDITABLE_RUNTIME_MODE);
5963
const mergeRun = childProjection === null ? null : resolveLatestMergeBackRun(childProjection);
6064
const canBringBack = shell.lineage.relationshipToParent === "fork" && mergeRun !== null;
6165
const bringBackReason =
@@ -116,7 +120,7 @@ export function SideChatHeader(props: { environmentId: EnvironmentId; threadId:
116120
<TooltipPopup side="bottom">
117121
{canAllowEdits
118122
? "Shares the main thread's files. Off, it asks before changing anything."
119-
: "This provider asks before every edit."}
123+
: "This provider can't approve only edits automatically."}
120124
</TooltipPopup>
121125
</Tooltip>
122126
<Menu>

0 commit comments

Comments
 (0)