Files
archie/ui/test/chat-app.test.js
T
sam af8ba18068 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

67 lines
2.9 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";
// ChatApp lives in a ~440px panel hung off the launcher, never on a page of its
// own. These tests hold that shape: one column, no page furniture, and the
// controls that are not conversation kept out of the reading area
// (archie-core-hesx).
test("the panel is a single column: no page title, no persistent sidebar", () => {
const { container, unmount } = render(<ChatApp />);
assert.equal(container.querySelector(".chat-topbar"), null, "page topbar should be gone");
assert.equal(container.querySelector(".chat-kicker"), null, "ARCHIE WORKSPACE kicker should be gone");
assert.equal(container.querySelector(".page-title"), null, "the panel header already names Archie");
assert.equal(container.querySelector(".chat-sidebar"), null, "conversations should not hold a column");
unmount();
});
test("the transcript and composer are the panel's own rows", () => {
const { container, unmount } = render(<ChatApp />);
assert.ok(container.querySelector(".chat-transcript"), "transcript should render");
assert.ok(container.querySelector(".chat-composer"), "composer should render");
unmount();
});
test("conversations are a switcher in the bar, not a column", () => {
const { container, unmount } = render(<ChatApp />);
const bar = container.querySelector(".chat-bar");
assert.ok(bar, "compact bar should render");
assert.ok(bar.querySelector(".chat-session-switch"), "session switcher should live in the bar");
unmount();
});
test("model controls are behind one settings affordance, not laid out inline", () => {
const { container, unmount } = render(<ChatApp />);
const settings = container.querySelector(".chat-settings");
assert.ok(settings, "settings popover should render");
assert.ok(settings.querySelector('[aria-label="Personality"]'), "personality lives in the popover");
assert.ok(settings.querySelector('[aria-label="Model"]'), "model lives in the popover");
// Closed by default: a 440px panel cannot spend its width on three selects.
assert.equal(settings.tagName, "DETAILS");
assert.equal(settings.hasAttribute("open"), false);
unmount();
});
test("operator panels are not rendered in the chat panel", () => {
const { container, unmount } = render(<ChatApp />);
assert.equal(container.querySelector(".chat-update-panel"), null, "update panel belongs to Configuration");
assert.equal(container.querySelector(".chat-dangerous-panel"), null, "dangerous actions belong to Configuration");
unmount();
});
test("the empty state still offers its prompts", () => {
const { container, unmount } = render(<ChatApp />);
assert.ok(container.querySelector(".chat-empty-state"), "empty state should be present");
assert.ok(container.querySelectorAll(".chat-prompt").length >= 3, "should have prompt buttons");
unmount();
});