Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
Fix project action preview settings persistence (#3842)
coach00763b6b44627d6
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsxindex f175a21a1..c296c7170 100644--- a/apps/web/src/components/ChatView.tsx+++ b/apps/web/src/components/ChatView.tsx@@ -145,6 +145,7 @@ import { stackedThreadToast, toastManager } from "./ui/toast";import { decodeProjectScriptKeybindingRule } from "~/lib/projectScriptKeybindings";import { type NewProjectScriptInput } from "./ProjectScriptsControl";import {+ buildProjectScript,commandForProjectScript,nextProjectScriptId,projectScriptIdFromCommand,@@ -2752,13 +2753,7 @@ function ChatViewContent(props: ChatViewProps) {input.name,activeProject.scripts.map((script) => script.id),);- const nextScript: ProjectScript = {- id: nextId,- name: input.name,- command: input.command,- icon: input.icon,- runOnWorktreeCreate: input.runOnWorktreeCreate,- };+ const nextScript = buildProjectScript(nextId, input);const nextScripts = input.runOnWorktreeCreate? [...activeProject.scripts.map((script) =>@@ -2792,13 +2787,7 @@ function ChatViewContent(props: ChatViewProps) {return AsyncResult.failure(Cause.fail(new Error("Script not found.")));}- const updatedScript: ProjectScript = {- ...existingScript,- name: input.name,- command: input.command,- icon: input.icon,- runOnWorktreeCreate: input.runOnWorktreeCreate,- };+ const updatedScript = buildProjectScript(existingScript.id, input);const nextScripts = activeProject.scripts.map((script) =>script.id === scriptId? updatedScriptdiff --git a/apps/web/src/projectScripts.test.ts b/apps/web/src/projectScripts.test.tsindex 3597b714c..1f7a6bfaa 100644--- a/apps/web/src/projectScripts.test.ts+++ b/apps/web/src/projectScripts.test.ts@@ -6,6 +6,7 @@ import {} from "@t3tools/shared/projectScripts";import {+ buildProjectScript,commandForProjectScript,nextProjectScriptId,primaryProjectScript,@@ -13,6 +14,46 @@ import {} from "./projectScripts";describe("projectScripts helpers", () => {+ it("builds scripts with preview settings", () => {+ expect(+ buildProjectScript("dev", {+ name: "Dev server",+ command: "pnpm dev",+ icon: "debug",+ runOnWorktreeCreate: false,+ previewUrl: "http://localhost:5733",+ autoOpenPreview: true,+ }),+ ).toEqual({+ id: "dev",+ name: "Dev server",+ command: "pnpm dev",+ icon: "debug",+ runOnWorktreeCreate: false,+ previewUrl: "http://localhost:5733",+ autoOpenPreview: true,+ });+ });++ it("omits preview settings when no preview URL is configured", () => {+ expect(+ buildProjectScript("test", {+ name: "Test",+ command: "pnpm test",+ icon: "test",+ runOnWorktreeCreate: false,+ previewUrl: null,+ autoOpenPreview: false,+ }),+ ).toEqual({+ id: "test",+ name: "Test",+ command: "pnpm test",+ icon: "test",+ runOnWorktreeCreate: false,+ });+ });+it("builds and parses script run commands", () => {const command = commandForProjectScript("lint");expect(command).toBe("script.lint.run");diff --git a/apps/web/src/projectScripts.ts b/apps/web/src/projectScripts.tsindex f0aeead14..e3efc9e3a 100644--- a/apps/web/src/projectScripts.ts+++ b/apps/web/src/projectScripts.ts@@ -7,6 +7,31 @@ import {import * as Schema from "effect/Schema";const isScriptRunCommand = Schema.is(SCRIPT_RUN_COMMAND_PATTERN);+export interface ProjectScriptInput {+ readonly name: ProjectScript["name"];+ readonly command: ProjectScript["command"];+ readonly icon: ProjectScript["icon"];+ readonly runOnWorktreeCreate: ProjectScript["runOnWorktreeCreate"];+ readonly previewUrl: Exclude<ProjectScript["previewUrl"], undefined> | null;+ readonly autoOpenPreview: boolean;+}++export function buildProjectScript(id: string, input: ProjectScriptInput): ProjectScript {+ return {+ id,+ name: input.name,+ command: input.command,+ icon: input.icon,+ runOnWorktreeCreate: input.runOnWorktreeCreate,+ ...(input.previewUrl === null+ ? {}+ : {+ previewUrl: input.previewUrl,+ autoOpenPreview: input.autoOpenPreview,+ }),+ };+}+function normalizeScriptId(value: string): string {const cleaned = value.trim()