forked from vhaudiquet/rhema-together
feat(web): add live activity status and collapse turn details
The composer now has one status line for `Rhema is working...` and typing peers. It replaces the separate typing paragraph. A running turn no longer adds a transcript card. When it ends, the log shows a collapsed `rhema finished · N steps` line. Thinking, draft text, tool calls, and usage live inside it. The event replay starts at the oldest loaded message so completed turns rebuild after a reload.
This commit is contained in:
1 parent
36de0aace7
commit
7f494b28de
4 files changed
+122
-82
No files matched your search
@@ -162,20 +162,25 @@ const timeline = computed<TimelineEntry[]>(() => {
|
||||
entries.push({ kind: 'notice', seq: notice.seq, level: notice.level, text: notice.text })
|
||||
}
|
||||
for (const activity of activities.value) {
|
||||
if (activity.status === 'running') continue
|
||||
entries.push({ kind: 'turn', seq: activity.seq, activity })
|
||||
}
|
||||
return entries.sort((a, b) => a.seq - b.seq)
|
||||
})
|
||||
|
||||
const agentWorking = computed(
|
||||
() => streamState.value === 'live' && activities.value.some((activity) => activity.status === 'running'),
|
||||
)
|
||||
|
||||
const typingText = computed(() => {
|
||||
const me = detail.value?.me.id
|
||||
const names = peers.value
|
||||
.filter((peer) => peer.member_id !== me && peer.state?.typing === true)
|
||||
.map((peer) => peer.display_name)
|
||||
if (names.length === 0) return ''
|
||||
if (names.length === 1) return `${names[0]} is typing`
|
||||
if (names.length === 2) return `${names[0]} and ${names[1]} are typing`
|
||||
return 'Several people are typing'
|
||||
if (names.length === 1) return `${names[0]} is typing...`
|
||||
if (names.length === 2) return `${names[0]} and ${names[1]} are typing...`
|
||||
return 'Several people are typing...'
|
||||
})
|
||||
|
||||
function eventData<T>(envelope: Envelope): T {
|
||||
@@ -350,6 +355,7 @@ function handleEnvelope(envelope: Envelope) {
|
||||
const activity = findActivity(data.turn_id)
|
||||
if (!activity) break
|
||||
activity.status = data.status
|
||||
activity.seq = envelope.seq
|
||||
activity.steps = data.steps
|
||||
activity.usage = data.usage
|
||||
if (data.status === 'error') activity.error = data.error ?? 'The turn failed.'
|
||||
@@ -663,7 +669,10 @@ async function loadMessages() {
|
||||
const page = await api.get<MessagePage>(`/rooms/${roomId.value}/messages`, { limit: 60 })
|
||||
for (const message of page.messages) addMessage(message, true)
|
||||
hasMore.value = page.has_more
|
||||
lastDurable = messages.value.reduce((max, message) => Math.max(max, message.seq), 0)
|
||||
// Replay from the oldest loaded message, not the newest: the feed
|
||||
// must also bring the turn_start and tool events that rebuild a
|
||||
// completed turn's summary.
|
||||
lastDurable = messages.value[0]?.seq ?? 0
|
||||
} catch (err) {
|
||||
messagesError.value = apiErrorMessage(err)
|
||||
} finally {
|
||||
@@ -840,9 +849,14 @@ onBeforeUnmount(() => {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p v-if="streamError" class="typing">{{ streamError }}</p>
|
||||
<p v-else-if="streamState === 'disconnected'" class="typing">Reconnecting to live updates.</p>
|
||||
<p v-if="typingText" class="typing">{{ typingText }}</p>
|
||||
<div class="room-status" aria-live="polite">
|
||||
<p v-if="streamError" class="room-status-line room-status-error">{{ streamError }}</p>
|
||||
<p v-else-if="streamState === 'disconnected'" class="room-status-line">
|
||||
Reconnecting to live updates.
|
||||
</p>
|
||||
<p v-if="agentWorking" class="room-status-line">Rhema is working...</p>
|
||||
<p v-if="typingText" class="room-status-line">{{ typingText }}</p>
|
||||
</div>
|
||||
|
||||
<ChatComposer :room-id="roomId" @sent="onSent" @typing="onTyping" />
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user