my-durable 0.0.122 → 0.0.123
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-BA08BJIS.js +89 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-CRIWe4u0.css +1 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/index.html +2 -2
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/esc-stop.ts +30 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/find.ts +147 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/paste.ts +95 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/quote.ts +67 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/AgentView.vue +213 -2
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/Composer.vue +125 -7
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/FindOverlay.vue +234 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/TranscriptItem.vue +18 -1
- package/package.json +1 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-DD66rPUN.css +0 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-DgGnG9bL.js +0 -83
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed, nextTick, ref, watch } from "vue";
|
|
2
|
+
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
|
3
3
|
import {
|
|
4
4
|
Activity,
|
|
5
5
|
ArrowUpRight,
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
GitFork,
|
|
13
13
|
MessageSquare,
|
|
14
14
|
Pencil,
|
|
15
|
+
Reply,
|
|
16
|
+
Search,
|
|
15
17
|
} from "lucide-vue-next";
|
|
16
18
|
import type { AgentSummary } from "@sdk/api";
|
|
17
19
|
import { lineage } from "@sdk/models";
|
|
@@ -19,12 +21,15 @@ import TranscriptItem from "./TranscriptItem.vue";
|
|
|
19
21
|
import DeviceIcon from "./DeviceIcon.vue";
|
|
20
22
|
import GitChip from "./GitChip.vue";
|
|
21
23
|
import Composer from "./Composer.vue";
|
|
24
|
+
import FindOverlay from "./FindOverlay.vue";
|
|
22
25
|
import {
|
|
23
26
|
activeLineage,
|
|
24
27
|
agent,
|
|
25
28
|
agentHandle,
|
|
26
29
|
agentState,
|
|
30
|
+
busy,
|
|
27
31
|
device,
|
|
32
|
+
interrupt,
|
|
28
33
|
notify,
|
|
29
34
|
preset,
|
|
30
35
|
select,
|
|
@@ -35,6 +40,9 @@ import {
|
|
|
35
40
|
layout,
|
|
36
41
|
ui,
|
|
37
42
|
} from "../client/store";
|
|
43
|
+
import { useReplyQuote } from "../client/quote";
|
|
44
|
+
import { pickAssistantReply } from "../client/find";
|
|
45
|
+
import { decideEscStop } from "../client/esc-stop";
|
|
38
46
|
|
|
39
47
|
const chat = ref<HTMLElement>();
|
|
40
48
|
const lineageNav = ref<HTMLElement>();
|
|
@@ -147,6 +155,149 @@ watch(
|
|
|
147
155
|
() => lineageNav.value && (lineageNav.value.scrollLeft = lineageNav.value.scrollWidth),
|
|
148
156
|
),
|
|
149
157
|
);
|
|
158
|
+
|
|
159
|
+
// --------------------------------------------- R16 view features (Unit B)
|
|
160
|
+
// Find-in-session, reply-to-passage and Esc-Esc stop. The pure pieces live in
|
|
161
|
+
// client/find.ts and client/esc-stop.ts; only the DOM wiring is here.
|
|
162
|
+
|
|
163
|
+
const findOpen = ref(false);
|
|
164
|
+
const replyQuote = useReplyQuote();
|
|
165
|
+
const replyTarget = ref<{
|
|
166
|
+
x: number;
|
|
167
|
+
y: number;
|
|
168
|
+
below: boolean;
|
|
169
|
+
excerpt: string;
|
|
170
|
+
label: string;
|
|
171
|
+
} | null>(null);
|
|
172
|
+
let lastEscAt: number | null = null;
|
|
173
|
+
|
|
174
|
+
const cssEscape = (value: string): string =>
|
|
175
|
+
typeof CSS !== "undefined" && CSS.escape
|
|
176
|
+
? CSS.escape(value)
|
|
177
|
+
: value.replace(/[^a-zA-Z0-9_-]/g, "\\$&");
|
|
178
|
+
|
|
179
|
+
/** The data-entry-id of the transcript entry a DOM node sits in, if any. */
|
|
180
|
+
const entryIdOf = (node: Node | null): string | null =>
|
|
181
|
+
(node instanceof Element ? node : (node?.parentElement ?? null))
|
|
182
|
+
?.closest("[data-entry-id]")
|
|
183
|
+
?.getAttribute("data-entry-id") ?? null;
|
|
184
|
+
|
|
185
|
+
/** Selection → Reply: float a Reply chip when the selection lies inside
|
|
186
|
+
* exactly one assistant reply. The decision itself is pure (client/find.ts). */
|
|
187
|
+
function refreshSelection() {
|
|
188
|
+
replyTarget.value = null;
|
|
189
|
+
const sel = window.getSelection();
|
|
190
|
+
if (!sel || sel.isCollapsed || !sel.rangeCount || !chat.value) return;
|
|
191
|
+
const target = pickAssistantReply(
|
|
192
|
+
items.value.map((i) => ({ id: i.id, role: i.kind })),
|
|
193
|
+
{
|
|
194
|
+
anchorId: entryIdOf(sel.anchorNode),
|
|
195
|
+
focusId: entryIdOf(sel.focusNode),
|
|
196
|
+
text: sel.toString(),
|
|
197
|
+
},
|
|
198
|
+
);
|
|
199
|
+
if (!target) return;
|
|
200
|
+
const rect = sel.getRangeAt(0).getBoundingClientRect();
|
|
201
|
+
const below = window.matchMedia?.("(pointer: coarse)")?.matches ?? false; // touch: chip under the selection
|
|
202
|
+
replyTarget.value = {
|
|
203
|
+
x: Math.min(Math.max(rect.left, 8), Math.max(8, window.innerWidth - 176)),
|
|
204
|
+
y: below ? rect.bottom + 8 : rect.top - 52,
|
|
205
|
+
below,
|
|
206
|
+
excerpt: target.excerpt,
|
|
207
|
+
label: target.label,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function quoteSelection() {
|
|
211
|
+
const target = replyTarget.value;
|
|
212
|
+
if (!target) return;
|
|
213
|
+
replyQuote.setQuote(target.excerpt, target.label); // Unit A's pinned contract
|
|
214
|
+
replyTarget.value = null;
|
|
215
|
+
window.getSelection()?.removeAllRanges();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** Find result → center the entry and flash it for 1.5s (TranscriptItem's
|
|
219
|
+
* .flash hook owns the animation; this only toggles the class). */
|
|
220
|
+
const flashTimers = new WeakMap<Element, number>();
|
|
221
|
+
function jumpToEntry(entryId: string | number) {
|
|
222
|
+
findOpen.value = false;
|
|
223
|
+
void nextTick(() => {
|
|
224
|
+
const el = chat.value?.querySelector(`[data-entry-id="${cssEscape(String(entryId))}"]`);
|
|
225
|
+
if (!el) return;
|
|
226
|
+
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
227
|
+
el.classList.remove("flash");
|
|
228
|
+
void (el as HTMLElement).offsetWidth; // restart the animation on repeat jumps
|
|
229
|
+
el.classList.add("flash");
|
|
230
|
+
window.clearTimeout(flashTimers.get(el));
|
|
231
|
+
flashTimers.set(el, window.setTimeout(() => el.classList.remove("flash"), 1500));
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** Keep an owned Escape away from every other listener (App.vue's keydown
|
|
236
|
+
* still single-Esc-interrupts a busy turn — the policy must run first). */
|
|
237
|
+
const consume = (e: KeyboardEvent) => {
|
|
238
|
+
e.preventDefault();
|
|
239
|
+
e.stopImmediatePropagation();
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
/** Ctrl/⌘+F opens Find even while the composer is focused; Escape runs the
|
|
243
|
+
* esc-stop policy. Registered in the CAPTURE phase on purpose: capture on
|
|
244
|
+
* document fires before App.vue's bubble listener, which is the only way a
|
|
245
|
+
* lone Escape can be kept from stopping a turn without touching App.vue.
|
|
246
|
+
* Dialogs stay App.vue's — we defer the moment ui.dialog is set. */
|
|
247
|
+
function onKeydown(e: KeyboardEvent) {
|
|
248
|
+
if (
|
|
249
|
+
(e.ctrlKey || e.metaKey) &&
|
|
250
|
+
!e.altKey &&
|
|
251
|
+
!e.shiftKey &&
|
|
252
|
+
(e.code === "KeyF" || e.key === "f" || e.key === "F")
|
|
253
|
+
) {
|
|
254
|
+
e.preventDefault(); // keep the browser's find bar out of the way
|
|
255
|
+
findOpen.value = true;
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (e.key !== "Escape" || e.isComposing || ui.dialog) return;
|
|
259
|
+
const action = decideEscStop({
|
|
260
|
+
dialogOpen: false,
|
|
261
|
+
overlayOpen: findOpen.value,
|
|
262
|
+
quoteOpen: !!replyQuote.quoted,
|
|
263
|
+
busy: busy.value,
|
|
264
|
+
now: Date.now(),
|
|
265
|
+
lastEscAt,
|
|
266
|
+
});
|
|
267
|
+
if (action === "close-overlay") {
|
|
268
|
+
consume(e);
|
|
269
|
+
findOpen.value = false;
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (action === "clear-strip") {
|
|
273
|
+
consume(e);
|
|
274
|
+
replyQuote.clear();
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
if (action === "stop") {
|
|
278
|
+
consume(e);
|
|
279
|
+
lastEscAt = null;
|
|
280
|
+
void interrupt(); // the store's own stop path — no new stop function
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (busy.value) {
|
|
284
|
+
// First Escape of a possible double: remember it, and keep it away from
|
|
285
|
+
// App.vue's legacy single-Esc interrupt — one press never stops a turn.
|
|
286
|
+
consume(e);
|
|
287
|
+
if (!e.repeat) lastEscAt = Date.now();
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
lastEscAt = null; // no turn running: this Escape belongs to the chrome
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
onMounted(() => {
|
|
294
|
+
document.addEventListener("keydown", onKeydown, true);
|
|
295
|
+
document.addEventListener("selectionchange", refreshSelection);
|
|
296
|
+
});
|
|
297
|
+
onBeforeUnmount(() => {
|
|
298
|
+
document.removeEventListener("keydown", onKeydown, true);
|
|
299
|
+
document.removeEventListener("selectionchange", refreshSelection);
|
|
300
|
+
});
|
|
150
301
|
</script>
|
|
151
302
|
|
|
152
303
|
<template>
|
|
@@ -213,6 +364,14 @@ watch(
|
|
|
213
364
|
>
|
|
214
365
|
<Pencil :size="18" />
|
|
215
366
|
</button>
|
|
367
|
+
<button
|
|
368
|
+
class="icon-button find-button"
|
|
369
|
+
aria-label="Find in session"
|
|
370
|
+
title="Find in session (Ctrl/⌘+F)"
|
|
371
|
+
@click="findOpen = true"
|
|
372
|
+
>
|
|
373
|
+
<Search :size="18" />
|
|
374
|
+
</button>
|
|
216
375
|
<button
|
|
217
376
|
class="icon-button conversation-menu-toggle"
|
|
218
377
|
aria-label="Browse conversations"
|
|
@@ -290,7 +449,13 @@ watch(
|
|
|
290
449
|
Retry stream
|
|
291
450
|
</button>
|
|
292
451
|
</div>
|
|
293
|
-
<div
|
|
452
|
+
<div
|
|
453
|
+
ref="chat"
|
|
454
|
+
class="chat-scroll"
|
|
455
|
+
data-testid="chat"
|
|
456
|
+
@mouseup="refreshSelection"
|
|
457
|
+
@scroll.passive="replyTarget = null"
|
|
458
|
+
>
|
|
294
459
|
<div v-if="!agentState.ready" class="chat-empty">
|
|
295
460
|
<Activity :size="30" />
|
|
296
461
|
<h2 v-if="agent.status.value === 'fault'">This agent is unavailable.</h2>
|
|
@@ -339,6 +504,52 @@ watch(
|
|
|
339
504
|
<p v-for="(n, i) in agentState.notices" :key="i" class="message-error">{{ n }}</p>
|
|
340
505
|
</template>
|
|
341
506
|
</div>
|
|
507
|
+
<button
|
|
508
|
+
v-if="replyTarget"
|
|
509
|
+
class="reply-quote-chip"
|
|
510
|
+
:class="{ below: replyTarget.below }"
|
|
511
|
+
:style="{ left: `${replyTarget.x}px`, top: `${replyTarget.y}px` }"
|
|
512
|
+
:aria-label="`Reply quoting ${replyTarget.label}`"
|
|
513
|
+
:title="replyTarget.label"
|
|
514
|
+
@mousedown.prevent
|
|
515
|
+
@click="quoteSelection"
|
|
516
|
+
>
|
|
517
|
+
<Reply :size="16" aria-hidden="true" />Reply
|
|
518
|
+
</button>
|
|
342
519
|
<Composer />
|
|
520
|
+
<FindOverlay v-if="findOpen" :items="items" @close="findOpen = false" @jump="jumpToEntry" />
|
|
343
521
|
</section>
|
|
344
522
|
</template>
|
|
523
|
+
|
|
524
|
+
<style scoped>
|
|
525
|
+
/* R16 (Unit B): the Find affordance keeps the toolbar's icon size but grows
|
|
526
|
+
* its touch target to ≥44px — mobile-safe, no hover dependency. */
|
|
527
|
+
.find-button {
|
|
528
|
+
position: relative;
|
|
529
|
+
}
|
|
530
|
+
.find-button::after {
|
|
531
|
+
content: "";
|
|
532
|
+
position: absolute;
|
|
533
|
+
inset: -0.5rem;
|
|
534
|
+
}
|
|
535
|
+
.reply-quote-chip {
|
|
536
|
+
position: fixed;
|
|
537
|
+
z-index: 40;
|
|
538
|
+
display: inline-flex;
|
|
539
|
+
align-items: center;
|
|
540
|
+
gap: 0.375rem;
|
|
541
|
+
min-height: 2.75rem; /* ≥44px target */
|
|
542
|
+
padding: 0 0.875rem;
|
|
543
|
+
border: 1px solid var(--line);
|
|
544
|
+
border-radius: var(--radius);
|
|
545
|
+
background: var(--card);
|
|
546
|
+
color: var(--fg);
|
|
547
|
+
font: inherit;
|
|
548
|
+
font-size: 0.875rem;
|
|
549
|
+
box-shadow: 0 0.375rem 1rem color-mix(in oklab, var(--bg) 70%, transparent);
|
|
550
|
+
cursor: pointer;
|
|
551
|
+
}
|
|
552
|
+
.reply-quote-chip:hover {
|
|
553
|
+
border-color: color-mix(in oklab, var(--accent) 55%, transparent);
|
|
554
|
+
}
|
|
555
|
+
</style>
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed, ref, watch } from "vue";
|
|
3
|
-
import { ArrowUp, ChevronDown, Clock3, LibraryBig, Octagon, Trash2, X } from "lucide-vue-next";
|
|
2
|
+
import { computed, nextTick, ref, watch } from "vue";
|
|
3
|
+
import { ArrowUp, ChevronDown, Clock3, LibraryBig, Octagon, Quote, Trash2, X } from "lucide-vue-next";
|
|
4
4
|
import type { WhenBusy } from "@sdk/api";
|
|
5
5
|
import { newId } from "../client/ids";
|
|
6
6
|
import { commands, parseCommand, type SlashCommand } from "../client/commands";
|
|
7
|
+
import { buildQuotedMessage, useReplyQuote } from "../client/quote";
|
|
8
|
+
import {
|
|
9
|
+
addPaste,
|
|
10
|
+
createPasteStore,
|
|
11
|
+
expandPastes,
|
|
12
|
+
insertPlaceholder,
|
|
13
|
+
oneLineExcerpt,
|
|
14
|
+
shouldFoldPaste,
|
|
15
|
+
} from "../client/paste";
|
|
7
16
|
import {
|
|
8
17
|
agent,
|
|
9
18
|
agentHandle,
|
|
@@ -47,6 +56,14 @@ const dropSnippet = (name: string) => {
|
|
|
47
56
|
snippets.value = snippets.value.filter((p) => p.name !== name);
|
|
48
57
|
saveSnippets();
|
|
49
58
|
};
|
|
59
|
+
// R16 reply-to-passage: Unit B's transcript selection sets the quote through
|
|
60
|
+
// the same composable; the strip here shows it and send() folds it in.
|
|
61
|
+
const replyQuote = useReplyQuote();
|
|
62
|
+
const quoteSrc = computed(() => oneLineExcerpt(replyQuote.quoted?.srcLabel ?? "", 80));
|
|
63
|
+
const quoteExcerpt = computed(() => oneLineExcerpt(replyQuote.quoted?.text ?? "", 120));
|
|
64
|
+
// R16 long pastes: >20 lines become a placeholder token; full text waits here.
|
|
65
|
+
const pastes = createPasteStore();
|
|
66
|
+
|
|
50
67
|
const pending = ref(false);
|
|
51
68
|
const canSend = computed(
|
|
52
69
|
() =>
|
|
@@ -84,6 +101,14 @@ async function pick(command: SlashCommand, enter = false) {
|
|
|
84
101
|
}
|
|
85
102
|
function keydown(e: KeyboardEvent) {
|
|
86
103
|
if (!matches.value.length) {
|
|
104
|
+
// R16: with the reply strip up, Escape clears only the strip — and must
|
|
105
|
+
// not reach the document Esc listeners (interrupt et al).
|
|
106
|
+
if (e.key === "Escape" && replyQuote.quoted) {
|
|
107
|
+
e.preventDefault();
|
|
108
|
+
e.stopPropagation();
|
|
109
|
+
replyQuote.clear();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
87
112
|
if (e.key === "Enter" && !e.shiftKey && !e.isComposing) {
|
|
88
113
|
e.preventDefault();
|
|
89
114
|
void send();
|
|
@@ -113,9 +138,36 @@ async function runCommand(text: string) {
|
|
|
113
138
|
return true;
|
|
114
139
|
}
|
|
115
140
|
|
|
141
|
+
// A paste longer than 20 lines never floods the composer: prevent the
|
|
142
|
+
// default insertion, drop the placeholder token at the caret instead.
|
|
143
|
+
function onPaste(e: ClipboardEvent) {
|
|
144
|
+
const text = e.clipboardData?.getData("text/plain") ?? "";
|
|
145
|
+
if (!shouldFoldPaste(text)) return;
|
|
146
|
+
e.preventDefault();
|
|
147
|
+
const ta = e.currentTarget as HTMLTextAreaElement;
|
|
148
|
+
const { text: next, caret } = insertPlaceholder(
|
|
149
|
+
ui.composer,
|
|
150
|
+
addPaste(pastes, text),
|
|
151
|
+
ta.selectionStart ?? ui.composer.length,
|
|
152
|
+
ta.selectionEnd ?? ui.composer.length,
|
|
153
|
+
);
|
|
154
|
+
ui.composer = next;
|
|
155
|
+
void nextTick(() => {
|
|
156
|
+
ta.focus();
|
|
157
|
+
ta.setSelectionRange(caret, caret);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
116
161
|
// A retried send (same agent, text and mode) reuses its requestId, so the device admits it once.
|
|
117
162
|
async function send() {
|
|
118
|
-
|
|
163
|
+
// R16: long-paste placeholders unfold (full text back in place) before the
|
|
164
|
+
// trim; a quoted reply folds in as a leading blockquote — but a slash
|
|
165
|
+
// command stays verbatim (expansion only, never quoted).
|
|
166
|
+
const expanded = expandPastes(ui.composer, pastes);
|
|
167
|
+
const userText = expanded.trim();
|
|
168
|
+
const quoted = replyQuote.quoted;
|
|
169
|
+
const content =
|
|
170
|
+
userText.startsWith("/") || !quoted ? userText : buildQuotedMessage(quoted, expanded).trim();
|
|
119
171
|
const handle = agentHandle.value;
|
|
120
172
|
if (!content || pending.value || !handle || !canSend.value) return;
|
|
121
173
|
if (content.startsWith("/") && (await runCommand(content))) return;
|
|
@@ -130,14 +182,20 @@ async function send() {
|
|
|
130
182
|
saved?.key === key && saved.content === content && saved.mode === mode.value
|
|
131
183
|
? saved.requestId
|
|
132
184
|
: newId();
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
185
|
+
try {
|
|
186
|
+
sessionStorage.setItem(
|
|
187
|
+
"dpi.pending-send",
|
|
188
|
+
JSON.stringify({ key, content, mode: mode.value, requestId }),
|
|
189
|
+
);
|
|
190
|
+
} catch {
|
|
191
|
+
// R16: an expanded long paste can exceed the storage quota — losing the
|
|
192
|
+
// retry-id reuse is fine, the send itself proceeds.
|
|
193
|
+
}
|
|
137
194
|
await attempt(async () => {
|
|
138
195
|
await handle.send(content, mode.value, requestId);
|
|
139
196
|
sessionStorage.removeItem("dpi.pending-send");
|
|
140
197
|
ui.composer = "";
|
|
198
|
+
replyQuote.clear(); // the quote went out with this message
|
|
141
199
|
});
|
|
142
200
|
pending.value = false;
|
|
143
201
|
}
|
|
@@ -165,6 +223,21 @@ function withdraw(id: number) {
|
|
|
165
223
|
</div>
|
|
166
224
|
</div>
|
|
167
225
|
<div class="composer">
|
|
226
|
+
<!-- R16: quoted passage awaiting the reply. Esc (below) or × clears it. -->
|
|
227
|
+
<div v-if="replyQuote.quoted" class="reply-strip">
|
|
228
|
+
<Quote :size="14" aria-hidden="true" />
|
|
229
|
+
<span class="src">{{ quoteSrc }}</span>
|
|
230
|
+
<span class="excerpt">“{{ quoteExcerpt }}”</span>
|
|
231
|
+
<button
|
|
232
|
+
type="button"
|
|
233
|
+
class="clear"
|
|
234
|
+
aria-label="Clear quoted reply"
|
|
235
|
+
title="Clear quoted reply"
|
|
236
|
+
@click="replyQuote.clear()"
|
|
237
|
+
>
|
|
238
|
+
<X :size="16" />
|
|
239
|
+
</button>
|
|
240
|
+
</div>
|
|
168
241
|
<ul v-if="matches.length" class="slash-menu" role="listbox" aria-label="Slash commands">
|
|
169
242
|
<li
|
|
170
243
|
v-for="(c, i) in matches"
|
|
@@ -185,6 +258,7 @@ function withdraw(id: number) {
|
|
|
185
258
|
placeholder="Give your agent something to do, or type / for commands…"
|
|
186
259
|
aria-label="Message your agent"
|
|
187
260
|
@keydown="keydown"
|
|
261
|
+
@paste="onPaste"
|
|
188
262
|
/>
|
|
189
263
|
<div class="composer-toolbar">
|
|
190
264
|
<div class="composer-left">
|
|
@@ -255,6 +329,50 @@ function withdraw(id: number) {
|
|
|
255
329
|
</template>
|
|
256
330
|
|
|
257
331
|
<style scoped>
|
|
332
|
+
/* R16 reply strip: same var palette as the rest of the composer; the clear
|
|
333
|
+
button keeps a 44px touch target (min 2.75rem) and is always visible. */
|
|
334
|
+
.reply-strip {
|
|
335
|
+
display: flex;
|
|
336
|
+
align-items: center;
|
|
337
|
+
gap: 0.5rem;
|
|
338
|
+
margin: 0.5rem 0.75rem 0;
|
|
339
|
+
padding: 0.25rem 0.125rem 0.25rem 0.75rem;
|
|
340
|
+
border: 1px solid var(--line);
|
|
341
|
+
border-left: 0.1875rem solid var(--accent);
|
|
342
|
+
border-radius: 0.5rem;
|
|
343
|
+
background: color-mix(in oklab, var(--accent) 7%, var(--card));
|
|
344
|
+
}
|
|
345
|
+
.reply-strip .src {
|
|
346
|
+
font-weight: 600;
|
|
347
|
+
font-size: 0.75rem;
|
|
348
|
+
white-space: nowrap;
|
|
349
|
+
}
|
|
350
|
+
.reply-strip .excerpt {
|
|
351
|
+
flex: 1;
|
|
352
|
+
min-width: 0;
|
|
353
|
+
overflow: hidden;
|
|
354
|
+
white-space: nowrap;
|
|
355
|
+
text-overflow: ellipsis;
|
|
356
|
+
font-size: 0.8125rem;
|
|
357
|
+
color: var(--secondary);
|
|
358
|
+
}
|
|
359
|
+
.reply-strip .clear {
|
|
360
|
+
flex: none;
|
|
361
|
+
display: inline-flex;
|
|
362
|
+
align-items: center;
|
|
363
|
+
justify-content: center;
|
|
364
|
+
min-width: 2.75rem;
|
|
365
|
+
min-height: 2.75rem;
|
|
366
|
+
background: none;
|
|
367
|
+
border: none;
|
|
368
|
+
border-radius: 0.375rem;
|
|
369
|
+
cursor: pointer;
|
|
370
|
+
color: inherit;
|
|
371
|
+
}
|
|
372
|
+
.reply-strip .clear:hover,
|
|
373
|
+
.reply-strip .clear:focus-visible {
|
|
374
|
+
background: color-mix(in oklab, var(--accent) 18%, transparent);
|
|
375
|
+
}
|
|
258
376
|
.lib-wrap { position: relative; }
|
|
259
377
|
.lib {
|
|
260
378
|
position: absolute; bottom: calc(100% + 0.5rem); left: 0; z-index: 70; width: 18.75rem; max-height: 16.25rem;
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// R16 find-in-session (Unit B): newest-first search over the loaded
|
|
3
|
+
// transcript. The pure search lives in client/find.ts; this overlay only
|
|
4
|
+
// debounces input (150ms), renders hits with a role badge + one-line
|
|
5
|
+
// excerpt, and navigates with ↑↓/Enter. Escape is deliberately NOT handled
|
|
6
|
+
// here — AgentView's document keydown runs the esc-stop policy, so the
|
|
7
|
+
// overlay closes first and an Escape never leaks into a stop.
|
|
8
|
+
import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
|
9
|
+
import { Search, X } from "lucide-vue-next";
|
|
10
|
+
import type { TranscriptItem } from "@sdk/transcript";
|
|
11
|
+
import { MAX_FIND_RESULTS, searchTranscript, type SearchHit } from "../client/find";
|
|
12
|
+
|
|
13
|
+
const props = defineProps<{ items: readonly TranscriptItem[] }>();
|
|
14
|
+
const emit = defineEmits<{ close: []; jump: [entryId: string | number] }>();
|
|
15
|
+
|
|
16
|
+
const FIND_DEBOUNCE_MS = 150;
|
|
17
|
+
|
|
18
|
+
const query = ref("");
|
|
19
|
+
/** The query actually searched — lags `query` by the debounce. */
|
|
20
|
+
const applied = ref("");
|
|
21
|
+
const results = ref<SearchHit[]>([]);
|
|
22
|
+
const active = ref(0);
|
|
23
|
+
const input = ref<HTMLInputElement>();
|
|
24
|
+
let debounce: number | undefined;
|
|
25
|
+
|
|
26
|
+
function run() {
|
|
27
|
+
results.value = searchTranscript(props.items, applied.value);
|
|
28
|
+
active.value = 0;
|
|
29
|
+
}
|
|
30
|
+
function onInput() {
|
|
31
|
+
window.clearTimeout(debounce);
|
|
32
|
+
debounce = window.setTimeout(() => {
|
|
33
|
+
applied.value = query.value;
|
|
34
|
+
run();
|
|
35
|
+
}, FIND_DEBOUNCE_MS);
|
|
36
|
+
}
|
|
37
|
+
// The transcript keeps streaming while the overlay is open — refresh in place.
|
|
38
|
+
watch(
|
|
39
|
+
() => props.items,
|
|
40
|
+
() => run(),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
function move(delta: number) {
|
|
44
|
+
if (!results.value.length) return;
|
|
45
|
+
active.value = (active.value + delta + results.value.length) % results.value.length;
|
|
46
|
+
}
|
|
47
|
+
function go(hit: SearchHit) {
|
|
48
|
+
emit("jump", hit.itemId);
|
|
49
|
+
emit("close");
|
|
50
|
+
}
|
|
51
|
+
function onKey(e: KeyboardEvent) {
|
|
52
|
+
if (e.key === "ArrowDown") {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
move(1);
|
|
55
|
+
} else if (e.key === "ArrowUp") {
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
move(-1);
|
|
58
|
+
} else if (e.key === "Enter") {
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
const hit = results.value[active.value];
|
|
61
|
+
if (hit) go(hit);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const ROLE_LABEL: Record<string, string> = {
|
|
66
|
+
user: "YOU",
|
|
67
|
+
assistant: "AGENT",
|
|
68
|
+
"tool-result": "TOOL",
|
|
69
|
+
event: "EVENT",
|
|
70
|
+
tool: "TOOL",
|
|
71
|
+
};
|
|
72
|
+
const roleOf = (itemId: string | number): string => {
|
|
73
|
+
const kind = props.items.find((i) => String(i.id) === String(itemId))?.kind ?? "event";
|
|
74
|
+
return ROLE_LABEL[kind] ?? "EVENT";
|
|
75
|
+
};
|
|
76
|
+
const count = computed(() => {
|
|
77
|
+
if (!applied.value.trim()) return "";
|
|
78
|
+
return results.value.length
|
|
79
|
+
? `${results.value.length}${results.value.length >= MAX_FIND_RESULTS ? "+" : ""} matches`
|
|
80
|
+
: "no matches";
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
onMounted(() => input.value?.focus());
|
|
84
|
+
onBeforeUnmount(() => window.clearTimeout(debounce));
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
<template>
|
|
88
|
+
<div class="find-backdrop" data-testid="find-overlay" @click.self="emit('close')">
|
|
89
|
+
<section class="find-overlay" role="dialog" aria-label="Find in session">
|
|
90
|
+
<header class="find-bar">
|
|
91
|
+
<Search :size="18" aria-hidden="true" />
|
|
92
|
+
<input
|
|
93
|
+
ref="input"
|
|
94
|
+
v-model="query"
|
|
95
|
+
type="text"
|
|
96
|
+
placeholder="Find in session…"
|
|
97
|
+
aria-label="Find in session"
|
|
98
|
+
autocomplete="off"
|
|
99
|
+
spellcheck="false"
|
|
100
|
+
@input="onInput"
|
|
101
|
+
@keydown="onKey"
|
|
102
|
+
/>
|
|
103
|
+
<span class="find-count" aria-live="polite">{{ count }}</span>
|
|
104
|
+
<button class="icon-button find-close" aria-label="Close find" @click="emit('close')">
|
|
105
|
+
<X :size="18" />
|
|
106
|
+
</button>
|
|
107
|
+
</header>
|
|
108
|
+
<ul v-if="applied.trim()" class="find-results" aria-label="Find results">
|
|
109
|
+
<li v-if="!results.length" class="find-empty">No matches in this session.</li>
|
|
110
|
+
<li v-for="(hit, i) in results" :key="`${String(hit.itemId)}:${hit.index}`">
|
|
111
|
+
<button
|
|
112
|
+
class="find-result"
|
|
113
|
+
:class="{ active: i === active }"
|
|
114
|
+
role="option"
|
|
115
|
+
:aria-selected="i === active"
|
|
116
|
+
@click="go(hit)"
|
|
117
|
+
@pointermove="active = i"
|
|
118
|
+
>
|
|
119
|
+
<span class="find-role" :data-role="roleOf(hit.itemId)">{{ roleOf(hit.itemId) }}</span>
|
|
120
|
+
<span class="find-excerpt">{{ hit.excerpt }}</span>
|
|
121
|
+
</button>
|
|
122
|
+
</li>
|
|
123
|
+
</ul>
|
|
124
|
+
</section>
|
|
125
|
+
</div>
|
|
126
|
+
</template>
|
|
127
|
+
|
|
128
|
+
<style scoped>
|
|
129
|
+
.find-backdrop {
|
|
130
|
+
position: fixed;
|
|
131
|
+
inset: 0;
|
|
132
|
+
z-index: 90; /* session chrome; modals stay above (100) */
|
|
133
|
+
display: flex;
|
|
134
|
+
justify-content: center;
|
|
135
|
+
align-items: flex-start;
|
|
136
|
+
padding: 4.5rem 1rem 1rem;
|
|
137
|
+
background: color-mix(in oklab, var(--bg) 55%, transparent);
|
|
138
|
+
}
|
|
139
|
+
.find-overlay {
|
|
140
|
+
width: min(34rem, 100%);
|
|
141
|
+
max-height: min(26rem, 70vh);
|
|
142
|
+
display: flex;
|
|
143
|
+
flex-direction: column;
|
|
144
|
+
overflow: hidden;
|
|
145
|
+
border: 1px solid var(--line);
|
|
146
|
+
border-radius: var(--radius);
|
|
147
|
+
background: var(--card);
|
|
148
|
+
box-shadow: 0 1.25rem 2.5rem color-mix(in oklab, var(--bg) 80%, transparent);
|
|
149
|
+
}
|
|
150
|
+
.find-bar {
|
|
151
|
+
flex: none;
|
|
152
|
+
display: flex;
|
|
153
|
+
align-items: center;
|
|
154
|
+
gap: 0.5rem;
|
|
155
|
+
padding: 0.5rem 0.625rem;
|
|
156
|
+
border-bottom: 1px solid var(--line);
|
|
157
|
+
color: var(--secondary);
|
|
158
|
+
}
|
|
159
|
+
.find-bar input {
|
|
160
|
+
flex: 1;
|
|
161
|
+
min-width: 0;
|
|
162
|
+
min-height: 2.75rem; /* ≥44px target, and it is the primary keyboard surface */
|
|
163
|
+
border: none;
|
|
164
|
+
background: transparent;
|
|
165
|
+
color: var(--fg);
|
|
166
|
+
font: inherit;
|
|
167
|
+
}
|
|
168
|
+
.find-bar input:focus {
|
|
169
|
+
outline: none;
|
|
170
|
+
}
|
|
171
|
+
.find-count {
|
|
172
|
+
flex: none;
|
|
173
|
+
font-size: 0.75rem;
|
|
174
|
+
color: var(--faint);
|
|
175
|
+
white-space: nowrap;
|
|
176
|
+
}
|
|
177
|
+
.find-close {
|
|
178
|
+
flex: none;
|
|
179
|
+
}
|
|
180
|
+
.find-results {
|
|
181
|
+
margin: 0;
|
|
182
|
+
padding: 0.25rem;
|
|
183
|
+
list-style: none;
|
|
184
|
+
overflow-y: auto;
|
|
185
|
+
}
|
|
186
|
+
.find-empty {
|
|
187
|
+
padding: 1rem;
|
|
188
|
+
color: var(--faint);
|
|
189
|
+
font-size: 0.875rem;
|
|
190
|
+
}
|
|
191
|
+
.find-result {
|
|
192
|
+
display: flex;
|
|
193
|
+
align-items: center;
|
|
194
|
+
gap: 0.625rem;
|
|
195
|
+
width: 100%;
|
|
196
|
+
min-height: 2.75rem; /* ≥44px touch target — no hover dependency */
|
|
197
|
+
padding: 0.375rem 0.625rem;
|
|
198
|
+
border: none;
|
|
199
|
+
border-radius: var(--radius-sm);
|
|
200
|
+
background: transparent;
|
|
201
|
+
color: var(--fg);
|
|
202
|
+
font: inherit;
|
|
203
|
+
text-align: left;
|
|
204
|
+
cursor: pointer;
|
|
205
|
+
}
|
|
206
|
+
.find-result.active {
|
|
207
|
+
background: color-mix(in oklab, var(--accent) 18%, transparent);
|
|
208
|
+
}
|
|
209
|
+
.find-role {
|
|
210
|
+
flex: none;
|
|
211
|
+
min-width: 3.25rem;
|
|
212
|
+
padding: 0.125rem 0.375rem;
|
|
213
|
+
border: 1px solid var(--line);
|
|
214
|
+
border-radius: 0.625rem;
|
|
215
|
+
font-size: 0.6875rem;
|
|
216
|
+
letter-spacing: 0.06em;
|
|
217
|
+
color: var(--secondary);
|
|
218
|
+
text-align: center;
|
|
219
|
+
}
|
|
220
|
+
.find-role[data-role="AGENT"] {
|
|
221
|
+
color: var(--accent);
|
|
222
|
+
border-color: color-mix(in oklab, var(--accent) 45%, transparent);
|
|
223
|
+
}
|
|
224
|
+
.find-excerpt {
|
|
225
|
+
flex: 1;
|
|
226
|
+
min-width: 0;
|
|
227
|
+
overflow: hidden;
|
|
228
|
+
text-overflow: ellipsis;
|
|
229
|
+
white-space: nowrap;
|
|
230
|
+
font-family: var(--font-mono);
|
|
231
|
+
font-size: 0.8125rem;
|
|
232
|
+
color: var(--fg);
|
|
233
|
+
}
|
|
234
|
+
</style>
|