feat(web/claw): render the reply, not the tool calls or the thinking
The web transcript was built to mirror the TUI: every tool call as a shell line or a glyph row, the thinking trace between them, each at the position the stream delivered it. That is the right shape for a terminal session you sit and watch. On the web it reads as machinery in front of the answer, and the answer is what the page is for. `TurnEntries` now keeps only the two entries the reader must handle: a consent card (the agent is waiting on an answer, so hiding it would stall the turn) and an attachment card (the file it handed over). Everything else in the turn renders as the reply, through `AppMarkdown`. The mirror in `useTranscript` still folds tool and thinking events; only the render ignores them. Replay, the pending-echo dedupe and consent placement keep working unchanged, and the bottom-pin watch loses the thinking-length term it only needed while that block took height. `TurnToolRow` had no other caller and goes with it.
This commit is contained in:
1 parent
3b32e02ebb
commit
6d5de9a574
4 files changed
+30
-159
No files matched your search
@@ -136,20 +136,12 @@ watch(
|
||||
},
|
||||
)
|
||||
|
||||
// Thinking grows inside the trailing entry without changing the
|
||||
// entries length, so its total length joins the watch to keep the
|
||||
// stream pinned at the bottom.
|
||||
function liveThinkingLength(): number {
|
||||
return (
|
||||
props.live?.entries.reduce(
|
||||
(count, entry) => (entry.kind === 'thinking' ? count + entry.text.length : count),
|
||||
0,
|
||||
) ?? 0
|
||||
)
|
||||
}
|
||||
|
||||
// A consent or attachment card opening inside the trailing turn
|
||||
// changes the rendered height, so the reply length and the entries
|
||||
// length both join the watch that keeps the stream pinned at the
|
||||
// bottom.
|
||||
watch(
|
||||
() => [props.items.length, props.live?.reply.length, liveThinkingLength(), props.live?.entries.length],
|
||||
() => [props.items.length, props.live?.reply.length, props.live?.entries.length],
|
||||
async () => {
|
||||
if (!pinned.value) return
|
||||
await nextTick()
|
||||
@@ -498,7 +490,6 @@ function streamTone(status: StreamStatus): 'ok' | 'warn' | 'error' {
|
||||
<div class="who">{{ agentName }}</div>
|
||||
<TurnEntries
|
||||
:entries="live.entries"
|
||||
:open-thinking="true"
|
||||
@consent-answer="(id, answer) => emit('consentAnswer', id, answer)"
|
||||
@consent-deny="(id) => emit('consentDeny', id)"
|
||||
@download-attachment="(id, name) => emit('downloadAttachment', id, name)"
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
// A turn's stream-ordered middle: tool rows, pieces of the thinking
|
||||
// trace, the agent's asks, its handovers — each at the position the
|
||||
// stream delivered it, so an ask sits at the tool call that raised it
|
||||
// and thinking sits between the calls it precedes.
|
||||
// The turn's middle, as the web surface shows it: the agent's asks
|
||||
// (consent cards) and its handovers (attachment cards), each at the
|
||||
// position the stream delivered it. Tool calls and the thinking trace
|
||||
// stay off this surface; the reply is what it shows, and these two
|
||||
// cards are the only things the reader must act on or can open.
|
||||
import { computed } from 'vue'
|
||||
import type { TurnEntry } from '~/composables/useTranscript'
|
||||
import type { ConsentAnswer } from '~/composables/useClaw'
|
||||
|
||||
defineProps<{
|
||||
const props = defineProps<{
|
||||
entries: TurnEntry[]
|
||||
/** A live turn's thinking blocks start expanded; finished ones collapse. */
|
||||
openThinking?: boolean
|
||||
}>()
|
||||
|
||||
/** Cards only: a turn's tool rows and thinking blocks never render. */
|
||||
const cards = computed(() =>
|
||||
props.entries.filter((entry) => entry.kind === 'consent' || entry.kind === 'attachment'),
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
consentAnswer: [id: string, answer: ConsentAnswer]
|
||||
consentDeny: [id: string]
|
||||
@@ -20,21 +25,16 @@ const emit = defineEmits<{
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="entries.length > 0" class="entries">
|
||||
<template v-for="(entry, index) in entries" :key="index">
|
||||
<TurnToolRow v-if="entry.kind === 'tool'" :row="entry.row" />
|
||||
<details v-else-if="entry.kind === 'thinking'" class="thinking" :open="openThinking">
|
||||
<summary>thinking</summary>
|
||||
<pre>{{ entry.text }}</pre>
|
||||
</details>
|
||||
<div v-if="cards.length > 0" class="entries">
|
||||
<template v-for="(entry, index) in cards" :key="index">
|
||||
<TurnConsentCard
|
||||
v-else-if="entry.kind === 'consent'"
|
||||
v-if="entry.kind === 'consent'"
|
||||
:consent="entry.consent"
|
||||
@answer="(id, answer) => emit('consentAnswer', id, answer)"
|
||||
@deny="(id) => emit('consentDeny', id)"
|
||||
/>
|
||||
<TurnAttachmentCard
|
||||
v-else
|
||||
v-else-if="entry.kind === 'attachment'"
|
||||
:attachment="entry.attachment"
|
||||
@download="(id, name) => emit('downloadAttachment', id, name)"
|
||||
/>
|
||||
@@ -49,27 +49,4 @@ const emit = defineEmits<{
|
||||
gap: 4px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.thinking {
|
||||
color: var(--text3);
|
||||
}
|
||||
|
||||
.thinking summary {
|
||||
cursor: pointer;
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.1em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.thinking pre {
|
||||
margin: 6px 0 0;
|
||||
padding: 8px 10px;
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
color: var(--text3);
|
||||
font-style: italic;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
</style>
|
||||
@@ -1,102 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
// One tool call in a turn: running, completed, or failed — shell lines
|
||||
// for bash (the TUI's tool_row), glyph rows for everything else.
|
||||
import type { ToolRow } from '~/composables/useTranscript'
|
||||
|
||||
defineProps<{ row: ToolRow }>()
|
||||
|
||||
/** Command rows render as shell lines, not glyph rows; run_command is
|
||||
* the bash tool's other name. */
|
||||
function isShellTool(name: string): boolean {
|
||||
return name === 'bash' || name === 'run_command'
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="tool-row" :class="{ error: row.isError === true }">
|
||||
<template v-if="isShellTool(row.name)">
|
||||
<span class="shell-mark" aria-hidden="true">$ </span>
|
||||
<span class="shell-command mono">{{ row.command ?? '…' }}</span>
|
||||
<span
|
||||
v-if="typeof row.code === 'number'"
|
||||
class="shell-code mono"
|
||||
:class="row.code === 0 ? 'ok' : 'failed'"
|
||||
>[{{ row.code }}]</span>
|
||||
<span v-else-if="row.isError === true" class="shell-code failed">✗</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="glyph" aria-hidden="true">{{
|
||||
row.isError === null ? '…' : row.isError ? '✗' : '✓'
|
||||
}}</span>
|
||||
<span class="name mono">{{ row.name }}</span>
|
||||
<span v-if="row.summary" class="summary mono">{{ row.summary }}</span>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.tool-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: baseline;
|
||||
padding: 5px 10px;
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-left: 3px solid var(--ok);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.tool-row.error {
|
||||
border-left-color: var(--error);
|
||||
}
|
||||
|
||||
.glyph {
|
||||
flex: none;
|
||||
color: var(--ok);
|
||||
}
|
||||
|
||||
.tool-row.error .glyph {
|
||||
color: var(--error);
|
||||
}
|
||||
|
||||
.name {
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.summary {
|
||||
color: var(--text3);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* A bash row reads as the shell line it ran: dim $ prefix, the
|
||||
command, and the exit code pushed to the row's right end. */
|
||||
.shell-mark {
|
||||
flex: none;
|
||||
color: var(--text3);
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.shell-command {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.shell-code {
|
||||
flex: none;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.shell-code.ok {
|
||||
color: var(--ok);
|
||||
}
|
||||
|
||||
.shell-code.failed {
|
||||
color: var(--error);
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user