Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions app/components/chat/Artifact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,21 @@ export const Artifact = memo(({ artifactId }: ArtifactProps) => {
const artifacts = useStore(workbenchStore.artifacts);
const artifact = artifacts[artifactId];

const actions = useStore(
computed(artifact.runner.actions, (actions) => {
// Filter out Supabase actions except for migrations
return Object.values(actions).filter((action) => {
// Exclude actions with type 'supabase' or actions that contain 'supabase' in their content
return action.type !== 'supabase' && !(action.type === 'shell' && action.content?.includes('supabase'));
});
}),
/*
* IMPORTANT: computed() must only be created once per component instance.
* Calling it inline recreates the store every render, giving `actions` a new
* reference each time and triggering an infinite useEffect → setState loop.
* useRef guarantees a single creation — safe because each Artifact mounts once
* for a fixed artifactId and artifact.runner never changes for that instance.
*/
const actionsStoreRef = useRef(
computed(artifact.runner.actions, (actions) =>
Object.values(actions).filter(
(action) => action.type !== 'supabase' && !(action.type === 'shell' && action.content?.includes('supabase')),
),
),
);
const actions = useStore(actionsStoreRef.current);

const toggleActions = () => {
userToggledActions.current = true;
Expand All @@ -59,11 +65,14 @@ export const Artifact = memo(({ artifactId }: ArtifactProps) => {
(action) => action.status !== 'complete' && !(action.type === 'start' && action.status === 'running'),
);

if (allActionFinished !== finished) {
setAllActionFinished(finished);
}
/*
* Always call setState — React bails out silently if the value hasn't
* changed, so this is safe and avoids having allActionFinished in deps
* (which would re-trigger this effect every time it updates).
*/
setAllActionFinished(finished);
}
}, [actions, artifact.type, allActionFinished]);
}, [actions, artifact.type]);

// Determine the dynamic title based on state for bundled artifacts
const dynamicTitle =
Expand Down
4 changes: 4 additions & 0 deletions app/components/chat/BaseChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import type { ProgressAnnotation } from '~/types/context';
import { SupabaseChatAlert } from '~/components/chat/SupabaseAlert';
import { expoUrlAtom } from '~/lib/stores/qrCodeStore';
import { useStore } from '@nanostores/react';
import { PromptQueuePanel } from './PromptQueuePanel';
import { LocalLlmPanel } from './LocalLLMPanel';
import { StickToBottom, useStickToBottomContext } from '~/lib/hooks';
import { ChatBox } from './ChatBox';
import type { DesignScheme } from '~/types/design-scheme';
Expand Down Expand Up @@ -469,6 +471,8 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
setSelectedElement={setSelectedElement}
onWebSearchResult={onWebSearchResult}
/>
<LocalLlmPanel />
{chatStarted && <PromptQueuePanel isStreaming={isStreaming} />}
</div>
</StickToBottom>
<div className="flex flex-col justify-center">
Expand Down
Loading
Loading