Skip to content

Open source CapCut alternative.

TypeScript

fix(site): resume a saved chat thread only in the starter project

David Le29bc962517f2
diff --git a/site/src/cut/components/AiPanel.tsx b/site/src/cut/components/AiPanel.tsx
index 5cba2e84..945b19de 100644
--- a/site/src/cut/components/AiPanel.tsx
+++ b/site/src/cut/components/AiPanel.tsx
@@ -88,6 +88,7 @@ import { useCreditsRecheck, useOutOfCredits } from "@/cut/lib/hosted";
import { streamGeminiChat } from "@/cut/lib/geminiChat";
import { AI_MODELS } from "@/cut/lib/aiModels";
import { saveAssetToLibrary } from "@/cut/lib/library";
+import { isStarterProjectId } from "@/cut/lib/starter";
import { formatDuration, useGenScene } from "@/cut/lib/genScene";
import { lightboxItemFromRef, useLightbox } from "@/cut/lib/lightbox";
import { refsFromDroppedFiles } from "@/cut/lib/refMedia";
@@ -276,11 +277,10 @@ export function AiPanel({
let alive = true;
void ensureCloudThreads(projectId).then(() => {
if (!alive) return;
- // First open on this browser: resume the project's newest saved thread
- // instead of a blank chat — for a new account's starter project that is
- // the seeded walkthrough. Set before chatsReady so the session mounts
- // once, on the right thread.
- if (!hadStoredChat) {
+ // The starter project's first open on this browser resumes its newest
+ // saved thread — the seeded walkthrough — instead of a blank chat. Set
+ // before chatsReady so the session mounts once, on the right thread.
+ if (!hadStoredChat && isStarterProjectId(projectId)) {
setActiveChat((cur) => {
const list = readThreads(projectId);
return list.length > 0 && !list.some((t) => t.id === cur) ? list[0].id : cur;
diff --git a/site/src/cut/lib/starter.ts b/site/src/cut/lib/starter.ts
index 1b984ce4..551a7fee 100644
--- a/site/src/cut/lib/starter.ts
+++ b/site/src/cut/lib/starter.ts
@@ -2,3 +2,6 @@
// Its id is derived from the owner, so the seed is idempotent and the client
// can address the project straight from the session without a lookup.
export const starterProjectId = (userId: string) => `starter-${userId}`;
+
+/** Whether an id addresses an account's starter project. */
+export const isStarterProjectId = (id: string) => id.startsWith("starter-");