Files
archie/ui/src/chat/ChatToolCall.vue
T
sam eb7d852567 refactor(ui/chat): remove chat features the server never sends
The dashboard talks only to the modules/chat API, which sends no slash
commands, model list, voice support, attachments or any question other
than an approval, so the UI built on those could never appear:

- the slash command menu, Retry, Undo, Branch and Preview compression in
  the More menu, and the /model, /update and /new handling
- the model picker, the update card and the api.update* calls
- voice recording and the task tags nothing ever added
- the questionnaire, picker and clarify cards, and the "Always this
  session" answer, so components/ui/questionnaire loses its last user
- channel.ts, command-scroll.ts and turn.ts, which nothing imported
- the old dock-storage migration and the second capitalised spelling of
  message and tool fields

Tasks are gone from the binary too, so chat links and prompts speak of
runs: the #N task-link step in the markdown renderer goes, since an agent
already links pages through dashboard_navigate.

state.ts keeps the shared state and actions; types.ts, stream.ts,
transcript.ts, escape.ts and dock-window.ts hold the types, the stream
reader, turn-to-message building, Escape layers and the dock's pointer
and keyboard handling. ChatDock.vue drops from 560 lines to 307.
2026-11-26 01:59:26 +11:00

84 lines
3.1 KiB
Vue

<script setup lang="ts">
import { CircleCheck, CircleX } from "@lucide/vue";
import { createReusableTemplate } from "@vueuse/core";
import { computed } from "vue";
import { CodeBlock, CodeBlockContent } from "@/components/ui/code-block";
import { Spinner } from "@/components/ui/spinner";
import {
TraceCollapsible,
TraceCollapsibleContent,
TraceCollapsibleTrigger,
TraceIcon,
TraceLine,
TraceTitle,
} from "@/components/ui/trace";
import { duration as formatDuration } from "@/lib/format";
import ChatNavChip from "./ChatNavChip.vue";
import type { ChatToolCall } from "./types";
/**
* One tool call: its name and main argument, with the full parameters and
* output folded away. It is evidence for the reply around it, so it stays dim
* unless the call failed. A failed call opens by default.
*/
const props = defineProps<{
tool: ChatToolCall;
/** The turn is still arriving, so a call with no output yet is running. */
streaming?: boolean;
}>();
const [DefineLine, Line] = createReusableTemplate();
const parameters = computed(() => props.tool.parameters ?? "");
const failed = computed(() => !!props.tool.failed);
const running = computed(() => !props.tool.text && !failed.value && !!props.streaming);
const duration = computed(() => formatDuration(props.tool.duration_ms));
// The line shows the call's main value, such as "git diff --stat" rather than
// its JSON: the first string argument, else the arguments as key: value pairs.
const argument = computed(() => {
try {
const args: unknown = JSON.parse(parameters.value);
if (args && typeof args === "object" && !Array.isArray(args)) {
const first = Object.values(args).find((v) => typeof v === "string" && v);
if (typeof first === "string") return first.split("\n", 1)[0];
return Object.entries(args)
.map(([key, value]) => `${key}: ${typeof value === "object" ? JSON.stringify(value) : value}`)
.join(", ");
}
} catch {
// Truncated or not JSON: show it as it came.
}
return parameters.value.split("\n", 1)[0];
});
const detail = computed(() =>
[parameters.value && `> ${parameters.value}`, props.tool.text].filter(Boolean).join("\n\n"),
);
</script>
<template>
<DefineLine>
<TraceLine :status="failed ? 'error' : running ? 'running' : undefined">
<TraceIcon>
<CircleX v-if="failed" />
<Spinner v-else-if="running" />
<CircleCheck v-else class="text-ok" />
</TraceIcon>
<span class="font-mono text-foreground">{{ tool.name || "tool" }}</span>
<TraceTitle class="font-mono text-caption">{{ argument }}</TraceTitle>
<span v-if="duration" class="shrink-0 text-caption tabular-nums">{{ duration }}</span>
</TraceLine>
</DefineLine>
<ChatNavChip v-if="tool.path" :path="tool.path" :label="tool.label" />
<TraceCollapsible v-else-if="detail" :default-open="failed">
<TraceCollapsibleTrigger><Line /></TraceCollapsibleTrigger>
<TraceCollapsibleContent>
<CodeBlock size="sm">
<CodeBlockContent wrap class="max-h-64">{{ detail }}</CodeBlockContent>
</CodeBlock>
</TraceCollapsibleContent>
</TraceCollapsible>
<Line v-else />
</template>