forked from vhaudiquet/rhema-claw
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
268917646e
commit
c56f544993
4 files changed
+30
-159
No files matched your search
+9
-4
@@ -90,6 +90,11 @@ Two consequences worth knowing before changing this code:
|
|||||||
|
|
||||||
## What the transcript does with the stream
|
## What the transcript does with the stream
|
||||||
|
|
||||||
|
- **Replies, asks and files only.** The stream carries tool calls and
|
||||||
|
the model's thinking trace; this surface drops both and renders the
|
||||||
|
reply. A consent card and an attachment card still appear inline,
|
||||||
|
because the reader has to answer or open them. The mirror still
|
||||||
|
folds those other events; only the render ignores them.
|
||||||
- **Long pastes travel as chips.** A paste over three lines (the TUI's
|
- **Long pastes travel as chips.** A paste over three lines (the TUI's
|
||||||
`PASTE_INLINE_LINES`) never lands in the composer; it stages as a
|
`PASTE_INLINE_LINES`) never lands in the composer; it stages as a
|
||||||
droppable chip (`▣1 42L`) and embeds into the sent text as
|
droppable chip (`▣1 42L`) and embeds into the sent text as
|
||||||
@@ -175,10 +180,10 @@ app/
|
|||||||
raw HTML escaped, styles in main.css .md)
|
raw HTML escaped, styles in main.css .md)
|
||||||
ClawBanner.vue the one error/notice banner surface
|
ClawBanner.vue the one error/notice banner surface
|
||||||
ChatPanel.vue transcript: sent lines (paste chips),
|
ChatPanel.vue transcript: sent lines (paste chips),
|
||||||
streamed turns as bash shell lines and
|
streamed turns as reply text plus
|
||||||
glyph rows, consent + attachment
|
consent + attachment cards; the growing
|
||||||
cards; the growing composer; agent
|
composer; agent replies render through
|
||||||
replies render through AppMarkdown
|
AppMarkdown
|
||||||
SessionsSidebar.vue conversable dispatch keys (phone status
|
SessionsSidebar.vue conversable dispatch keys (phone status
|
||||||
keys hidden), interactive first; the
|
keys hidden), interactive first; the
|
||||||
+ form creates a session
|
+ form creates a session
|
||||||
|
|||||||
@@ -136,20 +136,12 @@ watch(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
// Thinking grows inside the trailing entry without changing the
|
// A consent or attachment card opening inside the trailing turn
|
||||||
// entries length, so its total length joins the watch to keep the
|
// changes the rendered height, so the reply length and the entries
|
||||||
// stream pinned at the bottom.
|
// length both join the watch that keeps the stream pinned at the
|
||||||
function liveThinkingLength(): number {
|
// bottom.
|
||||||
return (
|
|
||||||
props.live?.entries.reduce(
|
|
||||||
(count, entry) => (entry.kind === 'thinking' ? count + entry.text.length : count),
|
|
||||||
0,
|
|
||||||
) ?? 0
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
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 () => {
|
async () => {
|
||||||
if (!pinned.value) return
|
if (!pinned.value) return
|
||||||
await nextTick()
|
await nextTick()
|
||||||
@@ -498,7 +490,6 @@ function streamTone(status: StreamStatus): 'ok' | 'warn' | 'error' {
|
|||||||
<div class="who">{{ agentName }}</div>
|
<div class="who">{{ agentName }}</div>
|
||||||
<TurnEntries
|
<TurnEntries
|
||||||
:entries="live.entries"
|
:entries="live.entries"
|
||||||
:open-thinking="true"
|
|
||||||
@consent-answer="(id, answer) => emit('consentAnswer', id, answer)"
|
@consent-answer="(id, answer) => emit('consentAnswer', id, answer)"
|
||||||
@consent-deny="(id) => emit('consentDeny', id)"
|
@consent-deny="(id) => emit('consentDeny', id)"
|
||||||
@download-attachment="(id, name) => emit('downloadAttachment', id, name)"
|
@download-attachment="(id, name) => emit('downloadAttachment', id, name)"
|
||||||
|
|||||||
@@ -1,17 +1,22 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
// A turn's stream-ordered middle: tool rows, pieces of the thinking
|
// The turn's middle, as the web surface shows it: the agent's asks
|
||||||
// trace, the agent's asks, its handovers — each at the position the
|
// (consent cards) and its handovers (attachment cards), each at the
|
||||||
// stream delivered it, so an ask sits at the tool call that raised it
|
// position the stream delivered it. Tool calls and the thinking trace
|
||||||
// and thinking sits between the calls it precedes.
|
// 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 { TurnEntry } from '~/composables/useTranscript'
|
||||||
import type { ConsentAnswer } from '~/composables/useClaw'
|
import type { ConsentAnswer } from '~/composables/useClaw'
|
||||||
|
|
||||||
defineProps<{
|
const props = defineProps<{
|
||||||
entries: TurnEntry[]
|
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<{
|
const emit = defineEmits<{
|
||||||
consentAnswer: [id: string, answer: ConsentAnswer]
|
consentAnswer: [id: string, answer: ConsentAnswer]
|
||||||
consentDeny: [id: string]
|
consentDeny: [id: string]
|
||||||
@@ -20,21 +25,16 @@ const emit = defineEmits<{
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="entries.length > 0" class="entries">
|
<div v-if="cards.length > 0" class="entries">
|
||||||
<template v-for="(entry, index) in entries" :key="index">
|
<template v-for="(entry, index) in cards" :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>
|
|
||||||
<TurnConsentCard
|
<TurnConsentCard
|
||||||
v-else-if="entry.kind === 'consent'"
|
v-if="entry.kind === 'consent'"
|
||||||
:consent="entry.consent"
|
:consent="entry.consent"
|
||||||
@answer="(id, answer) => emit('consentAnswer', id, answer)"
|
@answer="(id, answer) => emit('consentAnswer', id, answer)"
|
||||||
@deny="(id) => emit('consentDeny', id)"
|
@deny="(id) => emit('consentDeny', id)"
|
||||||
/>
|
/>
|
||||||
<TurnAttachmentCard
|
<TurnAttachmentCard
|
||||||
v-else
|
v-else-if="entry.kind === 'attachment'"
|
||||||
:attachment="entry.attachment"
|
:attachment="entry.attachment"
|
||||||
@download="(id, name) => emit('downloadAttachment', id, name)"
|
@download="(id, name) => emit('downloadAttachment', id, name)"
|
||||||
/>
|
/>
|
||||||
@@ -49,27 +49,4 @@ const emit = defineEmits<{
|
|||||||
gap: 4px;
|
gap: 4px;
|
||||||
margin-bottom: 10px;
|
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>
|
</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