feat(webui): dashboard-aware chat — Archie sees the page, points you there
The web chat is now a persistent slide-over drawer available on any page
(not just the /chat route), and the agent is told which dashboard page the
operator is on so it can point them to the relevant page with a clickable chip.
Backend (gateway):
- Message gains a per-message Page field; the system prompt renders it in
the <env> block (Current page), so Archie knows where the operator is.
- New dashboard_tools.go: a DashboardPages registry plus two web-only tools
— page_index (lists every page and what it shows) and dashboard_navigate
(validates a path, returns {path,label}; rejects unknown/empty paths).
- The web chat sink emits a dedicated navigate stream event when the model
calls dashboard_navigate, independent of ShowToolCalls.
Frontend (webui):
- chat sends currentPage() (location.hash) with each stream request; a
dashboard_navigate result renders as a clickable link chip (href=#/path).
- The chat is mounted once in a slide-over drawer with a topbar launcher,
scrim and Esc-to-close; /chat opens the drawer instead of a second page.
- ui/dist rebuilt (committed) with the bundled changes.
- .gitignore: ignore .impeccable/ (impeccable tool critique snapshots).
New capability (per scope discipline): designed in
docs/prds/dashboard-aware-chat-navigation.md.
Tests: dashboard_tools_test (registry, resolve/reject, web-only gating),
prompt page-line cases, webui Message.Page + navigate-frame capture, and
chat-tools chip tests. task check is green.
This commit is contained in:
1 parent
3ffc4df8d6
commit
ea1017af94
21 files changed
+743
-15
No files matched your search
@@ -42,3 +42,6 @@ node_modules/
|
||||
.beads-credential-key
|
||||
.beads/proxieddb/
|
||||
*.gate.lock*
|
||||
# Impeccable design-tool scratch/critique snapshots (usable by $impeccable polish, never committed)
|
||||
.impeccable/
|
||||
.serena/
|
||||
@@ -0,0 +1,135 @@
|
||||
# Dashboard-aware chat: Archie sees the page, and points the operator there
|
||||
|
||||
**Status:** Design decision (before implementation)
|
||||
**Date:** 2026-08-26
|
||||
**Compound:** the "chat available on any page" surface work (global chat presence)
|
||||
|
||||
## Decision
|
||||
|
||||
Make the web chat **dashboard-aware**: the agent is told which dashboard page
|
||||
the operator is on *right now*, knows what each page is for, and can **point**
|
||||
the operator to the relevant page with a **clickable destination chip** the UI
|
||||
renders and follows - Option B (context + navigate), not just "tell me in text."
|
||||
|
||||
Three seams, each an existing extension point, one new tool and one message field:
|
||||
|
||||
1. **Current page, into the prompt.** The browser sends its route with every
|
||||
chat message; the gateway threads it into the system prompt's runtime-metadata
|
||||
env block. Archie always knows where the operator is looking.
|
||||
2. **Page index.** A page_index tool lists the dashboard pages and what each one
|
||||
shows, so Archie knows what to point at - the agent "has the map".
|
||||
3. **Navigate.** A dashboard_navigate tool returns a structured path/label; the web
|
||||
UI renders it as a clickable chip that routes the operator there. This is the
|
||||
"plenty of resources" the requirement named.
|
||||
|
||||
We deliberately keep the agent's answer honest: the chip is *evidence* it can
|
||||
validly produce because dashboard_navigate is a real tool whose result is
|
||||
rendered, not a markdown link the model invents.
|
||||
|
||||
## Why now
|
||||
|
||||
This is the natural next step of the "chat on any page" work, and the original
|
||||
request named it explicitly: *"archie should be able to see what page you're on
|
||||
too. and point out where to go. so it needs plenty of resources."* Today the chat
|
||||
is a full-page route with no knowledge of the rest of the dashboard; the agent
|
||||
cannot see which page the operator is on and cannot reliably direct them anywhere.
|
||||
The critique of the chat UI already identified "chat is not available on any page"
|
||||
as the largest structural gap (P1). This design is the capability that makes that
|
||||
gap worth closing.
|
||||
|
||||
## Shape of the API
|
||||
|
||||
### Message field (gateway.go)
|
||||
|
||||
Add Page to Message:
|
||||
|
||||
```go
|
||||
// Page is the dashboard route the operator is on when they sent this message
|
||||
// (e.g. "/tasks", "/logs"). Empty for non-web channels, which have no page
|
||||
// context. It is per-message, not per-session: the operator navigates freely
|
||||
// while a conversation stays open.
|
||||
Page string
|
||||
```
|
||||
|
||||
### Web request (api_chat.go)
|
||||
|
||||
chatMessageRequest gains Page, decoded into Message.Page in decodeChatMessage.
|
||||
|
||||
### System prompt config (prompt.go)
|
||||
|
||||
SystemPromptConfig gains Page; BuildSystemPrompt passes it through to the template.
|
||||
The env block of archie.md.tpl renders the current page when set.
|
||||
|
||||
### Page index (dashboard_tools.go, new)
|
||||
|
||||
A package-level registry mapping route to {Label, Description}. page_index returns
|
||||
the list so the model knows what each page shows:
|
||||
|
||||
```go
|
||||
type DashboardPage struct {
|
||||
Path string // "/tasks"
|
||||
Label string // "Tasks"
|
||||
Description string // "Issues Archie picked up, and where they stand."
|
||||
}
|
||||
```
|
||||
|
||||
### Navigation tool (dashboard_tools.go)
|
||||
|
||||
dashboard_navigate validates its path against the registry and returns the resolved
|
||||
path/label. Unknown path means a clear error, not a guess. The model must call the
|
||||
tool (not invent a link) to produce a chip, so the chip is honest.
|
||||
|
||||
### Tool wiring (turn.go)
|
||||
|
||||
extraTools already merges TaskTools + SessionTools. Add the dashboard tools alongside
|
||||
them, gated on the channel being the web UI. The tool list is built from the same
|
||||
registry the prompt's page line comes from, so the agent never points at a page it
|
||||
was not told about.
|
||||
|
||||
### Web UI (chat-render.js, chat-tools.js)
|
||||
|
||||
A dashboard_navigate tool call renders as a **clickable chip**: an anchor with
|
||||
href="#/tasks" and the label. Because the app routes on location.hash, the chip is a
|
||||
real link that works from any page once the chat is a global presence. The chip is
|
||||
styled as an action, not a code line, so it visibly invites a click.
|
||||
|
||||
### Route transfer (chat.js)
|
||||
|
||||
Each sendMessage includes the current location.hash route as page in the stream
|
||||
request body, so the backend gets the operator's live position.
|
||||
|
||||
## What we deliberately do NOT do
|
||||
|
||||
- **No navigation from a markdown link.** The model must use dashboard_navigate; a
|
||||
bare "click here" is not rendered as a trusted route.
|
||||
- **No full-page route hijack from the chat.** The chip sets location.hash.
|
||||
- **No page index for non-web channels.** Telegram/discord have no dashboard.
|
||||
- **No automatic history annotation.** Page is per-message from the browser.
|
||||
- **No change to the dangerous-action approval flow.** Separately tracked.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
1. Chat messages from any page carry the current page to the agent's prompt.
|
||||
2. page_index returns every dashboard page with a plain-language description.
|
||||
3. dashboard_navigate renders a clickable chip that routes to the target page.
|
||||
4. dashboard_navigate rejects an unknown route with a clear error, no chip.
|
||||
5. Non-web chat channels get neither tool, and Message.Page stays empty.
|
||||
6. Tests cover prompt page line; navigate resolve/reject; non-web exclusion; and the
|
||||
web request decoder round-trips page.
|
||||
|
||||
## Files this change touches
|
||||
|
||||
- internal/gateway/gateway.go - Message.Page
|
||||
- internal/gateway/prompt.go + templates/archie.md.tpl - SystemPromptConfig.Page, env line
|
||||
- internal/gateway/dashboard_tools.go (new) - registry, page_index, dashboard_navigate
|
||||
- internal/gateway/turn.go - merge dashboard tools into extraTools
|
||||
- internal/gateway/prompt_test.go + dashboard_tools_test.go (new) - prompt + tool tests
|
||||
- internal/webui/api_chat.go - chatMessageRequest.Page, decoder
|
||||
- ui/src/chat/chat.js - send page with each stream request; render navigate chips
|
||||
- ui/src/chat/chat-render.js + chat-tools.js + chat.css - clickable chip
|
||||
- ui/src/main.js + shell - persistent chat presence + current-page tracking (separate)
|
||||
|
||||
> The persistent "chat on any page" surface (drawer/launcher in the shell) is the
|
||||
> companion change that makes the chip navigable from anywhere. It is the same
|
||||
> capability and should land with or just before it, but is not required for the
|
||||
> backend to be correct and testable on its own.
|
||||
@@ -0,0 +1,124 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/tools"
|
||||
)
|
||||
|
||||
// DashboardPage describes one dashboard surface so the chat agent can both
|
||||
// understand what each place is for and point the operator there.
|
||||
type DashboardPage struct {
|
||||
// Path is the route (e.g. "/tasks"). It is what the browser hash becomes.
|
||||
Path string
|
||||
// Label is the human name shown in navigation (e.g. "Tasks").
|
||||
Label string
|
||||
// Description is a one-line plain-language explanation of what the page
|
||||
// shows, so the agent can answer "where do I go for that?" correctly.
|
||||
Description string
|
||||
}
|
||||
|
||||
// dashboardPages is the single source of truth for what the dashboard exposes.
|
||||
// It is deliberately a package-level registry rather than a per-router field:
|
||||
// the same pages are shown regardless of identity, and the prompt's current
|
||||
// page line and the dashboard_navigate tool both draw from it, so the agent
|
||||
// never points at a page it was not told about.
|
||||
var dashboardPages = []DashboardPage{
|
||||
{Path: "/", Label: "Dashboard", Description: "The control room: what Archie is working on, what needs you, and token spend."},
|
||||
{Path: "/chat", Label: "Chat", Description: "Conversations with Archie and the web chat session tools."},
|
||||
{Path: "/tasks", Label: "Tasks", Description: "Issues Archie has picked up and where they stand: the work queue."},
|
||||
{Path: "/logs", Label: "Logs", Description: "The daemon log stream, filterable by level and component."},
|
||||
{Path: "/captures", Label: "Event inspector", Description: "Captured inbound events for inspection."},
|
||||
{Path: "/mappings", Label: "Field mappings", Description: "How inbound event fields map onto internal ones."},
|
||||
{Path: "/skills", Label: "Skills", Description: "The SKILL.md capabilities Archie can activate."},
|
||||
{Path: "/workflows", Label: "Workflows", Description: "The routed workflows (bootstrap, implement, tdd, feasibility) and their run history."},
|
||||
{Path: "/memory", Label: "Memory", Description: "What Archie carries between conversations and the tools that read it."},
|
||||
{Path: "/channels", Label: "Channels", Description: "Inbound chat and notification channels (e.g. Telegram) and their state."},
|
||||
{Path: "/settings", Label: "Configuration", Description: "Daemon configuration editable from the dashboard."},
|
||||
}
|
||||
|
||||
// DashboardPages returns a copy of the dashboard page registry.
|
||||
func DashboardPages() []DashboardPage {
|
||||
out := make([]DashboardPage, len(dashboardPages))
|
||||
copy(out, dashboardPages)
|
||||
return out
|
||||
}
|
||||
|
||||
// PageIndexResult is what page_index returns: the full list of dashboard pages
|
||||
// and what each one shows, so the agent can answer where to go.
|
||||
type PageIndexResult struct {
|
||||
Pages []DashboardPage `json:"pages"`
|
||||
}
|
||||
|
||||
// pageIndexTool returns the tool that lists every dashboard page. It is only
|
||||
// registered for the web channel (see PageIndexTools), because pointing a
|
||||
// non-web operator at an internal dashboard route is meaningless.
|
||||
func pageIndexTool() (tools.ToolEntry, bool) {
|
||||
entry := tools.ToolEntry{
|
||||
Name: "page_index",
|
||||
Toolset: "dashboard",
|
||||
Description: "List every dashboard page and, in one line, what it shows. Use it to tell the operator where to go for something rather than guessing.",
|
||||
Classification: tools.ClassIdempotent,
|
||||
Handler: func(_ context.Context, _ map[string]any) (any, error) {
|
||||
return PageIndexResult{Pages: DashboardPages()}, nil
|
||||
},
|
||||
}
|
||||
return entry, true
|
||||
}
|
||||
|
||||
// DashboardNavigateResult is what dashboard_navigate returns. The web UI
|
||||
// renders it as a clickable chip that routes the operator to the page.
|
||||
type DashboardNavigateResult struct {
|
||||
Path string `json:"path"`
|
||||
Label string `json:"label"`
|
||||
}
|
||||
|
||||
// dashboardNavigateTool resolves a page path and returns the navigation the UI
|
||||
// can follow. It validates against the registry and refuses an unknown route
|
||||
// rather than guessing, so a chip is only ever produced for a real page.
|
||||
func dashboardNavigateTool() (tools.ToolEntry, bool) {
|
||||
entry := tools.ToolEntry{
|
||||
Name: "dashboard_navigate",
|
||||
Toolset: "dashboard",
|
||||
Description: "Point the operator at a dashboard page. Pass the page path (e.g. /tasks). Returns the page to navigate to; the web chat renders it as a clickable chip. Never guess a path, look it up with page_index first.",
|
||||
Classification: tools.ClassIdempotent,
|
||||
Schema: tools.JSONSchema{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"path": map[string]any{
|
||||
"type": "string",
|
||||
"description": "The dashboard route to navigate to, e.g. /tasks. Must match a page_index entry.",
|
||||
},
|
||||
},
|
||||
"required": []any{"path"},
|
||||
},
|
||||
Handler: func(_ context.Context, input map[string]any) (any, error) {
|
||||
path := strings.TrimSpace(asString(input["path"]))
|
||||
if path == "" {
|
||||
return nil, errors.New("dashboard_navigate: path is required")
|
||||
}
|
||||
for _, p := range dashboardPages {
|
||||
if p.Path == path {
|
||||
return DashboardNavigateResult{Path: p.Path, Label: p.Label}, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("dashboard_navigate: unknown page %s", path)
|
||||
},
|
||||
}
|
||||
return entry, true
|
||||
}
|
||||
|
||||
// PageIndexTools returns the dashboard tools for a channel. Only the web UI
|
||||
// has a dashboard (and only the web chat sends a Current page), so a non-web
|
||||
// channel (e.g. telegram) gets none.
|
||||
func PageIndexTools(channel string) []tools.ToolEntry {
|
||||
if !strings.EqualFold(channel, "web") {
|
||||
return nil
|
||||
}
|
||||
pageIndex, _ := pageIndexTool()
|
||||
navigate, _ := dashboardNavigateTool()
|
||||
return []tools.ToolEntry{pageIndex, navigate}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// quietContext is the tool execution context; the tools never use it beyond
|
||||
// the signature, so a background context is safe and deterministic.
|
||||
func quietContext() context.Context { return context.Background() }
|
||||
|
||||
func TestDashboardPagesRegistryCoversEveryRoute(t *testing.T) {
|
||||
pages := DashboardPages()
|
||||
if len(pages) == 0 {
|
||||
t.Fatal("DashboardPages() returned no pages")
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
for _, p := range pages {
|
||||
if p.Path == "" || p.Label == "" || p.Description == "" {
|
||||
t.Fatalf("page %#v is missing path/label/description", p)
|
||||
}
|
||||
if seen[p.Path] {
|
||||
t.Fatalf("duplicate page path %q", p.Path)
|
||||
}
|
||||
seen[p.Path] = true
|
||||
}
|
||||
// The dashboard's primary surfaces must be present so the agent can point
|
||||
// the operator at the control room and the work queue.
|
||||
for _, want := range []string{"/", "/tasks", "/logs"} {
|
||||
if !seen[want] {
|
||||
t.Errorf("page index does not cover %q", want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPageIndexToolReturnsEveryPage(t *testing.T) {
|
||||
entry, ok := pageIndexTool()
|
||||
if !ok {
|
||||
t.Fatal("page_index tool not available")
|
||||
}
|
||||
if entry.Name != "page_index" {
|
||||
t.Fatalf("tool name = %q", entry.Name)
|
||||
}
|
||||
out, err := entry.Handler(quietContext(), map[string]any{})
|
||||
if err != nil {
|
||||
t.Fatalf("page_index handler: %v", err)
|
||||
}
|
||||
res, ok := out.(PageIndexResult)
|
||||
if !ok {
|
||||
t.Fatalf("page_index returned %T, want PageIndexResult", out)
|
||||
}
|
||||
if len(res.Pages) != len(DashboardPages()) {
|
||||
t.Fatalf("page_index returned %d pages, want %d", len(res.Pages), len(DashboardPages()))
|
||||
}
|
||||
}
|
||||
|
||||
func TestDashboardNavigateResolvesKnownRoute(t *testing.T) {
|
||||
entry, ok := dashboardNavigateTool()
|
||||
if !ok {
|
||||
t.Fatal("dashboard_navigate tool not available")
|
||||
}
|
||||
out, err := entry.Handler(quietContext(), map[string]any{"path": "/tasks"})
|
||||
if err != nil {
|
||||
t.Fatalf("dashboard_navigate(/tasks): %v", err)
|
||||
}
|
||||
res, ok := out.(DashboardNavigateResult)
|
||||
if !ok {
|
||||
t.Fatalf("dashboard_navigate returned %T, want DashboardNavigateResult", out)
|
||||
}
|
||||
if res.Path != "/tasks" {
|
||||
t.Fatalf("resolved path = %q, want /tasks", res.Path)
|
||||
}
|
||||
if res.Label == "" {
|
||||
t.Fatal("resolved label is empty")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDashboardNavigateRejectsUnknownRoute(t *testing.T) {
|
||||
entry, ok := dashboardNavigateTool()
|
||||
if !ok {
|
||||
t.Fatal("dashboard_navigate tool not available")
|
||||
}
|
||||
_, err := entry.Handler(quietContext(), map[string]any{"path": "/not-a-page"})
|
||||
if err == nil {
|
||||
t.Fatal("dashboard_navigate(/not-a-page) returned no error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDashboardNavigateRejectsEmptyPath(t *testing.T) {
|
||||
entry, _ := dashboardNavigateTool()
|
||||
if _, err := entry.Handler(quietContext(), map[string]any{}); err == nil {
|
||||
t.Fatal("dashboard_navigate with no path returned no error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDashboardToolsBindWebOnly(t *testing.T) {
|
||||
// Only the web channel should carry dashboard tooling: pointing a Telegram
|
||||
// operator at an internal dashboard route is meaningless.
|
||||
web := PageIndexTools("web")
|
||||
if len(web) == 0 {
|
||||
t.Fatal("web channel should get dashboard tools")
|
||||
}
|
||||
names := map[string]bool{}
|
||||
for _, e := range web {
|
||||
names[e.Name] = true
|
||||
}
|
||||
if !names["page_index"] || !names["dashboard_navigate"] {
|
||||
t.Fatalf("web dashboard tools missing page_index/dashboard_navigate: %v", names)
|
||||
}
|
||||
|
||||
// A non-web channel gets none.
|
||||
if got := PageIndexTools("telegram"); len(got) != 0 {
|
||||
t.Fatalf("telegram channel got %d dashboard tools, want 0", len(got))
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,12 @@ type Message struct {
|
||||
From string
|
||||
// Text is the raw message text, including any leading slash command.
|
||||
Text string
|
||||
// Page is the dashboard route the operator is on when they sent this
|
||||
// message (e.g. "/tasks", "/logs"). It is per-message, not per-session:
|
||||
// the operator navigates freely while a conversation stays open, so the
|
||||
// agent is told where they are right now. Empty for non-web channels,
|
||||
// which have no page context.
|
||||
Page string
|
||||
// At is when the message happened in application time and is the sole
|
||||
// ordering key for conversation history. A zero value is stamped with the
|
||||
// current time at save.
|
||||
|
||||
@@ -47,6 +47,12 @@ type SystemPromptConfig struct {
|
||||
// claimed to work for one particular person and that person's name was
|
||||
// sent to the model provider on every turn whether or not it was theirs.
|
||||
Operator string
|
||||
// Page is the dashboard route the operator is on right now (e.g.
|
||||
// "/tasks"). It is supplied per message by the web channel; empty for
|
||||
// non-web channels, which have no page context. Rendered in the <env>
|
||||
// runtime-metadata block so the agent knows where the operator is
|
||||
// looking and can point them somewhere relevant.
|
||||
Page string
|
||||
// Now stamps the prompt's date. The zero value omits nothing -- it
|
||||
// simply renders the zero date -- so callers should always set it.
|
||||
Now time.Time
|
||||
|
||||
@@ -102,6 +102,24 @@ func TestBuildSystemPromptSections(t *testing.T) {
|
||||
"Session: telegram:1312197967",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "the current dashboard page is rendered in the env block when set",
|
||||
cfg: SystemPromptConfig{
|
||||
Now: fixedTime(t),
|
||||
Page: "/tasks",
|
||||
Model: "deepseek/deepseek-v4-pro",
|
||||
},
|
||||
contains: []string{
|
||||
"Current page: /tasks",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "the current page line is omitted for non-web channels",
|
||||
cfg: SystemPromptConfig{Now: fixedTime(t), Channel: "telegram"},
|
||||
absent: []string{
|
||||
"Current page:",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
{{- /* Chat agent system prompt. The persona supplies identity and style; */ -}}
|
||||
{{- /* everything below is the invariant substrate every turn depends on. */ -}}
|
||||
{{- with .Persona}}{{.}}
|
||||
|
||||
{{end -}}
|
||||
@@ -89,6 +87,9 @@ Operator: {{xml .}}
|
||||
{{- with .Channel}}
|
||||
Channel: {{xml .}}
|
||||
{{- end}}
|
||||
{{- with .Page}}
|
||||
Current page: {{xml .}}
|
||||
{{- end}}
|
||||
{{- with .Model}}
|
||||
Model: {{xml .}}
|
||||
{{- end}}
|
||||
|
||||
@@ -251,6 +251,9 @@ func (r *TurnRunner) Run(ctx context.Context, msg Message, stream TurnStream) (s
|
||||
TaskTools(r.TaskLister, r.Tasks, r.TaskLogs, r.TaskActor, r.TaskIdentity),
|
||||
SessionTools(r.Sessions, r.Router.SessionTracker(), r.Channel, msg)...,
|
||||
)
|
||||
// The dashboard tools (page_index, dashboard_navigate) belong to the web
|
||||
// UI only: a non-web channel has no dashboard to point at.
|
||||
extraTools = append(extraTools, PageIndexTools(r.Channel)...)
|
||||
modelName := r.Models.ActiveModel()
|
||||
prepared, err := r.Model.Prepare(ctx, modelName, extraTools)
|
||||
if err != nil {
|
||||
@@ -272,6 +275,7 @@ func (r *TurnRunner) Run(ctx context.Context, msg Message, stream TurnStream) (s
|
||||
SessionID: sessionID,
|
||||
Now: time.Now(),
|
||||
Operator: r.Operator,
|
||||
Page: msg.Page,
|
||||
})
|
||||
modelDetails := ModelDetails{}
|
||||
if detailed, ok := r.Models.(DetailedModelManager); ok {
|
||||
|
||||
@@ -43,6 +43,10 @@ type chatMessageRequest struct {
|
||||
ChannelID string `json:"channel_id"`
|
||||
SourceID string `json:"source_id"`
|
||||
Text string `json:"text"`
|
||||
// Page is the dashboard route the operator is on (e.g. "/tasks"). It is
|
||||
// set by the web chat so the agent's system prompt can state where the
|
||||
// operator is looking and point them somewhere relevant.
|
||||
Page string `json:"page,omitempty"`
|
||||
}
|
||||
|
||||
type chatPersonaRequest struct {
|
||||
@@ -236,6 +240,7 @@ func (s *Server) decodeChatMessage(w http.ResponseWriter, r *http.Request) (gate
|
||||
return gateway.Message{
|
||||
SourceID: req.SourceID, ChannelID: req.ChannelID,
|
||||
ThreadID: "", From: "web", Text: req.Text,
|
||||
Page: req.Page,
|
||||
}, true
|
||||
}
|
||||
|
||||
@@ -278,6 +283,11 @@ type chatStreamEvent struct {
|
||||
Parameters string `json:"parameters,omitempty"`
|
||||
Failed bool `json:"failed,omitempty"`
|
||||
SessionID string `json:"session_id,omitempty"`
|
||||
// Path and Label carry a dashboard_navigate result so the browser can
|
||||
// render a clickable chip that routes the operator to the page. Present
|
||||
// only on a navigate event.
|
||||
Path string `json:"path,omitempty"`
|
||||
Label string `json:"label,omitempty"`
|
||||
}
|
||||
|
||||
// chatStreamSink adapts the stream writer to gateway.TurnStream so text and
|
||||
@@ -300,6 +310,23 @@ func (s chatStreamSink) Delta(text string) {
|
||||
}
|
||||
|
||||
func (s chatStreamSink) ToolCall(event gateway.ToolCallEvent) {
|
||||
// A dashboard_navigate call is an explicit point-the-operator-there
|
||||
// result, not tool narration, so it renders a clickable chip even when
|
||||
// ShowToolCalls is off. Parse the resolved path/label from the tool's
|
||||
// JSON result and emit a dedicated navigate frame.
|
||||
if event.Name == "dashboard_navigate" && event.Err == "" {
|
||||
var result gateway.DashboardNavigateResult
|
||||
if err := json.Unmarshal([]byte(event.Output), &result); err == nil && result.Path != "" {
|
||||
s.write(chatStreamEvent{
|
||||
Type: "navigate",
|
||||
Tool: event.Name,
|
||||
ToolCallID: event.ID,
|
||||
Path: result.Path,
|
||||
Label: result.Label,
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
if !s.showToolCalls || event.Name == "" {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -522,6 +522,8 @@ type chatSSEEvent struct {
|
||||
Parameters string `json:"parameters"`
|
||||
Failed bool `json:"failed"`
|
||||
SessionID string `json:"session_id"`
|
||||
Path string `json:"path"`
|
||||
Label string `json:"label"`
|
||||
}
|
||||
|
||||
func parseChatSSE(t *testing.T, body string) []chatSSEEvent {
|
||||
@@ -879,3 +881,78 @@ func TestChatStreamReportsUndeliverableLocalFile(t *testing.T) {
|
||||
t.Errorf("delta stream = %q, want it to report non-delivery", joined.String())
|
||||
}
|
||||
}
|
||||
|
||||
// TestChatStreamCarriesCurrentPage proves the web chat decodes the operator's
|
||||
// dashboard page from the request body and hands it to the agent as
|
||||
// Message.Page, so the system prompt can state where the operator is.
|
||||
func TestChatStreamCarriesCurrentPage(t *testing.T) {
|
||||
server, sessions := chatTestServer(t)
|
||||
var got gateway.Message
|
||||
server.Chat.Router.LLMStream = func(_ context.Context, msg gateway.Message, stream gateway.TurnStream) (string, error) {
|
||||
got = msg
|
||||
stream.Delta("on it")
|
||||
return "on it", nil
|
||||
}
|
||||
saveWebSession(t, sessions, "web-1")
|
||||
|
||||
req := httptest.NewRequestWithContext(context.Background(), http.MethodPost, "/api/chat/stream",
|
||||
strings.NewReader(`{"channel_id":"browser-web-1","text":"where do I see that?","page":"/tasks"}`))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
res := httptest.NewRecorder()
|
||||
server.Handler().ServeHTTP(res, req)
|
||||
if res.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d, body = %s", res.Code, res.Body)
|
||||
}
|
||||
if got.Page != "/tasks" {
|
||||
t.Fatalf("Message.Page = %q, want /tasks", got.Page)
|
||||
}
|
||||
}
|
||||
|
||||
// TestChatStreamEmitsNavigateChip proves a dashboard_navigate tool call emits
|
||||
// a dedicated navigate frame (with the resolved path/label) even when
|
||||
// ShowToolCalls is off, so the browser can render a clickable chip to route
|
||||
// the operator to the page.
|
||||
func TestChatStreamEmitsNavigateChip(t *testing.T) {
|
||||
stream := func(_ context.Context, _ gateway.Message, turn gateway.TurnStream) (string, error) {
|
||||
out, _ := json.Marshal(gateway.DashboardNavigateResult{Path: "/tasks", Label: "Tasks"})
|
||||
turn.ToolCall(gateway.ToolCallEvent{ID: "nav-1", Name: "dashboard_navigate", Output: string(out)})
|
||||
return "That is on the Tasks page.", nil
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
cfg *config.Holder
|
||||
}{
|
||||
{name: "show_tool_calls off (navigate is unconditional)", cfg: config.NewHolder(config.Config{Chat: config.ChatConfig{ShowToolCalls: false}})},
|
||||
{name: "no Cfg wired at all", cfg: nil},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
server, sessions := chatTestServer(t)
|
||||
server.Chat.Router.LLMStream = stream
|
||||
server.Cfg = tc.cfg
|
||||
saveWebSession(t, sessions, "web-1")
|
||||
|
||||
req := httptest.NewRequestWithContext(context.Background(), http.MethodPost, "/api/chat/stream",
|
||||
strings.NewReader(`{"channel_id":"browser-web-1","text":"show me tasks"}`))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
res := httptest.NewRecorder()
|
||||
server.Handler().ServeHTTP(res, req)
|
||||
if res.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d, body = %s", res.Code, res.Body)
|
||||
}
|
||||
var chipFound bool
|
||||
for _, ev := range parseChatSSE(t, res.Body.String()) {
|
||||
if ev.Type == "navigate" && ev.Path == "/tasks" && ev.Label == "Tasks" {
|
||||
chipFound = true
|
||||
} else if ev.Type == "tool" {
|
||||
t.Fatalf("navigate tool leaked as a tool frame: %+v", ev)
|
||||
}
|
||||
}
|
||||
if !chipFound {
|
||||
t.Fatalf("no navigate chip emitted; frames = %#v", parseChatSSE(t, res.Body.String()))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
:root{--font-sans:ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;--font-mono:ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;--text-xs:.6875rem;--text-sm:.8125rem;--text-base:.875rem;--text-lg:1.0625rem;--text-xl:1.375rem;--text-2xl:1.875rem;--text-3xl:2.5rem;--sp-1:.25rem;--sp-2:.5rem;--sp-3:.75rem;--sp-4:1rem;--sp-5:1.5rem;--sp-6:2rem;--sp-7:3rem;--radius-sm:6px;--radius-md:10px;--radius-lg:14px;--radius-xl:20px;--radius-pill:999px;--transition:.14s cubic-bezier(.4, 0, .2, 1)}[data-theme=dark]{--bg:#0d1014;--bg-raised:#141920;--surface:#171d25;--surface-hover:#1d242e;--border:#232b36;--border-strong:#303a48;--fg:#e8edf4;--fg-muted:#8b97a8;--fg-subtle:#5d6878;--accent:#4c8dff;--accent-fg:#fff;--accent-soft:#4c8dff24;--ok:#3fbf7f;--ok-soft:#3fbf7f24;--warn:#e8a33d;--warn-soft:#e8a33d24;--danger:#f0616d;--danger-soft:#f0616d24;--info:#4c8dff;--info-soft:#4c8dff24;--idle:#6b7688;--idle-soft:#6b768824;--accent-2:#7b5cff;--bg-blur:#1419208c;--surface-glass:#171d259e;--surface-glass-strong:#141920c7;--workspace:#11151b8c;--hairline:#ffffff0f;--wash-a:#4c8dff1a;--wash-b:#7b5cff1f;--wash-c:#3fbf7f0f;--shadow-workspace:0 24px 70px #00000080;--shadow-sm:0 1px 2px #0006;--shadow-md:0 8px 28px #0000006b}[data-theme=light]{--bg:#f6f8fb;--bg-raised:#fff;--surface:#fff;--surface-hover:#f1f4f9;--border:#e2e8f0;--border-strong:#cbd5e1;--fg:#16202e;--fg-muted:#5a6779;--fg-subtle:#8c99ab;--accent:#2563eb;--accent-fg:#fff;--accent-soft:#2563eb1a;--ok:#10935c;--ok-soft:#10935c1f;--warn:#b87514;--warn-soft:#b875141f;--danger:#d4344a;--danger-soft:#d4344a1f;--info:#2563eb;--info-soft:#2563eb1a;--idle:#64748b;--idle-soft:#64748b1f;--accent-2:#7c3aed;--bg-blur:#fff9;--surface-glass:#ffffffb8;--surface-glass-strong:#ffffffe0;--workspace:#ffffff8c;--hairline:#0f172a0f;--wash-a:#2563eb1a;--wash-b:#7c3aed1f;--wash-c:#10935c12;--shadow-workspace:0 24px 70px #0f172a24;--shadow-sm:0 1px 2px #0f172a0f;--shadow-md:0 8px 28px #0f172a1a}*,:before,:after{box-sizing:border-box}html,body{height:100%;margin:0}body{color:var(--fg);font-family:var(--font-sans);font-size:var(--text-base);-webkit-font-smoothing:antialiased;line-height:1.5}a{color:inherit;text-decoration:none}body{background:radial-gradient(70rem 40rem at 8% -10%, var(--wash-a), transparent 62%), radial-gradient(56rem 34rem at 92% 4%, var(--wash-b), transparent 58%), radial-gradient(48rem 30rem at 50% 108%, var(--wash-c), transparent 60%), var(--bg);padding:var(--sp-4);background-attachment:fixed}.shell{min-height:calc(100vh - var(--sp-4) * 2);border-radius:var(--radius-xl);border:1px solid var(--hairline);background:var(--workspace);-webkit-backdrop-filter:blur(28px)saturate(120%);backdrop-filter:blur(28px)saturate(120%);box-shadow:var(--shadow-workspace);flex-direction:column;display:flex;overflow:hidden}.topbar{align-items:center;gap:var(--sp-4);padding:var(--sp-3) var(--sp-4);border-bottom:1px solid var(--hairline);background:var(--bg-blur);z-index:10;display:flex;position:sticky;top:0}.brand{align-items:center;gap:var(--sp-2);font-weight:600;font-size:var(--text-sm);letter-spacing:-.01em;flex:none;display:flex}.brand-mark{background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;width:26px;height:26px;font-size:var(--text-xs);border-radius:8px;place-items:center;font-weight:700;display:grid}.nav{border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);align-items:center;gap:2px;margin:0 auto;padding:3px;display:flex}.nav-item{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);color:var(--fg-muted);font-size:var(--text-sm);white-space:nowrap;cursor:pointer;transition:background var(--transition), color var(--transition);display:inline-flex}.nav-item:hover{color:var(--fg);background:var(--surface-hover)}.nav-item[aria-current=page]{background:var(--accent);color:var(--accent-fg);font-weight:500}.nav-item .nav-label{display:inline}.topbar-end{align-items:center;gap:var(--sp-2);flex:none;display:flex}.topbar-search{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);color:var(--fg-subtle);display:flex}.topbar-search input{color:var(--fg);font:inherit;font-size:var(--text-sm);background:0 0;border:0;outline:none;width:8rem}.topbar-search input::placeholder{color:var(--fg-subtle)}.mobile-search-toggle{display:none}.icon-btn{border-radius:var(--radius-pill);border:1px solid var(--hairline);background:var(--surface-glass-strong);width:32px;height:32px;color:var(--fg-muted);cursor:pointer;transition:color var(--transition), background var(--transition);place-items:center;display:grid}.icon-btn:hover{color:var(--fg);background:var(--surface-hover)}.avatar{border-radius:var(--radius-pill);width:32px;height:32px;font-size:var(--text-xs);color:#fff;background:linear-gradient(135deg, var(--accenLine truncated
|
||||
:root{--font-sans:ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;--font-mono:ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;--text-xs:.6875rem;--text-sm:.8125rem;--text-base:.875rem;--text-lg:1.0625rem;--text-xl:1.375rem;--text-2xl:1.875rem;--text-3xl:2.5rem;--sp-1:.25rem;--sp-2:.5rem;--sp-3:.75rem;--sp-4:1rem;--sp-5:1.5rem;--sp-6:2rem;--sp-7:3rem;--radius-sm:6px;--radius-md:10px;--radius-lg:14px;--radius-xl:20px;--radius-pill:999px;--transition:.14s cubic-bezier(.4, 0, .2, 1)}[data-theme=dark]{--bg:#0d1014;--bg-raised:#141920;--surface:#171d25;--surface-hover:#1d242e;--border:#232b36;--border-strong:#303a48;--fg:#e8edf4;--fg-muted:#8b97a8;--fg-subtle:#5d6878;--accent:#4c8dff;--accent-fg:#fff;--accent-soft:#4c8dff24;--ok:#3fbf7f;--ok-soft:#3fbf7f24;--warn:#e8a33d;--warn-soft:#e8a33d24;--danger:#f0616d;--danger-soft:#f0616d24;--info:#4c8dff;--info-soft:#4c8dff24;--idle:#6b7688;--idle-soft:#6b768824;--accent-2:#7b5cff;--bg-blur:#1419208c;--surface-glass:#171d259e;--surface-glass-strong:#141920c7;--workspace:#11151b8c;--hairline:#ffffff0f;--wash-a:#4c8dff1a;--wash-b:#7b5cff1f;--wash-c:#3fbf7f0f;--shadow-workspace:0 24px 70px #00000080;--shadow-sm:0 1px 2px #0006;--shadow-md:0 8px 28px #0000006b}[data-theme=light]{--bg:#f6f8fb;--bg-raised:#fff;--surface:#fff;--surface-hover:#f1f4f9;--border:#e2e8f0;--border-strong:#cbd5e1;--fg:#16202e;--fg-muted:#5a6779;--fg-subtle:#8c99ab;--accent:#2563eb;--accent-fg:#fff;--accent-soft:#2563eb1a;--ok:#10935c;--ok-soft:#10935c1f;--warn:#b87514;--warn-soft:#b875141f;--danger:#d4344a;--danger-soft:#d4344a1f;--info:#2563eb;--info-soft:#2563eb1a;--idle:#64748b;--idle-soft:#64748b1f;--accent-2:#7c3aed;--bg-blur:#fff9;--surface-glass:#ffffffb8;--surface-glass-strong:#ffffffe0;--workspace:#ffffff8c;--hairline:#0f172a0f;--wash-a:#2563eb1a;--wash-b:#7c3aed1f;--wash-c:#10935c12;--shadow-workspace:0 24px 70px #0f172a24;--shadow-sm:0 1px 2px #0f172a0f;--shadow-md:0 8px 28px #0f172a1a}*,:before,:after{box-sizing:border-box}html,body{height:100%;margin:0}body{color:var(--fg);font-family:var(--font-sans);font-size:var(--text-base);-webkit-font-smoothing:antialiased;line-height:1.5}a{color:inherit;text-decoration:none}body{background:radial-gradient(70rem 40rem at 8% -10%, var(--wash-a), transparent 62%), radial-gradient(56rem 34rem at 92% 4%, var(--wash-b), transparent 58%), radial-gradient(48rem 30rem at 50% 108%, var(--wash-c), transparent 60%), var(--bg);padding:var(--sp-4);background-attachment:fixed}.shell{min-height:calc(100vh - var(--sp-4) * 2);border-radius:var(--radius-xl);border:1px solid var(--hairline);background:var(--workspace);-webkit-backdrop-filter:blur(28px)saturate(120%);backdrop-filter:blur(28px)saturate(120%);box-shadow:var(--shadow-workspace);flex-direction:column;display:flex;overflow:hidden}.topbar{align-items:center;gap:var(--sp-4);padding:var(--sp-3) var(--sp-4);border-bottom:1px solid var(--hairline);background:var(--bg-blur);z-index:10;display:flex;position:sticky;top:0}.brand{align-items:center;gap:var(--sp-2);font-weight:600;font-size:var(--text-sm);letter-spacing:-.01em;flex:none;display:flex}.brand-mark{background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;width:26px;height:26px;font-size:var(--text-xs);border-radius:8px;place-items:center;font-weight:700;display:grid}.nav{border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);align-items:center;gap:2px;margin:0 auto;padding:3px;display:flex}.nav-item{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);color:var(--fg-muted);font-size:var(--text-sm);white-space:nowrap;cursor:pointer;transition:background var(--transition), color var(--transition);display:inline-flex}.nav-item:hover{color:var(--fg);background:var(--surface-hover)}.nav-item[aria-current=page]{background:var(--accent);color:var(--accent-fg);font-weight:500}.nav-item .nav-label{display:inline}.topbar-end{align-items:center;gap:var(--sp-2);flex:none;display:flex}.topbar-search{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);color:var(--fg-subtle);display:flex}.topbar-search input{color:var(--fg);font:inherit;font-size:var(--text-sm);background:0 0;border:0;outline:none;width:8rem}.topbar-search input::placeholder{color:var(--fg-subtle)}.mobile-search-toggle{display:none}.icon-btn{border-radius:var(--radius-pill);border:1px solid var(--hairline);background:var(--surface-glass-strong);width:32px;height:32px;color:var(--fg-muted);cursor:pointer;transition:color var(--transition), background var(--transition);place-items:center;display:grid}.icon-btn:hover{color:var(--fg);background:var(--surface-hover)}.avatar{border-radius:var(--radius-pill);width:32px;height:32px;font-size:var(--text-xs);color:#fff;background:linear-gradient(135deg, var(--accenLine truncated
|
||||
Vendored
+4
-4
@@ -1,12 +1,12 @@
|
||||
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function e(e=globalThis.crypto){if(typeof e?.randomUUID==`function`)return e.randomUUID();let t=new Uint8Array(16);if(typeof e?.getRandomValues==`function`)e.getRandomValues(t);else for(let e=0;e<t.length;e+=1)t[e]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t,e=>e.toString(16).padStart(2,`0`));return`${n.slice(0,4).join(``)}-${n.slice(4,6).join(``)}-${n.slice(6,8).join(``)}-${n.slice(8,10).join(``)}-${n.slice(10).join(``)}`}async function t(e){let t=await fetch(e,{headers:{Accept:`application/json`},signal:AbortSignal.timeout(15e3)});if(t.status===401)throw new i(`unauthorised`,401);if(!t.ok)throw new i(`${t.status} ${t.statusText}`,t.status);return t.json()}function n(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e||{}))r!==``&&r!=null&&t.set(n,r);let n=t.toString();return n?`?${n}`:``}async function r(e){try{let t=(await e.text()).trim();if(t)return t.split(`
|
||||
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var i=class extends Error{constructor(e,t){super(e),this.status=t}},a={summary:()=>t(`/api/summary`),tasks:()=>t(`/api/tasks`),taskMeta:()=>t(`/api/task-meta`),task:e=>t(`/api/tasks/${e}`),taskAction:async(e,t)=>{let n=await fetch(`/api/tasks/${e}/action`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({action:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},setup:()=>t(`/api/setup`),workflows:()=>t(`/api/workflows`),workRequest:async e=>{let t=await fetch(`/api/work-requests`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},skills:()=>t(`/api/skills`),channels:()=>t(`/api/channels`),channelReload:async e=>{let t=await fetch(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:`{}`,signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},config:()=>t(`/api/config`),version:()=>t(`/api/version`),configUpdate:async e=>{let t=await fetch(`/api/config`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({updates:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},configReset:async e=>{let t=await fetch(`/api/config/reset`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({key:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},logs:e=>t(`/api/logs`+n(e)),captures:e=>t(`/api/captures`+n({limit:e})),mappings:()=>t(`/api/mappings`),mappingCreate:async e=>{let t=await fetch(`/api/mappings`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},mappingUpdate:async(e,t)=>{let n=await fetch(`/api/mappings/${e}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(t),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},mappingDelete:async e=>{let t=await fetch(`/api/mappings/${e}`,{method:`DELETE`,headers:{Accept:`application/json`,"X-Archie-CSRF":`1`},signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status)},mappingPreview:async(e,t)=>{let n=await fetch(`/api/mappings/preview`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({capture_id:e,fields:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},memory:()=>t(`/api/memory`),chatSessions:()=>t(`/api/chat/sessions`),chatMessages:e=>t(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>t(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:async e=>{let t=await fetch(`/api/chat/cancel`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({session_id:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},chatMessage:async(t,n)=>{let a=await fetch(`/api/chat/message`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({channel_id:t,source_id:e(),text:n}),signal:AbortSignal.timeout(15e3)});if(!a.ok)throw new i(await r(a),a.status);return a.json()},chatPersona:async(e,t)=>{let n=await fetch(`/api/chat/persona`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({session_id:e,name:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},chatUpdate:()=>t(`/api/chat/update`),chatUpdateDefer:async e=>{let t=await fetch(`/api/chat/update/defer`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({snapshot:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},chatUpdateInstall:async e=>{let t=await fetch(`/api/chat/update/install`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({snapshot:e}),signal:AbortSignal.timeout(12e4)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},chatDangerous:()=>t(`/api/chat/dangerous`),chatDangerousRequest:async(e,t)=>{let n=await fetch(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.str
Line truncated
|
||||
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var i=class extends Error{constructor(e,t){super(e),this.status=t}},a={summary:()=>t(`/api/summary`),tasks:()=>t(`/api/tasks`),taskMeta:()=>t(`/api/task-meta`),task:e=>t(`/api/tasks/${e}`),taskAction:async(e,t)=>{let n=await fetch(`/api/tasks/${e}/action`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({action:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},setup:()=>t(`/api/setup`),workflows:()=>t(`/api/workflows`),workRequest:async e=>{let t=await fetch(`/api/work-requests`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},skills:()=>t(`/api/skills`),channels:()=>t(`/api/channels`),channelReload:async e=>{let t=await fetch(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:`{}`,signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},config:()=>t(`/api/config`),version:()=>t(`/api/version`),configUpdate:async e=>{let t=await fetch(`/api/config`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({updates:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},configReset:async e=>{let t=await fetch(`/api/config/reset`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({key:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},logs:e=>t(`/api/logs`+n(e)),captures:e=>t(`/api/captures`+n({limit:e})),mappings:()=>t(`/api/mappings`),mappingCreate:async e=>{let t=await fetch(`/api/mappings`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},mappingUpdate:async(e,t)=>{let n=await fetch(`/api/mappings/${e}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(t),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},mappingDelete:async e=>{let t=await fetch(`/api/mappings/${e}`,{method:`DELETE`,headers:{Accept:`application/json`,"X-Archie-CSRF":`1`},signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status)},mappingPreview:async(e,t)=>{let n=await fetch(`/api/mappings/preview`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({capture_id:e,fields:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},memory:()=>t(`/api/memory`),chatSessions:()=>t(`/api/chat/sessions`),chatMessages:e=>t(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>t(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:async e=>{let t=await fetch(`/api/chat/cancel`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({session_id:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},chatMessage:async(t,n)=>{let a=await fetch(`/api/chat/message`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({channel_id:t,source_id:e(),text:n,page:location.hash.slice(1)||`/`}),signal:AbortSignal.timeout(15e3)});if(!a.ok)throw new i(await r(a),a.status);return a.json()},chatPersona:async(e,t)=>{let n=await fetch(`/api/chat/persona`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({session_id:e,name:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},chatUpdate:()=>t(`/api/chat/update`),chatUpdateDefer:async e=>{let t=await fetch(`/api/chat/update/defer`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({snapshot:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},chatUpdateInstall:async e=>{let t=await fetch(`/api/chat/update/install`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({snapshot:e}),signal:AbortSignal.timeout(12e4)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},chatDangerous:()=>t(`/api/chat/dangerous`),chatDangerousRequest:async(e,t)=>{let n=await fetch(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":
Line truncated
|
||||
<path d="${c(150,240)}" fill="none" stroke="var(--border)"
|
||||
stroke-width="12" stroke-linecap="round"/>
|
||||
<path d="${c(150,240)}" fill="none" stroke="${i}"
|
||||
stroke-width="12" stroke-linecap="round"
|
||||
stroke-dasharray="${s}"
|
||||
stroke-dashoffset="${s*(1-r/100)}"
|
||||
class="gauge-value"/>`,y(`div.gauge-wrap`,l,y(`div.gauge-center`,y(`div.gauge-pct`,`${Math.round(r)}%`),y(`div.gauge-label`,t)))}function j(e){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return y(`div`,y(`div.segbar`,...e.filter(e=>e.value>0).map(e=>y(`span`,{class:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`}))),y(`div.segbar-legend`,...e.map(e=>y(`span.segbar-key`,y(`span`,{class:`segbar-dot segbar-${e.kind||`idle`}`}),e.label))))}var M=`archie.setup-complete.dismissed.v1`;function N(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(M),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function P(e=globalThis.localStorage){e?.setItem?.(M,`1`)}var F=new Set([`waiting_human`,`parked`]);function I(e=[]){let t=e.filter(e=>F.has(e.status)),n=e.filter(e=>e.status===`running`);return{attention:{count:t.length,href:t.length===1?`#/tasks?task=${encodeURIComponent(t[0].id)}`:`#/tasks?status=needs_you`},running:{count:n.length,href:`#/tasks?status=running`}}}function L(){let e=y(`div`),t=y(`tbody`),n=y(`div.grid.grid-4`),r=y(`div`),i=y(`div`),s=y(`div.dash-top`,r,i),c=y(`div`),l=y(`div.hero-actions-inner`),u=y(`h1.hero-title`,B()),d=S(`connecting`,`idle`),f=[],p=new Map;h(),_();let m=o(e=>{f.unshift(e),f.splice(50),g()},e=>{d.className=`pill pill-${e===`live`?`ok`:`warn`}`,d.textContent=e});e.addEventListener(`archie:teardown`,m);function h(){x(e,y(`div.hero`,y(`div`,u,y(`p.hero-sub`,`Your agent's control room — what it is working on, what needs you, and what it is spending.`)),y(`div.hero-actions`,l)),y(`div.dash-section`,y(`div.dash-section-head`,y(`h2.dash-section-title`,`Health`)),s),y(`div.dash-section`,y(`div.dash-section-head`,y(`h2.dash-section-title`,`Throughput`),y(`span.dash-section-note`,`Across all repositories`)),n),y(`div.dash-section`,y(`div.dash-section-head`,y(`h2.dash-section-title`,`Right now`)),y(`div.dash-split`,c,y(`div.card`,y(`div.card-head`,y(`div`,y(`h2.card-title`,`Live activity`),y(`p.card-sub`,`Last 50, newest first`)),d),y(`div.table-scroll`,y(`table.table`,y(`thead`,y(`tr`,...[`Event`,`Task`,`Detail`,`When`].map(e=>y(`th`,e)))),t)))))),g()}function g(){if(!f.length){x(t,y(`tr`,y(`td`,{colspan:4},T(`Waiting for activity`,`Events appear here as Archie works.`))));return}x(t,...f.map(e=>R(e,p)))}async function _(){try{let[e,t,n,r]=await Promise.all([a.summary(),a.setup().catch(()=>null),a.workflows().catch(()=>null),a.tasks().catch(()=>[])]);p.clear();for(let e of r)e.owner&&e.repo&&e.issue_number&&p.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);g(),v(r),u.textContent=t?.operator?`${B()}, ${t.operator}`:B(),b(e),C(t),E(e,n),k(e)}catch(e){x(n,y(`div.card`,T(`Cannot reach archied`,String(e.message||e)))),x(l,y(`button.btn.btn-primary`,{onclick:_},D(`refresh`,{size:15}),`Retry`))}}function v(e){let t=I(e),n=t.attention.count,r=t.running.count;x(l,n>0&&y(`a.btn.btn-attention`,{href:t.attention.href},D(`tasks`,{size:15}),`${n} need${n===1?`s`:``} you`),r>0&&y(`a.btn`,{href:t.running.href},D(`workflows`,{size:15}),`${r} running`),y(`a.btn`,{href:`#/logs`},D(`logs`,{size:15}),`Logs`),y(`button.btn.btn-primary`,{onclick:_},D(`refresh`,{size:15}),`Refresh`))}function b(e){let t=e?.statuses||{},r=(t.merged||0)+(t.pr_open||0),i=(t.parked||0)+(t.waiting_human||0),a=Object.values(t).reduce((e,t)=>e+t,0),o=e?.tokens_by_day||[];x(n,O({label:`Working now`,value:t.running||0,compare:`${t.queued||0} waiting to start`,series:o.map(e=>e.tokens||0)}),O({label:`Needs you`,value:i,compare:i?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),O({label:`Delivered`,value:r,compare:a?`${Math.round(r/a*100)}% of all tasks`:`No tasks yet`}),O({label:`Tokens used`,value:w(o.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${o.length||0} days`,trend:U(o.map(e=>e.tokens||0)),goodDirection:`down`,series:o.map(e=>e.tokens||0)}))}function C(e){let t=N(e),n=t.kind===`omit`||t.kind===`dismissed`;if(s.classList.toggle(`dash-top-standalone`,n),n)return x(r);let i=t.remaining;if(i.length){let t=Math.round((e.steps.length-i.length)/e.steps.length*100);x(r,y(`div.card.setup`,y(`div.card-head`,y(`div`,y(`h2.card-title`,`Finish setting up`),y(`p.card-sub`,`Archie needs these before it can work on its own.`)),y(`span.setup-pct`,`${t}%`)),y(`div.setup-bar`,y(`div.setup-bar-fill`,{style:`width:${t}%`})),y(`ul.setup-list`,...e.steps.map(A))));return}x(r,y(`div.card.setup.setup-done`,y(`div.card-head`,y(`div`,y(`h2.card-title`,`Setup complete`),y(`p.card-sub`,`Archie is configured and ready to work.`)),y(`div.setup-complete-actions`,y(`span.setup-pct`,D(`check`,{size:16})),y(`button.icon-btn.setup-dismiss`,{type:`button`,title:`Dismiss setup complete`,"aria-label":`Dismiss setup complete`,onclick:()=>{P(),C(e)}},`×`)))))}function
Line truncated
|
||||
class="gauge-value"/>`,y(`div.gauge-wrap`,l,y(`div.gauge-center`,y(`div.gauge-pct`,`${Math.round(r)}%`),y(`div.gauge-label`,t)))}function j(e){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return y(`div`,y(`div.segbar`,...e.filter(e=>e.value>0).map(e=>y(`span`,{class:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`}))),y(`div.segbar-legend`,...e.map(e=>y(`span.segbar-key`,y(`span`,{class:`segbar-dot segbar-${e.kind||`idle`}`}),e.label))))}var M=`archie.setup-complete.dismissed.v1`;function N(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(M),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function P(e=globalThis.localStorage){e?.setItem?.(M,`1`)}var F=new Set([`waiting_human`,`parked`]);function I(e=[]){let t=e.filter(e=>F.has(e.status)),n=e.filter(e=>e.status===`running`);return{attention:{count:t.length,href:t.length===1?`#/tasks?task=${encodeURIComponent(t[0].id)}`:`#/tasks?status=needs_you`},running:{count:n.length,href:`#/tasks?status=running`}}}function L(){let e=y(`div`),t=y(`tbody`),n=y(`div.grid.grid-4`),r=y(`div`),i=y(`div`),s=y(`div.dash-top`,r,i),c=y(`div`),l=y(`div.hero-actions-inner`),u=y(`h1.hero-title`,B()),d=S(`connecting`,`idle`),f=[],p=new Map;h(),_();let m=o(e=>{f.unshift(e),f.splice(50),g()},e=>{d.className=`pill pill-${e===`live`?`ok`:`warn`}`,d.textContent=e});e.addEventListener(`archie:teardown`,m);function h(){x(e,y(`div.hero`,y(`div`,u,y(`p.hero-sub`,`Your agent's control room — what it is working on, what needs you, and what it is spending.`)),y(`div.hero-actions`,l)),y(`div.dash-section`,y(`div.dash-section-head`,y(`h2.dash-section-title`,`Health`)),s),y(`div.dash-section`,y(`div.dash-section-head`,y(`h2.dash-section-title`,`Throughput`),y(`span.dash-section-note`,`Across all repositories`)),n),y(`div.dash-section`,y(`div.dash-section-head`,y(`h2.dash-section-title`,`Right now`)),y(`div.dash-split`,c,y(`div.card`,y(`div.card-head`,y(`div`,y(`h2.card-title`,`Live activity`),y(`p.card-sub`,`Last 50, newest first`)),d),y(`div.table-scroll`,y(`table.table`,y(`thead`,y(`tr`,...[`Event`,`Task`,`Detail`,`When`].map(e=>y(`th`,e)))),t)))))),g()}function g(){if(!f.length){x(t,y(`tr`,y(`td`,{colspan:4},T(`Waiting for activity`,`Events appear here as Archie works.`))));return}x(t,...f.map(e=>R(e,p)))}async function _(){try{let[e,t,n,r]=await Promise.all([a.summary(),a.setup().catch(()=>null),a.workflows().catch(()=>null),a.tasks().catch(()=>[])]);p.clear();for(let e of r)e.owner&&e.repo&&e.issue_number&&p.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);g(),v(r),u.textContent=t?.operator?`${B()}, ${t.operator}`:B(),b(e),C(t),E(e,n),k(e)}catch(e){x(n,y(`div.card`,T(`Cannot reach archied`,String(e.message||e)))),x(l,y(`button.btn.btn-primary`,{onclick:_},D(`refresh`,{size:15}),`Retry`))}}function v(e){let t=I(e),n=t.attention.count,r=t.running.count;x(l,n>0&&y(`a.btn.btn-attention`,{href:t.attention.href},D(`tasks`,{size:15}),`${n} need${n===1?`s`:``} you`),r>0&&y(`a.btn`,{href:t.running.href},D(`workflows`,{size:15}),`${r} running`),y(`a.btn`,{href:`#/logs`},D(`logs`,{size:15}),`Logs`),y(`button.btn.btn-primary`,{onclick:_},D(`refresh`,{size:15}),`Refresh`))}function b(e){let t=e?.statuses||{},r=(t.merged||0)+(t.pr_open||0),i=(t.parked||0)+(t.waiting_human||0),a=Object.values(t).reduce((e,t)=>e+t,0),o=e?.tokens_by_day||[];x(n,O({label:`Working now`,value:t.running||0,compare:`${t.queued||0} waiting to start`,series:o.map(e=>e.tokens||0)}),O({label:`Needs you`,value:i,compare:i?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),O({label:`Delivered`,value:r,compare:a?`${Math.round(r/a*100)}% of all tasks`:`No tasks yet`}),O({label:`Tokens used`,value:w(o.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${o.length||0} days`,trend:ee(o.map(e=>e.tokens||0)),goodDirection:`down`,series:o.map(e=>e.tokens||0)}))}function C(e){let t=N(e),n=t.kind===`omit`||t.kind===`dismissed`;if(s.classList.toggle(`dash-top-standalone`,n),n)return x(r);let i=t.remaining;if(i.length){let t=Math.round((e.steps.length-i.length)/e.steps.length*100);x(r,y(`div.card.setup`,y(`div.card-head`,y(`div`,y(`h2.card-title`,`Finish setting up`),y(`p.card-sub`,`Archie needs these before it can work on its own.`)),y(`span.setup-pct`,`${t}%`)),y(`div.setup-bar`,y(`div.setup-bar-fill`,{style:`width:${t}%`})),y(`ul.setup-list`,...e.steps.map(A))));return}x(r,y(`div.card.setup.setup-done`,y(`div.card-head`,y(`div`,y(`h2.card-title`,`Setup complete`),y(`p.card-sub`,`Archie is configured and ready to work.`)),y(`div.setup-complete-actions`,y(`span.setup-pct`,D(`check`,{size:16})),y(`button.icon-btn.setup-dismiss`,{type:`button`,title:`Dismiss setup complete`,"aria-label":`Dismiss setup complete`,onclick:()=>{P(),C(e)}},`×`)))))}function
Line truncated
|
||||
`)},y(`td.strong`,e.label||e.id),y(`td.mono`,e.install_type||`—`),y(`td.mono`,e.running_version||`—`),y(`td.mono`,e.latest_available||`—`),y(`td`,S(xe[e.status]||e.status,Se[e.status]||`idle`)))))))):we(`How each component is deployed, and whether what's running matches what's installed.`,T(`No components reported`,`The configured update-check command returned nothing.`))}function we(e,...t){return y(`div.card.cfg-section`,y(`div.card-head`,y(`div`,y(`h2.card-title`,`Update status`),y(`p.card-sub`,e))),...t)}function Te(){let e=y(`div.cfg-page`),t=y(`div`),n=y(`div`),r=y(`div`);i(),o(),s(),c();function i(){x(e,y(`div.page-head`,y(`div`,y(`h1.page-title`,`Configuration`),y(`p.page-sub`,`What archied is actually running with right now.`)),y(`div.page-actions`,y(`button.btn`,{onclick:()=>{o(),s(),c()}},`Refresh`))),n,r,t)}async function o(){try{l(await a.config(),o)}catch(e){x(t,y(`div.card`,T(`Cannot reach archied`,String(e.message||e))))}}async function s(){try{let e=await a.version();x(n,Ce(e?.components||[]))}catch(e){if(e?.status===501){x(n);return}x(n,y(`div.card`,T(`Update status unavailable`,String(e.message||e))))}}async function c(){try{let e=await a.taskMeta();x(r,De(e))}catch(e){x(r,J(`Work lifecycle`,`The task statuses and operator actions archied ships.`,T(`Lifecycle unavailable`,String(e.message||e))))}}function l(e,n){if(!e||Object.keys(e).length===0){x(t,y(`div.card`,T(`No configuration loaded`,`archied is running without a config file wired into the dashboard, so there is nothing to show.`)));return}let r={locked:e.locked||{},overridden:e.overridden||[],onSaved:n},i=[e.reload?.overlay_unavailable&&y(`div.card.cfg-notice`,y(`p`,`The runtime config overlay is not in effect: ${e.reload.overlay_unavailable}`)),e.reload?.last_error&&y(`div.card.cfg-notice`,y(`p`,`The last config reload failed; the running config is unchanged: ${e.reload.last_error}`))];x(t,...i,je(e.identity,r),Me(e.repositories),Pe(e.models,e.providers),Ie(e.budgets,r),Le(e.storage,e.containers,r),ze(e.web,r),Ee(e.provenance))}return e}function Ee(e){return e?.length?J(`Configuration sources`,`Applied from top to bottom; later entries take precedence over earlier ones.`,y(`div.kv-list`,...e.map(e=>q(`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,e.path)))):J(`Configuration sources`,`The files that supplied the running configuration.`,T(`Source provenance is unavailable.`))}function J(e,t,...n){return y(`div.card.cfg-section`,y(`div.card-head`,y(`div`,y(`h2.card-title`,e),y(`p.card-sub`,t))),...n)}function De(e){let t=e?.statuses||[],n=e?.actions||[],r=t.length?y(`div.kv-list`,...t.map(e=>Oe(e))):T(`No statuses reported`,`The server did not return any lifecycle statuses.`),i=n.length?y(`div.kv-list`,...n.map(e=>ke(e))):T(`No actions reported`,`The server did not return any operator actions.`);return J(`Work lifecycle`,`The task statuses and operator actions archied ships. Add one on the backend and it appears here without a frontend change.`,y(`h3.cfg-subhead`,`Statuses`),r,y(`h3.cfg-subhead`,`Actions`),i)}function Oe(e){let t=e.label??m(e.id),n=e.kind??h(e.id);return y(`div.kv`,y(`span.kv-label`,e.id),y(`span.kv-value`,S(t,n)))}function ke(e){let t=e.label??e.id,n=Ae(e.kind),r=n?`button.btn.btn-small.${n}`:`button.btn.btn-small`;return y(`div.kv`,y(`span.kv-label`,e.id),y(`span.kv-value`,y(r,{type:`button`,disabled:!0},t)))}function Ae(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function je(e,t){return e?J(`Identity`,`Who Archie is on the forge, and how it addresses commits and comments.`,y(`div.kv-list`,q(`Bot account`,e.bot_user,{key:`bot_user`,type:`string`,raw:e.bot_user,...t}),q(`Commit author email`,e.bot_email,{key:`bot_email`,type:`string`,raw:e.bot_email,...t}),q(`Pickup label`,e.label,{key:`label`,type:`string`,raw:e.label,...t}),q(`Forge type`,e.forge_type,{key:`forge.type`,type:`string`,raw:e.forge_type,...t}),q(`Forge host`,e.forge_host,{key:`forge.host`,type:`string`,raw:e.forge_host,...t}),q(`Max diff size (lines)`,e.diff_cap_lines||`Unlimited`,{key:`diff_cap_lines`,type:`int`,raw:e.diff_cap_lines,...t}))):J(`Identity`,`Who Archie is on the forge.`,T(`Not available`))}function Me(e){return e?.length?J(`Repositories`,`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request.`,y(`div.table-scroll`,y(`table.table`,y(`thead`,y(`tr`,...[`Repository`,`Base branch`,`Ecosystem`,`Quality gate`,`Protected paths`].map(e=>y(`th`,e)))),y(`tbody`,...e.map(e=>y(`tr`,y(`td.strong`,`${e.owner}/${e.name}`),y(`td.mono`,e.base),y(`td`,e.ecosystem||`go`),y(`td.mono`,Ne(e.gate)),y(`td.mono`,e.protect?.length?e.protect.join(`, `):`—`))))))):J(`Repositories`,`The repositories Archie polls for work.`,T(`No repositories configured`,`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`))}function Ne(e){return e?.length?e.map(e=>e.join(` `)).join(` → `):`—`}function Pe(e,t){let n=Object.entries(e||{}),r=Object.entries(t||{}),i=n.length?y(`Line truncated
|
||||
<div class="chat-page-content">
|
||||
<header class="chat-topbar">
|
||||
@@ -75,7 +75,7 @@
|
||||
`;function pt(){let e=document.createElement(`template`);e.innerHTML=ft.trim();let t=e.content.firstElementChild,n={};for(let e of t.querySelectorAll(`[data-chat-ref]`))n[e.dataset.chatRef]=e;return{root:t,refs:n}}function Y(e){let t=document.createDocumentFragment(),n=/(~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|`[^`]+`|\[[^\]]+\]\(https?:\/\/[^\s)]+\)|\*[^*]+\*|_[^_]+_)/g,r=0;for(let i of e.matchAll(n)){i.index>r&&t.append(document.createTextNode(e.slice(r,i.index)));let n=i[0];if(n.startsWith(`~~`))t.append(y(`del`,n.slice(2,-2)));else if(n.startsWith(`**`)||n.startsWith(`__`))t.append(y(`strong`,n.slice(2,-2)));else if(n.startsWith("`"))t.append(y(`code`,n.slice(1,-1)));else if(n.startsWith(`[`)){let e=n.match(/^\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)$/);t.append(y(`a`,{href:e[2],target:`_blank`,rel:`noreferrer`},e[1]))}else t.append(y(`em`,n.slice(1,-1)));r=i.index+n.length}return r<e.length&&t.append(document.createTextNode(e.slice(r))),t}function mt(e){let t=y(`div.chat-bubble-text`),n=String(e||``).split(`
|
||||
`),r=[],i=null,a=null,o=()=>{r.length&&(t.append(y(`p`,Y(r.join(` `)))),r=[])},s=()=>{i&&t.append(i),i=null};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.append(y(`pre`,y(`code`,a.join(`
|
||||
`)))),a=null):a=[];continue}if(a){a.push(c);continue}let l=ht(c),u=e+1<n.length?ht(n[e+1]):null;if(l&&u&>(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=ht(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}let i=y(`tbody`);for(let e of r)i.append(y(`tr`,...e.map(e=>y(`td`,Y(e)))));t.append(y(`table`,y(`thead`,y(`tr`,...l.map(e=>y(`th`,Y(e))))),i));continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.append(y(`h${d[1].length}`,Y(d[2])));continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tagName.toLowerCase()!==e)&&(s(),i=y(e)),i.append(y(`li`,Y((f||p)[1])));continue}if(c.startsWith(`>`)){o(),s(),t.append(y(`blockquote`,Y(c.replace(/^>\s?/,``))));continue}r.push(c)}return o(),s(),a&&t.append(y(`pre`,y(`code`,a.join(`
|
||||
`)))),t}function ht(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function gt(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}function _t(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function vt(){return y(`div.chat-bubble-row.assistant`,y(`div.chat-bubble`,y(`div.chat-bubble-meta`,`Archie`),y(`div.chat-tools`),y(`div.chat-bubble-text`)))}function yt(e){let t=e.from??e.From??``,n=e.text??e.Text??``,r=t!==`web`;return y(`div.chat-bubble-row.${r?`assistant`:`user`}`,y(`div.chat-bubble`,y(`div.chat-bubble-meta`,r?`Archie`:`You`),r?bt(e,n):y(`div.chat-bubble-text`,n)))}function bt(e,t){let n=e.tool_calls||e.ToolCalls||[],r=[y(`div.chat-tools`)];for(let e of n){let t=!!(e.err||e.Err);r[0].append(y(`div.chat-tool`+(t?`.failed`:``),y(`span.chat-tool-icon`,`🔧`),y(`span.chat-tool-name`,e.name||e.Name||`tool`),y(`span.chat-tool-summary`,e.summary||e.Summary||e.err||e.Err||`done`)))}return r.push(mt(t)),r}function X(e,t){let n=mt(t);return typeof e?.replaceWith==`function`?e.replaceWith(n):e?.parentNode&&e.parentNode.replaceChild(n,e),n}function xt(e,t){let n=t?.tool??``;if(!e||!n)return null;let r=t.parameters??``,i=t.text??``,a=y(`div.chat-tool`,y(`span.chat-tool-icon`,`🔧`),y(`span.chat-tool-name`,n),r&&y(`code.chat-tool-parameters`,r),y(`span.chat-tool-summary`,i));return t.failed&&(a.className=`chat-tool failed`),St(e).append(a),a}function St(e){let t=e.querySelector(`.chat-tools`);if(t)return t;let n=y(`div.chat-tools`);return e.append(n),n}var Ct=`archie.web.chat.channel`;function Z(){let t=localStorage.getItem(Ct);return t||(t=e(),localStorage.setItem(Ct,t)),t}function wt(t){return{text:t,sourceID:e()}}function Tt(e){return{...e}}function Et(e,t){let n=!!(e&&typeof e==`object`&&e.turn&&typeof e.turn.text==`string`),r=n?e.turn.text:t.trim();return{text:r,turn:n?Tt(e.turn):wt(r),isRetry:n}}function Dt({sessionList:e,sessionTools:t,sessions:n,currentSession:r,onSelect:i}){if(e.replaceChildren(),t.hidden=!r,!n.length){e.append(y(`div.chat-empty`,`Your conversations will appear here.`));return}for(let t of n)e.append(y(`button.chat-session`,{class:r===t.session_id?`active`:``,onclick:()=>i(t.session_id)},y(`strong`,_t(t)),y(`span`,new Date(t.last_active_at).toLocaleString())))}function Ot(e,t,n){e.persona.replaceChildren(y(`option`,{value:``},`Personality`));for(let n of t.personas||[])e.persona.append(y(`option`,{value:n},n));e.persona.value=t.active_persona||``;let r=t.providers||[];e.provider.hidden=r.length===0,e.provider.replaceChildren(y(`option`,{value:``},`Provider`));for(let t of r)e.provider.append(y(`option`,{value:t},t));e.provider.value=t.active_provider||r[0]||``,kt(e,t,e.provider.value),e.restart.hidden=!t.restart_available,e.dangerousPanel.hidden=!t.dangerous_available,t.dangerous_available&&n()}function kt(e,t,n){let r=t.models_by_provider||{},i=n&&r[n]?r[n]:t.models||[];e.model.replaceChildren(y(`option`,{value:``},`Model`));for(let t of i)e.model.append(y(`option`,{value:t},t));e.model.value=t.active_model||``}function At(e,t){let n=(t||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e),r=y(`div.chat-command-list`);n.length||r.append(y(`span`,`Send a message to begin.`));for(let e of n)r.append(y(`div.chat-command-item`,y(`code`,e.usage||e.command),y(`span`,e.description||``)));return e.replaceChildren(y(`summary`,`Available commands (${n.length})`),r),n}function jt(e,t,{onDefer:n,onInstall:r}){e.replaceChildren();let i=t?.snapshot||null,a=t?.available||[];if(!a.length){e.append(y(`span`,i?.deferred?`Update deferred.`:`Archie is up to date.`));return}e.append(y(`div`,y(`strong`,`Update available`),y(`span`,a.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `))),y(`div.chat-update-actions`,y(`button.btn`,{onclick:n},`Defer`),t.can_install?y(`button.btn.btn-primary`,{onclick:r},`Install update`):null))}function Mt(e,t,{onRequest:n,onDecision:r}){e.replaceChildren();let i=t?.checkpoints||[],a=t?.pending||[],o=y(`select.chat-select`,{"aria-label":`Checkpoint`},y(`option`,{value:``},`Select checkpoint`),...i.map(e=>y(`option`,{value:e.Number??e.number},`${e.Number??e.number} — ${e.Label??e.label??`checkpoint`}`))),s=y(`input.chat-dangerous-input`,{placeholder:`Process name or id`,"aria-label":`Process name or id`}),c=(e,t)=>()=>n(e,String(t.value||t).trim()),l=(e,t,n)=>y(`button.btn`,{onclick:()=>r(e,t)},n),u=a.length?a.map(e=>y(`div.chat-dangerous-pending`,y(`span`,e.description),y(`div.chat-update-actions`,l(e.id,`approve`,`Approve`),l(e.id,`permanent`,`Approve for 24h`),l(e.id,`deny`,`Deny`)))):[y(`span.chat-hint`,`No pending dangerous actions.`)];e.append(y(`div.chat-dangerous-head`,y(`strong`,`Dangerous actions`),y(`span.chat-hint`,`Every action requires approval.`)),y(`div.chat-dangerous-controls`,y(`div`,o,y(`button.btn`,{onclick:c(`rollback`,o)},`Request rollback`)),y(`div`,s,y(`button.btn`,{
Line truncated
|
||||
`)))),t}function ht(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function gt(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}function _t(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function vt(){return y(`div.chat-bubble-row.assistant`,y(`div.chat-bubble`,y(`div.chat-bubble-meta`,`Archie`),y(`div.chat-tools`),y(`div.chat-bubble-text`)))}function yt(e){let t=e.from??e.From??``,n=e.text??e.Text??``,r=t!==`web`;return y(`div.chat-bubble-row.${r?`assistant`:`user`}`,y(`div.chat-bubble`,y(`div.chat-bubble-meta`,r?`Archie`:`You`),r?bt(e,n):y(`div.chat-bubble-text`,n)))}function bt(e,t){let n=e.tool_calls||e.ToolCalls||[],r=[y(`div.chat-tools`)];for(let e of n){let t=!!(e.err||e.Err);r[0].append(y(`div.chat-tool`+(t?`.failed`:``),y(`span.chat-tool-icon`,`🔧`),y(`span.chat-tool-name`,e.name||e.Name||`tool`),y(`span.chat-tool-summary`,e.summary||e.Summary||e.err||e.Err||`done`)))}return r.push(mt(t)),r}function X(e,t){let n=mt(t);return typeof e?.replaceWith==`function`?e.replaceWith(n):e?.parentNode&&e.parentNode.replaceChild(n,e),n}function xt(e,t){let n=t?.tool??``;if(!e||!n)return null;let r=t.parameters??``,i=t.text??``,a=y(`div.chat-tool`,y(`span.chat-tool-icon`,`🔧`),y(`span.chat-tool-name`,n),r&&y(`code.chat-tool-parameters`,r),y(`span.chat-tool-summary`,i));return t.failed&&(a.className=`chat-tool failed`),St(e).append(a),a}function St(e){let t=e.querySelector(`.chat-tools`);if(t)return t;let n=y(`div.chat-tools`);return e.append(n),n}function Ct(e,t){let n=t?.path??``,r=t?.label||n;if(!e||!n)return null;let i=y(`a.chat-nav-chip`,{href:`#`+n,title:`Go to `+r,"aria-label":`Go to `+r},y(`span.chat-nav-chip-icon`,{"aria-hidden":`true`},`↗`),y(`span.chat-nav-chip-label`,r));return St(e).append(i),i}var wt=`archie.web.chat.channel`;function Z(){let t=localStorage.getItem(wt);return t||(t=e(),localStorage.setItem(wt,t)),t}function Tt(t){return{text:t,sourceID:e()}}function Et(e){return{...e}}function Dt(e,t){let n=!!(e&&typeof e==`object`&&e.turn&&typeof e.turn.text==`string`),r=n?e.turn.text:t.trim();return{text:r,turn:n?Et(e.turn):Tt(r),isRetry:n}}function Ot({sessionList:e,sessionTools:t,sessions:n,currentSession:r,onSelect:i}){if(e.replaceChildren(),t.hidden=!r,!n.length){e.append(y(`div.chat-empty`,`Your conversations will appear here.`));return}for(let t of n)e.append(y(`button.chat-session`,{class:r===t.session_id?`active`:``,onclick:()=>i(t.session_id)},y(`strong`,_t(t)),y(`span`,new Date(t.last_active_at).toLocaleString())))}function kt(e,t,n){e.persona.replaceChildren(y(`option`,{value:``},`Personality`));for(let n of t.personas||[])e.persona.append(y(`option`,{value:n},n));e.persona.value=t.active_persona||``;let r=t.providers||[];e.provider.hidden=r.length===0,e.provider.replaceChildren(y(`option`,{value:``},`Provider`));for(let t of r)e.provider.append(y(`option`,{value:t},t));e.provider.value=t.active_provider||r[0]||``,At(e,t,e.provider.value),e.restart.hidden=!t.restart_available,e.dangerousPanel.hidden=!t.dangerous_available,t.dangerous_available&&n()}function At(e,t,n){let r=t.models_by_provider||{},i=n&&r[n]?r[n]:t.models||[];e.model.replaceChildren(y(`option`,{value:``},`Model`));for(let t of i)e.model.append(y(`option`,{value:t},t));e.model.value=t.active_model||``}function jt(e,t){let n=(t||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e),r=y(`div.chat-command-list`);n.length||r.append(y(`span`,`Send a message to begin.`));for(let e of n)r.append(y(`div.chat-command-item`,y(`code`,e.usage||e.command),y(`span`,e.description||``)));return e.replaceChildren(y(`summary`,`Available commands (${n.length})`),r),n}function Mt(e,t,{onDefer:n,onInstall:r}){e.replaceChildren();let i=t?.snapshot||null,a=t?.available||[];if(!a.length){e.append(y(`span`,i?.deferred?`Update deferred.`:`Archie is up to date.`));return}e.append(y(`div`,y(`strong`,`Update available`),y(`span`,a.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `))),y(`div.chat-update-actions`,y(`button.btn`,{onclick:n},`Defer`),t.can_install?y(`button.btn.btn-primary`,{onclick:r},`Install update`):null))}function Nt(e,t,{onRequest:n,onDecision:r}){e.replaceChildren();let i=t?.checkpoints||[],a=t?.pending||[],o=y(`select.chat-select`,{"aria-label":`Checkpoint`},y(`option`,{value:``},`Select checkpoint`),...i.map(e=>y(`option`,{value:e.Number??e.number},`${e.Number??e.number} — ${e.Label??e.label??`checkpoint`}`))),s=y(`input.chat-dangerous-input`,{placeholder:`Process name or id`,"aria-label":`Process name or id`}),c=(e,t)=>()=>n(e,String(t.value||t).trim()),l=(e,t,n)=>y(`button.btn`,{onclick:()=>r(e,t)},n),u=a.length?a.map(e=>y(`div.chat-dangerous-pending`,y(`span`,e.description),y(`div.chat-update-actions`,l(e.id,`approve`,`Approve`),l(e.id,`permanent`,`Approve for 24h`),l(e.id,`deny`,`Deny`)))):[y(`span.chat-hint`,`No pending dangerousLine truncated
|
||||
|
||||
`);i=a.pop()||``;for(let e of a){let t=e.split(`
|
||||
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(S=n.session_id),n.type===`delta`&&(d+=n.text,u=X(u,d)),n.type===`tool`&&xt(l.querySelector(`.chat-bubble`)??l,n),n.type===`done`&&(f=!0,d||(d=n.text,u=X(u,d))),n.type===`error`)throw Error(n.text)}if(n)break}if(!f)throw Error(`chat stream ended before completion`);u.isConnected&&(u=X(u,d)),c.textContent=`Ready`,await R()}catch(e){if(e.name===`AbortError`&&!p)u=X(u,`Turn stopped.`),c.textContent=`Stopped`;else{u=X(u,`Unable to complete that turn: ${e.message||e}`);let t=Tt(n),r=y(`button.btn.chat-retry`,{type:`button`,onclick:()=>H({turn:t,replyBubble:l})},`Retry`);l.append(r),c.textContent=`Error — retry available`}}finally{clearTimeout(m),T=null,w=!1,o.disabled=!1,s.disabled=!0,i.disabled=!1,i.focus()}}o.onclick=()=>H(),s.onclick=()=>{let e=S;c.textContent=`Stopping…`,e&&a.chatCancel(e).catch(()=>{}),T?.abort()},i.oninput=P,i.onkeydown=e=>{if(!g.hidden&&k.length){if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&k.some(e=>e.command===i.value.trim())){e.preventDefault(),N(),H();return}if(e.key===`ArrowDown`){e.preventDefault(),A=(A+1)%k.length,P();return}if(e.key===`ArrowUp`){e.preventDefault(),A=(A+k.length-1)%k.length,P();return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),F(A);return}if(e.key===`Escape`){e.preventDefault(),N();return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),H())},l.onchange=async()=>{!S||!l.value||(await a.chatPersona(S,l.value),D.active_personas={...D.active_personas||{},[S]:l.value},c.textContent=`Personality: ${l.value}`)},u.onchange=async()=>{kt({model:d},D,u.value),u.value&&await U(`/model --provider ${u.value}`)},d.onchange=async()=>{d.value&&await U(`/model ${d.value}`)};async function U(e){try{let t=await a.chatMessage(Z(),e);c.textContent=t.reply||`Model updated`,await R()}catch(e){c.textContent=`Model update failed: ${e.message||e}`}}b.onclick=I;let ee={retry:()=>z(`/retry`),undo:()=>z(`/undo`),title:()=>B(`/title`,`Session title`),branch:()=>B(`/branch`,`Branch name (optional)`),compress:()=>z(`/compress --preview`)};for(let t of e.querySelectorAll(`[data-chat-action]`))t.onclick=ee[t.dataset.chatAction];return R().catch(e=>{c.textContent=e.message||`Chat unavailable`}),I(),e}var Q=[{path:`/`,label:`Dashboard`,icon:`dashboard`,view:L},{path:`/chat`,label:`Chat`,icon:`chat`,view:Pt},{path:`/tasks`,label:`Tasks`,icon:`tasks`,view:ce},{path:`/logs`,label:`Logs`,icon:`logs`,view:He},{path:`/captures`,label:`Event inspector`,icon:`captures`,view:$e},{path:`/mappings`,label:`Field mappings`,icon:`mappings`,view:ct},{path:`/skills`,label:`Skills`,icon:`skills`,view:le},{path:`/workflows`,label:`Workflows`,icon:`workflows`,view:pe},{path:`/memory`,label:`Memory`,icon:`memory`,view:lt},{path:`/channels`,label:`Channels`,icon:`channels`,view:me},{path:`/settings`,label:`Configuration`,icon:`settings`,view:Te}],Ft=`archie.theme`;function It(e){document.documentElement.dataset.theme=e,localStorage.setItem(Ft,e)}function $(){return localStorage.getItem(Ft)||`dark`}function Lt(e){let t=new Map,n=y(`nav.nav`,...[null].flatMap(()=>[...Q.map(n=>{let r=y(`a.nav-item`,{href:`#${n.path}`,onclick:t=>{n.soon?t.preventDefault():e(n.path)},"aria-disabled":n.soon||void 0,title:n.soon?`Coming soon`:void 0},D(n.icon),y(`span.nav-label`,n.label),n.soon&&y(`span.nav-soon`,`soon`));return t.set(n.path,r),r})])),r=y(`button.icon-btn`,{title:`Toggle light and dark`,"aria-label":`Toggle light and dark`,onclick:()=>{It($()===`dark`?`light`:`dark`),x(r,D($()===`dark`?`moon`:`sun`))}});x(r,D($()===`dark`?`moon`:`sun`));let i,a=()=>{i?.classList.remove(`is-open`),o.setAttribute(`aria-expanded`,`false`)},o=y(`button.icon-btn.mobile-search-toggle`,{type:`button`,"aria-label":`Open Jump to navigation`,"aria-expanded":`false`,onclick:()=>{i.classList.add(`is-open`),o.setAttribute(`aria-expanded`,`true`),s.focus()}},D(`search`,{size:15})),s=y(`input`,{type:`search`,placeholder:`Jump to…`,"aria-label":`Jump to a section`,onkeydown:t=>{if(t.key===`Escape`){a(),t.target.blur();return}if(t.key!==`Enter`)return;let n=t.target.value.trim().toLowerCase(),r=Q.find(e=>!e.soon&&e.label.toLowerCase().startsWith(n));r&&(e(r.path),t.target.value=``,t.target.blur(),a())}});return i=y(`div.topbar-search`,y(`span.topbar-search-icon`,{"aria-hidden":`true`},D(`search`,{size:15})),o,s),{node:y(`header.topbar`,y(`div.brand`,y(`span.brand-mark`,`A`),`Archie`),n,y(`div.topbar-end`,i,y(`button.icon-btn`,{title:`Documentation`,"aria-label":`Documentation`},D(`help`)),r,y(`div.avatar`,{title:`Signed in locally`},`A`))),highlight(e){for(let[n,r]of t)n===e?r.setAttribute(`aria-current`,`page`):r.removeAttribute(`aria-current`)}}}function Rt(){It($());let e=y(`main.main`),t=Lt(n);x(document.getElementById(`app`),y(`div.shell`,t.node,e));function n(e){location.hash===`#${e}`?r(e):location.hash=e}function r(n){e.firstElementChild?.dispatchEvent(new CustomEvent(`archie:teardown`));let[r,i=``]=n.spli
Line truncated
|
||||
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(S=n.session_id),n.type===`delta`&&(d+=n.text,u=X(u,d)),n.type===`tool`&&xt(l.querySelector(`.chat-bubble`)??l,n),n.type===`navigate`&&Ct(l.querySelector(`.chat-bubble`)??l,n),n.type===`done`&&(f=!0,d||(d=n.text,u=X(u,d))),n.type===`error`)throw Error(n.text)}if(n)break}if(!f)throw Error(`chat stream ended before completion`);u.isConnected&&(u=X(u,d)),c.textContent=`Ready`,await R()}catch(e){if(e.name===`AbortError`&&!p)u=X(u,`Turn stopped.`),c.textContent=`Stopped`;else{u=X(u,`Unable to complete that turn: ${e.message||e}`);let t=Et(n),r=y(`button.btn.chat-retry`,{type:`button`,onclick:()=>H({turn:t,replyBubble:l})},`Retry`);l.append(r),c.textContent=`Error — retry available`}}finally{clearTimeout(m),T=null,w=!1,o.disabled=!1,s.disabled=!0,i.disabled=!1,i.focus()}}o.onclick=()=>H(),s.onclick=()=>{let e=S;c.textContent=`Stopping…`,e&&a.chatCancel(e).catch(()=>{}),T?.abort()},i.oninput=P,i.onkeydown=e=>{if(!g.hidden&&k.length){if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&k.some(e=>e.command===i.value.trim())){e.preventDefault(),N(),H();return}if(e.key===`ArrowDown`){e.preventDefault(),A=(A+1)%k.length,P();return}if(e.key===`ArrowUp`){e.preventDefault(),A=(A+k.length-1)%k.length,P();return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),F(A);return}if(e.key===`Escape`){e.preventDefault(),N();return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),H())},l.onchange=async()=>{!S||!l.value||(await a.chatPersona(S,l.value),D.active_personas={...D.active_personas||{},[S]:l.value},c.textContent=`Personality: ${l.value}`)},u.onchange=async()=>{At({model:d},D,u.value),u.value&&await ee(`/model --provider ${u.value}`)},d.onchange=async()=>{d.value&&await ee(`/model ${d.value}`)};async function ee(e){try{let t=await a.chatMessage(Z(),e);c.textContent=t.reply||`Model updated`,await R()}catch(e){c.textContent=`Model update failed: ${e.message||e}`}}b.onclick=I;let te={retry:()=>z(`/retry`),undo:()=>z(`/undo`),title:()=>B(`/title`,`Session title`),branch:()=>B(`/branch`,`Branch name (optional)`),compress:()=>z(`/compress --preview`)};for(let t of e.querySelectorAll(`[data-chat-action]`))t.onclick=te[t.dataset.chatAction];return R().catch(e=>{c.textContent=e.message||`Chat unavailable`}),I(),e}var Q=[{path:`/`,label:`Dashboard`,icon:`dashboard`,view:L},{path:`/chat`,label:`Chat`,icon:`chat`,view:It},{path:`/tasks`,label:`Tasks`,icon:`tasks`,view:le},{path:`/logs`,label:`Logs`,icon:`logs`,view:He},{path:`/captures`,label:`Event inspector`,icon:`captures`,view:$e},{path:`/mappings`,label:`Field mappings`,icon:`mappings`,view:ct},{path:`/skills`,label:`Skills`,icon:`skills`,view:ue},{path:`/workflows`,label:`Workflows`,icon:`workflows`,view:pe},{path:`/memory`,label:`Memory`,icon:`memory`,view:lt},{path:`/channels`,label:`Channels`,icon:`channels`,view:me},{path:`/settings`,label:`Configuration`,icon:`settings`,view:Te}],Lt=`archie.theme`;function Rt(e){document.documentElement.dataset.theme=e,localStorage.setItem(Lt,e)}function $(){return localStorage.getItem(Lt)||`dark`}function zt(e,t){let n=new Map,r=y(`nav.nav`,...[null].flatMap(()=>[...Q.map(t=>{let r=y(`a.nav-item`,{href:`#${t.path}`,onclick:n=>{t.soon?n.preventDefault():e(t.path)},"aria-disabled":t.soon||void 0,title:t.soon?`Coming soon`:void 0},D(t.icon),y(`span.nav-label`,t.label),t.soon&&y(`span.nav-soon`,`soon`));return n.set(t.path,r),r})])),i=y(`button.icon-btn`,{title:`Toggle light and dark`,"aria-label":`Toggle light and dark`,onclick:()=>{Rt($()===`dark`?`light`:`dark`),x(i,D($()===`dark`?`moon`:`sun`))}});x(i,D($()===`dark`?`moon`:`sun`));let a,o=()=>{a?.classList.remove(`is-open`),s.setAttribute(`aria-expanded`,`false`)},s=y(`button.icon-btn.mobile-search-toggle`,{type:`button`,"aria-label":`Open Jump to navigation`,"aria-expanded":`false`,onclick:()=>{a.classList.add(`is-open`),s.setAttribute(`aria-expanded`,`true`),c.focus()}},D(`search`,{size:15})),c=y(`input`,{type:`search`,placeholder:`Jump to…`,"aria-label":`Jump to a section`,onkeydown:t=>{if(t.key===`Escape`){t.preventDefault(),o(),t.target.blur();return}if(t.key!==`Enter`)return;let n=t.target.value.trim().toLowerCase(),r=Q.find(e=>!e.soon&&e.label.toLowerCase().startsWith(n));r&&(e(r.path),t.target.value=``,t.target.blur(),o())}});return a=y(`div.topbar-search`,y(`span.topbar-search-icon`,{"aria-hidden":`true`},D(`search`,{size:15})),s,c),{node:y(`header.topbar`,y(`div.brand`,y(`span.brand-mark`,`A`),`Archie`),r,y(`div.topbar-end`,a,y(`button.icon-btn.icon-btn-chat`,{"aria-label":`Open chat`,title:`Chat with Archie`,"aria-expanded":`false`,onclick:()=>t?.()},D(`chat`)),y(`button.icon-btn`,{title:`Documentation`,"aria-label":`Documentation`},D(`help`)),i,y(`div.avatar`,{title:`Signed in locally`},`A`))),highlight(e){for(let[t,r]of n)t===e?r.setAttribute(`aria-current`,`page`):r.removeAttribute(`aria-current`)}}}function Bt(){Rt($());let e=y(`main.main`),t=y
Line truncated
|
||||
+1
-1
@@ -165,7 +165,7 @@ export const api = {
|
||||
chatMessage: async (channelID, text) => {
|
||||
const res = await fetch("/api/chat/message", {
|
||||
method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ channel_id: channelID, source_id: randomUUID(), text }),
|
||||
body: JSON.stringify({ channel_id: channelID, source_id: randomUUID(), text, page: location.hash.slice(1) || "/" }),
|
||||
signal: AbortSignal.timeout(15000),
|
||||
});
|
||||
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
|
||||
|
||||
@@ -27,6 +27,7 @@ const paths = {
|
||||
trendUp: '<path d="M4 17L10 11l4 4 6-6"/><path d="M14 7h6v6"/>',
|
||||
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"/>',
|
||||
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"/>',
|
||||
};
|
||||
|
||||
|
||||
@@ -42,3 +42,27 @@ function toolList(host) {
|
||||
host.append(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
// appendNavigateChip renders a dashboard_navigate result as a clickable chip
|
||||
// that routes the operator to a dashboard page. It is an action, not a tool
|
||||
// narration line: the model called dashboard_navigate to point the operator
|
||||
// somewhere, so the chip is a real link (the app routes on location.hash),
|
||||
// and it is the only clickable navigation surface the transcript offers. The
|
||||
// label is the tool's resolved page name, never a markdown link the model
|
||||
// invented.
|
||||
export function appendNavigateChip(host, event) {
|
||||
const path = event?.path ?? "";
|
||||
const label = event?.label || path;
|
||||
if (!host || !path) return null;
|
||||
const chip = el("a.chat-nav-chip",
|
||||
{
|
||||
href: "#" + path,
|
||||
title: "Go to " + label,
|
||||
"aria-label": "Go to " + label,
|
||||
},
|
||||
el("span.chat-nav-chip-icon", { "aria-hidden": "true" }, "↗"),
|
||||
el("span.chat-nav-chip-label", label),
|
||||
);
|
||||
toolList(host).append(chip);
|
||||
return chip;
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
.chat-page { height: calc(100vh - 5rem); display: flex; flex-direction: column; overflow: hidden; }
|
||||
/* When the chat is a drawer (shell), it fills the panel; the standalone page
|
||||
keeps its viewport-minus-chrome height. */
|
||||
.chat-drawer .chat-page { height: 100%; }
|
||||
.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; }
|
||||
@@ -68,6 +71,34 @@
|
||||
.chat-tool-name { color: var(--fg); font-weight: 600; }
|
||||
.chat-tool.failed .chat-tool-summary { color: var(--danger); }
|
||||
|
||||
/* A dashboard_navigate result: a clickable chip that routes the operator to a
|
||||
dashboard page. It is an action, not evidence, so it is styled as a button
|
||||
beside the tool list rather than a muted log line, and it visibly invites a
|
||||
click. It is the only clickable navigation surface in the transcript. */
|
||||
.chat-nav-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: .4rem;
|
||||
padding: .4rem .7rem;
|
||||
border-radius: 999px;
|
||||
border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
|
||||
background: var(--accent-soft);
|
||||
color: var(--accent);
|
||||
font-size: .82rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: background var(--transition), border-color var(--transition), color var(--transition);
|
||||
}
|
||||
.chat-nav-chip:hover {
|
||||
border-color: var(--accent);
|
||||
background: color-mix(in srgb, var(--accent) 16%, var(--surface));
|
||||
}
|
||||
.chat-nav-chip:focus-visible {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
.chat-nav-chip-icon { font-size: .8rem; line-height: 1; }
|
||||
|
||||
.chat-compose { padding: .85rem 1rem 1rem; 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; }
|
||||
|
||||
+14
-2
@@ -3,7 +3,7 @@ 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 } from "./chat-tools.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";
|
||||
@@ -12,6 +12,15 @@ import { updateUnavailableMessage } from "./chat-update-status.js";
|
||||
|
||||
import "./chat.css";
|
||||
|
||||
// currentPage is the dashboard route the operator is on right now (the hash
|
||||
// minus the leading "#"). It is sent with each chat message so the agent's
|
||||
// system prompt can state where the operator is looking and point them
|
||||
// somewhere relevant. A future global chat drawer still reads this live from
|
||||
// the URL, so it stays correct as the operator navigates.
|
||||
function currentPage() {
|
||||
return location.hash.slice(1) || "/";
|
||||
}
|
||||
|
||||
export function chatPage() {
|
||||
const { root, refs } = createChatView();
|
||||
const { sessionList, transcript, composer, send, stop, status, persona, provider, model,
|
||||
@@ -240,7 +249,7 @@ export function chatPage() {
|
||||
const response = await fetch("/api/chat/stream", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json", Accept: "text/event-stream" },
|
||||
body: JSON.stringify({ channel_id: channelID(), source_id: turn.sourceID, text: turn.text }),
|
||||
body: JSON.stringify({ channel_id: channelID(), source_id: turn.sourceID, text: turn.text, page: currentPage() }),
|
||||
signal: activeController.signal,
|
||||
});
|
||||
if (!response.ok) throw new Error((await response.text()) || `${response.status} ${response.statusText}`);
|
||||
@@ -264,6 +273,9 @@ export function chatPage() {
|
||||
if (event.type === "tool") {
|
||||
appendToolCall(replyBubble.querySelector(".chat-bubble") ?? replyBubble, event);
|
||||
}
|
||||
if (event.type === "navigate") {
|
||||
appendNavigateChip(replyBubble.querySelector(".chat-bubble") ?? replyBubble, event);
|
||||
}
|
||||
if (event.type === "done") {
|
||||
finished = true;
|
||||
if (!streamedText) {
|
||||
|
||||
@@ -192,6 +192,75 @@ 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 {
|
||||
position: fixed;
|
||||
inset: var(--sp-4);
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
justify-content: flex-end;
|
||||
pointer-events: none;
|
||||
z-index: 40;
|
||||
}
|
||||
.chat-drawer-panel {
|
||||
pointer-events: auto;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: grid;
|
||||
grid-template-rows: auto minmax(0, 1fr);
|
||||
width: min(430px, 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;
|
||||
transform: translateX(1.2rem);
|
||||
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. */
|
||||
.chat-drawer:not(.is-open) .chat-drawer-panel {
|
||||
pointer-events: none;
|
||||
}
|
||||
.chat-drawer.is-open .chat-drawer-panel {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
.chat-drawer-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--sp-2);
|
||||
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);
|
||||
}
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/* ── Constrained desktop ────────────────────────────────────────────────── */
|
||||
|
||||
@media (max-width: 1220px) and (min-width: 901px) {
|
||||
|
||||
+54
-4
@@ -46,7 +46,7 @@ function currentTheme() {
|
||||
return localStorage.getItem(THEME_KEY) || "dark";
|
||||
}
|
||||
|
||||
function commandBar(onNavigate) {
|
||||
function commandBar(onNavigate, onToggleChat) {
|
||||
const items = new Map();
|
||||
|
||||
const nav = el(
|
||||
@@ -113,6 +113,9 @@ function commandBar(onNavigate) {
|
||||
"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;
|
||||
@@ -143,6 +146,12 @@ function commandBar(onNavigate) {
|
||||
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"),
|
||||
@@ -161,11 +170,36 @@ function start() {
|
||||
applyTheme(currentTheme());
|
||||
|
||||
const outlet = el("main.main");
|
||||
const bar = commandBar(navigate);
|
||||
mount(document.getElementById("app"), el("div.shell", bar.node, outlet));
|
||||
// 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;
|
||||
if (location.hash !== '#' + path) location.hash = path;
|
||||
else show(path);
|
||||
}
|
||||
|
||||
@@ -176,10 +210,26 @@ function start() {
|
||||
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) || "/");
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import "./shim.js";
|
||||
import { assistantBubble } from "../src/chat/chat-render.js";
|
||||
import { appendToolCall } from "../src/chat/chat-tools.js";
|
||||
import { appendToolCall, appendNavigateChip } from "../src/chat/chat-tools.js";
|
||||
|
||||
// childIndex reports where a node sits among its parent's children, which is
|
||||
// how the tests assert that the work is listed above the answer.
|
||||
@@ -91,3 +91,28 @@ test("a bubble without a tool list still records tool activity", () => {
|
||||
|
||||
assert.equal(host.querySelector(".chat-tool-name").textContent, "shell");
|
||||
});
|
||||
|
||||
// A dashboard_navigate call is an explicit point-the-operator-somewhere
|
||||
// result, so it renders as a clickable chip link rather than a muted tool
|
||||
// line, and the chip must be a real link (the app routes on location.hash).
|
||||
test("a navigate chip is a clickable link to the resolved page", () => {
|
||||
const row = assistantBubble();
|
||||
const host = row.querySelector(".chat-bubble");
|
||||
|
||||
appendNavigateChip(host, { path: "/tasks", label: "Tasks" });
|
||||
|
||||
const chip = host.querySelector(".chat-nav-chip");
|
||||
assert.ok(chip, "navigate chip should render");
|
||||
assert.equal(chip.getAttribute("href"), "#/tasks");
|
||||
assert.equal(chip.querySelector(".chat-nav-chip-label").textContent, "Tasks");
|
||||
assert.equal(chip.getAttribute("aria-label"), "Go to Tasks");
|
||||
});
|
||||
|
||||
test("a navigate chip without a path is not rendered", () => {
|
||||
const row = assistantBubble();
|
||||
const host = row.querySelector(".chat-bubble");
|
||||
|
||||
appendNavigateChip(host, { path: "", label: "Tasks" });
|
||||
|
||||
assert.equal(host.querySelector(".chat-nav-chip"), null);
|
||||
});
|
||||
Reference in new issue
Block a user