Rename remaining JS files to JSX

This commit is contained in:
sam committed 2026-09-03 00:12:03 +10:00
1 parent a9af691b81
commit 9e86bd0962
39 files changed
+83 -348

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
// Single place that knows how to talk to archied. Every feature folder goes
// through this, so auth handling and error shape live in one file.
import { randomUUID } from "./uuid.js";
import { randomUUID } from "./uuid.jsx";
async function req(path) {
// A daemon that accepts the connection but never answers would otherwise
+1 -1
View File
@@ -55,7 +55,7 @@ export function pill(text, kind = "idle") {
// Re-exported from task-meta.js so the pill severity vocabulary has a single
// source (the server catalog). Importers that pull statusKind from dom.js --
// e.g. dashboard.js -- keep working, and the hardcoded switch is gone.
export { statusKind } from "./task-meta.js";
export { statusKind } from "./task-meta.jsx";
/** Humanised relative time: "2 min ago". Raw timestamps make people do maths. */
export function ago(value) {
@@ -1,4 +1,4 @@
import { el } from "./dom.js";
import { el } from "./dom.jsx";
/**
* Arc gauge for a single headline percentage.
File renamed without changes.
@@ -1,4 +1,4 @@
import { el } from "./dom.js";
import { el } from "./dom.jsx";
/**
* Shared log-entry rendering. Both the daemon-wide log page
@@ -1,5 +1,5 @@
import { el } from "./dom.js";
import { icon } from "./icons.js";
import { el } from "./dom.jsx";
import { icon } from "./icons.jsx";
/**
* A KPI tile: label, big value, trend against a stated comparison window, and
@@ -8,7 +8,7 @@
// keep working when archied is unreachable; loadTaskMeta() replaces them with
// the live catalog as soon as it arrives. They must match the backend catalog
// so drawing the page never flashes a stale label.
import { api } from "./api.js";
import { api } from "./api.jsx";
const DEFAULT_STATUSES = [
{ id: "queued", label: "Queued", kind: "idle" },
File renamed without changes.
@@ -1,4 +1,4 @@
import { ago, el, pill } from "../base/dom.js";
import { ago, el, pill } from "../base/dom.jsx";
/**
* One captured event's summary row, plus its expandable detail row when
@@ -1,7 +1,7 @@
import "./captures.css";
import { api, subscribeEvents } from "../base/api.js";
import { el, empty, mount, pill } from "../base/dom.js";
import { captureRow } from "./capture-row.js";
import { api, subscribeEvents } from "../base/api.jsx";
import { el, empty, mount, pill } from "../base/dom.jsx";
import { captureRow } from "./capture-row.jsx";
/**
* Event inspector (t2db.2): the operator-facing half of capture. Recent
@@ -1,6 +1,6 @@
import "./channels.css";
import { api } from "../base/api.js";
import { el, empty, mount, pill } from "../base/dom.js";
import { api } from "../base/api.jsx";
import { el, empty, mount, pill } from "../base/dom.jsx";
/**
* How you reach Archie. Backed by GET /api/channels, which derives from
@@ -1,5 +1,5 @@
import { el } from "../base/dom.js";
import { sessionTitle } from "./chat-render.js";
import { el } from "../base/dom.jsx";
import { sessionTitle } from "./chat-render.jsx";
export function renderSessions({ sessionList, sessionTools, sessions, currentSession, onSelect }) {
sessionList.replaceChildren();
@@ -1,4 +1,4 @@
import { el } from "../base/dom.js";
import { el } from "../base/dom.jsx";
export function renderUpdate(panel, data, { onDefer, onInstall }) {
panel.replaceChildren();
@@ -1,5 +1,5 @@
import { el } from "../base/dom.js";
import { renderMarkdown } from "./markdown.js";
import { el } from "../base/dom.jsx";
import { renderMarkdown } from "./markdown.jsx";
export function sessionTitle(session) {
return session.title || session.branch_name || `Conversation ${session.session_id.slice(0, 8)}`;
@@ -1,4 +1,4 @@
import { randomUUID } from "../base/uuid.js";
import { randomUUID } from "../base/uuid.jsx";
export function newChatTurn(text) {
return { text, sourceID: randomUUID() };
@@ -1,4 +1,4 @@
import { randomUUID } from "../base/uuid.js";
import { randomUUID } from "../base/uuid.jsx";
const CHANNEL_KEY = "archie.web.chat.channel";
@@ -1,4 +1,4 @@
import { renderMarkdown } from "./markdown.js";
import { renderMarkdown } from "./markdown.jsx";
export function updateStreamingReply(current, text) {
const next = renderMarkdown(text);
@@ -1,4 +1,4 @@
import { el } from "../base/dom.js";
import { el } from "../base/dom.jsx";
// Tool activity is rendered into its own list inside the assistant bubble
// rather than folded into the reply text: the text node is replaced wholesale
File renamed without changes.
File renamed without changes.
+11 -11
View File
@@ -1,14 +1,14 @@
import { el } from "../base/dom.js";
import { api } from "../base/api.js";
import { createChatView } from "./chat-view.js";
import { assistantBubble, chatBubble } from "./chat-render.js";
import { updateStreamingReply } from "./chat-stream.js";
import { appendToolCall, appendNavigateChip } from "./chat-tools.js";
import { channelID } from "./chat-state.js";
import { retryChatTurn, resolveTurn } from "./chat-retry.js";
import { renderCommands, renderModels, renderSelectors, renderSessions } from "./chat-catalog.js";
import { renderDangerous, renderUpdate } from "./chat-panels.js";
import { updateUnavailableMessage } from "./chat-update-status.js";
import { el } from "../base/dom.jsx";
import { api } from "../base/api.jsx";
import { createChatView } from "./chat-view.jsx";
import { assistantBubble, chatBubble } from "./chat-render.jsx";
import { updateStreamingReply } from "./chat-stream.jsx";
import { appendToolCall, appendNavigateChip } from "./chat-tools.jsx";
import { channelID } from "./chat-state.jsx";
import { retryChatTurn, resolveTurn } from "./chat-retry.jsx";
import { renderCommands, renderModels, renderSelectors, renderSessions } from "./chat-catalog.jsx";
import { renderDangerous, renderUpdate } from "./chat-panels.jsx";
import { updateUnavailableMessage } from "./chat-update-status.jsx";
import "./chat.css";
@@ -1,4 +1,4 @@
import { el } from "../base/dom.js";
import { el } from "../base/dom.jsx";
function inlineMarkdown(text) {
const fragment = document.createDocumentFragment();
@@ -1,6 +1,6 @@
import "./curators.css";
import { api } from "../base/api.js";
import { el, empty, mount, pill, ago } from "../base/dom.js";
import { api } from "../base/api.jsx";
import { el, empty, mount, pill, ago } from "../base/dom.jsx";
/**
* Curator observability (archie-core-1786637489932-6). Backed by GET
+3 -3
View File
@@ -1,7 +1,7 @@
import "./logs.css";
import { api, subscribeLogs } from "../base/api.js";
import { el, empty, mount, pill } from "../base/dom.js";
import { logRow } from "../base/log-row.js";
import { api, subscribeLogs } from "../base/api.jsx";
import { el, empty, mount, pill } from "../base/dom.jsx";
import { logRow } from "../base/log-row.jsx";
/**
* The log view: history from the file on disk, then live lines appended from
-253
View File
@@ -1,253 +0,0 @@
import "./css/_main.css";
import { el, mount } from "./base/dom.js";
import { icon } from "./base/icons.js";
import { dashboardPage } from "./dashboard/dashboard.js";
import { tasksPage } from "./tasks/tasks.js";
import { skillsPage } from "./skills/skills.js";
import { workflowsPage } from "./workflows/workflows.js";
import { channelsPage } from "./channels/channels.js";
import { curatorsPage } from "./curators/curators.js";
import { settingsPage } from "./settings/settings.js";
import { logsPage } from "./logs/logs.js";
import { capturesPage } from "./captures/captures.js";
import { mappingsPage } from "./mappings/mappings.js";
import { memoryPage } from "./memory/memory.js";
import { chatPage } from "./chat/chat.js";
/**
* Routes are declared once here. Adding a section means adding a feature
* folder and one entry -- there is no switch statement to hunt for.
*
* `soon: true` sections are deliberately visible before they are built: a
* greyed, labelled entry tells you the capability exists and is coming, which
* is more honest than hiding it and more useful than a 404.
*/
const routes = [
{ path: "/", label: "Dashboard", icon: "dashboard", view: dashboardPage },
{ path: "/chat", label: "Chat", icon: "chat", view: chatPage },
{ path: "/tasks", label: "Tasks", icon: "tasks", view: tasksPage },
{ path: "/logs", label: "Logs", icon: "logs", view: logsPage },
{ path: "/captures", label: "Event inspector", icon: "captures", view: capturesPage },
{ path: "/mappings", label: "Field mappings", icon: "mappings", view: mappingsPage },
{ path: "/skills", label: "Skills", icon: "skills", view: skillsPage },
{ path: "/workflows", label: "Workflows", icon: "workflows", view: workflowsPage },
{ path: "/memory", label: "Memory", icon: "memory", view: memoryPage },
{ path: "/curators", label: "Curators", icon: "curators", view: curatorsPage },
{ path: "/channels", label: "Channels", icon: "channels", view: channelsPage },
{ path: "/settings", label: "Configuration", icon: "settings", view: settingsPage },
];
const THEME_KEY = "archie.theme";
function applyTheme(theme) {
document.documentElement.dataset.theme = theme;
localStorage.setItem(THEME_KEY, theme);
}
function currentTheme() {
return localStorage.getItem(THEME_KEY) || "dark";
}
function commandBar(onNavigate, onToggleChat) {
const items = new Map();
const nav = el(
"nav.nav",
...[null].flatMap(() => [
...routes
.map((route) => {
const item = el(
"a.nav-item",
{
href: `#${route.path}`,
onclick: (e) => {
if (route.soon) e.preventDefault();
else onNavigate(route.path);
},
"aria-disabled": route.soon || undefined,
title: route.soon ? "Coming soon" : undefined,
},
icon(route.icon),
el("span.nav-label", route.label),
route.soon && el("span.nav-soon", "soon"),
);
items.set(route.path, item);
return item;
}),
]),
);
const themeBtn = el("button.icon-btn", {
title: "Toggle light and dark",
"aria-label": "Toggle light and dark",
onclick: () => {
applyTheme(currentTheme() === "dark" ? "light" : "dark");
mount(themeBtn, icon(currentTheme() === "dark" ? "moon" : "sun"));
},
});
mount(themeBtn, icon(currentTheme() === "dark" ? "moon" : "sun"));
// Search jumps between sections. It is deliberately not a data search: the
// sections own their own filtering, and a second search that means something
// different in each place is worse than none.
let searchWrap;
const closeMobileSearch = () => {
searchWrap?.classList.remove("is-open");
searchToggle.setAttribute("aria-expanded", "false");
};
const searchToggle = el(
"button.icon-btn.mobile-search-toggle",
{
type: "button",
"aria-label": "Open Jump to navigation",
"aria-expanded": "false",
onclick: () => {
searchWrap.classList.add("is-open");
searchToggle.setAttribute("aria-expanded", "true");
search.focus();
},
},
icon("search", { size: 15 }),
);
const search = el("input", {
type: "search",
placeholder: "Jump to\u2026",
"aria-label": "Jump to a section",
onkeydown: (e) => {
if (e.key === "Escape") {
// preventDefault so the window-level handler (chat drawer close) does
// not also fire: dismissing the search should not dismiss the drawer.
e.preventDefault();
closeMobileSearch();
e.target.blur();
return;
}
if (e.key !== "Enter") return;
const q = e.target.value.trim().toLowerCase();
const hit = routes.find((r) => !r.soon && r.label.toLowerCase().startsWith(q));
if (hit) {
onNavigate(hit.path);
e.target.value = "";
e.target.blur();
closeMobileSearch();
}
},
});
searchWrap = el(
"div.topbar-search",
el("span.topbar-search-icon", { "aria-hidden": "true" }, icon("search", { size: 15 })),
searchToggle,
search,
);
return {
node: el(
"header.topbar",
el("div.brand", el("span.brand-mark", "A"), "Archie"),
nav,
el(
"div.topbar-end",
searchWrap,
el("button.icon-btn.icon-btn-chat", {
"aria-label": "Open chat",
title: "Chat with Archie",
"aria-expanded": "false",
onclick: () => onToggleChat?.(),
}, icon("chat")),
el("button.icon-btn", { title: "Documentation", "aria-label": "Documentation" }, icon("help")),
themeBtn,
el("div.avatar", { title: "Signed in locally" }, "A"),
),
),
highlight(path) {
for (const [p, node] of items) {
if (p === path) node.setAttribute("aria-current", "page");
else node.removeAttribute("aria-current");
}
},
};
}
function start() {
applyTheme(currentTheme());
const outlet = el("main.main");
// 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.
const chatDrawer = el("aside.chat-drawer", { "aria-label": "Chat with Archie" });
const chatClose = el("button.icon-btn.chat-drawer-close", {
"aria-label": "Close chat",
title: "Close chat",
onclick: () => toggleChat(false),
}, icon("close"));
const drawerHead = el("div.chat-drawer-head", el("strong", "Archie"), chatClose);
chatDrawer.append(el("div.chat-drawer-panel", drawerHead, chatPage()),
el("div.chat-scrim", { onclick: () => toggleChat(false) }));
const bar = commandBar(navigate, () => toggleChat());
const shell = el("div.shell", bar.node, outlet, chatDrawer);
mount(document.getElementById("app"), shell);
function toggleChat(open) {
const shouldOpen = open === undefined ? !chatDrawer.classList.contains("is-open") : open;
chatDrawer.classList.toggle("is-open", shouldOpen);
document.body.classList.toggle("chat-open", shouldOpen);
const btn = shell.querySelector(".icon-btn-chat");
if (btn) btn.setAttribute("aria-expanded", String(shouldOpen));
}
window.__archieToggleChat = toggleChat;
function navigate(path) {
if (location.hash !== '#' + path) location.hash = path;
else show(path);
}
function show(rawPath) {
// Let a page release its subscriptions before it is replaced, so the SSE
// stream does not leak a connection per navigation.
outlet.firstElementChild?.dispatchEvent(new CustomEvent("archie:teardown"));
const [path, query = ""] = rawPath.split("?", 2);
const route = routes.find((r) => r.path === path) || routes[0];
bar.highlight(route.path);
// 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") {
mount(outlet);
toggleChat(true);
return;
}
mount(outlet, route.view ? route.view(new URLSearchParams(query)) : comingSoon(route));
// Navigating to a page dismisses the chat drawer; the operator has moved on.
toggleChat(false);
}
window.addEventListener("hashchange", () => show(location.hash.slice(1) || "/"));
window.addEventListener("keydown", (e) => {
// 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 (e.defaultPrevented) return;
if (e.key === "Escape" && chatDrawer.classList.contains("is-open")) toggleChat(false);
});
show(location.hash.slice(1) || "/");
}
function comingSoon(route) {
return el(
"div",
el("div.page-head", el("div", el("h1.page-title", route.label))),
el(
"div.card",
el(
"div.empty",
el("div.empty-title", `${route.label} is not built yet`),
el("div", "This section is next up. Nothing is broken."),
),
),
);
}
start();
+13 -25
View File
@@ -209,31 +209,19 @@ function start() {
// Let a page release its subscriptions before it is replaced, so the SSE
// stream does not leak a connection per navigation.
outlet.firstElementChild?.dispatchEvent(new CustomEvent("archie:teardown"));
// Unmount Preact cleanly if a Preact component was mounted here
import("preact").then(({ render, isValidElement }) => {
render(null, outlet);
const [path, query = ""] = rawPath.split("?", 2);
const route = routes.find((r) => r.path === path) || routes[0];
bar.highlight(route.path);
// 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") {
mount(outlet);
toggleChat(true);
return;
}
const viewContent = route.view ? route.view(new URLSearchParams(query)) : comingSoon(route);
if (isValidElement(viewContent)) {
render(viewContent, outlet);
} else {
mount(outlet, viewContent);
}
// Navigating to a page dismisses the chat drawer; the operator has moved on.
toggleChat(false);
});
const [path, query = ""] = rawPath.split("?", 2);
const route = routes.find((r) => r.path === path) || routes[0];
bar.highlight(route.path);
// 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") {
mount(outlet);
toggleChat(true);
return;
}
mount(outlet, route.view ? route.view(new URLSearchParams(query)) : comingSoon(route));
// Navigating to a page dismisses the chat drawer; the operator has moved on.
toggleChat(false);
}
window.addEventListener("hashchange", () => show(location.hash.slice(1) || "/"));
@@ -1,4 +1,4 @@
import { el, pill } from "../base/dom.js";
import { el, pill } from "../base/dom.jsx";
/**
* Pure rendering + path/type logic for the mapping editor, split out from
@@ -1,7 +1,7 @@
import "./mappings.css";
import { api } from "../base/api.js";
import { el, empty, mount } from "../base/dom.js";
import { fieldsTable, mappingRow, payloadTree } from "./mapping-editor.js";
import { api } from "../base/api.jsx";
import { el, empty, mount } from "../base/dom.jsx";
import { fieldsTable, mappingRow, payloadTree } from "./mapping-editor.jsx";
/**
* Payload field mapping (t2db.3): bind named fields to JSON paths inside a
@@ -1,7 +1,7 @@
import "./memory.css";
import { api } from "../base/api.js";
import { el, empty, mount, pill } from "../base/dom.js";
import { icon } from "../base/icons.js";
import { api } from "../base/api.jsx";
import { el, empty, mount, pill } from "../base/dom.jsx";
import { icon } from "../base/icons.jsx";
/**
* Memory: what Archie can recall, and with what.
@@ -1,5 +1,5 @@
import { api } from "../base/api.js";
import { el, mount } from "../base/dom.js";
import { api } from "../base/api.jsx";
import { el, mount } from "../base/dom.jsx";
/**
* One key/value row on the Configuration page, and its inline edit flow.
@@ -1,9 +1,9 @@
import "./settings.css";
import { api } from "../base/api.js";
import { el, empty, mount, pill } from "../base/dom.js";
import { statusKind, statusLabel } from "../base/task-meta.js";
import { row } from "./config-row.js";
import { updateStatusCard } from "./update-status.js";
import { api } from "../base/api.jsx";
import { el, empty, mount, pill } from "../base/dom.jsx";
import { statusKind, statusLabel } from "../base/task-meta.jsx";
import { row } from "./config-row.jsx";
import { updateStatusCard } from "./update-status.jsx";
/**
* A view of the config archied is actually running with, grouped by
@@ -272,7 +272,7 @@ function repositoriesCard(repos, onSaved) {
// repoBoolCell renders an immediately-autosaving checkbox, PATCHing
// api.configRepoUpdate on change and reverting the toggle if the save
// fails (archie-core-b6ew.6). A table cell doesn't fit config-row.js's
// fails (archie-core-b6ew.6). A table cell doesn't fit config-row.jsx's
// label/value/actions Edit-then-Save flow, and a checkbox is the more
// natural control for a boolean in a table anyway.
function repoBoolCell(r, field, onSaved) {
@@ -1,4 +1,4 @@
import { el, empty, pill } from "../base/dom.js";
import { el, empty, pill } from "../base/dom.jsx";
const STATUS_LABELS = {
ok: "OK",
@@ -1,6 +1,6 @@
import "./skills.css";
import { api } from "../base/api.js";
import { el, empty, mount } from "../base/dom.js";
import { api } from "../base/api.jsx";
import { el, empty, mount } from "../base/dom.jsx";
/**
* What Archie can actually do, beyond what is in the source. Backed by
@@ -1,4 +1,4 @@
import { attentionStatusIds, statusIds } from "../base/task-meta.js";
import { attentionStatusIds, statusIds } from "../base/task-meta.jsx";
// The vocabulary is the server catalog, not a hand-synced copy: the "needs
// you" grouping and the set of known statuses come straight from task-meta so
@@ -1,5 +1,5 @@
import { el, empty } from "../base/dom.js";
import { logRow } from "../base/log-row.js";
import { el, empty } from "../base/dom.jsx";
import { logRow } from "../base/log-row.jsx";
/**
* Renders one task's persisted attempt log (GET /api/tasks/:id/logs) --
File renamed without changes.
@@ -1,12 +1,12 @@
import "./tasks.css";
import { api } from "../base/api.js";
import { ago, el, empty, mount, pill } from "../base/dom.js";
import { statTile } from "../base/statTile.js";
import { taskRowA11y } from "./task-row.js";
import { initialTaskFilter, taskMatchesStatus } from "./task-filters.js";
import { describeTimelineEvent } from "./timeline-event.js";
import { taskLogPanel } from "./task-logs.js";
import { actionFor, statusIds, statusKind, statusLabel } from "../base/task-meta.js";
import { api } from "../base/api.jsx";
import { ago, el, empty, mount, pill } from "../base/dom.jsx";
import { statTile } from "../base/statTile.jsx";
import { taskRowA11y } from "./task-row.jsx";
import { initialTaskFilter, taskMatchesStatus } from "./task-filters.jsx";
import { describeTimelineEvent } from "./timeline-event.jsx";
import { taskLogPanel } from "./task-logs.jsx";
import { actionFor, statusIds, statusKind, statusLabel } from "../base/task-meta.jsx";
/**
* The work board: every task archied knows about, filterable by status and
File renamed without changes.
@@ -1,6 +1,6 @@
import "./workflows.css";
import { api } from "../base/api.js";
import { el, empty, mount } from "../base/dom.js";
import { api } from "../base/api.jsx";
import { el, empty, mount } from "../base/dom.jsx";
/**
* Plain-language workflow names. Falls back to a title-cased version of the