Skip to content

Commit 74e51eb

Browse files
perf(web): project actions settings compile without manual memoization
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a702563 commit 74e51eb

1 file changed

Lines changed: 29 additions & 36 deletions

File tree

‎apps/web/src/components/settings/ProjectActionsSettings.tsx‎

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from "@t3tools/client-runtime/state/runtime";
88
import { DEFAULT_RESOLVED_KEYBINDINGS } from "@t3tools/shared/keybindings";
99
import { ChevronDownIcon, PlusIcon } from "lucide-react";
10-
import { useCallback, useMemo, useState } from "react";
10+
import { useState } from "react";
1111
import { useT3ProjectFileState } from "../../hooks/useT3ProjectFileScripts";
1212
import { useEnvironments } from "../../state/environments";
1313
import {
@@ -84,43 +84,36 @@ export function ProjectActionsSettings() {
8484
representativeMember?.environmentId ?? EnvironmentId.make("none"),
8585
representativeMember?.workspaceRoot ?? null,
8686
);
87-
const importableScripts = useMemo(
88-
() =>
89-
t3File.scripts.filter(
90-
(fileScript) =>
91-
!scripts.some(
92-
(script) =>
93-
script.command === fileScript.command ||
94-
script.name.toLowerCase() === fileScript.name.toLowerCase(),
95-
),
87+
const importableScripts = t3File.scripts.filter(
88+
(fileScript) =>
89+
!scripts.some(
90+
(script) =>
91+
script.command === fileScript.command ||
92+
script.name.toLowerCase() === fileScript.name.toLowerCase(),
9693
),
97-
[scripts, t3File.scripts],
98-
);
99-
const importFileScript = useCallback(
100-
async (fileScript: T3ProjectFileScript) => {
101-
const payload: NewProjectScriptInput = {
102-
name: fileScript.name,
103-
command: fileScript.command,
104-
icon: fileScript.icon ?? "play",
105-
runOnWorktreeCreate: fileScript.runOnWorktreeCreate ?? false,
106-
waitForSetup: fileScript.runOnWorktreeCreate === true && fileScript.async === false,
107-
runOnSettle: fileScript.runOnSettle ?? false,
108-
keybinding: null,
109-
previewUrl: fileScript.previewUrl ?? null,
110-
autoOpenPreview: fileScript.previewUrl ? (fileScript.autoOpenPreview ?? false) : false,
111-
};
112-
const result = await submit(null, payload);
113-
if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
114-
const error = squashAtomCommandFailure(result);
115-
setRequest({
116-
scriptId: null,
117-
initial: payload,
118-
error: error instanceof Error ? error.message : "Failed to import action.",
119-
});
120-
}
121-
},
122-
[submit],
12394
);
95+
const importFileScript = async (fileScript: T3ProjectFileScript) => {
96+
const payload: NewProjectScriptInput = {
97+
name: fileScript.name,
98+
command: fileScript.command,
99+
icon: fileScript.icon ?? "play",
100+
runOnWorktreeCreate: fileScript.runOnWorktreeCreate ?? false,
101+
waitForSetup: fileScript.runOnWorktreeCreate === true && fileScript.async === false,
102+
runOnSettle: fileScript.runOnSettle ?? false,
103+
keybinding: null,
104+
previewUrl: fileScript.previewUrl ?? null,
105+
autoOpenPreview: fileScript.previewUrl ? (fileScript.autoOpenPreview ?? false) : false,
106+
};
107+
const result = await submit(null, payload);
108+
if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
109+
const error = squashAtomCommandFailure(result);
110+
setRequest({
111+
scriptId: null,
112+
initial: payload,
113+
error: error instanceof Error ? error.message : "Failed to import action.",
114+
});
115+
}
116+
};
124117

125118
return (
126119
<SettingsSection id="project-actions" title="Actions">

0 commit comments

Comments
 (0)