feat(ui): one chat panel on every page; the workflow editor syncs its draft around a turn
Replaces the separate Build with Archie bar and its per-workflow channel, so every conversation belongs to the account and is listed on every device, and the command palette is the same everywhere.
This commit is contained in:
1 parent
e98f68ecba
commit
99f4eacc2b
9 files changed
+121
-270
No files matched your search
@@ -1,70 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, ref, watch } from "vue";
|
||||
import { ChevronDown, ChevronUp, MessageCirclePlus, Sparkles } from "@lucide/vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { channelID, workflowChannel } from "@/chat/channel";
|
||||
import ChatComposer from "@/chat/ChatComposer.vue";
|
||||
import ChatSessionList from "@/chat/ChatSessionList.vue";
|
||||
import ChatTranscript from "@/chat/ChatTranscript.vue";
|
||||
import { bindChannel, isSending, messages, newChat, setTurnHooks, streamingTurn } from "@/chat/state";
|
||||
|
||||
/**
|
||||
* Archie edits the workflow with the operator, on the same conversation system
|
||||
* as the chat panel. Each workflow has its own conversation, so it opens on that
|
||||
* workflow's history rather than on whatever the operator last asked the panel.
|
||||
* Archie writes the draft; the operator keeps or reverts each change in the
|
||||
* draft review and publishes.
|
||||
*/
|
||||
const props = defineProps<{ workflow: string; beforeSend: () => Promise<void> }>();
|
||||
const emit = defineEmits<{ proposed: []; working: [boolean] }>();
|
||||
|
||||
const expanded = ref(false);
|
||||
const hasConversation = computed(() => messages.value.length > 0 || !!streamingTurn.value);
|
||||
|
||||
watch(
|
||||
() => props.workflow,
|
||||
(workflow) => bindChannel(workflowChannel(workflow)),
|
||||
{ immediate: true },
|
||||
);
|
||||
// Archie works from the saved draft, so pending edits are written first; it may
|
||||
// have written the draft even on a turn that failed later, so it is read after
|
||||
// every turn.
|
||||
setTurnHooks({ before: () => props.beforeSend(), after: () => emit("proposed") });
|
||||
watch(isSending, (value) => {
|
||||
emit("working", value);
|
||||
if (value) expanded.value = true;
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
setTurnHooks({});
|
||||
bindChannel(channelID());
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="pointer-events-auto flex w-full max-w-xl flex-col rounded-lg border border-border bg-popover shadow-[var(--shadow-md)]">
|
||||
<div v-if="hasConversation" class="flex items-center gap-1 border-b px-3 py-2">
|
||||
<Sparkles class="size-4 shrink-0 text-primary" aria-hidden="true" />
|
||||
<ChatSessionList />
|
||||
<Button variant="ghost" size="icon-sm" class="flex-none" title="New chat" aria-label="New chat" @click="newChat">
|
||||
<MessageCirclePlus />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
class="flex-none"
|
||||
:aria-label="expanded ? 'Hide conversation' : 'Show conversation'"
|
||||
:title="expanded ? 'Hide conversation' : 'Show conversation'"
|
||||
:aria-expanded="expanded"
|
||||
@click="expanded = !expanded"
|
||||
>
|
||||
<ChevronDown v-if="expanded" />
|
||||
<ChevronUp v-else />
|
||||
</Button>
|
||||
</div>
|
||||
<div v-if="hasConversation && expanded" class="flex h-[min(20rem,40vh)] min-h-0 flex-col">
|
||||
<ChatTranscript />
|
||||
</div>
|
||||
<ChatComposer :open="false" placeholder="Build with Archie" :class="!hasConversation && 'border-t-0!'" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -8,8 +8,9 @@ import {
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { computed, onBeforeUnmount, ref, watch } from "vue";
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
||||
import { CircleAlert, Ellipsis, RotateCcw, Trash2 } from "@lucide/vue";
|
||||
import { isSending, setTurnHooks } from "@/chat/state";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
@@ -39,7 +40,6 @@ import { useWorkflowHistory } from "./workflow-history";
|
||||
import { revisionOfRun, type WorkflowRevision } from "./workflow-revisions";
|
||||
import { deleteStep, duplicateStep, insertStep, moveStep, normalizeStepIDs, replaceStep, revertWorkflowChange, stepAt, workflowChanges, workflowField, type StepPath } from "./workflow-edit";
|
||||
import ChangeList from "@/components/ChangeList.vue";
|
||||
import ArchieBuilder from "./ArchieBuilder.vue";
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { useWorkflowRuns } from "./workflow-runs";
|
||||
import { useWorkflowTriggers } from "./workflow-triggers";
|
||||
@@ -215,7 +215,9 @@ watch(yaml, (value) => {
|
||||
void persistDraft(edit.target, edit.value);
|
||||
}, 800);
|
||||
});
|
||||
onMounted(() => setTurnHooks({ before: flushDraft, after: () => void takeProposal() }));
|
||||
onBeforeUnmount(() => {
|
||||
setTurnHooks({});
|
||||
clearTimeout(pending);
|
||||
void persistDraft(selected.value, yaml.value);
|
||||
});
|
||||
@@ -226,7 +228,7 @@ async function dropDraft(target: string): Promise<void> {
|
||||
}
|
||||
// Edits made while Archie works would be overwritten by its draft, so the
|
||||
// canvas and YAML go read-only until the turn ends; viewing stays open.
|
||||
const archieWorking = ref(false);
|
||||
const archieWorking = isSending;
|
||||
// Archie works from the saved draft, so pending edits are written first.
|
||||
async function flushDraft(): Promise<void> {
|
||||
clearTimeout(pending);
|
||||
@@ -487,15 +489,6 @@ function syncScroll(event: Event): void {
|
||||
</template>
|
||||
</template>
|
||||
</WorkflowCanvas>
|
||||
<div class="pointer-events-none absolute inset-x-0 bottom-14 z-10 flex justify-center px-3">
|
||||
<ArchieBuilder
|
||||
v-if="selected"
|
||||
:workflow="selected"
|
||||
:before-send="flushDraft"
|
||||
@proposed="takeProposal"
|
||||
@working="(value) => (archieWorking = value)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</TabsContent>
|
||||
<TabsContent value="history" class="max-md:min-h-0 max-md:overflow-y-auto">
|
||||
|
||||
Reference in new issue
Block a user