Files
archie/ui/test/chat-panel.test.js
T
sam 1d2e58ebaa 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.
2026-09-20 16:30:01 +10:00

69 lines
2.8 KiB
JavaScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { render } from "@testing-library/preact";
import { ChatApp } from "../src/chat/chat.jsx";
import { panelTitle } from "../src/chat/chat-render.jsx";
// Remediation from testing the launcher panel (archie-core-ifay): the panel
// should read as a chat window, not as a toolbar with a transcript attached.
test("the header names the open conversation", () => {
const sessions = [
{ session_id: "abc12345", title: "Gate failures" },
{ session_id: "def67890", branch_name: "spike/retry" },
];
assert.equal(panelTitle(sessions, "abc12345"), "Gate failures");
assert.equal(panelTitle(sessions, "def67890"), "spike/retry");
});
test("with no conversation open the header falls back to the product name", () => {
assert.equal(panelTitle([], ""), "Archie");
assert.equal(panelTitle(undefined, undefined), "Archie");
// A session id with no matching record must not render "undefined".
assert.equal(panelTitle([], "missing"), "Archie");
});
test("the commands accordion is gone; the slash palette is the only command surface", () => {
const { container, unmount } = render(<ChatApp />);
assert.equal(container.querySelector(".chat-command-help"), null);
unmount();
});
test("the composer carries no keyboard hint text", () => {
const { container, unmount } = render(<ChatApp />);
assert.ok(
!/Enter to send/i.test(container.textContent),
"the Enter/Shift+Enter hint should be gone",
);
unmount();
});
test("Stop is absent while nothing is generating", () => {
const { container, unmount } = render(<ChatApp />);
const labels = [...container.querySelectorAll(".chat-compose button")].map((b) => b.textContent.trim());
assert.ok(!labels.includes("Stop"), `Stop should not render when idle: ${labels.join(", ")}`);
assert.ok(labels.includes("Send"), "Send should still render");
unmount();
});
test("new chat lives in the header, and the panel has no close button", () => {
const { container, unmount } = render(<ChatApp />);
const head = container.querySelector(".chat-drawer-head");
assert.ok(head, "the panel owns its header");
assert.ok(head.querySelector(".chat-new"), "new chat should sit in the header");
assert.equal(container.querySelector(".chat-bar .chat-new"), null, "and not in the bar");
// The launcher stays visible and is the only control that closes the panel.
const closers = [...container.querySelectorAll("button")].filter(
(b) => /close/i.test(b.getAttribute("aria-label") || ""),
);
assert.deepEqual(closers, [], "the panel should carry no close button");
unmount();
});
test("message bubbles carry no speaker label", () => {
const { container, unmount } = render(<ChatApp />);
assert.equal(container.querySelector(".chat-bubble-meta"), null);
unmount();
});