diff --git a/src/components/AskDesk.css b/src/components/AskDesk.css
index bb9f616..8d82a1c 100644
--- a/src/components/AskDesk.css
+++ b/src/components/AskDesk.css
@@ -1,121 +1,200 @@
-/* Ask the desk — a panel over the console, not a page of its own. Whoever
- opens it is in the middle of something; it should be dismissible in one
- press and leave the work behind it visible. */
+/* Ask the desk — full screen.
-.desk__scrim {
- position: fixed; inset: 0; z-index: 60;
- background: rgba(11, 42, 91, .32);
- display: flex; justify-content: flex-end;
-}
+ It was a 560px side panel, which was wrong for what the desk actually
+ returns: a timeline of fifteen steps, a table of every stalled lead, a
+ paragraph naming both PAN numbers. Reading those down a gutter while the
+ page behind sat unused was the panel fighting the content. Full screen, one
+ readable column, and the conversation list alongside. */
.desk {
- width: min(560px, 100%); height: 100%;
+ position: fixed; inset: 0; z-index: 60;
display: flex; flex-direction: column;
- background: var(--zk-card);
- border-left: 1px solid var(--zk-line);
- box-shadow: -18px 0 48px rgba(11, 42, 91, .18);
- animation: desk-in .2s var(--ease);
+ background: var(--zk-tint);
+ animation: desk-in .16s var(--ease);
}
-@keyframes desk-in { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
+@keyframes desk-in { from { opacity: .4; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .desk { animation: none; } }
-.desk__head {
- display: flex; align-items: flex-start; gap: 16px;
- padding: 18px 22px 14px; border-bottom: 1px solid var(--zk-line-soft); flex: none;
+/* ── Bar ─────────────────────────────────────────────────────────────────── */
+.desk__bar {
+ flex: none; display: flex; align-items: center; gap: 16px;
+ padding: 12px 22px; background: var(--zk-navy); color: #fff;
}
-.desk__head h2 { margin: 0; font-size: var(--fs-xl); font-weight: 700; color: var(--zk-ink); }
-.desk__head p { margin: 3px 0 0; font-size: var(--fs-xs); color: var(--zk-muted); max-width: 46ch; }
-.desk__x {
- margin-left: auto; flex: none; width: 32px; height: 32px; border-radius: 50%;
- border: 1px solid var(--zk-line); background: #fff; color: var(--zk-muted);
- font-size: 20px; line-height: 1; cursor: pointer;
+.desk__id { min-width: 0; flex: 1; }
+.desk__id h2 { margin: 0; font-size: var(--fs-lg); font-weight: 700; }
+.desk__id p { margin: 2px 0 0; font-size: var(--fs-2xs); opacity: .72; }
+.desk__x, .desk__rails {
+ flex: none; width: 34px; height: 34px; display: grid; place-items: center;
+ border: 0; border-radius: 8px; background: transparent; color: #fff; cursor: pointer;
}
-.desk__x:hover { background: var(--zk-tint); color: var(--zk-ink); }
+.desk__x svg, .desk__rails svg { width: 18px; height: 18px; }
+.desk__x:hover, .desk__rails:hover { background: rgba(255,255,255,.14); }
+.desk__x:focus-visible, .desk__rails:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(255,255,255,.3); }
+.desk__rails { display: none; margin-left: -6px; } /* narrow screens only */
+.desk__new {
+ flex: none; font: inherit; font-size: var(--fs-xs); font-weight: 600; cursor: pointer;
+ padding: 7px 15px; border-radius: var(--r-pill);
+ border: 1px solid rgba(255,255,255,.3); background: transparent; color: #fff;
+}
+.desk__new:hover { background: rgba(255,255,255,.12); }
-.desk__feed {
- flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
- padding: 18px 22px; display: flex; flex-direction: column; gap: 16px;
+/* ── Frame ───────────────────────────────────────────────────────────────── */
+.desk__body { flex: 1; min-height: 0; display: flex; }
+
+.desk__rail {
+ flex: none; width: 260px; background: #fff; border-right: 1px solid var(--zk-line);
+ overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 4px;
+}
+.desk__railh {
+ font-size: var(--fs-3xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
+ color: var(--zk-grey); padding: 4px 8px 8px;
+}
+.desk__railnone { margin: 4px 8px; font-size: var(--fs-2xs); color: var(--zk-grey); line-height: 1.5; }
+.desk__sess {
+ display: block; width: 100%; text-align: left; cursor: pointer;
+ padding: 9px 10px; border-radius: 8px; border: 1px solid transparent; background: transparent;
+ font: inherit; color: var(--zk-ink);
+}
+.desk__sess:hover { background: var(--zk-tint); }
+.desk__sess.is-on { background: var(--zk-tint-blue); border-color: var(--zk-blue-light); }
+.desk__sesst {
+ display: block; font-size: var(--fs-xs); font-weight: 600; line-height: 1.35;
+ overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
+}
+.desk__sessw { display: block; font-size: var(--fs-3xs); color: var(--zk-grey); margin-top: 3px; }
+
+.desk__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
+.desk__feed { flex: 1; min-height: 0; overflow-y: auto; padding: 28px 24px 8px; }
+/* One column, near 70ch, because the answers are prose and prose has a measure. */
+.desk__col { max-width: 760px; margin: 0 auto; }
+
+/* ── Turns ───────────────────────────────────────────────────────────────── */
+.desk__turn { margin-bottom: 26px; }
+.desk__turn--user { display: flex; justify-content: flex-end; }
+.desk__q {
+ margin: 0; max-width: 78%; padding: 11px 16px;
+ border-radius: var(--r-md) var(--r-md) var(--r-xs) var(--r-md);
+ background: var(--zk-navy); color: #fff; font-size: var(--fs-sm); line-height: 1.5;
+}
+.desk__a { font-size: var(--fs-sm); color: var(--zk-ink); }
+.desk__a p { margin: 0 0 11px; line-height: 1.6; }
+.desk__a h4 { margin: 20px 0 8px; font-size: var(--fs-md); font-weight: 700; }
+.desk__a ul, .desk__a ol { margin: 0 0 12px; padding-left: 22px; }
+.desk__a li { margin-bottom: 5px; line-height: 1.55; }
+.desk__a blockquote {
+ margin: 0 0 12px; padding: 9px 15px; border-left: 3px solid var(--zk-amber-bar);
+ background: var(--zk-amber-tint); border-radius: 0 var(--r-sm) var(--r-sm) 0;
+}
+.desk__a code {
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em;
+ background: var(--zk-tint); padding: 1px 5px; border-radius: 4px;
}
-/* Nothing asked yet: say what it is for, and offer four real questions. */
-.desk__empty p { margin: 0 0 12px; font-size: var(--fs-sm); color: var(--zk-muted); }
-.desk__sugg { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
+.desk__tablewrap { overflow-x: auto; margin: 0 0 14px; }
+.desk__a table { border-collapse: collapse; width: 100%; font-size: var(--fs-xs); }
+.desk__a th {
+ text-align: left; font-weight: 600; color: var(--zk-grey); white-space: nowrap;
+ padding: 8px 14px 8px 0; border-bottom: 1px solid var(--zk-line);
+}
+.desk__a td { padding: 8px 14px 8px 0; border-bottom: 1px solid var(--zk-line-soft); }
+.desk__a th:last-child, .desk__a td:last-child { padding-right: 0; text-align: right; font-variant-numeric: tabular-nums; }
+.desk__a tr:last-child td { border-bottom: 0; }
+
+.desk__tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
+.desk__tools span {
+ font-size: var(--fs-3xs); color: var(--zk-muted);
+ background: var(--zk-line-soft); padding: 2px 9px; border-radius: var(--r-pill);
+}
+
+/* ── Empty state ─────────────────────────────────────────────────────────── */
+.desk__empty { padding: 32px 0 8px; }
+.desk__empty h3 { margin: 0 0 6px; font-size: var(--fs-xl); font-weight: 700; color: var(--zk-ink); }
+.desk__empty > p { margin: 0 0 20px; font-size: var(--fs-sm); color: var(--zk-muted); max-width: 60ch; }
+.desk__sugg { display: flex; flex-direction: column; gap: 9px; align-items: flex-start; }
.desk__sugg button {
font: inherit; font-size: var(--fs-xs); text-align: left; cursor: pointer;
- padding: 9px 14px; border-radius: var(--r-sm);
+ padding: 10px 16px; border-radius: var(--r-sm);
border: 1px solid var(--zk-line); background: #fff; color: var(--zk-ink);
}
.desk__sugg button:hover:not(:disabled) { border-color: var(--zk-blue-light); background: var(--zk-tint-blue); color: var(--zk-navy); }
.desk__sugg button:disabled { opacity: .5; cursor: default; }
-.desk__row { display: flex; }
-.desk__row--user { justify-content: flex-end; }
-
-/* The question, as the operator wrote it. */
-.desk__q {
- margin: 0; max-width: 82%;
- padding: 10px 14px; border-radius: var(--r-md) var(--r-md) var(--r-xs) var(--r-md);
- background: var(--zk-navy); color: #fff; font-size: var(--fs-sm); line-height: 1.5;
-}
-
-/* The answer. Left-aligned and unboxed, because it is prose to be read, not a
- message in a chat to be scanned. */
-.desk__a { max-width: 100%; font-size: var(--fs-sm); color: var(--zk-ink); }
-.desk__a p { margin: 0 0 10px; line-height: 1.55; }
-.desk__a h4 { margin: 14px 0 6px; font-size: var(--fs-md); font-weight: 700; }
-.desk__a ul, .desk__a ol { margin: 0 0 10px; padding-left: 20px; }
-.desk__a li { margin-bottom: 5px; line-height: 1.5; }
-.desk__a code {
- font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em;
- background: var(--zk-tint); padding: 1px 5px; border-radius: 4px;
-}
-.desk__a strong { font-weight: 700; }
-
-/* What it actually ran to answer — its working, not just its conclusion. */
-.desk__tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
-.desk__tools span {
- font-size: var(--fs-3xs); color: var(--zk-muted);
- background: var(--zk-line-soft); padding: 2px 8px; border-radius: var(--r-pill);
-}
-
.desk__wait { display: flex; align-items: center; gap: 10px; font-size: var(--fs-xs); color: var(--zk-muted); }
.desk__dots { display: inline-flex; gap: 4px; }
.desk__dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--zk-blue); animation: desk-blink 1.2s infinite; }
.desk__dots i:nth-child(2) { animation-delay: .2s; }
.desk__dots i:nth-child(3) { animation-delay: .4s; }
-@keyframes desk-blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
+@keyframes desk-blink { 0%,60%,100% { opacity: .25; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .desk__dots i { animation: none; opacity: .6; } }
.desk__err {
border: 1px solid var(--zk-danger-line); background: var(--zk-danger-tint);
- border-radius: var(--r-md); padding: 12px 14px; display: flex; flex-direction: column; gap: 3px;
+ border-radius: var(--r-md); padding: 12px 15px; display: flex; flex-direction: column; gap: 3px;
}
.desk__err strong { font-size: var(--fs-sm); color: var(--zk-danger-ink); }
.desk__err span { font-size: var(--fs-2xs); color: var(--zk-muted); }
-.desk__ask {
- flex: none; display: flex; gap: 10px; align-items: flex-end;
- padding: 14px 22px 18px; border-top: 1px solid var(--zk-line-soft); background: #fff;
-}
+/* ── Ask ─────────────────────────────────────────────────────────────────── */
+.desk__ask { flex: none; border-top: 1px solid var(--zk-line); background: #fff; padding: 14px 24px 18px; }
+.desk__askcol { display: flex; gap: 12px; align-items: flex-end; }
.desk__ask textarea {
flex: 1; resize: none; font: inherit; font-size: var(--fs-sm); color: var(--zk-ink);
- padding: 10px 12px; border: 1px solid var(--zk-line); border-radius: var(--r-sm); background: #fff;
+ padding: 12px 14px; border: 1px solid var(--zk-line); border-radius: var(--r-sm);
+ background: #fff; min-height: 46px; max-height: 160px;
}
.desk__ask textarea:focus { outline: none; border-color: var(--zk-blue); box-shadow: var(--ring); }
.desk__ask textarea:disabled { background: var(--zk-tint); color: var(--zk-grey); }
-@media (max-width: 640px) {
- .desk { width: 100%; border-left: 0; }
- .desk__head, .desk__feed, .desk__ask { padding-left: 16px; padding-right: 16px; }
+/* ── Chart drawn from the answer's own table ─────────────────────────────── */
+.dchart {
+ margin: 0 0 14px; padding: 15px 18px;
+ border: 1px solid var(--zk-line); border-radius: var(--r-md); background: #fff;
}
+.dchart__head {
+ display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
+ font-size: var(--fs-3xs); color: var(--zk-grey); margin-bottom: 14px;
+}
+.dchart__toggle { margin-left: auto; display: inline-flex; border: 1px solid var(--zk-line); border-radius: var(--r-pill); overflow: hidden; }
+.dchart__toggle button {
+ font: inherit; font-size: var(--fs-3xs); font-weight: 600; cursor: pointer;
+ padding: 4px 12px; border: 0; background: #fff; color: var(--zk-muted);
+}
+.dchart__toggle button.is-on { background: var(--zk-navy); color: #fff; }
-/* Ask the desk for anything countable and it answers with a table. */
-.desk__tablewrap { overflow-x: auto; margin: 0 0 12px; }
-.desk__a table { border-collapse: collapse; width: 100%; font-size: var(--fs-xs); }
-.desk__a th {
- text-align: left; font-weight: 600; color: var(--zk-grey); white-space: nowrap;
- padding: 7px 12px 7px 0; border-bottom: 1px solid var(--zk-line);
+.dchart__bars { display: flex; flex-direction: column; gap: 8px; }
+.dchart__row { display: grid; grid-template-columns: minmax(96px, 30%) 1fr auto; gap: 12px; align-items: center; }
+.dchart__lab { font-size: var(--fs-2xs); color: var(--zk-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.dchart__track { height: 16px; background: var(--zk-line-soft); border-radius: 3px; overflow: hidden; }
+.dchart__fill { display: block; height: 100%; border-radius: 3px; }
+.dchart__val { font-size: var(--fs-2xs); font-variant-numeric: tabular-nums; color: var(--zk-muted); white-space: nowrap; }
+.dchart__cap { margin: 10px 0 0; font-size: var(--fs-3xs); color: var(--zk-grey); }
+
+.dchart__donut { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
+.dchart__donut svg { width: 160px; height: 160px; flex: none; }
+.dchart__total { font-size: 21px; font-weight: 700; fill: var(--zk-ink); font-variant-numeric: tabular-nums; }
+.dchart__totlab { font-size: 10px; fill: var(--zk-grey); letter-spacing: .06em; text-transform: uppercase; }
+.dchart__key { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 6px; }
+.dchart__key li { display: grid; grid-template-columns: 10px 1fr auto auto; gap: 10px; align-items: center; font-size: var(--fs-2xs); }
+.dchart__sw { width: 10px; height: 10px; border-radius: 2px; }
+.dchart__keylab { color: var(--zk-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.dchart__keyval { color: var(--zk-muted); font-variant-numeric: tabular-nums; }
+.dchart__keypct { color: var(--zk-grey); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
+
+/* ── Narrow ──────────────────────────────────────────────────────────────── */
+@media (max-width: 900px) {
+ .desk__rails { display: grid; }
+ .desk__id p { display: none; }
+ .desk__new { font-size: 0; padding: 8px; }
+ .desk__new::before { content: '+'; font-size: 17px; font-weight: 700; }
+ .desk__rail {
+ position: absolute; top: 58px; bottom: 0; left: 0; z-index: 2;
+ transform: translateX(-100%); transition: transform .18s var(--ease);
+ box-shadow: 8px 0 28px rgba(11,42,91,.14);
+ }
+ .desk__rail.is-open { transform: none; }
+ .desk__body { position: relative; }
+ .desk__feed { padding: 20px 16px 8px; }
+ .desk__ask { padding: 12px 16px 16px; }
+ .dchart__row { grid-template-columns: minmax(72px, 34%) 1fr auto; }
}
-.desk__a td { padding: 7px 12px 7px 0; border-bottom: 1px solid var(--zk-line-soft); }
-.desk__a th:last-child, .desk__a td:last-child { padding-right: 0; text-align: right; font-variant-numeric: tabular-nums; }
-.desk__a tr:last-child td { border-bottom: 0; }
+@media (prefers-reduced-motion: reduce) { .desk__rail { transition: none; } }
diff --git a/src/components/AskDesk.jsx b/src/components/AskDesk.jsx
index aa72756..e934ece 100644
--- a/src/components/AskDesk.jsx
+++ b/src/components/AskDesk.jsx
@@ -1,261 +1,344 @@
-import { useCallback, useEffect, useRef, useState } from 'react'
+import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { SUPPORT_AGENT_ID } from '../api/config.js'
import { useZino } from '../api/provider.jsx'
import { describeError } from '../api/errors.js'
+import DeskChart, { chartableFrom } from './DeskChart.jsx'
import './AskDesk.css'
/**
- * Ask the desk.
+ * Ask the desk — the support desk, full screen.
*
* A support desk on the platform, bound to this app, that reads the deployed
* config and the live book through read-only tools and answers with evidence.
- * It is a different kind of thing from the five AI employees: they DO the work
- * and write to the workflow; this one only reads, and only to answer a person's
- * question. Nothing it says changes a lead.
+ * A different kind of thing from the five AI employees: they DO the work and
+ * write to the workflow; this one only reads, to answer a person's question.
+ * Nothing it says changes a lead.
*
- * The panel is deliberately thin. The desk is an ordinary interactive agent on
- * the platform, so a conversation is a session and a question is a message on
- * it; the console's own token is accepted on those routes as-is.
- *
- * Answers take twenty to forty seconds because it runs real queries first, so
- * the waiting state says what it is doing rather than showing a spinner.
+ * Full screen rather than a side panel, because the answers are long — a
+ * timeline, a table of every stalled lead — and reading them in a 560px gutter
+ * meant scrolling a column while the page behind it sat unused. The
+ * conversation list comes with it: an investigation is worth returning to, and
+ * every conversation opens a ticket on the platform whether or not anyone
+ * reads it back.
*/
const SUGGESTIONS = [
- 'Which leads have not moved in over 12 hours?',
'How many leads are in each stage right now?',
+ 'Which leads have not moved in over 12 hours?',
'What reason did the AI give for each underwriting referral?',
'Total written premium, and how many policies were issued?',
]
-/* The desk answers in markdown. Rather than carry a parser for five features,
- this handles exactly what it uses: headings, bullets, numbered steps, tables,
- bold and inline code. Anything else falls through as text, which is the right
- failure — an unrendered asterisk is legible; a crashed panel is not.
-
- Tables earn their place: asked for anything countable the desk replies with
- one, and rendered as raw pipes a correct answer reads like a broken one. */
+/* ── The desk answers in markdown. This renders the five things it uses:
+ headings, lists, tables, bold and inline code. Anything else falls through
+ as text, which is the right failure — an unrendered asterisk is legible; a
+ crashed panel is not. ── */
function inline(text, key) {
- const parts = String(text).split(/(\*\*[^*]+\*\*|`[^`]+`)/g)
- return parts.map((p, i) => {
+ return String(text).split(/(\*\*[^*]+\*\*|`[^`]+`)/g).map((p, i) => {
if (p.startsWith('**') && p.endsWith('**')) return {p.slice(2, -2)}
if (p.startsWith('`') && p.endsWith('`')) return {p.slice(1, -1)}
return p
})
}
-
-/** `| a | b |` -> ['a','b']; a separator row (`|---|`) has no content. */
const cells = (line) => line.trim().replace(/^\||\|$/g, '').split('|').map((c) => c.trim())
const isRow = (line) => /^\s*\|.*\|\s*$/.test(line)
const isRule = (line) => /^\s*\|[\s:|-]+\|\s*$/.test(line)
-function Rich({ text }) {
+/** Parses one answer into blocks, so a table can be drawn as well as printed. */
+function parse(text) {
const lines = String(text || '').split('\n')
const out = []
let list = null
let rows = null
- const flush = () => {
- if (rows) {
- const [head, ...body] = rows
- out.push(
-
| {inline(c, `h${i}`)} | )}
|---|
| {inline(c, `${ri}-${ci}`)} | )}
{inline(line, i)}
) + flush(); out.push({ t: 'p', text: line }) } }) flush() - return <>{out}> + return out } -/** The tools a turn ran, as chips — the desk's working, not just its answer. */ +function Answer({ text }) { + const blocks = useMemo(() => parse(text), [text]) + // Chart type is per-table and remembered while the answer is on screen. + const [kinds, setKinds] = useState({}) + + return ( + <> + {blocks.map((b, i) => { + if (b.t === 'h') return{inline(b.text, i)}
+ if (b.t === 'quote') return{inline(b.text, i)}+ if (b.t === 'ul') return
| {inline(c, `h${j}`)} | )}
|---|
| {inline(c, `${ri}-${ci}`)} | )}