fix(webui): make the chat panel behave like a chat window
Remediation from testing the launcher (archie-core-ifay), plus the morph Sam
asked for.
The panel grows out of the launcher rather than fading in beside it: closed, it
is collapsed to a pill the size of the button and translated over it; open, it
is the full panel. Scale, border-radius and position interpolate together, and
the contents fade in once the shape has mostly arrived, so the button reads as
becoming the panel. The launcher stays visible throughout and is the only
control that opens and closes it, so the panel carries no close button.
- Header shows the open conversation's name; ChatApp owns the header now,
because the title and the actions that change it belong to the same
component.
- New chat became the Lucide message-circle-plus glyph and moved into the
header. Added to the icon set, which is the same 24-grid stroke system.
- The commands accordion is gone. The composer's slash palette was already
the command surface and floats above the input; having both was two
answers to one question.
- Arrow keys scroll the palette so the selection stays visible. The decision
is pure arithmetic in command-scroll.js, including the case of an option
taller than the list, which aligns to its top so the command name is not
the part scrolled out of sight.
- The settings popover closes on any pointerdown or focus outside it.
- Stop renders only while a reply is streaming.
- The composer keeps focus and stays writeable during a send, so the next
message can be typed while one streams. It was `disabled`, which also made
the focus() in the send's finally block a silent no-op. sendMessage already
refuses a second concurrent turn via isSendingRef.
- Composer actions sit at the right of the input row, the resize handle is
gone, and the Enter/Shift+Enter hint is removed.
- Message bubbles dropped their "Archie"/"You" labels; side and colour
already say who spoke.
- Fixed an empty band under the composer: the panel still declared two grid
rows from when the launcher owned the header.
This commit is contained in:
12 files changed
+278
-77
No files matched your search
@@ -32,6 +32,7 @@ const paths = {
|
||||
trendDown: '<path d="M4 7l6 6 4-4 6 6"/><path d="M14 17h6v-6"/>',
|
||||
check: '<path d="M4.5 12.5l5 5 10-11"/>',
|
||||
close: '<path d="M6 6l12 12M18 6L6 18"/>',
|
||||
"message-circle-plus": '<path d="M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"/><path d="M8 12h8"/><path d="M12 8v8"/>',
|
||||
help: '<circle cx="12" cy="12" r="9"/><path d="M9.6 9.4a2.5 2.5 0 1 1 3.3 2.4c-.6.2-.9.8-.9 1.4v.4"/><path d="M12 17.2h.01"/>',
|
||||
};
|
||||
|
||||
|
||||
@@ -10,3 +10,14 @@
|
||||
export function sessionTitle(session) {
|
||||
return session.title || session.branch_name || `Conversation ${session.session_id.slice(0, 8)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* panelTitle names the launcher panel's header. The panel is small and the
|
||||
* session switcher sits below it, so the header says which conversation is
|
||||
* open rather than repeating the product name.
|
||||
*/
|
||||
export function panelTitle(sessions, currentSession) {
|
||||
if (!currentSession) return "Archie";
|
||||
const session = (sessions || []).find((item) => item.session_id === currentSession);
|
||||
return session ? sessionTitle(session) : "Archie";
|
||||
}
|
||||
@@ -3,7 +3,10 @@
|
||||
(archie-core-hesx). */
|
||||
.chat-panel-content {
|
||||
display: grid;
|
||||
grid-template-rows: auto minmax(0, 1fr);
|
||||
/* header, bar, then the conversation takes the rest: without the third
|
||||
track the transcript sized to its content and left the composer floating
|
||||
above dead space. */
|
||||
grid-template-rows: auto auto minmax(0, 1fr);
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
@@ -203,18 +206,17 @@
|
||||
.chat-nav-chip-icon { font-size: .8rem; line-height: 1; }
|
||||
|
||||
.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; }
|
||||
/* Text and actions share one row: the buttons sit at the right of the input,
|
||||
not on a line of their own under it. */
|
||||
.chat-composer-shell { position: relative; display: flex; align-items: flex-end; gap: var(--sp-2); padding: .7rem .8rem; background: var(--surface-hover); border: 1px solid var(--border-strong); border-radius: .9rem; }
|
||||
.chat-composer { flex: 1 1 auto; min-width: 0; min-height: 2.6rem; resize: none; box-sizing: border-box; background: transparent; color: var(--fg); border: 0; padding: .25rem 0; font: inherit; }
|
||||
.chat-composer:focus { outline: 0; }
|
||||
.chat-command-menu { position: absolute; z-index: 3; right: .8rem; bottom: calc(100% - .25rem); left: .8rem; display: grid; gap: .15rem; max-height: 18rem; overflow: auto; padding: .35rem; background: var(--surface); border: 1px solid var(--border-strong); border-radius: .7rem; box-shadow: 0 .7rem 2rem color-mix(in srgb, #000 30%, transparent); }
|
||||
.chat-command-menu[hidden] { display: none; }
|
||||
.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); }
|
||||
/* 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-compose-actions { display: flex; align-items: center; flex: none; gap: var(--sp-2); }
|
||||
.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; }
|
||||
|
||||
+56
-34
@@ -1,10 +1,12 @@
|
||||
import { h, Fragment } from "preact";
|
||||
import { useState, useEffect, useRef } from "preact/hooks";
|
||||
import { api } from "../base/api.jsx";
|
||||
import { Icon } from "../base/icons.jsx";
|
||||
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 { commandScrollTop } from "./command-scroll.js";
|
||||
import { panelTitle, sessionTitle } from "./chat-render.jsx";
|
||||
|
||||
import "./chat.css";
|
||||
|
||||
@@ -12,7 +14,7 @@ function currentPage() {
|
||||
return location.hash.slice(1) || "/";
|
||||
}
|
||||
|
||||
export function ChatApp() {
|
||||
export function ChatApp({ open = true }) {
|
||||
const [sessions, setSessions] = useState([]);
|
||||
const [currentSession, setCurrentSession] = useState("");
|
||||
const [messages, setMessages] = useState([]);
|
||||
@@ -38,9 +40,46 @@ export function ChatApp() {
|
||||
const activeControllerRef = useRef(null);
|
||||
const sessionToolsRef = useRef(null);
|
||||
const commandMenuRef = useRef(null);
|
||||
const settingsRef = useRef(null);
|
||||
const isSendingRef = useRef(isSending);
|
||||
isSendingRef.current = isSending;
|
||||
|
||||
useEffect(() => {
|
||||
const closeSettings = (event) => {
|
||||
const details = settingsRef.current;
|
||||
if (!details?.open) return;
|
||||
if (event.target instanceof Node && details.contains(event.target)) return;
|
||||
details.open = false;
|
||||
};
|
||||
document.addEventListener("pointerdown", closeSettings);
|
||||
document.addEventListener("focusin", closeSettings);
|
||||
return () => {
|
||||
document.removeEventListener("pointerdown", closeSettings);
|
||||
document.removeEventListener("focusin", closeSettings);
|
||||
};
|
||||
}, []);
|
||||
|
||||
// The panel stays mounted so the session survives navigation, so opening it
|
||||
// is a prop change rather than a mount: focus the composer on that edge.
|
||||
useEffect(() => {
|
||||
if (open) composerRef.current?.focus();
|
||||
}, [open]);
|
||||
|
||||
// Arrow keys move the palette selection; the list scrolls so the highlight
|
||||
// stays visible once the matches run past the visible rows.
|
||||
useEffect(() => {
|
||||
if (!isCommandMenuOpen) return;
|
||||
const menu = commandMenuRef.current;
|
||||
const option = menu?.children?.[commandSelection];
|
||||
if (!menu || !option) return;
|
||||
menu.scrollTop = commandScrollTop({
|
||||
scrollTop: menu.scrollTop,
|
||||
viewportHeight: menu.clientHeight,
|
||||
optionTop: option.offsetTop,
|
||||
optionHeight: option.offsetHeight,
|
||||
});
|
||||
}, [commandSelection, isCommandMenuOpen]);
|
||||
|
||||
// Auto scroll transcript to bottom on new messages or streaming tokens
|
||||
useEffect(() => {
|
||||
if (transcriptRef.current) {
|
||||
@@ -400,6 +439,15 @@ export function ChatApp() {
|
||||
|
||||
return (
|
||||
<div className="chat-panel-content">
|
||||
<div className="chat-drawer-head">
|
||||
<strong className="chat-panel-title">{panelTitle(sessions, currentSession)}</strong>
|
||||
<div className="chat-head-actions">
|
||||
<button className="icon-btn chat-new" type="button" title="New chat" aria-label="New chat" onClick={handleNewChat}>
|
||||
<Icon name="message-circle-plus" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="chat-bar">
|
||||
<label className="chat-session-switch">
|
||||
<span className="sr-only">Conversation</span>
|
||||
@@ -420,11 +468,7 @@ export function ChatApp() {
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<button className="icon-btn chat-new" type="button" title="New chat" aria-label="New chat" onClick={handleNewChat}>
|
||||
+
|
||||
</button>
|
||||
|
||||
<details className="chat-settings">
|
||||
<details className="chat-settings" ref={settingsRef}>
|
||||
<summary aria-label="Chat settings" title="Chat settings">
|
||||
<span aria-hidden="true">⚙</span>
|
||||
</summary>
|
||||
@@ -487,21 +531,6 @@ export function ChatApp() {
|
||||
<div className="chat-layout">
|
||||
<section className="chat-workspace">
|
||||
<div className="chat-workspace-head">
|
||||
<details className="chat-command-help">
|
||||
<summary>Available commands ({commandSpecs.length})</summary>
|
||||
<div className="chat-command-list">
|
||||
{!commandSpecs.length ? (
|
||||
<span>Send a message to begin.</span>
|
||||
) : (
|
||||
commandSpecs.map((spec) => (
|
||||
<div className="chat-command-item" key={spec.command}>
|
||||
<code>{spec.usage || spec.command}</code>
|
||||
<span>{spec.description || ""}</span>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</details>
|
||||
<details
|
||||
className="chat-session-tools"
|
||||
ref={sessionToolsRef}
|
||||
@@ -602,7 +631,6 @@ export function ChatApp() {
|
||||
className={`chat-bubble-row ${isAssistant ? "assistant" : "user"}`}
|
||||
>
|
||||
<div className="chat-bubble">
|
||||
<div className="chat-bubble-meta">{isAssistant ? "Archie" : "You"}</div>
|
||||
{isAssistant ? (
|
||||
<Fragment>
|
||||
{tools.length > 0 && (
|
||||
@@ -665,7 +693,6 @@ export function ChatApp() {
|
||||
{streamingTurn && (
|
||||
<div className="chat-bubble-row assistant">
|
||||
<div className="chat-bubble">
|
||||
<div className="chat-bubble-meta">Archie</div>
|
||||
{streamingTurn.tools?.length > 0 && (
|
||||
<div className="chat-tools">
|
||||
{streamingTurn.tools.map((tool, tIdx) => {
|
||||
@@ -732,7 +759,6 @@ export function ChatApp() {
|
||||
rows={3}
|
||||
placeholder="Message Archie, or type / for commands"
|
||||
aria-label="Message Archie"
|
||||
disabled={isSending}
|
||||
value={composerText}
|
||||
onInput={handleComposerInput}
|
||||
onKeyDown={handleComposerKeyDown}
|
||||
@@ -761,15 +787,11 @@ export function ChatApp() {
|
||||
</div>
|
||||
)}
|
||||
<div className="chat-compose-actions">
|
||||
<span className="chat-hint">Enter to send · Shift+Enter for a new line</span>
|
||||
<button
|
||||
className="btn"
|
||||
type="button"
|
||||
disabled={!isSending}
|
||||
onClick={handleStop}
|
||||
>
|
||||
Stop
|
||||
</button>
|
||||
{isSending && (
|
||||
<button className="btn" type="button" onClick={handleStop}>
|
||||
Stop
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
className="btn btn-primary"
|
||||
type="button"
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// Keeping the arrow-key selection visible in the command palette.
|
||||
//
|
||||
// The palette caps its height and scrolls, so once the matches run past the
|
||||
// visible rows the selection walked off-screen and the highlight was invisible
|
||||
// (archie-core-ifay). Browsers have scrollIntoView, but the decision is pure
|
||||
// arithmetic and worth testing on its own, so the effect only applies what
|
||||
// this returns.
|
||||
|
||||
/**
|
||||
* commandScrollTop returns the scrollTop that brings the selected option fully
|
||||
* into view, or the current scrollTop when it is already visible. Mirrors
|
||||
* `scrollIntoView({ block: "nearest" })`: it moves the minimum distance, and
|
||||
* scrolls up for an option above the viewport, down for one below.
|
||||
*/
|
||||
export function commandScrollTop({ scrollTop, viewportHeight, optionTop, optionHeight }) {
|
||||
// An option taller than the viewport cannot be shown whole. Align its top,
|
||||
// which holds the command itself; aligning the bottom would scroll the name
|
||||
// out of sight and leave only the tail of its description.
|
||||
if (optionHeight >= viewportHeight) return optionTop;
|
||||
|
||||
if (optionTop < scrollTop) return optionTop;
|
||||
|
||||
const optionBottom = optionTop + optionHeight;
|
||||
const viewportBottom = scrollTop + viewportHeight;
|
||||
if (optionBottom > viewportBottom) return optionBottom - viewportHeight;
|
||||
|
||||
return scrollTop;
|
||||
}
|
||||
+51
-18
@@ -281,22 +281,51 @@ body {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* The panel grows out of the launcher. Closed, it is collapsed to a small
|
||||
round shape sitting exactly over the button; open, it is the full panel
|
||||
beside it. Scaling from the bottom-right corner and translating by the
|
||||
launcher's own width is what makes the button appear to become the panel,
|
||||
rather than a panel merely fading in next to it. */
|
||||
.chat-drawer-panel {
|
||||
pointer-events: auto;
|
||||
display: grid;
|
||||
grid-template-rows: auto minmax(0, 1fr);
|
||||
/* One child: ChatApp, which owns its own header row. A second track here
|
||||
left an empty band under the composer. */
|
||||
grid-template-rows: minmax(0, 1fr);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-md);
|
||||
overflow: hidden;
|
||||
|
||||
opacity: 0;
|
||||
/* Grows out of the launcher: the origin is the corner nearest the button. */
|
||||
border-radius: var(--radius-pill);
|
||||
transform-origin: bottom right;
|
||||
transform: scale(0.92) translateX(var(--sp-3));
|
||||
transition: opacity var(--transition), transform var(--transition);
|
||||
transform: translateX(calc(var(--fab-size) + var(--fab-gap))) scale(0.16);
|
||||
transition:
|
||||
opacity 160ms cubic-bezier(0.4, 0, 0.2, 1),
|
||||
transform 260ms cubic-bezier(0.22, 1, 0.36, 1),
|
||||
border-radius 260ms cubic-bezier(0.22, 1, 0.36, 1);
|
||||
}
|
||||
|
||||
.chat-drawer.is-open .chat-drawer-panel {
|
||||
opacity: 1;
|
||||
border-radius: var(--radius-lg);
|
||||
transform: none;
|
||||
}
|
||||
|
||||
/* The contents follow the shape rather than stretching with it: they fade in
|
||||
once the panel is most of the way open, so the morph reads as a container
|
||||
opening instead of a page being scaled up. */
|
||||
.chat-drawer-panel > * {
|
||||
opacity: 0;
|
||||
transition: opacity 120ms linear;
|
||||
}
|
||||
|
||||
.chat-drawer.is-open .chat-drawer-panel > * {
|
||||
opacity: 1;
|
||||
transition: opacity 160ms linear 120ms;
|
||||
}
|
||||
|
||||
/* A closed panel is still mounted so the session and its stream survive. It
|
||||
@@ -304,12 +333,11 @@ body {
|
||||
.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;
|
||||
transition:
|
||||
opacity 140ms cubic-bezier(0.4, 0, 0.2, 1),
|
||||
transform 200ms cubic-bezier(0.4, 0, 1, 1),
|
||||
border-radius 200ms cubic-bezier(0.4, 0, 1, 1),
|
||||
visibility 0s linear 200ms;
|
||||
}
|
||||
|
||||
.chat-drawer-head {
|
||||
@@ -333,19 +361,24 @@ body {
|
||||
position: fixed;
|
||||
right: var(--fab-inset);
|
||||
left: var(--fab-inset);
|
||||
bottom: var(--fab-inset);
|
||||
/* Clears the launcher, which stays put as the close control. */
|
||||
bottom: calc(var(--fab-inset) + var(--fab-size) + var(--fab-gap));
|
||||
width: auto;
|
||||
height: min(78vh, calc(100vh - var(--fab-inset) * 2));
|
||||
height: min(72vh, calc(100vh - var(--fab-inset) * 2 - var(--fab-size) - var(--fab-gap)));
|
||||
}
|
||||
|
||||
/* The sheet sits above the launcher rather than beside it, so it grows down
|
||||
toward the button instead of sideways. */
|
||||
.chat-drawer-panel {
|
||||
transform-origin: bottom center;
|
||||
transform: scale(0.98) translateY(var(--sp-3));
|
||||
transform-origin: bottom right;
|
||||
transform: translateY(calc(var(--fab-size) + var(--fab-gap))) scale(0.16);
|
||||
}
|
||||
|
||||
.chat-dock.is-open .chat-fab {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
/* The launcher is the only way to close the panel, so it stays above the
|
||||
sheet rather than hiding under it. */
|
||||
.chat-fab {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-7
@@ -224,13 +224,10 @@ function ChatLauncher() {
|
||||
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 />
|
||||
{/* ChatApp owns the header: the title is the open conversation. It
|
||||
carries no close button -- the launcher stays visible and is the
|
||||
one control that opens and closes the panel. */}
|
||||
<ChatApp open={open} />
|
||||
</div>
|
||||
</aside>
|
||||
<button
|
||||
|
||||
Reference in new issue
Block a user