Skip to content
Merged
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
25 changes: 17 additions & 8 deletions apps/app/src/components/plugin/PluginComposerActions.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
setPluginSlotRegistrations,
type PluginRegistrationSet,
} from "@/lib/plugin-slots";
import { useComposer } from "@/lib/plugin-sdk-hooks";
import { setPluginThreadRowStatus } from "@/lib/plugin-thread-row-status";
import type { PromptDraftState } from "@/lib/prompt-draft";
import {
ThreadRow,
Expand Down Expand Up @@ -139,34 +139,43 @@ function OverflowFixture() {
}

function ThreadRowStatusAction() {
const { setThreadRowStatus } = useComposer();
const statusOwner = useMemo(() => Symbol("thread-row-status-story"), []);
const [status, setStatus] = useState<
"running" | "success" | "error" | "clear"
>("running");
useEffect(() => {
const setStatusForThread = (
nextStatus: Parameters<typeof setPluginThreadRowStatus>[2],
) =>
setPluginThreadRowStatus(
THREAD_ID,
"story-thread-row-status",
nextStatus,
statusOwner,
);
if (status === "running") {
setThreadRowStatus({
setStatusForThread({
icon: "Zap",
label: "Plugin running",
tone: "running",
});
} else if (status === "success") {
setThreadRowStatus({
setStatusForThread({
icon: "Check",
label: "Plugin completed",
tone: "success",
});
} else if (status === "error") {
setThreadRowStatus({
setStatusForThread({
icon: "AlertCircle",
label: "Plugin failed",
tone: "error",
});
} else {
setThreadRowStatus(null);
setStatusForThread(null);
}
return () => setThreadRowStatus(null);
}, [setThreadRowStatus, status]);
return () => setStatusForThread(null);
}, [status, statusOwner]);

return (
<div className="flex items-center gap-0.5">
Expand Down
2 changes: 0 additions & 2 deletions apps/app/src/components/plugin/plugin-composer-host.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export interface PluginComposerHost {
scope: PluginComposerScope;
draft: PromptDraftState;
textEffectKey: string;
/** Visible thread row decorated by plugin status, when it differs from scope. */
threadRowStatusThreadId?: string | null;
getCurrent(): PromptDraftState;
setDraft(next: PromptDraftState): void;
focus(): void;
Expand Down
Loading
Loading