Compare commits

...
Author SHA1 Message Date
Cursor AgentandJulius Marminge 95a569af55 Add react-scan provider dialog recordings
Co-authored-by: Julius Marminge <[email protected]>
2026-05-13 16:16:49 +00:00
Cursor AgentandJulius Marminge be215fb3ea Reduce provider instance dialog rerenders
Co-authored-by: Julius Marminge <[email protected]>
2026-05-13 16:07:16 +00:00
Julius Marminge 556c42452c Harden GitHub workflow permissions
- Restrict release workflow defaults to read-only access
- Grant `id-token` only to the publish job
- Document safe handling for `pull_request_target` in PR size checks
2026-05-13 14:19:18 +02:00
Julius Marminge 7e20b23e7e Constrain provider update popover overflow (#2669) 2026-05-13 10:23:31 +02:00
Julius Marminge b83e9c95e4 Refactor composer refs and context providers (#2664) 2026-05-12 21:54:28 +02:00
23 changed files with 2080 additions and 2013 deletions

No files matched your search

+3
View File
@@ -124,6 +124,9 @@ jobs:
group: pr-size-${{ github.event.pull_request.number }}
cancel-in-progress: true
steps:
# This pull_request_target job may fetch untrusted PR commits only as passive
# git data. Do not add dependency installs, build/test scripts, or cache
# actions here; use pull_request plus workflow_run for that pattern instead.
- name: Checkout base repository
uses: actions/checkout@v4
with:
+5 -2
View File
@@ -23,8 +23,8 @@ on:
type: string
permissions:
contents: write
id-token: write
contents: read
id-token: none
jobs:
check_changes:
@@ -420,6 +420,9 @@ jobs:
if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.build.result == 'success' }}
runs-on: ubuntu-24.04 # blacksmith-8vcpu-ubuntu-2404
timeout-minutes: 10
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v6
+5 -5
View File
@@ -35,8 +35,8 @@
"effect": "catalog:",
"lexical": "^0.41.0",
"lucide-react": "^0.564.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react": "19.2.6",
"react-dom": "19.2.6",
"react-markdown": "^10.1.0",
"remark-gfm": "^4.0.1",
"tailwind-merge": "^3.4.0",
@@ -48,12 +48,12 @@
"@tailwindcss/vite": "^4.0.0",
"@tanstack/router-plugin": "^1.161.0",
"@types/babel__core": "^7.20.5",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"@types/react": "~19.2.14",
"@types/react-dom": "~19.2.3",
"@vercel/config": "^0.3.0",
"@vitejs/plugin-react": "^6.0.0",
"@vitest/browser-playwright": "^4.0.18",
"babel-plugin-react-compiler": "^19.0.0-beta-e552027-20250112",
"babel-plugin-react-compiler": "1.0.0",
"msw": "2.12.11",
"playwright": "^1.58.2",
"tailwindcss": "^4.0.0",
+1 -1
View File
@@ -3607,7 +3607,7 @@ export default function ChatView(props: ChatViewProps) {
<ComposerBannerStack className="relative z-0" items={composerBannerItems} />
<div className="relative z-10">
<ChatComposer
ref={composerRef}
composerRef={composerRef}
composerDraftTarget={composerDraftTarget}
environmentId={environmentId}
routeKind={routeKind}
+2 -2
View File
@@ -364,12 +364,12 @@ export function CommandPalette({ children }: { children: ReactNode }) {
}, [keybindings, terminalOpen, toggleOpen]);
return (
<ComposerHandleContext.Provider value={composerHandleRef}>
<ComposerHandleContext value={composerHandleRef}>
<CommandDialog open={open} onOpenChange={setOpen}>
{children}
<CommandPaletteDialog />
</CommandDialog>
</ComposerHandleContext.Provider>
</ComposerHandleContext>
);
}
+88 -102
View File
@@ -38,17 +38,14 @@ import {
} from "lexical";
import {
createContext,
forwardRef,
use,
useCallback,
useContext,
useEffect,
useEffectEvent,
useImperativeHandle,
useLayoutEffect,
useMemo,
useRef,
type ClipboardEventHandler,
type ReactElement,
type Ref,
} from "react";
import {
@@ -160,7 +157,7 @@ function ComposerMentionDecorator(props: { path: string }) {
);
}
class ComposerMentionNode extends DecoratorNode<ReactElement> {
class ComposerMentionNode extends DecoratorNode<React.ReactElement> {
__path: string;
static override getType(): string {
@@ -208,7 +205,7 @@ class ComposerMentionNode extends DecoratorNode<ReactElement> {
return true;
}
override decorate(): ReactElement {
override decorate(): React.ReactElement {
return <ComposerMentionDecorator path={this.__path} />;
}
}
@@ -278,7 +275,7 @@ function ComposerSkillDecorator(props: { skillLabel: string; skillDescription: s
);
}
class ComposerSkillNode extends DecoratorNode<ReactElement> {
class ComposerSkillNode extends DecoratorNode<React.ReactElement> {
__skillName: string;
__skillLabel: string;
__skillDescription: string | null;
@@ -346,7 +343,7 @@ class ComposerSkillNode extends DecoratorNode<ReactElement> {
return true;
}
override decorate(): ReactElement {
override decorate(): React.ReactElement {
return (
<ComposerSkillDecorator
skillLabel={this.__skillLabel}
@@ -368,7 +365,7 @@ function ComposerTerminalContextDecorator(props: { context: TerminalContextDraft
return <ComposerPendingTerminalContextChip context={props.context} />;
}
class ComposerTerminalContextNode extends DecoratorNode<ReactElement> {
class ComposerTerminalContextNode extends DecoratorNode<React.ReactElement> {
__context: TerminalContextDraft;
static override getType(): string {
@@ -417,7 +414,7 @@ class ComposerTerminalContextNode extends DecoratorNode<ReactElement> {
return true;
}
override decorate(): ReactElement {
override decorate(): React.ReactElement {
return <ComposerTerminalContextDecorator context={this.__context} />;
}
}
@@ -900,11 +897,8 @@ interface ComposerPromptEditorProps {
key: "ArrowDown" | "ArrowUp" | "Enter" | "Tab",
event: KeyboardEvent,
) => boolean;
onPaste: ClipboardEventHandler<HTMLElement>;
}
interface ComposerPromptEditorInnerProps extends ComposerPromptEditorProps {
editorRef: Ref<ComposerPromptEditorHandle>;
onPaste: React.ClipboardEventHandler<HTMLElement>;
editorRef: React.RefObject<ComposerPromptEditorHandle | null>;
}
function ComposerCommandKeyPlugin(props: {
@@ -1059,7 +1053,7 @@ function ComposerInlineTokenSelectionNormalizePlugin() {
function ComposerInlineTokenBackspacePlugin() {
const [editor] = useLexicalComposerContext();
const { onRemoveTerminalContext } = useContext(ComposerTerminalContextActionsContext);
const { onRemoveTerminalContext } = use(ComposerTerminalContextActionsContext);
useEffect(() => {
return editor.registerCommand(
@@ -1150,68 +1144,65 @@ function ComposerSurroundSelectionPlugin(props: {
skillMetadataRef.current = skillMetadataByName(props.skills);
}, [props.skills]);
const applySurroundInsertion = useCallback(
(inputData: string): boolean => {
const surroundCloseSymbol = SURROUND_SYMBOLS_MAP.get(inputData);
const pendingSurroundSelection = pendingSurroundSelectionRef.current;
if (!surroundCloseSymbol) {
pendingSurroundSelectionRef.current = null;
return false;
const applySurroundInsertion = useEffectEvent((inputData: string): boolean => {
const surroundCloseSymbol = SURROUND_SYMBOLS_MAP.get(inputData);
const pendingSurroundSelection = pendingSurroundSelectionRef.current;
if (!surroundCloseSymbol) {
pendingSurroundSelectionRef.current = null;
return false;
}
let handled = false;
editor.update(() => {
const selectionSnapshot =
pendingSurroundSelection ??
(() => {
const selection = $getSelection();
if (!$isRangeSelection(selection) || selection.isCollapsed()) {
return null;
}
if ($selectionTouchesInlineToken(selection)) {
return null;
}
const range = getSelectionRangeForExpandedComposerOffsets(selection);
if (!range || range.start === range.end) {
return null;
}
const value = $getRoot().getTextContent();
if (selectionTouchesMentionBoundary(value, range.start, range.end)) {
return null;
}
return {
value,
expandedStart: range.start,
expandedEnd: range.end,
};
})();
if (!selectionSnapshot || !surroundCloseSymbol) {
return;
}
let handled = false;
editor.update(() => {
const selectionSnapshot =
pendingSurroundSelection ??
(() => {
const selection = $getSelection();
if (!$isRangeSelection(selection) || selection.isCollapsed()) {
return null;
}
if ($selectionTouchesInlineToken(selection)) {
return null;
}
const range = getSelectionRangeForExpandedComposerOffsets(selection);
if (!range || range.start === range.end) {
return null;
}
const value = $getRoot().getTextContent();
if (selectionTouchesMentionBoundary(value, range.start, range.end)) {
return null;
}
return {
value,
expandedStart: range.start,
expandedEnd: range.end,
};
})();
const selectedText = selectionSnapshot.value.slice(
selectionSnapshot.expandedStart,
selectionSnapshot.expandedEnd,
);
const nextValue = `${selectionSnapshot.value.slice(0, selectionSnapshot.expandedStart)}${inputData}${selectedText}${surroundCloseSymbol}${selectionSnapshot.value.slice(selectionSnapshot.expandedEnd)}`;
$setComposerEditorPrompt(nextValue, terminalContextsRef.current, skillMetadataRef.current);
const selectionStart = collapseExpandedComposerCursor(
nextValue,
selectionSnapshot.expandedStart,
);
$setSelectionRangeAtComposerOffsets(
selectionStart + inputData.length,
selectionStart + inputData.length + selectedText.length,
);
handled = true;
pendingSurroundSelectionRef.current = null;
});
if (!selectionSnapshot || !surroundCloseSymbol) {
return;
}
const selectedText = selectionSnapshot.value.slice(
selectionSnapshot.expandedStart,
selectionSnapshot.expandedEnd,
);
const nextValue = `${selectionSnapshot.value.slice(0, selectionSnapshot.expandedStart)}${inputData}${selectedText}${surroundCloseSymbol}${selectionSnapshot.value.slice(selectionSnapshot.expandedEnd)}`;
$setComposerEditorPrompt(nextValue, terminalContextsRef.current, skillMetadataRef.current);
const selectionStart = collapseExpandedComposerCursor(
nextValue,
selectionSnapshot.expandedStart,
);
$setSelectionRangeAtComposerOffsets(
selectionStart + inputData.length,
selectionStart + inputData.length + selectedText.length,
);
handled = true;
pendingSurroundSelectionRef.current = null;
});
return handled;
},
[editor],
);
return handled;
});
useEffect(() => {
const onKeyDown = (event: KeyboardEvent) => {
@@ -1388,7 +1379,7 @@ function ComposerSurroundSelectionPlugin(props: {
}
unregisterRootListener();
};
}, [applySurroundInsertion, editor]);
}, [editor]);
return null;
}
@@ -1406,7 +1397,7 @@ function ComposerPromptEditorInner({
onCommandKeyDown,
onPaste,
editorRef,
}: ComposerPromptEditorInnerProps) {
}: ComposerPromptEditorProps) {
const [editor] = useLexicalComposerContext();
const onChangeRef = useRef(onChange);
const initialCursor = clampCollapsedComposerCursor(value, cursor);
@@ -1614,13 +1605,13 @@ function ComposerPromptEditorInner({
}, []);
return (
<ComposerTerminalContextActionsContext.Provider value={terminalContextActions}>
<ComposerTerminalContextActionsContext value={terminalContextActions}>
<div className="relative">
<PlainTextPlugin
contentEditable={
<ContentEditable
className={cn(
"block max-h-[200px] min-h-17.5 w-full overflow-y-auto whitespace-pre-wrap wrap-break-word bg-transparent text-[16px] leading-relaxed text-foreground focus:outline-none sm:text-[14px]",
"block max-h-50 min-h-17.5 w-full overflow-y-auto whitespace-pre-wrap wrap-break-word bg-transparent text-[16px] leading-relaxed text-foreground focus:outline-none sm:text-[14px]",
className,
)}
data-testid="composer-editor"
@@ -1646,29 +1637,24 @@ function ComposerPromptEditorInner({
<ComposerInlineTokenBackspacePlugin />
<HistoryPlugin />
</div>
</ComposerTerminalContextActionsContext.Provider>
</ComposerTerminalContextActionsContext>
);
}
export const ComposerPromptEditor = forwardRef<
ComposerPromptEditorHandle,
ComposerPromptEditorProps
>(function ComposerPromptEditor(
{
value,
cursor,
terminalContexts,
skills,
disabled,
placeholder,
className,
onRemoveTerminalContext,
onChange,
onCommandKeyDown,
onPaste,
},
ref,
) {
export function ComposerPromptEditor({
value,
cursor,
terminalContexts,
skills,
disabled,
placeholder,
className,
onRemoveTerminalContext,
onChange,
onCommandKeyDown,
onPaste,
editorRef,
}: ComposerPromptEditorProps) {
const initialValueRef = useRef(value);
const initialTerminalContextsRef = useRef(terminalContexts);
const initialSkillMetadataRef = useRef(skillMetadataByName(skills));
@@ -1703,10 +1689,10 @@ export const ComposerPromptEditor = forwardRef<
onRemoveTerminalContext={onRemoveTerminalContext}
onChange={onChange}
onPaste={onPaste}
editorRef={ref}
editorRef={editorRef}
{...(onCommandKeyDown ? { onCommandKeyDown } : {})}
{...(className ? { className } : {})}
/>
</LexicalComposer>
);
});
}
File diff suppressed because it is too large. Load diff
@@ -13,18 +13,16 @@ const getStateSpy = vi.fn(() => ({ isAtEnd: true }));
vi.mock("@legendapp/list/react", async () => {
const React = await import("react");
const LegendList = React.forwardRef(function MockLegendList(
props: {
data: Array<{ id: string }>;
keyExtractor: (item: { id: string }) => string;
renderItem: (args: { item: { id: string } }) => React.ReactNode;
ListHeaderComponent?: React.ReactNode;
ListFooterComponent?: React.ReactNode;
},
ref: React.ForwardedRef<LegendListRef>,
) {
function LegendList(props: {
data: Array<{ id: string }>;
keyExtractor: (item: { id: string }) => string;
renderItem: (args: { item: { id: string } }) => React.ReactNode;
ListHeaderComponent?: React.ReactNode;
ListFooterComponent?: React.ReactNode;
ref?: React.Ref<LegendListRef>;
}) {
React.useImperativeHandle(
ref,
props.ref,
() =>
({
scrollToEnd: scrollToEndSpy,
@@ -41,7 +39,7 @@ vi.mock("@legendapp/list/react", async () => {
{props.ListFooterComponent}
</div>
);
});
}
return { LegendList };
});
@@ -1,32 +1,28 @@
import { EnvironmentId, MessageId } from "@t3tools/contracts";
import { createRef } from "react";
import { createRef, type ReactNode, type Ref } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { beforeAll, describe, expect, it, vi } from "vitest";
import type { LegendListRef } from "@legendapp/list/react";
vi.mock("@legendapp/list/react", async () => {
const React = await import("react");
const legendListTestId = "legend-list";
const LegendList = React.forwardRef(function MockLegendList(
props: {
data: Array<{ id: string }>;
keyExtractor: (item: { id: string }) => string;
renderItem: (args: { item: { id: string } }) => React.ReactNode;
ListHeaderComponent?: React.ReactNode;
ListFooterComponent?: React.ReactNode;
},
_ref: React.ForwardedRef<LegendListRef>,
) {
return (
<div data-testid="legend-list">
{props.ListHeaderComponent}
{props.data.map((item) => (
<div key={props.keyExtractor(item)}>{props.renderItem({ item })}</div>
))}
{props.ListFooterComponent}
</div>
);
});
const LegendList = (props: {
data: Array<{ id: string }>;
keyExtractor: (item: { id: string }) => string;
renderItem: (args: { item: { id: string } }) => ReactNode;
ListHeaderComponent?: ReactNode;
ListFooterComponent?: ReactNode;
ref?: Ref<LegendListRef>;
}) => (
<div data-testid={legendListTestId}>
{props.ListHeaderComponent}
{props.data.map((item) => (
<div key={props.keyExtractor(item)}>{props.renderItem({ item })}</div>
))}
{props.ListFooterComponent}
</div>
);
return { LegendList };
});
@@ -69,7 +69,7 @@ import { SkillInlineText } from "./SkillInlineText";
import { formatWorkspaceRelativePath } from "../../filePathDisplay";
// ---------------------------------------------------------------------------
// Context — shared state consumed by every row component via useContext.
// Context — shared state consumed by every row component via Context.
// Propagates through LegendList's memo boundaries for shared callbacks and
// non-row-scoped state. `nowIso` is intentionally excluded — self-ticking
// components (WorkingTimer, LiveElapsed) handle it.
@@ -264,8 +264,8 @@ export const MessagesTimeline = memo(function MessagesTimeline({
}
return (
<TimelineRowCtx.Provider value={sharedState}>
<TimelineRowActivityCtx.Provider value={activityState}>
<TimelineRowCtx value={sharedState}>
<TimelineRowActivityCtx value={activityState}>
<LegendList<MessagesTimelineRow>
ref={listRef}
data={rows}
@@ -281,8 +281,8 @@ export const MessagesTimeline = memo(function MessagesTimeline({
ListHeaderComponent={TIMELINE_LIST_HEADER}
ListFooterComponent={TIMELINE_LIST_FOOTER}
/>
</TimelineRowActivityCtx.Provider>
</TimelineRowCtx.Provider>
</TimelineRowActivityCtx>
</TimelineRowCtx>
);
});
@@ -2,7 +2,7 @@
import { CheckIcon } from "lucide-react";
import { Radio as RadioPrimitive } from "@base-ui/react/radio";
import { useCallback, useEffect, useMemo, useState } from "react";
import { useCallback, useMemo, useRef, useState } from "react";
import {
ProviderInstanceId,
ProviderDriverKind,
@@ -122,7 +122,7 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns
const [label, setLabel] = useState("");
const [accentColor, setAccentColor] = useState<string>("");
const [instanceId, setInstanceId] = useState("");
const [instanceIdDirty, setInstanceIdDirty] = useState(false);
const instanceIdDirtyRef = useRef(false);
// Driver-specific config drafts keyed by driver so toggling between drivers
// during the same dialog session does not lose in-progress input.
const [configByDriver, setConfigByDriver] = useState<Record<string, Record<string, unknown>>>({});
@@ -135,26 +135,57 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns
[settings.providerInstances],
);
// Reset the form every time the dialog opens so each creation starts
// from a clean slate.
useEffect(() => {
if (!open) return;
const resetForm = useCallback(() => {
setDriver(DEFAULT_DRIVER_KIND);
setLabel("");
setAccentColor("");
setInstanceId("");
setWizardStep(0);
setInstanceIdDirty(false);
instanceIdDirtyRef.current = false;
setConfigByDriver({});
setHasAttemptedSubmit(false);
}, [open]);
}, []);
// Auto-derive the instance id from driver + label until the user types
// in the Instance ID field directly (after which they own its value).
useEffect(() => {
if (instanceIdDirty) return;
setInstanceId(deriveInstanceId(driver, label));
}, [driver, label, instanceIdDirty]);
const handleDialogOpenChange = useCallback(
(nextOpen: boolean) => {
if (!nextOpen) {
resetForm();
}
onOpenChange(nextOpen);
},
[onOpenChange, resetForm],
);
const closeDialog = useCallback(() => {
resetForm();
onOpenChange(false);
}, [onOpenChange, resetForm]);
const updateDriver = useCallback(
(value: string) => {
const nextDriver = ProviderDriverKind.make(value);
setDriver(nextDriver);
if (!instanceIdDirtyRef.current) {
setInstanceId(deriveInstanceId(nextDriver, label));
}
},
[label],
);
const updateLabel = useCallback(
(nextLabel: string) => {
setLabel(nextLabel);
if (!instanceIdDirtyRef.current) {
setInstanceId(deriveInstanceId(driver, nextLabel));
}
},
[driver],
);
const updateInstanceId = useCallback((nextInstanceId: string) => {
instanceIdDirtyRef.current = true;
setInstanceId(nextInstanceId);
}, []);
const driverOption = DRIVER_OPTION_BY_VALUE[driver] ?? DEFAULT_DRIVER_OPTION;
const driverSettingsFields = useMemo(
@@ -214,7 +245,7 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns
title: "Provider instance added",
description: `${driverOption.label} instance '${instanceId}' was added.`,
});
onOpenChange(false);
closeDialog();
} catch (error) {
toastManager.add({
type: "error",
@@ -230,13 +261,13 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns
instanceIdError,
label,
accentColor,
onOpenChange,
closeDialog,
settings.providerInstances,
updateSettings,
]);
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<Dialog open={open} onOpenChange={handleDialogOpenChange}>
<DialogPopup className="max-w-xl overflow-hidden">
<div className="flex min-h-0 flex-col overflow-hidden border-foreground/10 bg-background shadow-2xl">
<DialogHeader className="border-b border-border/70 bg-background">
@@ -301,7 +332,7 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns
</span>
<RadioGroup
value={driver}
onValueChange={(value) => setDriver(ProviderDriverKind.make(value))}
onValueChange={updateDriver}
aria-labelledby="add-instance-driver-label"
className="grid grid-cols-2 gap-2.5"
>
@@ -365,7 +396,7 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns
className="bg-background"
placeholder="e.g. Work"
value={label}
onChange={(event) => setLabel(event.target.value)}
onChange={(event) => updateLabel(event.target.value)}
/>
<span className="text-[11px] text-muted-foreground">
Shown in the provider list. Optional.
@@ -378,10 +409,7 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns
className="bg-background"
placeholder={`${driver}_work`}
value={instanceId}
onChange={(event) => {
setInstanceIdDirty(true);
setInstanceId(event.target.value);
}}
onChange={(event) => updateInstanceId(event.target.value)}
aria-invalid={showInstanceIdError}
/>
{showInstanceIdError ? (
@@ -466,7 +494,7 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns
size="sm"
onClick={() => {
if (wizardStep === 0) {
onOpenChange(false);
closeDialog();
return;
}
setWizardStep((step) => Math.max(0, step - 1));
@@ -29,6 +29,7 @@ import { Button } from "../ui/button";
import { Collapsible, CollapsibleContent } from "../ui/collapsible";
import { DraftInput } from "../ui/draft-input";
import { Popover, PopoverPopup, PopoverTrigger } from "../ui/popover";
import { ScrollArea } from "../ui/scroll-area";
import { Switch } from "../ui/switch";
import { stackedThreadToast, toastManager } from "../ui/toast";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
@@ -697,8 +698,12 @@ export function ProviderInstanceCard({
</Button>
}
/>
<PopoverPopup side="bottom" align="start" className="w-84">
<div className="grid gap-3">
<PopoverPopup
side="bottom"
align="start"
className="w-[min(21rem,calc(100vw-1.5rem))] [--popup-width:min(21rem,calc(100vw-1.5rem))]"
>
<div className="grid min-w-0 gap-3">
<div className="grid gap-0.5">
<p className="text-[13px] font-semibold leading-tight text-foreground">
Update available
@@ -735,10 +740,12 @@ export function ProviderInstanceCard({
</div>
) : null}
{updateCommand ? (
<div className="flex items-center gap-1 rounded-md border border-border/70 bg-muted/40 py-0.5 pr-0.5 pl-2">
<code className="min-w-0 flex-1 overflow-x-auto whitespace-nowrap font-mono text-[11px] text-foreground [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
{updateCommand}
</code>
<div className="flex min-w-0 items-center gap-1 rounded-md border border-border/70 bg-muted/40 py-0.5 pr-0.5 pl-2">
<ScrollArea scrollFade className="h-8 min-w-0 flex-1 rounded-none">
<code className="flex h-full w-max items-center whitespace-nowrap pr-3 font-mono text-[11px] text-foreground">
{updateCommand}
</code>
</ScrollArea>
<Tooltip>
<TooltipTrigger
render={
@@ -236,7 +236,10 @@ function createBaseServerConfig(): ServerConfig {
};
}
function createOutdatedProvider(driver: string): ServerProvider {
function createOutdatedProvider(
driver: string,
updateCommand = "npm install -g openai/codex@latest",
): ServerProvider {
return {
instanceId: ProviderInstanceId.make(driver),
driver: ProviderDriverKind.make(driver),
@@ -255,7 +258,7 @@ function createOutdatedProvider(driver: string): ServerProvider {
latestVersion: "1.1.0",
message: "Update available.",
checkedAt: "2026-05-04T10:00:00.000Z",
updateCommand: "npm install -g openai/codex@latest",
updateCommand,
canUpdate: true,
},
};
@@ -1155,6 +1158,47 @@ describe("GeneralSettingsPanel observability", () => {
instanceId: ProviderInstanceId.make("codex"),
});
});
it("keeps long provider update commands inside the fixed-width popover", async () => {
const longUpdateCommand =
"npm install -g @anthropic-ai/claude-code@latest --registry=https://registry.npmjs.org --cache=/tmp/t3code-provider-update-cache";
setServerConfigSnapshot({
...createBaseServerConfig(),
providers: [createOutdatedProvider("codex", longUpdateCommand)],
});
mounted = await render(
<AppAtomRegistryProvider>
<ProviderSettingsPanel />
</AppAtomRegistryProvider>,
);
await page.getByRole("button", { name: "Update available — view details" }).click();
await expect.element(page.getByText(longUpdateCommand)).toBeInTheDocument();
await vi.waitFor(() => {
const popup = document.querySelector<HTMLElement>('[data-slot="popover-popup"]');
const commandCode = Array.from(document.querySelectorAll<HTMLElement>("code")).find(
(element) => element.textContent === longUpdateCommand,
);
const scrollViewport = commandCode?.closest<HTMLElement>(
'[data-slot="scroll-area-viewport"]',
);
expect(popup).toBeTruthy();
expect(commandCode).toBeTruthy();
expect(scrollViewport).toBeTruthy();
const popupRect = popup!.getBoundingClientRect();
const viewportRect = scrollViewport!.getBoundingClientRect();
expect(popupRect.width).toBeGreaterThan(300);
expect(popupRect.width).toBeLessThanOrEqual(337);
expect(viewportRect.right).toBeLessThanOrEqual(popupRect.right + 0.5);
expect(scrollViewport!.scrollWidth).toBeGreaterThan(scrollViewport!.clientWidth);
});
});
});
describe("SourceControlSettingsPanel discovery states", () => {
+4 -4
View File
@@ -22,9 +22,9 @@ function Combobox<Value, Multiple extends boolean | undefined = false>(
const chipsRef = React.useRef<Element | null>(null);
const value = React.useMemo(() => ({ chipsRef, multiple: !!props.multiple }), [props.multiple]);
return (
<ComboboxContext.Provider value={value}>
<ComboboxContext value={value}>
<ComboboxPrimitive.Root {...props} />
</ComboboxContext.Provider>
</ComboboxContext>
);
}
@@ -151,7 +151,7 @@ function ComboboxPopup({
side?: ComboboxPrimitive.Positioner.Props["side"];
anchor?: ComboboxPrimitive.Positioner.Props["anchor"];
}) {
const { chipsRef } = React.useContext(ComboboxContext);
const { chipsRef } = React.use(ComboboxContext);
const anchor = anchorProp ?? chipsRef;
return (
@@ -324,7 +324,7 @@ function ComboboxChips({
}: ComboboxPrimitive.Chips.Props & {
startAddon?: React.ReactNode;
}) {
const { chipsRef } = React.useContext(ComboboxContext);
const { chipsRef } = React.use(ComboboxContext);
return (
<ComboboxPrimitive.Chips
+3 -3
View File
@@ -25,7 +25,7 @@ export function NumberField({
const contextValue = React.useMemo(() => ({ fieldId }), [fieldId]);
return (
<NumberFieldContext.Provider value={contextValue}>
<NumberFieldContext value={contextValue}>
<NumberFieldPrimitive.Root
className={cn("flex w-full flex-col items-start gap-2", className)}
data-size={size}
@@ -33,7 +33,7 @@ export function NumberField({
id={fieldId}
{...props}
/>
</NumberFieldContext.Provider>
</NumberFieldContext>
);
}
@@ -112,7 +112,7 @@ export function NumberFieldScrubArea({
}: NumberFieldPrimitive.ScrubArea.Props & {
label: string;
}): React.ReactElement {
const context = React.useContext(NumberFieldContext);
const context = React.use(NumberFieldContext);
if (!context) {
throw new Error(
+11 -11
View File
@@ -77,7 +77,7 @@ const SidebarContext = React.createContext<SidebarContextProps | null>(null);
const SidebarInstanceContext = React.createContext<SidebarInstanceContextProps | null>(null);
function useSidebar() {
const context = React.useContext(SidebarContext);
const context = React.use(SidebarContext);
if (!context) {
throw new Error("useSidebar must be used within a SidebarProvider.");
}
@@ -148,7 +148,7 @@ function SidebarProvider({
);
return (
<SidebarContext.Provider value={contextValue}>
<SidebarContext value={contextValue}>
<div
className={cn(
"group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
@@ -166,7 +166,7 @@ function SidebarProvider({
>
{children}
</div>
</SidebarContext.Provider>
</SidebarContext>
);
}
@@ -206,7 +206,7 @@ function Sidebar({
if (collapsible === "none") {
return (
<SidebarInstanceContext.Provider value={instanceContextValue}>
<SidebarInstanceContext value={instanceContextValue}>
<div
className={cn(
"flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
@@ -217,13 +217,13 @@ function Sidebar({
>
{children}
</div>
</SidebarInstanceContext.Provider>
</SidebarInstanceContext>
);
}
if (isMobile) {
return (
<SidebarInstanceContext.Provider value={instanceContextValue}>
<SidebarInstanceContext value={instanceContextValue}>
<Sheet onOpenChange={setOpenMobile} open={openMobile} {...props}>
<SheetPopup
className={cn(
@@ -255,12 +255,12 @@ function Sidebar({
</div>
</SheetPopup>
</Sheet>
</SidebarInstanceContext.Provider>
</SidebarInstanceContext>
);
}
return (
<SidebarInstanceContext.Provider value={instanceContextValue}>
<SidebarInstanceContext value={instanceContextValue}>
<div
className="group peer hidden text-sidebar-foreground md:block"
data-collapsible={state === "collapsed" ? collapsible : ""}
@@ -305,7 +305,7 @@ function Sidebar({
</div>
</div>
</div>
</SidebarInstanceContext.Provider>
</SidebarInstanceContext>
);
}
@@ -345,7 +345,7 @@ function SidebarRail({
...props
}: React.ComponentProps<"button">) {
const { open, toggleSidebar } = useSidebar();
const sidebarInstance = React.useContext(SidebarInstanceContext);
const sidebarInstance = React.use(SidebarInstanceContext);
const railRef = React.useRef<HTMLButtonElement | null>(null);
const suppressClickRef = React.useRef(false);
const resizeStateRef = React.useRef<{
@@ -889,7 +889,7 @@ function SidebarMenuSkeleton({
}: React.ComponentProps<"div"> & {
showIcon?: boolean;
}) {
// Random width between 50 to 90%.
// Random width between 50 to 90%. Intentionally wrapped in useMemo to avoid changing width on every render.
const width = React.useMemo(() => {
return `${Math.floor(Math.random() * 40) + 50}%`;
}, []);
+2 -2
View File
@@ -43,7 +43,7 @@ function ToggleGroup({
orientation={orientation}
{...props}
>
<ToggleGroupContext.Provider value={value}>{children}</ToggleGroupContext.Provider>
<ToggleGroupContext value={value}>{children}</ToggleGroupContext>
</ToggleGroupPrimitive>
);
}
@@ -55,7 +55,7 @@ function Toggle({
size,
...props
}: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
const context = React.useContext(ToggleGroupContext);
const context = React.use(ToggleGroupContext);
const resolvedVariant = variant ?? context.variant;
const resolvedSize = size ?? context.size;
+3 -3
View File
@@ -1,10 +1,10 @@
import { createContext, useContext, type MutableRefObject } from "react";
import { createContext, use } from "react";
import type { ChatComposerHandle } from "./components/chat/ChatComposer";
export type ComposerHandleRef = MutableRefObject<ChatComposerHandle | null>;
export type ComposerHandleRef = React.RefObject<ChatComposerHandle | null>;
export const ComposerHandleContext = createContext<ComposerHandleRef | null>(null);
export function useComposerHandleContext(): ComposerHandleRef | null {
return useContext(ComposerHandleContext);
return use(ComposerHandleContext);
}
@@ -1,11 +1,11 @@
import { RegistryContext } from "@effect/atom-react";
import { AtomRegistry } from "effect/unstable/reactivity";
import type { ReactNode } from "react";
import { createElement } from "react";
export let appAtomRegistry = AtomRegistry.make();
export function AppAtomRegistryProvider({ children }: { readonly children: ReactNode }) {
return <RegistryContext.Provider value={appAtomRegistry}>{children}</RegistryContext.Provider>;
export function AppAtomRegistryProvider({ children }: React.PropsWithChildren) {
return createElement(RegistryContext.Provider, { value: appAtomRegistry }, children);
}
export function resetAppAtomRegistryForTests() {
+8 -8
View File
@@ -108,8 +108,8 @@
"effect": "catalog:",
"lexical": "^0.41.0",
"lucide-react": "^0.564.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react": "19.2.6",
"react-dom": "19.2.6",
"react-markdown": "^10.1.0",
"remark-gfm": "^4.0.1",
"tailwind-merge": "^3.4.0",
@@ -121,12 +121,12 @@
"@tailwindcss/vite": "^4.0.0",
"@tanstack/router-plugin": "^1.161.0",
"@types/babel__core": "^7.20.5",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"@types/react": "~19.2.14",
"@types/react-dom": "~19.2.3",
"@vercel/config": "^0.3.0",
"@vitejs/plugin-react": "^6.0.0",
"@vitest/browser-playwright": "^4.0.18",
"babel-plugin-react-compiler": "^19.0.0-beta-e552027-20250112",
"babel-plugin-react-compiler": "1.0.0",
"msw": "2.12.11",
"playwright": "^1.58.2",
"tailwindcss": "^4.0.0",
@@ -1011,7 +1011,7 @@
"babel-dead-code-elimination": ["[email protected]", "", { "dependencies": { "@babel/core": "^7.23.7", "@babel/parser": "^7.23.6", "@babel/traverse": "^7.23.7", "@babel/types": "^7.23.6" } }, "sha512-GERT7L2TiYcYDtYk1IpD+ASAYXjKbLTDPhBtYj7X1NuRMDTMtAx9kyBenub1Ev41lo91OHCKdmP+egTDmfQ7Ig=="],
"babel-plugin-react-compiler": ["babel-plugin-react-compiler@19.0.0-beta-ebf51a3-20250411", "", { "dependencies": { "@babel/types": "^7.26.0" } }, "sha512-q84bNR9JG1crykAlJUt5Ud0/5BUyMFuQww/mrwIQDFBaxsikqBDj3f/FNDsVd2iR26A1HvXKWPEIfgJDv8/V2g=="],
"babel-plugin-react-compiler": ["[email protected]", "", { "dependencies": { "@babel/types": "^7.26.0" } }, "sha512-Ixm8tFfoKKIPYdCCKYTsqv+Fd4IJ0DQqMyEimo+pxUOMUR9cVPlwTrFt9Avu+3cb6Zp3mAzl+t1MrG2fxxKsxw=="],
"bail": ["[email protected]", "", {}, "sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw=="],
@@ -1737,9 +1737,9 @@
"raw-body": ["[email protected]", "", { "dependencies": { "bytes": "~3.1.2", "http-errors": "~2.0.1", "iconv-lite": "~0.7.0", "unpipe": "~1.0.0" } }, "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA=="],
"react": ["[email protected].4", "", {}, "sha512-9nfp2hYpCwOjAN+8TZFGhtWEwgvWHXqESH8qT89AT/lWklpLON22Lc8pEtnpsZz7VmawabSU0gCjnj8aC0euHQ=="],
"react": ["[email protected].6", "", {}, "sha512-sfWGGfavi0xr8Pg0sVsyHMAOziVYKgPLNrS7ig+ivMNb3wbCBw3KxtflsGBAwD3gYQlE/AEZsTLgToRrSCjb0Q=="],
"react-dom": ["[email protected].4", "", { "dependencies": { "scheduler": "^0.27.0" }, "peerDependencies": { "react": "^19.2.4" } }, "sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ=="],
"react-dom": ["[email protected].6", "", { "dependencies": { "scheduler": "^0.27.0" }, "peerDependencies": { "react": "^19.2.6" } }, "sha512-0prMI+hvBbPjsWnxDLxlCGyM8PN6UuWjEUCYmZhO67xIV9Xasa/r/vDnq+Xyq4Lo27g8QSbO5YzARu0D1Sps3g=="],
"react-error-boundary": ["[email protected]", "", { "peerDependencies": { "react": "^18.0.0 || ^19.0.0" } }, "sha512-BrYwPOdXi5mqkk5lw+Uvt0ThHx32rCt3BkukS4X23A2AIWDPSGX6iaWTc0y9TU/mHDA/6qOSGel+B2ERkOvD1w=="],
@@ -0,0 +1,17 @@
# React component health recording: provider instance dialog
This directory contains the react-scan comparison for the provider instance dialog rerender fix.
- `before-provider-dialog.webm`: recorded from commit `556c42452c5ac94ae8d8698d64fcd372c1680955`.
- `after-provider-dialog.webm`: recorded from commit `be215fb3ea877f46cf7491148b6fdcfa54ab5eae`.
Capture setup:
- Vite served the app in hosted-static mode (`VITE_HOSTED_APP_CHANNEL=latest`) so the settings route could load without a backend.
- The page HTML was intercepted by Playwright and injected with `[email protected]` before the React bundle.
- The scripted interaction opened Settings > Providers, opened "Add provider instance", advanced to the identity step, typed "Performance Workspace" into the label field, then edited the instance ID.
Measured during label typing with the React DevTools hook:
- Before: 34 `AddProviderInstanceDialog` render commits.
- After: 23 `AddProviderInstanceDialog` render commits.