@devries-cameron20 / t3code Mirror · read-only / commits / b618d53941
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 08:00 UTC

perf(web): project script settings compile with the React Compiler (#20502)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 16, 2026 at 18:53 UTC b618d53941b8bdde151e5b104c47ad29e2447687
2 files changed +76 -70
apps/web/reactCompiledFiles.ts
+1
@@ -77,4 +77,5 @@ export const REACT_COMPILED_FILES = [
77 "apps/web/src/components/settings/UsageProviderSettings.tsx",
78 "apps/web/src/components/settings/TelemetryExportSettings.tsx",
79 "apps/web/src/components/settings/useHostConnectionChecks.ts",
80 + "apps/web/src/components/settings/useProjectScriptSettings.ts",
81 ] as const;
apps/web/src/components/settings/useProjectScriptSettings.ts
+75 -70
@@ -96,79 +96,84 @@ export function useProjectScriptSettings(
96 }
97 savingRef.current = true;
98 setSaving(true);
99 - try {
100 - for (const { environmentId, settings, keybindings, project } of targets) {
101 - const current = project
102 - ? resolveProjectScripts(settings, project)
103 - : settings.defaultProjectScripts;
104 - const nextScripts = transform(current);
105 - const effectiveScripts = nextScripts ?? settings.defaultProjectScripts;
106 - const result = await updateSettings({
107 - environmentId,
108 - input: {
109 - patch: project
110 - ? {
111 - projectSettingsOverrides: {
112 - [project.id]:
113 - nextScripts === null
114 - ? clearProjectSettingsOverrides(settings, project.id, [
115 - "defaultProjectScripts",
116 - ])
117 - : {
118 - ...settings.projectSettingsOverrides[project.id],
119 - defaultProjectScripts: nextScripts,
120 - },
121 - },
122 - }
123 - : { defaultProjectScripts: nextScripts ?? [] },
124 - },
125 - });
126 - if (result._tag === "Failure") return reportScriptFailure(result);
127 - const changedIds = scriptId
128 - ? [scriptId]
129 - : current
130 - .filter((script) => !effectiveScripts.some((next) => next.id === script.id))
131 - .map((script) => script.id);
132 - for (const id of changedIds) {
133 - const command = commandForProjectScript(id);
134 - const previousValue = keybindingValueForCommand(keybindings, command);
135 - const previous = previousValue
136 - ? decodeProjectScriptKeybindingRule({ keybinding: previousValue, command })
137 - : null;
138 - const next = decodeProjectScriptKeybindingRule({ keybinding, command });
139 - const retainedElsewhere =
140 - !nextScripts?.some((script) => script.id === id) &&
141 - ((project && settings.defaultProjectScripts.some((script) => script.id === id)) ||
142 - Object.entries(settings.projectSettingsOverrides).some(
143 - ([projectId, entry]) =>
144 - projectId !== project?.id &&
145 - entry.defaultProjectScripts?.some((script) => script.id === id),
146 - ) ||
147 - projects.some(
148 - (other) =>
149 - other.environmentId === environmentId &&
150 - other.id !== project?.id &&
151 - (project ? resolveProjectScripts(settings, other) : other.scripts).some(
152 - (script) => script.id === id,
153 - ),
154 - ));
155 - const bindingResult = next
156 - ? await upsertKeybinding({
157 - environmentId,
158 - input:
159 - previous && previous.key !== next.key ? { ...next, replace: previous } : next,
160 - })
161 - : previous && !retainedElsewhere
162 - ? await removeKeybinding({ environmentId, input: previous })
163 - : null;
164 - if (bindingResult?._tag === "Failure") return reportScriptFailure(bindingResult);
165 - }
166 - }
167 - return AsyncResult.success(undefined);
168 - } finally {
99 + return writeTargets(transform, scriptId, keybinding).finally(() => {
100 savingRef.current = false;
101 setSaving(false);
102 + });
103 + }
104 +
105 + async function writeTargets(
106 + transform: (current: readonly ProjectScript[]) => readonly ProjectScript[] | null,
107 + scriptId: string | undefined,
108 + keybinding: string | null | undefined,
109 + ): Promise<AtomCommandResult<void, unknown>> {
110 + for (const { environmentId, settings, keybindings, project } of targets) {
111 + const current = project
112 + ? resolveProjectScripts(settings, project)
113 + : settings.defaultProjectScripts;
114 + const nextScripts = transform(current);
115 + const effectiveScripts = nextScripts ?? settings.defaultProjectScripts;
116 + const result = await updateSettings({
117 + environmentId,
118 + input: {
119 + patch: project
120 + ? {
121 + projectSettingsOverrides: {
122 + [project.id]:
123 + nextScripts === null
124 + ? clearProjectSettingsOverrides(settings, project.id, [
125 + "defaultProjectScripts",
126 + ])
127 + : {
128 + ...settings.projectSettingsOverrides[project.id],
129 + defaultProjectScripts: nextScripts,
130 + },
131 + },
132 + }
133 + : { defaultProjectScripts: nextScripts ?? [] },
134 + },
135 + });
136 + if (result._tag === "Failure") return reportScriptFailure(result);
137 + const changedIds = scriptId
138 + ? [scriptId]
139 + : current
140 + .filter((script) => !effectiveScripts.some((next) => next.id === script.id))
141 + .map((script) => script.id);
142 + for (const id of changedIds) {
143 + const command = commandForProjectScript(id);
144 + const previousValue = keybindingValueForCommand(keybindings, command);
145 + const previous = previousValue
146 + ? decodeProjectScriptKeybindingRule({ keybinding: previousValue, command })
147 + : null;
148 + const next = decodeProjectScriptKeybindingRule({ keybinding, command });
149 + const retainedElsewhere =
150 + !nextScripts?.some((script) => script.id === id) &&
151 + ((project && settings.defaultProjectScripts.some((script) => script.id === id)) ||
152 + Object.entries(settings.projectSettingsOverrides).some(
153 + ([projectId, entry]) =>
154 + projectId !== project?.id &&
155 + entry.defaultProjectScripts?.some((script) => script.id === id),
156 + ) ||
157 + projects.some(
158 + (other) =>
159 + other.environmentId === environmentId &&
160 + other.id !== project?.id &&
161 + (project ? resolveProjectScripts(settings, other) : other.scripts).some(
162 + (script) => script.id === id,
163 + ),
164 + ));
165 + const bindingResult = next
166 + ? await upsertKeybinding({
167 + environmentId,
168 + input: previous && previous.key !== next.key ? { ...next, replace: previous } : next,
169 + })
170 + : previous && !retainedElsewhere
171 + ? await removeKeybinding({ environmentId, input: previous })
172 + : null;
173 + if (bindingResult?._tag === "Failure") return reportScriptFailure(bindingResult);
174 + }
175 }
176 + return AsyncResult.success(undefined);
177 }
178
179 function submit(scriptId: string | null, input: NewProjectScriptInput) {