fix(webui): make chat a FAB-opened panel and stop the topbar clipping
Four P0 defects from the frontend audit, plus the one-line theme fix that was
making every one of them look worse.
Chat is a floating launcher and the panel it opens, not a route
(archie-core-yuvg, archie-core-hesx). /chat rendered an empty page with a
drawer over it, and that drawer hosted the full-page chat workspace: a page
title, a conversations column, a four-control action row and a command-help
column, all inside 440px. Measured at 1440x900, .chat-workspace was 174px wide
holding 270px of content and the composer ran off the viewport.
- The Chat nav entry, the /chat route and the topbar chat icon are gone;
the launcher is the single way in.
- The panel anchors to the launcher and opens leftward from it, sharing its
bottom edge, so the button never moves. No scrim and no scroll lock: the
page stays readable and clickable, which is the point of asking Archie
about the page you are on.
- Conversations became a switcher in a compact bar; personality, provider
and model moved into a disclosure beside it; the empty state and composer
dropped to panel type scale.
- The launcher renders outside .shell because .shell's backdrop-filter is a
containing block for fixed positioning, which otherwise pinned the button
to the scrolling shell instead of the viewport.
- Update-check, Dangerous actions and Reload Telegram left the panel; their
api.* calls are untouched for the rehome to Configuration
(archie-core-tf20).
The topbar no longer clips its utility cluster (archie-core-mkb3). brand, nav
and topbar-end were all flex:none with no wrap above 1220px, and .app sets
overflow:hidden, so between 1221px and ~1582px the avatar, theme toggle and
documentation button were cut off with no way to reach them. The nav is now
the one region allowed to shrink, the search collapses to its icon below
1500px, and the nav wraps to its own row below 1270px where it stops fitting.
Live activity clamps its detail column (archie-core-qo7f). An agent_finish
payload rendered raw turned one row into six viewports and the dashboard into
7,481px. The cell shows the first meaningful line; the full text stays on the
title.
color-scheme is bound to the active theme (archie-core-nm0y), so scrollbars
and native controls stop rendering light inside the dark UI.
This commit is contained in:
1 parent
5baeadd85e
commit
1422dc5955
15 files changed
+729
-465
No files matched your search
+129
-21
@@ -1,8 +1,120 @@
|
||||
.chat-page-content { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden; }
|
||||
.chat-topbar { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
|
||||
.chat-kicker, .chat-workspace-label { color: var(--fg-muted); font-size: .68rem; font-weight: 700; letter-spacing: .12em; }
|
||||
.chat-topbar-actions { display: flex; align-items: center; gap: .55rem; }
|
||||
.chat-topbar-actions .chat-select { max-width: 14rem; min-width: 0; }
|
||||
/* The panel's own column. ChatApp is mounted in a ~440px launcher panel, never
|
||||
on a page, so there is one column and every row earns its height
|
||||
(archie-core-hesx). */
|
||||
.chat-panel-content {
|
||||
display: grid;
|
||||
grid-template-rows: auto minmax(0, 1fr);
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* One row for everything that is not the conversation: which conversation,
|
||||
a new one, and the model controls folded away behind a disclosure. */
|
||||
.chat-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
padding: var(--sp-2) var(--sp-3);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.chat-session-switch {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.chat-session-switch select {
|
||||
width: 100%;
|
||||
background: var(--surface-hover);
|
||||
color: var(--fg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: var(--sp-2);
|
||||
font: inherit;
|
||||
font-size: var(--text-sm);
|
||||
}
|
||||
|
||||
.chat-new,
|
||||
.chat-settings > summary {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.chat-settings {
|
||||
position: relative;
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.chat-settings > summary {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--fg-muted);
|
||||
cursor: pointer;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.chat-settings > summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.chat-settings > summary:hover {
|
||||
background: var(--surface-hover);
|
||||
color: var(--fg);
|
||||
}
|
||||
|
||||
/* Opens over the transcript rather than pushing it down: the panel is short
|
||||
and the conversation should not jump when the controls are consulted. */
|
||||
.chat-settings-body {
|
||||
position: absolute;
|
||||
top: calc(100% + var(--sp-2));
|
||||
right: 0;
|
||||
z-index: 2;
|
||||
display: grid;
|
||||
gap: var(--sp-3);
|
||||
width: 15rem;
|
||||
padding: var(--sp-3);
|
||||
background: var(--bg-raised);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-md);
|
||||
box-shadow: var(--shadow-md);
|
||||
}
|
||||
|
||||
.chat-settings-body label {
|
||||
display: grid;
|
||||
gap: var(--sp-1);
|
||||
font-size: var(--text-xs);
|
||||
color: var(--fg-muted);
|
||||
}
|
||||
|
||||
.chat-settings-body .chat-select {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.chat-layout {
|
||||
display: grid;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.chat-workspace {
|
||||
display: grid;
|
||||
grid-template-rows: auto minmax(0, 1fr) auto;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.chat-workspace-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
padding: var(--sp-2) var(--sp-3);
|
||||
border-bottom: 1px solid var(--border);
|
||||
font-size: var(--text-xs);
|
||||
}
|
||||
|
||||
.chat-update-panel { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 0 .75rem; padding: .7rem .9rem; border: 1px solid var(--border); border-radius: .75rem; color: var(--fg-muted); font-size: .8rem; }
|
||||
.chat-update-panel > div:first-child { display: grid; gap: .2rem; }
|
||||
.chat-update-panel strong { color: var(--fg); }
|
||||
@@ -15,27 +127,21 @@
|
||||
.chat-dangerous-input { min-width: 0; flex: 1; padding: .5rem .65rem; background: var(--surface-hover); color: var(--fg); border: 1px solid var(--border-strong); border-radius: .5rem; font: inherit; }
|
||||
.chat-dangerous-pending-list { display: grid; gap: .45rem; margin-top: .75rem; }
|
||||
.chat-dangerous-pending { padding-top: .55rem; border-top: 1px solid var(--border); color: var(--fg-muted); font-size: .8rem; }
|
||||
.chat-layout { display: grid; grid-template-columns: 242px minmax(0, 1fr); gap: .75rem; flex: 1 1 auto; min-height: 0; overflow: hidden; }
|
||||
.chat-sidebar, .chat-workspace { background: var(--surface); border: 1px solid var(--border); border-radius: 1rem; }
|
||||
.chat-sidebar { padding: .8rem; overflow-y: auto; }
|
||||
.chat-sidebar-head, .chat-toolbar, .chat-compose-actions { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
|
||||
.chat-session-list { display: grid; gap: .35rem; margin-top: 1rem; }
|
||||
.chat-session { display: grid; gap: .25rem; text-align: left; background: transparent; color: var(--fg-muted); border: 1px solid transparent; border-radius: .65rem; padding: .7rem; cursor: pointer; }
|
||||
.chat-session:hover, .chat-session.active { background: var(--surface-hover); color: var(--fg); border-color: var(--border-strong); }
|
||||
.chat-session span { font-size: .72rem; }
|
||||
.chat-workspace { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; min-width: 0; }
|
||||
.chat-workspace-head { display: flex; align-items: center; justify-content: space-between; padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); }
|
||||
.chat-session-tools { position: relative; margin-left: .6rem; color: var(--fg-muted); font-size: .78rem; }
|
||||
.chat-session-tools summary { cursor: pointer; }
|
||||
.chat-session-tool-list { position: absolute; z-index: 2; right: 0; top: calc(100% + .45rem); display: flex; flex-wrap: wrap; gap: .35rem; width: min(22rem, 72vw); padding: .55rem; background: var(--surface); border: 1px solid var(--border-strong); border-radius: .65rem; box-shadow: 0 .7rem 2rem color-mix(in srgb, #000 30%, transparent); }
|
||||
.chat-select { background: var(--surface-hover); color: var(--fg); border: 1px solid var(--border-strong); border-radius: .5rem; padding: .5rem .65rem; }
|
||||
.chat-transcript { overflow: auto; padding: 1.25rem; display: grid; align-content: start; gap: 1rem; }
|
||||
.chat-empty-state { align-self: center; justify-self: center; width: min(100%, 40rem); padding: 3rem 1rem; text-align: center; }
|
||||
.chat-empty-mark { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; margin: 0 auto 1rem; border: 1px solid var(--border-strong); border-radius: .8rem; color: var(--accent); font-weight: 700; }
|
||||
.chat-empty-state h2 { margin: 0; font-size: clamp(1.5rem, 3vw, 2.25rem); letter-spacing: -.04em; }
|
||||
.chat-empty-state p { margin: .6rem 0 1.4rem; color: var(--fg-muted); }
|
||||
.chat-prompt-grid { display: flex; justify-content: center; flex-wrap: wrap; gap: .5rem; }
|
||||
.chat-prompt { padding: .55rem .75rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-hover); color: var(--fg-muted); cursor: pointer; }
|
||||
.chat-transcript { overflow: auto; padding: var(--sp-4); display: grid; align-content: start; gap: var(--sp-4); }
|
||||
.chat-empty-state { align-self: center; justify-self: center; width: 100%; padding: var(--sp-5) 0; text-align: center; }
|
||||
.chat-empty-mark { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; margin: 0 auto var(--sp-3); border: 1px solid var(--border-strong); border-radius: .8rem; color: var(--accent); font-weight: 700; }
|
||||
.chat-empty-state h2 { margin: 0; font-size: var(--text-lg); letter-spacing: -.02em; }
|
||||
.chat-empty-state p { margin: var(--sp-2) 0 var(--sp-4); color: var(--fg-muted); font-size: var(--text-sm); }
|
||||
.chat-prompt-grid { display: grid; gap: var(--sp-2); }
|
||||
.chat-prompt { padding: var(--sp-2) var(--sp-3); font-size: var(--text-sm); text-align: left; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-hover); color: var(--fg-muted); cursor: pointer; }
|
||||
.chat-prompt:hover { color: var(--fg); border-color: var(--border-strong); }
|
||||
.chat-bubble-row { display: flex; }
|
||||
.chat-bubble-row.user { justify-content: flex-end; }
|
||||
@@ -96,7 +202,7 @@
|
||||
}
|
||||
.chat-nav-chip-icon { font-size: .8rem; line-height: 1; }
|
||||
|
||||
.chat-compose { padding: .85rem 1rem 1rem; border-top: 1px solid var(--border); }
|
||||
.chat-compose { padding: var(--sp-3); border-top: 1px solid var(--border); }
|
||||
.chat-composer-shell { position: relative; padding: .7rem .8rem .55rem; background: var(--surface-hover); border: 1px solid var(--border-strong); border-radius: .9rem; }
|
||||
.chat-composer { width: 100%; min-height: 3.3rem; resize: vertical; box-sizing: border-box; background: transparent; color: var(--fg); border: 0; padding: .25rem 0; font: inherit; }
|
||||
.chat-composer:focus { outline: 0; }
|
||||
@@ -105,12 +211,14 @@
|
||||
.chat-command-option { display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr; gap: .65rem; align-items: center; padding: .5rem .6rem; text-align: left; color: var(--fg-muted); background: transparent; border: 1px solid transparent; border-radius: .45rem; cursor: pointer; }
|
||||
.chat-command-option:hover, .chat-command-option[aria-selected="true"] { color: var(--fg); background: var(--surface-hover); border-color: var(--border); }
|
||||
.chat-command-option code { color: var(--fg); }
|
||||
.chat-compose-actions { margin-top: .55rem; }
|
||||
/* The hint takes the whole first row so Stop and Send always sit together on
|
||||
the second, rather than the hint pushing Send onto a line of its own. */
|
||||
.chat-compose-actions { margin-top: var(--sp-2); flex-wrap: wrap; row-gap: var(--sp-2); justify-content: flex-end; }
|
||||
.chat-compose-actions .chat-hint { flex: 1 0 100%; font-size: var(--text-xs); color: var(--fg-muted); }
|
||||
.chat-hint, .chat-empty { color: var(--fg-muted); font-size: .78rem; }
|
||||
.chat-command-help { color: var(--fg-muted); font-size: .78rem; margin-right: auto; }
|
||||
.chat-command-help summary { cursor: pointer; }
|
||||
.chat-command-list { min-width: min(34rem, 70vw); max-width: 40rem; padding-top: .4rem; line-height: 1.45; }
|
||||
.chat-command-item { display: grid; grid-template-columns: minmax(10rem, 16rem) 1fr; gap: .7rem; padding: .3rem 0; }
|
||||
.chat-command-item code { color: var(--fg); }
|
||||
@media (max-width: 760px) { .chat-topbar, .chat-topbar-actions { align-items: flex-start; flex-direction: column; } .chat-layout { grid-template-columns: 1fr; } .chat-sidebar { max-height: 14rem; overflow: auto; } }
|
||||
@media (max-width: 520px) { .chat-update-panel { align-items: flex-start; flex-direction: column; } }
|
||||
+71
-282
@@ -5,7 +5,6 @@ import { ChatMarkdown } from "./markdown.jsx";
|
||||
import { channelID } from "./chat-state.jsx";
|
||||
import { newChatTurn, retryChatTurn, resolveTurn } from "./chat-retry.jsx";
|
||||
import { sessionTitle } from "./chat-render.jsx";
|
||||
import { updateUnavailableMessage } from "./chat-update-status.jsx";
|
||||
|
||||
import "./chat.css";
|
||||
|
||||
@@ -31,13 +30,6 @@ export function ChatApp() {
|
||||
const [commandSelection, setCommandSelection] = useState(0);
|
||||
const [isCommandMenuOpen, setIsCommandMenuOpen] = useState(false);
|
||||
|
||||
const [updateData, setUpdateData] = useState(null);
|
||||
const [updateSnapshot, setUpdateSnapshot] = useState(null);
|
||||
|
||||
const [dangerousData, setDangerousData] = useState(null);
|
||||
const [dangerousCheckpoint, setDangerousCheckpoint] = useState("");
|
||||
const [dangerousStopSpec, setDangerousStopSpec] = useState("");
|
||||
|
||||
const [streamingTurn, setStreamingTurn] = useState(null);
|
||||
// streamingTurn: { text: string, tools: [], isError: bool, turn: object, isRetry: bool }
|
||||
|
||||
@@ -60,7 +52,6 @@ export function ChatApp() {
|
||||
refreshSessions().catch((err) => {
|
||||
setStatusText(err.message || "Chat unavailable");
|
||||
});
|
||||
refreshUpdate();
|
||||
|
||||
const onTeardown = () => {
|
||||
activeControllerRef.current?.abort();
|
||||
@@ -72,75 +63,6 @@ export function ChatApp() {
|
||||
};
|
||||
}, []);
|
||||
|
||||
async function refreshUpdate() {
|
||||
try {
|
||||
const data = await api.chatUpdate();
|
||||
setUpdateSnapshot(data?.snapshot || null);
|
||||
setUpdateData(data);
|
||||
} catch (err) {
|
||||
const message = updateUnavailableMessage(err);
|
||||
if (message) {
|
||||
setUpdateData({ error: message });
|
||||
} else {
|
||||
setUpdateData(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function deferUpdate() {
|
||||
if (!updateSnapshot) return;
|
||||
try {
|
||||
await api.chatUpdateDefer(updateSnapshot);
|
||||
setUpdateData({ snapshot: { deferred: true }, available: [] });
|
||||
setStatusText("Update deferred");
|
||||
} catch (err) {
|
||||
setStatusText(err.message || "Could not defer update");
|
||||
}
|
||||
}
|
||||
|
||||
async function installUpdate() {
|
||||
if (!updateSnapshot) return;
|
||||
try {
|
||||
setStatusText("Installing…");
|
||||
const result = await api.chatUpdateInstall(updateSnapshot);
|
||||
setUpdateSnapshot(null);
|
||||
setUpdateData({ snapshot: {}, available: [] });
|
||||
setStatusText(result?.result?.restart_requested ? "Update installed; restart queued" : "Update complete");
|
||||
} catch (err) {
|
||||
setStatusText(err.message || "Update install failed");
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshDangerous() {
|
||||
try {
|
||||
const data = await api.chatDangerous();
|
||||
setDangerousData(data);
|
||||
} catch (err) {
|
||||
setDangerousData({ error: err.message || "Dangerous actions unavailable" });
|
||||
}
|
||||
}
|
||||
|
||||
async function requestDangerousAction(kind, spec) {
|
||||
if (!spec) return;
|
||||
try {
|
||||
await api.chatDangerousRequest(kind, spec);
|
||||
setStatusText("Approval requested");
|
||||
await refreshDangerous();
|
||||
} catch (err) {
|
||||
setStatusText(err.message || "Could not request action");
|
||||
}
|
||||
}
|
||||
|
||||
async function decideDangerousAction(id, decision) {
|
||||
try {
|
||||
await api.chatDangerousDecision(id, decision);
|
||||
setStatusText(decision === "deny" ? "Action denied" : "Action approved");
|
||||
await refreshDangerous();
|
||||
} catch (err) {
|
||||
setStatusText(err.message || "Approval failed");
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshSessions() {
|
||||
const data = await api.chatSessions();
|
||||
const sessionList = data.sessions || [];
|
||||
@@ -158,10 +80,6 @@ export function ChatApp() {
|
||||
);
|
||||
setCommandSpecs(specs);
|
||||
|
||||
if (data.dangerous_available) {
|
||||
await refreshDangerous();
|
||||
}
|
||||
|
||||
if (!currentSession && sessionList[0]) {
|
||||
await selectSession(sessionList[0].session_id, data, sessionList);
|
||||
}
|
||||
@@ -258,12 +176,6 @@ export function ChatApp() {
|
||||
}
|
||||
}
|
||||
|
||||
function handleRestartTelegram() {
|
||||
if (!window.confirm("Reload the Telegram chat adapter?")) return;
|
||||
setComposerText("/restart");
|
||||
sendMessage({ textOverride: "/restart" });
|
||||
}
|
||||
|
||||
function handleNewChat() {
|
||||
setComposerText("/new");
|
||||
sendMessage({ textOverride: "/new" });
|
||||
@@ -487,213 +399,94 @@ export function ChatApp() {
|
||||
: selectorData.models || [];
|
||||
|
||||
return (
|
||||
<div className="chat-page-content">
|
||||
<header className="chat-topbar">
|
||||
<div>
|
||||
<span className="chat-kicker">ARCHIE WORKSPACE</span>
|
||||
<h1 className="page-title">Chat</h1>
|
||||
</div>
|
||||
<div className="chat-topbar-actions">
|
||||
<span className="chat-status">{statusText}</span>
|
||||
{selectorData.restart_available && (
|
||||
<button className="btn" type="button" onClick={handleRestartTelegram}>
|
||||
Reload Telegram
|
||||
</button>
|
||||
)}
|
||||
<button className="btn" type="button" onClick={refreshUpdate}>
|
||||
Check updates
|
||||
</button>
|
||||
<div className="chat-panel-content">
|
||||
<div className="chat-bar">
|
||||
<label className="chat-session-switch">
|
||||
<span className="sr-only">Conversation</span>
|
||||
<select
|
||||
className="chat-select"
|
||||
aria-label="Personality"
|
||||
value={selectedPersona}
|
||||
onChange={handlePersonaChange}
|
||||
value={currentSession}
|
||||
onChange={(e) => selectSession(e.target.value)}
|
||||
disabled={!sessions.length}
|
||||
>
|
||||
<option value="">Personality</option>
|
||||
{(selectorData.personas || []).map((name) => (
|
||||
<option key={name} value={name}>
|
||||
{name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{(selectorData.providers || []).length > 0 && (
|
||||
<select
|
||||
className="chat-select"
|
||||
aria-label="Provider"
|
||||
value={selectedProvider}
|
||||
onChange={handleProviderChange}
|
||||
>
|
||||
<option value="">Provider</option>
|
||||
{(selectorData.providers || []).map((p) => (
|
||||
<option key={p} value={p}>
|
||||
{p}
|
||||
{!sessions.length ? (
|
||||
<option value="">No conversations yet</option>
|
||||
) : (
|
||||
sessions.map((session) => (
|
||||
<option key={session.session_id} value={session.session_id}>
|
||||
{sessionTitle(session)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
)}
|
||||
<select
|
||||
className="chat-select"
|
||||
aria-label="Model"
|
||||
value={selectedModel}
|
||||
onChange={handleModelChange}
|
||||
>
|
||||
<option value="">Model</option>
|
||||
{currentModels.map((m) => (
|
||||
<option key={m} value={m}>
|
||||
{m}
|
||||
</option>
|
||||
))}
|
||||
))
|
||||
)}
|
||||
</select>
|
||||
</div>
|
||||
</header>
|
||||
</label>
|
||||
|
||||
{/* Update Panel */}
|
||||
{updateData && (
|
||||
<div className="chat-update-panel">
|
||||
{updateData.error ? (
|
||||
<span>{updateData.error}</span>
|
||||
) : updateData.available?.length ? (
|
||||
<Fragment>
|
||||
<div>
|
||||
<strong>Update available</strong>
|
||||
<span>
|
||||
{updateData.available
|
||||
.map((c) => `${c.Label || c.label}: ${c.Available || c.available}`)
|
||||
.join(" · ")}
|
||||
</span>
|
||||
</div>
|
||||
<div className="chat-update-actions">
|
||||
<button className="btn" type="button" onClick={deferUpdate}>
|
||||
Defer
|
||||
</button>
|
||||
{updateData.can_install && (
|
||||
<button className="btn btn-primary" type="button" onClick={installUpdate}>
|
||||
Install update
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</Fragment>
|
||||
) : (
|
||||
<span>{updateData.snapshot?.deferred ? "Update deferred." : "Archie is up to date."}</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<button className="icon-btn chat-new" type="button" title="New chat" aria-label="New chat" onClick={handleNewChat}>
|
||||
+
|
||||
</button>
|
||||
|
||||
{/* Dangerous Panel */}
|
||||
{selectorData.dangerous_available && dangerousData && (
|
||||
<div className="chat-dangerous-panel">
|
||||
<div className="chat-dangerous-head">
|
||||
<strong>Dangerous actions</strong>
|
||||
<span className="chat-hint">Every action requires approval.</span>
|
||||
</div>
|
||||
<div className="chat-dangerous-controls">
|
||||
<div>
|
||||
<details className="chat-settings">
|
||||
<summary aria-label="Chat settings" title="Chat settings">
|
||||
<span aria-hidden="true">⚙</span>
|
||||
</summary>
|
||||
<div className="chat-settings-body">
|
||||
<span className="chat-status">{statusText}</span>
|
||||
<label>
|
||||
Personality
|
||||
<select
|
||||
className="chat-select"
|
||||
aria-label="Checkpoint"
|
||||
value={dangerousCheckpoint}
|
||||
onChange={(e) => setDangerousCheckpoint(e.target.value)}
|
||||
aria-label="Personality"
|
||||
value={selectedPersona}
|
||||
onChange={handlePersonaChange}
|
||||
>
|
||||
<option value="">Select checkpoint</option>
|
||||
{(dangerousData.checkpoints || []).map((cp) => (
|
||||
<option key={cp.Number ?? cp.number} value={cp.Number ?? cp.number}>
|
||||
{cp.Number ?? cp.number} — {cp.Label ?? cp.label ?? "checkpoint"}
|
||||
<option value="">Default</option>
|
||||
{(selectorData.personas || []).map((name) => (
|
||||
<option key={name} value={name}>
|
||||
{name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<button
|
||||
className="btn"
|
||||
type="button"
|
||||
onClick={() => requestDangerousAction("rollback", dangerousCheckpoint)}
|
||||
>
|
||||
Request rollback
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
className="chat-dangerous-input"
|
||||
placeholder="Process name or id"
|
||||
aria-label="Process name or id"
|
||||
value={dangerousStopSpec}
|
||||
onInput={(e) => setDangerousStopSpec(e.target.value)}
|
||||
/>
|
||||
<button
|
||||
className="btn"
|
||||
type="button"
|
||||
onClick={() => requestDangerousAction("stop", dangerousStopSpec)}
|
||||
>
|
||||
Request stop
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="chat-dangerous-pending-list">
|
||||
{(dangerousData.pending || []).length ? (
|
||||
dangerousData.pending.map((action) => (
|
||||
<div className="chat-dangerous-pending" key={action.id}>
|
||||
<span>{action.description}</span>
|
||||
<div className="chat-update-actions">
|
||||
<button
|
||||
className="btn"
|
||||
type="button"
|
||||
onClick={() => decideDangerousAction(action.id, "approve")}
|
||||
>
|
||||
Approve
|
||||
</button>
|
||||
<button
|
||||
className="btn"
|
||||
type="button"
|
||||
onClick={() => decideDangerousAction(action.id, "permanent")}
|
||||
>
|
||||
Approve for 24h
|
||||
</button>
|
||||
<button
|
||||
className="btn"
|
||||
type="button"
|
||||
onClick={() => decideDangerousAction(action.id, "deny")}
|
||||
>
|
||||
Deny
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
<span className="chat-hint">No pending dangerous actions.</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Main Layout */}
|
||||
<div className="chat-layout">
|
||||
<aside className="chat-sidebar">
|
||||
<div className="chat-sidebar-head">
|
||||
<strong>Conversations</strong>
|
||||
<button className="btn btn-primary" type="button" onClick={handleNewChat}>
|
||||
+ New chat
|
||||
</button>
|
||||
</div>
|
||||
<div className="chat-session-list">
|
||||
{!sessions.length ? (
|
||||
<div className="chat-empty">Your conversations will appear here.</div>
|
||||
) : (
|
||||
sessions.map((session) => (
|
||||
<button
|
||||
key={session.session_id}
|
||||
className={`chat-session ${currentSession === session.session_id ? "active" : ""}`}
|
||||
type="button"
|
||||
onClick={() => selectSession(session.session_id)}
|
||||
</label>
|
||||
{(selectorData.providers || []).length > 0 && (
|
||||
<label>
|
||||
Provider
|
||||
<select
|
||||
className="chat-select"
|
||||
aria-label="Provider"
|
||||
value={selectedProvider}
|
||||
onChange={handleProviderChange}
|
||||
>
|
||||
<strong>{sessionTitle(session)}</strong>
|
||||
<span>{new Date(session.last_active_at).toLocaleString()}</span>
|
||||
</button>
|
||||
))
|
||||
<option value="">Default</option>
|
||||
{(selectorData.providers || []).map((provider) => (
|
||||
<option key={provider} value={provider}>
|
||||
{provider}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
<label>
|
||||
Model
|
||||
<select
|
||||
className="chat-select"
|
||||
aria-label="Model"
|
||||
value={selectedModel}
|
||||
onChange={handleModelChange}
|
||||
>
|
||||
<option value="">Default</option>
|
||||
{currentModels.map((model) => (
|
||||
<option key={model} value={model}>
|
||||
{model}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
</aside>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
<div className="chat-layout">
|
||||
<section className="chat-workspace">
|
||||
<div className="chat-workspace-head">
|
||||
<span className="chat-workspace-label">PERSONAL ASSISTANT</span>
|
||||
<details className="chat-command-help">
|
||||
<summary>Available commands ({commandSpecs.length})</summary>
|
||||
<div className="chat-command-list">
|
||||
@@ -937,7 +730,7 @@ export function ChatApp() {
|
||||
ref={composerRef}
|
||||
className="chat-composer"
|
||||
rows={3}
|
||||
placeholder="Message Archie… (commands like /status and /new work here)"
|
||||
placeholder="Message Archie, or type / for commands"
|
||||
aria-label="Message Archie"
|
||||
disabled={isSending}
|
||||
value={composerText}
|
||||
@@ -993,7 +786,3 @@ export function ChatApp() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function ChatPage() {
|
||||
return <ChatApp />;
|
||||
}
|
||||
@@ -54,3 +54,17 @@ a {
|
||||
clip-path: inset(50%);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Visible to assistive technology only. For a control whose purpose is clear
|
||||
from its position but which still needs a name in the accessibility tree. */
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
margin: -1px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
white-space: nowrap;
|
||||
border: 0;
|
||||
}
|
||||
+175
-73
@@ -74,14 +74,28 @@ body {
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
margin: 0 auto;
|
||||
/* The nav is the only region that can afford to lose width, so it is the
|
||||
only one allowed to shrink. min-width:0 lets it actually do so inside a
|
||||
flex row, and the scroll is the last resort before anything clips --
|
||||
.app sets overflow:hidden, so an unshrinkable row loses the utility
|
||||
cluster off the right edge with no way to reach it. */
|
||||
flex: 0 1 auto;
|
||||
min-width: 0;
|
||||
overflow-x: auto;
|
||||
scrollbar-width: none;
|
||||
padding: 3px;
|
||||
border-radius: var(--radius-pill);
|
||||
background: var(--surface-glass-strong);
|
||||
border: 1px solid var(--hairline);
|
||||
}
|
||||
|
||||
.nav::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
display: inline-flex;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
padding: var(--sp-2) var(--sp-3);
|
||||
@@ -192,28 +206,86 @@ body {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* ── Chat drawer ─────────────────────────────────────────────────────── */
|
||||
/* The chat is a persistent slide-over, not a route: it is mounted once and
|
||||
opened from the topbar, so the operator can talk to Archie from any page
|
||||
without leaving the work that prompted the question. It overlays the
|
||||
layout rather than replacing it, and the navigation/outlet stay interactive
|
||||
behind the scrim. */
|
||||
.chat-drawer {
|
||||
/* ── Chat launcher and panel ─────────────────────────────────────────── */
|
||||
/* A floating launcher, bottom-right, and the panel it opens immediately to
|
||||
its left. The two share a bottom edge and the panel grows out of the button,
|
||||
so the launcher never moves and always reads as the thing that produced the
|
||||
panel.
|
||||
|
||||
Deliberately not a modal: no scrim, no body scroll lock, no focus trap. The
|
||||
operator asks Archie about the page they are on, so that page has to stay
|
||||
readable, scrollable and clickable while the panel is open. */
|
||||
.chat-dock {
|
||||
--fab-size: 56px;
|
||||
--fab-inset: var(--sp-5);
|
||||
--fab-gap: var(--sp-3);
|
||||
position: fixed;
|
||||
inset: var(--sp-4);
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
justify-content: flex-end;
|
||||
pointer-events: none;
|
||||
right: var(--fab-inset);
|
||||
bottom: var(--fab-inset);
|
||||
z-index: 40;
|
||||
}
|
||||
|
||||
.chat-fab {
|
||||
position: relative;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: var(--fab-size);
|
||||
height: var(--fab-size);
|
||||
border: 0;
|
||||
border-radius: var(--radius-pill);
|
||||
background: linear-gradient(135deg, var(--accent), var(--accent-2));
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
box-shadow: var(--shadow-md);
|
||||
transition: transform var(--transition), box-shadow var(--transition);
|
||||
}
|
||||
|
||||
.chat-fab:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 12px 34px color-mix(in srgb, var(--accent) 38%, transparent);
|
||||
}
|
||||
|
||||
.chat-fab:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
/* Both glyphs are stacked and cross-faded, so the button keeps one size and
|
||||
the swap cannot reflow the dock. */
|
||||
.chat-fab-icon {
|
||||
grid-area: 1 / 1;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
transition: opacity var(--transition), transform var(--transition);
|
||||
}
|
||||
|
||||
.chat-fab-icon-close,
|
||||
.chat-dock.is-open .chat-fab-icon-open {
|
||||
opacity: 0;
|
||||
transform: scale(0.7) rotate(-45deg);
|
||||
}
|
||||
|
||||
.chat-fab-icon-open,
|
||||
.chat-dock.is-open .chat-fab-icon-close {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
/* The panel is positioned off the dock, not the viewport: it sits one gap to
|
||||
the left of the launcher and rises from the shared bottom edge. */
|
||||
.chat-drawer {
|
||||
position: absolute;
|
||||
right: calc(var(--fab-size) + var(--fab-gap));
|
||||
bottom: 0;
|
||||
width: min(440px, calc(100vw - var(--fab-size) - var(--fab-gap) - var(--fab-inset) * 2));
|
||||
height: min(640px, calc(100vh - var(--fab-inset) * 2));
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.chat-drawer-panel {
|
||||
pointer-events: auto;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: grid;
|
||||
grid-template-rows: auto minmax(0, 1fr);
|
||||
width: min(430px, 100%);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
@@ -221,19 +293,25 @@ body {
|
||||
box-shadow: var(--shadow-md);
|
||||
overflow: hidden;
|
||||
opacity: 0;
|
||||
transform: translateX(1.2rem);
|
||||
/* Grows out of the launcher: the origin is the corner nearest the button. */
|
||||
transform-origin: bottom right;
|
||||
transform: scale(0.92) translateX(var(--sp-3));
|
||||
transition: opacity var(--transition), transform var(--transition);
|
||||
}
|
||||
/* A closed (opacity-0, still mounted) panel must not block the page behind
|
||||
it: opacity does not disable hit-testing, so without this the invisible
|
||||
430px panel would make the whole right column unclickable at z-index 40. */
|
||||
|
||||
/* A closed panel is still mounted so the session and its stream survive. It
|
||||
must not take hits or reach the tab order while invisible. */
|
||||
.chat-drawer:not(.is-open) .chat-drawer-panel {
|
||||
pointer-events: none;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.chat-drawer.is-open .chat-drawer-panel {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.chat-drawer-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -242,28 +320,89 @@ body {
|
||||
padding: var(--sp-3) var(--sp-4);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.chat-scrim {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: color-mix(in srgb, var(--bg) 40%, transparent);
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity var(--transition);
|
||||
|
||||
/* Below this there is no room beside the launcher, so the panel stops being
|
||||
anchored to it and becomes a sheet on the viewport. The launcher hides while
|
||||
the sheet is up: its own close button is the way out. */
|
||||
@media (max-width: 720px) {
|
||||
.chat-dock {
|
||||
--fab-inset: var(--sp-4);
|
||||
}
|
||||
|
||||
.chat-drawer {
|
||||
position: fixed;
|
||||
right: var(--fab-inset);
|
||||
left: var(--fab-inset);
|
||||
bottom: var(--fab-inset);
|
||||
width: auto;
|
||||
height: min(78vh, calc(100vh - var(--fab-inset) * 2));
|
||||
}
|
||||
|
||||
.chat-drawer-panel {
|
||||
transform-origin: bottom center;
|
||||
transform: scale(0.98) translateY(var(--sp-3));
|
||||
}
|
||||
|
||||
.chat-dock.is-open .chat-fab {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
/* The scrim shows and closes from outside clicks only when the drawer is
|
||||
open; it is driven by the drawer's own state so it can never be on top of
|
||||
a closed drawer. */
|
||||
.chat-drawer.is-open .chat-scrim {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
body.chat-open {
|
||||
overflow: hidden;
|
||||
|
||||
/* ── Collapsed search ───────────────────────────────────────────────────── */
|
||||
|
||||
/* The always-open "Jump to" field is the widest thing in the utility cluster
|
||||
and the least often used. Past this width it collapses to its icon and
|
||||
expands on demand, which is what keeps the nav from having to scroll at
|
||||
ordinary laptop sizes. Measured: the labelled nav needs 917px and the
|
||||
collapsed cluster 160px, so an expanded field does not fit beside them until
|
||||
about 1430px -- collapsing to 1500 keeps 1440 comfortable rather than
|
||||
marginal. */
|
||||
@media (max-width: 1500px) {
|
||||
.topbar-search {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.topbar-search-icon {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mobile-search-toggle {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.topbar-search input {
|
||||
width: 0;
|
||||
padding: 0;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: width var(--transition), opacity var(--transition);
|
||||
}
|
||||
|
||||
.topbar-search.is-open,
|
||||
.topbar-search:focus-within {
|
||||
padding-right: var(--sp-2);
|
||||
border: 1px solid var(--hairline);
|
||||
background: var(--surface-glass-strong);
|
||||
}
|
||||
|
||||
.topbar-search.is-open input,
|
||||
.topbar-search:focus-within input {
|
||||
width: min(9rem, 34vw);
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Constrained desktop ────────────────────────────────────────────────── */
|
||||
|
||||
@media (max-width: 1220px) and (min-width: 901px) {
|
||||
/* The nav needs 917px on one line. Below the width where it still fits beside
|
||||
the brand and the collapsed cluster it takes a row of its own, which reads
|
||||
better than the scroll that would otherwise kick in. */
|
||||
@media (max-width: 1270px) and (min-width: 901px) {
|
||||
.topbar {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
@@ -320,43 +459,6 @@ body.chat-open {
|
||||
}
|
||||
|
||||
|
||||
.topbar-search {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.topbar-search-icon {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mobile-search-toggle {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.topbar-search input {
|
||||
width: 0;
|
||||
padding: 0;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: width var(--transition), opacity var(--transition);
|
||||
}
|
||||
|
||||
.topbar-search.is-open,
|
||||
.topbar-search:focus-within {
|
||||
padding-right: var(--sp-2);
|
||||
border: 1px solid var(--hairline);
|
||||
background: var(--surface-glass-strong);
|
||||
}
|
||||
|
||||
.topbar-search.is-open input,
|
||||
.topbar-search:focus-within input {
|
||||
width: min(9rem, 34vw);
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.main {
|
||||
padding: var(--sp-4);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
|
||||
/* ── Dark (default) ─────────────────────────────────────────────────────── */
|
||||
[data-theme="dark"] {
|
||||
color-scheme: dark;
|
||||
|
||||
--bg: #0d1014;
|
||||
--bg-raised: #141920;
|
||||
--surface: #171d25;
|
||||
@@ -88,6 +90,8 @@
|
||||
|
||||
/* ── Light ──────────────────────────────────────────────────────────────── */
|
||||
[data-theme="light"] {
|
||||
color-scheme: light;
|
||||
|
||||
--bg: #f6f8fb;
|
||||
--bg-raised: #ffffff;
|
||||
--surface: #ffffff;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// Live activity's detail column.
|
||||
//
|
||||
// The daemon puts whatever a stage produced into an event's detail, so the
|
||||
// column holds anything from "session-memory" to a few thousand characters of
|
||||
// agent transcript. Printed raw, one agent_finish row was taller than six
|
||||
// viewports and the table stopped being scannable (archie-core-qo7f).
|
||||
//
|
||||
// The rule is one line in the cell, the whole payload still available. The cut
|
||||
// happens here rather than in CSS because the row also needs to know whether
|
||||
// there is more to show.
|
||||
|
||||
// Long enough for a useful parked reason, short enough that every row is the
|
||||
// same height at the widths the table is used at.
|
||||
const CELL_LIMIT = 160;
|
||||
|
||||
/**
|
||||
* activityDetail returns `{ text, full, truncated }` for one event:
|
||||
* `text` is the single line the cell renders, `full` the untouched payload,
|
||||
* and `truncated` whether the two differ.
|
||||
*/
|
||||
export function activityDetail(event) {
|
||||
const full = String(event?.detail || event?.message || "");
|
||||
if (!full) return { text: "", full: "", truncated: false };
|
||||
|
||||
// The first line that says something: agent output often opens with blanks.
|
||||
const firstLine = full.split("\n").map((line) => line.trim()).find(Boolean) || "";
|
||||
const clipped = firstLine.length > CELL_LIMIT ? `${firstLine.slice(0, CELL_LIMIT).trimEnd()}…` : firstLine;
|
||||
|
||||
return { text: clipped, full, truncated: clipped !== full };
|
||||
}
|
||||
@@ -411,3 +411,18 @@
|
||||
background: var(--warn-soft);
|
||||
filter: brightness(1.1);
|
||||
}
|
||||
|
||||
/* Live activity's detail column. activity-detail.js already cuts the payload
|
||||
to one line; this stops a long unbroken token (a path, a URL, a hash) from
|
||||
widening the column past the table and keeps every row the same height. */
|
||||
.activity-detail {
|
||||
max-width: 0;
|
||||
width: 55%;
|
||||
}
|
||||
|
||||
.activity-detail span {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import { ago, compact } from "../base/format.jsx";
|
||||
import { statusKind } from "../base/task-meta.jsx";
|
||||
import { StatTile } from "../base/statTile.jsx";
|
||||
import { Gauge, SegmentBar } from "../base/gauge.jsx";
|
||||
import { activityDetail } from "./activity-detail.js";
|
||||
import { Icon } from "../base/icons.jsx";
|
||||
import { Pill } from "../base/pill.jsx";
|
||||
import { dismissSetupComplete, setupPanelState } from "./setup-preference.jsx";
|
||||
@@ -401,6 +402,7 @@ function DashboardApp() {
|
||||
activity.map((event, i) => {
|
||||
const taskID = taskIDForEvent(event, taskIDsBySource);
|
||||
const hasTask = taskID > 0;
|
||||
const detail = activityDetail(event);
|
||||
const openTask = () => {
|
||||
if (hasTask) location.hash = `#/tasks?task=${encodeURIComponent(taskID)}`;
|
||||
};
|
||||
@@ -423,7 +425,9 @@ function DashboardApp() {
|
||||
<span>{event.kind || event.type || "event"}</span>
|
||||
</td>
|
||||
<td className="mono">{hasTask ? `#${taskID}` : "—"}</td>
|
||||
<td>{event.detail || event.message || ""}</td>
|
||||
<td className="activity-detail">
|
||||
<span title={detail.truncated ? detail.full : undefined}>{detail.text}</span>
|
||||
</td>
|
||||
<td>{ago(event.at || Date.now())}</td>
|
||||
</tr>
|
||||
);
|
||||
|
||||
+92
-68
@@ -1,5 +1,5 @@
|
||||
import "./css/_main.css";
|
||||
import { h, render } from "preact";
|
||||
import { Fragment, h, render } from "preact";
|
||||
import { useCallback, useEffect, useRef, useState } from "preact/hooks";
|
||||
import { api } from "./base/api.jsx";
|
||||
import { hiddenRoutes } from "./capabilities.jsx";
|
||||
@@ -17,7 +17,7 @@ import { logsPage } from "./logs/logs.jsx";
|
||||
import { capturesPage } from "./captures/captures.jsx";
|
||||
import { mappingsPage } from "./mappings/mappings.jsx";
|
||||
import { bindingsPage } from "./bindings/bindings.jsx";
|
||||
import { ChatPage } from "./chat/chat.jsx";
|
||||
import { ChatApp } from "./chat/chat.jsx";
|
||||
import { matchRoute, navPath } from "./routing.jsx";
|
||||
|
||||
/**
|
||||
@@ -44,7 +44,6 @@ import { matchRoute, navPath } from "./routing.jsx";
|
||||
// :name -- one captured path segment, e.g. /tasks/:id
|
||||
const routes = [
|
||||
{ path: "/", label: "Dashboard", icon: "dashboard", view: dashboardPage },
|
||||
{ path: "/chat", label: "Chat", icon: "chat", view: ChatPage, section: "chat" },
|
||||
{ path: "/tasks", label: "Tasks", icon: "tasks", view: tasksPage },
|
||||
{ path: "/tasks/:id", label: "Task run", view: taskDetailPage, nav: false, navPath: "/tasks" },
|
||||
{ path: "/logs", label: "Logs", icon: "logs", view: logsPage, section: "logs" },
|
||||
@@ -75,7 +74,7 @@ function navEntries(hidden) {
|
||||
return routes.filter((route) => route.nav !== false && !hidden.includes(route.path));
|
||||
}
|
||||
|
||||
function Topbar({ activePath, hidden, onNavigate, chatOpen, onToggleChat, theme, onToggleTheme }) {
|
||||
function Topbar({ activePath, hidden, onNavigate, theme, onToggleTheme }) {
|
||||
const [searchOpen, setSearchOpen] = useState(false);
|
||||
const searchRef = useRef(null);
|
||||
|
||||
@@ -159,15 +158,6 @@ function Topbar({ activePath, hidden, onNavigate, chatOpen, onToggleChat, theme,
|
||||
onKeyDown={onSearchKeyDown}
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
className="icon-btn icon-btn-chat"
|
||||
aria-label="Open chat"
|
||||
title="Chat with Archie"
|
||||
aria-expanded={chatOpen ? "true" : "false"}
|
||||
onClick={() => onToggleChat()}
|
||||
>
|
||||
<Icon name="chat" />
|
||||
</button>
|
||||
<button className="icon-btn" title="Documentation" aria-label="Documentation">
|
||||
<Icon name="help" />
|
||||
</button>
|
||||
@@ -187,26 +177,80 @@ function Topbar({ activePath, hidden, onNavigate, chatOpen, onToggleChat, theme,
|
||||
);
|
||||
}
|
||||
|
||||
// The chat drawer lives beside the outlet, mounted once. It is closed by
|
||||
// default and opened from the topbar launcher; because it is a slide-over
|
||||
// rather than a route, the operator can talk to Archie from any page without
|
||||
// leaving the work that prompted the question. It hosts a single ChatPage
|
||||
// instance, so session state and the stream survive navigation and are not
|
||||
// duplicated per page.
|
||||
function ChatDrawer({ open, onClose }) {
|
||||
// Chat is a floating launcher and the panel it opens, mounted once beside the
|
||||
// outlet. It is not a route: the operator asks Archie about the page they are
|
||||
// already on, so navigating must not close it and opening must not replace the
|
||||
// work that prompted the question.
|
||||
//
|
||||
// The panel anchors to the launcher and opens leftward from it, sharing its
|
||||
// bottom edge, so the button stays put and reads as the thing the panel came
|
||||
// out of. Nothing is dimmed and the page keeps scrolling: this is a companion
|
||||
// to the work, not a modal over it.
|
||||
//
|
||||
// It hosts a single ChatApp instance, so session state and the stream survive
|
||||
// navigation rather than being rebuilt per page.
|
||||
const CHAT_PANEL_ID = "chat-panel";
|
||||
|
||||
function ChatLauncher() {
|
||||
const [open, setOpen] = useState(false);
|
||||
const fabRef = useRef(null);
|
||||
|
||||
const close = useCallback(() => {
|
||||
setOpen(false);
|
||||
// Focus goes back to the control that opened the panel; otherwise a
|
||||
// keyboard user who dismisses it lands at the top of the document.
|
||||
fabRef.current?.focus();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return undefined;
|
||||
const onKeyDown = (event) => {
|
||||
// A focused control (the composer dismissing its command menu, or the
|
||||
// topbar search) already handled Escape via preventDefault; closing the
|
||||
// panel too would make that menu impossible to dismiss on its own.
|
||||
if (event.defaultPrevented || event.key !== "Escape") return;
|
||||
close();
|
||||
};
|
||||
document.addEventListener("keydown", onKeyDown);
|
||||
return () => document.removeEventListener("keydown", onKeyDown);
|
||||
}, [open, close]);
|
||||
|
||||
return (
|
||||
<aside className={`chat-drawer${open ? " is-open" : ""}`} aria-label="Chat with Archie">
|
||||
<div className="chat-drawer-panel">
|
||||
<div className="chat-drawer-head">
|
||||
<strong>Archie</strong>
|
||||
<button className="icon-btn chat-drawer-close" aria-label="Close chat" title="Close chat" onClick={onClose}>
|
||||
<Icon name="close" />
|
||||
</button>
|
||||
<div className={`chat-dock${open ? " is-open" : ""}`}>
|
||||
<aside
|
||||
className={`chat-drawer${open ? " is-open" : ""}`}
|
||||
id={CHAT_PANEL_ID}
|
||||
aria-label="Chat with Archie"
|
||||
aria-hidden={open ? undefined : "true"}
|
||||
>
|
||||
<div className="chat-drawer-panel">
|
||||
<div className="chat-drawer-head">
|
||||
<strong>Archie</strong>
|
||||
<button className="icon-btn chat-drawer-close" aria-label="Close chat" title="Close chat" onClick={close}>
|
||||
<Icon name="close" />
|
||||
</button>
|
||||
</div>
|
||||
<ChatApp />
|
||||
</div>
|
||||
<ChatPage />
|
||||
</div>
|
||||
<div className="chat-scrim" onClick={onClose} />
|
||||
</aside>
|
||||
</aside>
|
||||
<button
|
||||
ref={fabRef}
|
||||
type="button"
|
||||
className="chat-fab"
|
||||
aria-label={open ? "Close chat" : "Chat with Archie"}
|
||||
title={open ? "Close chat" : "Chat with Archie"}
|
||||
aria-expanded={open ? "true" : "false"}
|
||||
aria-controls={CHAT_PANEL_ID}
|
||||
onClick={() => (open ? close() : setOpen(true))}
|
||||
>
|
||||
<span className="chat-fab-icon chat-fab-icon-open" aria-hidden="true">
|
||||
<Icon name="chat" size={22} />
|
||||
</span>
|
||||
<span className="chat-fab-icon chat-fab-icon-close" aria-hidden="true">
|
||||
<Icon name="close" size={22} />
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -264,13 +308,6 @@ function renderRoute(rawPath) {
|
||||
const route = match?.route || routes[0];
|
||||
const params = match?.params || {};
|
||||
|
||||
// The chat is a drawer, not a page: /chat opens it rather than mounting a
|
||||
// second ChatPage (which would duplicate session state and the stream).
|
||||
if (route.path === "/chat") {
|
||||
render(null, outlet);
|
||||
return;
|
||||
}
|
||||
|
||||
// The key covers the path and its parameters, but NOT the query: the query
|
||||
// string is an entry state, so a navigation that only changes the query of
|
||||
// the page already mounted keeps the operator's own filter selection.
|
||||
@@ -302,9 +339,6 @@ function show(rawPath) {
|
||||
// Tasks stays current on #/tasks/42 instead of every item losing it.
|
||||
chrome?.setActive(navPath(route));
|
||||
|
||||
// The chat is a drawer, not a page: /chat opens it rather than mounting a
|
||||
// second ChatPage (which would duplicate session state and the stream).
|
||||
chrome?.setChatOpen(route.path === "/chat");
|
||||
renderRoute(rawPath);
|
||||
}
|
||||
|
||||
@@ -314,35 +348,22 @@ function navigate(next) {
|
||||
}
|
||||
|
||||
window.addEventListener("hashchange", () => show(location.hash.slice(1) || "/"));
|
||||
window.addEventListener("keydown", (event) => {
|
||||
// A focused control (the composer dismissing its command menu, or the topbar
|
||||
// search) already handled Escape via preventDefault; closing the drawer too
|
||||
// would make the menu impossible to dismiss alone.
|
||||
if (event.defaultPrevented) return;
|
||||
if (event.key === "Escape") chrome?.setChatOpen(false);
|
||||
});
|
||||
|
||||
function App() {
|
||||
const [active, setActive] = useState("/");
|
||||
const [theme, setTheme] = useState(currentTheme);
|
||||
const [chatOpen, setChatOpen] = useState(false);
|
||||
const [hidden, setHidden] = useState([]);
|
||||
|
||||
// Publishes the router's handles. A callback ref runs at commit time, so a
|
||||
// hashchange that lands right after the first paint already finds them.
|
||||
const publish = useCallback((element) => {
|
||||
outlet = element;
|
||||
chrome = { setActive, setChatOpen };
|
||||
chrome = { setActive };
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
applyTheme(theme);
|
||||
}, [theme]);
|
||||
|
||||
useEffect(() => {
|
||||
document.body.classList.toggle("chat-open", chatOpen);
|
||||
}, [chatOpen]);
|
||||
|
||||
// Asked for once, after the shell is up: the nav renders immediately and
|
||||
// loses the entries this process cannot back a moment later, rather than
|
||||
// holding the whole page behind one request.
|
||||
@@ -368,19 +389,22 @@ function App() {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="shell">
|
||||
<Topbar
|
||||
activePath={active}
|
||||
hidden={hidden}
|
||||
onNavigate={navigate}
|
||||
chatOpen={chatOpen}
|
||||
onToggleChat={() => setChatOpen((open) => !open)}
|
||||
theme={theme}
|
||||
onToggleTheme={() => setTheme((current) => (current === "dark" ? "light" : "dark"))}
|
||||
/>
|
||||
<main className="main" ref={publish} />
|
||||
<ChatDrawer open={chatOpen} onClose={() => setChatOpen(false)} />
|
||||
</div>
|
||||
<Fragment>
|
||||
<div className="shell">
|
||||
<Topbar
|
||||
activePath={active}
|
||||
hidden={hidden}
|
||||
onNavigate={navigate}
|
||||
theme={theme}
|
||||
onToggleTheme={() => setTheme((current) => (current === "dark" ? "light" : "dark"))}
|
||||
/>
|
||||
<main className="main" ref={publish} />
|
||||
</div>
|
||||
{/* Outside .shell on purpose: its backdrop-filter is a containing block
|
||||
for fixed positioning, so a launcher nested inside would anchor to the
|
||||
scrolling shell and ride off the bottom of a long page. */}
|
||||
<ChatLauncher />
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user