Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,17 @@

### Changed

1. **`web.crawl` accepts a relative `include`.** A prefix that does not start with `/` now matches anywhere in a link's path,
1. **The agent-question page separates what waits from the history (Eric, 2026-11-19).** A sticky header carries the
person's name and the count of open cards (also in the tab's title); *Waiting for you* lists the cases with an open
card - a wait to decide or an advice to read - newest activity first; *History* is a scrollable panel with the closed
cases, newest first, that keeps its scroll position while new cards arrive, so the whole inbox stays in reach without
pushing the open work away. The page is one vanilla HTML file still, byte-identical in the Node.js twin. The
agent-question app of each pack is the backend - the inbox, the endpoints, the stream - and the front-end that will
replace this page, a small React app pointed at either backend, is on the Node.js pack's backlog (Eric: one front-end
to maintain in one place, mercury-nodejs `extensions/agent-question`); this pack points to it and keeps the vanilla
page as the fallback.

2. **`web.crawl` accepts a relative `include`.** A prefix that does not start with `/` now matches anywhere in a link's path,
since a model names a section as `guides/` as often as `/guides/`: the live drive of the Playground's `site-notes` graph
showed a crawl returning the start page alone because the model's `include` was relative. The README's Event-over-HTTP
example lists one route per entry - the engines' map takes no comma-separated list.
Expand Down
9 changes: 8 additions & 1 deletion extensions/agent-question/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ application is one of those routes. It is a standalone application on the packag
wait (`kind` `approval` or `question`) is **upserted** on `(graph_id, correlation_id, turn)` - a re-advice for the same
turn updates the card rather than adding one - and an **advice** (a status update, an acknowledgement, an outcome) is
**appended**, since those accumulate. Write first: the row is committed before any push to a browser.
- **The person's side**, under the pack's host: `GET /questions/app` is the page; `GET /questions?since=<seq>` the
- **The person's side**, under the pack's host: `GET /questions/app` is the page - a sticky header with the person's
name and the count of open cards, the cases that wait for a decision or a look first, and the closed cases in a
scrollable History panel that keeps its place while new cards arrive; `GET /questions?since=<seq>` the
**replay** a reconnecting device calls first - every row that changed since its cursor, waits and advices alike, with
the cursor to continue from; `GET /questions/events` the **stream** a connected device holds, each event carrying a
changed row, `Last-Event-ID` the same cursor, so a browser's reconnect misses nothing. The person selects which card
Expand All @@ -25,6 +27,11 @@ application is one of those routes. It is a standalone application on the packag
never overwrites it (the live drive of 2026-11-19). Rows are never deleted here; `schema/purge.sql` is the
installation's.

This app is the backend - the inbox, the endpoints, the stream; the page is its vanilla front-end. The front-end that
will replace it, a small React app pointed at either pack's backend, is built and maintained in the Node.js pack only, so
there is one app to maintain in one place (Eric, 2026-11-19): use it from mercury-nodejs `extensions/agent-question`
against this backend when it lands; the vanilla page here stays as the fallback.

The Node.js twin (mercury-nodejs `extensions/agent-question`) serves the same route, the same page and the same
schema, pinned by the same vector file.

Expand Down
37 changes: 27 additions & 10 deletions extensions/agent-question/agent_question.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,7 @@ async def mark_seen(request: web.Request) -> web.Response:
"textarea,input[type=text]{width:100%;box-sizing:border-box;margin:.2rem 0}button{padding:.4rem 1rem;border-radius:6px;"
"border:1px solid #556;background:#fff;cursor:pointer}button.primary{background:#1f2a44;color:#fff}"
".outcome{font-size:.85rem;color:#334;margin-top:.4rem}.empty{color:#667;padding:2rem;text-align:center}"
"header{position:sticky;top:0;z-index:2}.section{display:flex;align-items:center;gap:.5rem;font-size:.95rem;color:#445;margin:1.2rem 0 .4rem}.count{background:#e0a800;color:#222;border-radius:999px;padding:0 .5rem;font-size:.8rem;min-width:1.2rem;text-align:center}.count:empty{display:none}#history-section .count{background:#dde;color:#334}.panel{max-height:45vh;overflow-y:auto;border:1px solid #dde;border-radius:10px;background:#fafbfc;padding:0 .8rem}.panel .case{margin:.6rem 0}"
)

SCRIPT = r"""
Expand Down Expand Up @@ -1054,17 +1055,29 @@ async def mark_seen(request: web.Request) -> web.Response:
}
return body + '</div>';
}
function caseHtml(list) {
list.sort((a, b) => a.seq - b.seq);
const first = list[0];
return '<section class="case"><h2>' + esc(first.description) + '</h2><div class="meta">' + esc(first.graph_id) + ' · ' + esc(first.correlation_id) + '</div>' + list.map(card).join('') + '</section>';
}
function render() {
const main = document.getElementById('cases');
if (!rows.size) { main.innerHTML = '<div class="empty">Nothing waits for you.</div>'; return; }
// what waits for the person first - every case with an open card - and the closed cases in the history panel,
// newest activity first on both sides; the panel keeps its scroll position across updates
const waiting = document.getElementById('cases'), history = document.getElementById('history');
const groups = new Map();
for (const r of rows.values()) { const key = r.graph_id + '\u0000' + r.correlation_id; if (!groups.has(key)) groups.set(key, []); groups.get(key).push(r); }
const ordered = [...groups.entries()].sort((a, b) => Math.max(...b[1].map(r => r.seq)) - Math.max(...a[1].map(r => r.seq)));
main.innerHTML = ordered.map(([key, list]) => {
list.sort((a, b) => a.seq - b.seq);
const first = list[0];
return '<section class="case"><h2>' + esc(first.description) + '</h2><div class="meta">' + esc(first.graph_id) + ' · ' + esc(first.correlation_id) + '</div>' + list.map(card).join('') + '</section>';
}).join('');
const newest = (list) => Math.max(...list.map(r => r.seq));
const ordered = [...groups.values()].sort((a, b) => newest(b) - newest(a));
const open = ordered.filter(list => list.some(r => r.state === 'open'));
const closed = ordered.filter(list => !list.some(r => r.state === 'open'));
const openCards = open.reduce((n, list) => n + list.filter(r => r.state === 'open').length, 0);
document.getElementById('waiting-count').textContent = openCards ? String(openCards) : '';
document.getElementById('history-count').textContent = closed.length ? String(closed.length) : '';
document.title = (openCards ? '(' + openCards + ') ' : '') + TITLE;
waiting.innerHTML = open.length ? open.map(caseHtml).join('') : '<div class="empty">Nothing waits for you.</div>';
const keep = history.scrollTop;
history.innerHTML = closed.length ? closed.map(caseHtml).join('') : '<div class="empty">Nothing yet.</div>';
history.scrollTop = keep;
}
document.getElementById('cases').addEventListener('click', async (ev) => {
const seen = ev.target.closest('button[data-seen]');
Expand Down Expand Up @@ -1102,8 +1115,12 @@ def page(title: str) -> str:
f"<title>{html.escape(title)}</title>\n<style>{STYLE}</style>\n</head>\n<body>\n"
f"<header><h1>{html.escape(title)}</h1><label class=\"meta\">your name <input id=\"name\" type=\"text\" "
"placeholder=\"as the model will see it\"></label><span id=\"status\">connecting...</span></header>\n"
"<main id=\"cases\"><div class=\"empty\">Loading...</div></main>\n"
f"<script>const LIST = {json.dumps(LIST_PATH)}; const EVENTS = {json.dumps(EVENTS_PATH)};{SCRIPT}</script>\n"
"<main><section id=\"waiting-section\"><h2 class=\"section\">Waiting for you <span id=\"waiting-count\" "
"class=\"count\"></span></h2><div id=\"cases\"><div class=\"empty\">Loading...</div></div></section>\n"
"<section id=\"history-section\"><h2 class=\"section\">History <span id=\"history-count\" class=\"count\"></span>"
"</h2><div id=\"history\" class=\"panel\"><div class=\"empty\">Loading...</div></div></section></main>\n"
f"<script>const LIST = {json.dumps(LIST_PATH)}; const EVENTS = {json.dumps(EVENTS_PATH)}; "
f"const TITLE = {json.dumps(title)};{SCRIPT}</script>\n"
"</body>\n</html>\n"
)

Expand Down
5 changes: 5 additions & 0 deletions memory/continuity.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@
never deleted by the app; a new card state is a change to `state_after` and the schema's check constraint in both
packs; a wait decided elsewhere stays open on a card until a device tries it (410 → expired) or it expires - the
acknowledgement advice beside it tells the person.
**The person's side (Eric, 2026-11-19):** the page is one vanilla file, byte-identical in both packs - since 2026-11-19
a sticky header with the count of open cards, *Waiting for you* and a scrollable *History* panel. This app is the
backend in both packs; the front-end that replaces the page, a small React app pointed at either backend, is built and
maintained in the Node pack only (mercury-nodejs thread `agent-question-react-ui`), and this pack points to it - never a
second front-end here.
<!-- id: agent-question-app | created: 2026-11-19 | last_used: 2026-11-19 | uses: 1 | tier: working | origin: 2026-11-19-071444 -->

## Conventions
Expand Down
27 changes: 27 additions & 0 deletions memory/sessions/2026-11-19-094736.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Session (2026-11-19T09:47:36.000Z)

**Agent:** Claude Code
**Title:** The agent-question page separates what waits from the history; the React UI lives in the Node pack
**User:** Eric - "The agent-question UI is a bit primitive. Please add a backlog to upgrade it to a small React app ... Could you allow the user to scroll the panel to see history?" and "putting it only in the mercury-nodejs language pack so there is one app to maintain in one place. Add a reference pointer in the mercury-python repo".

## What We Did

- **The page** (`extensions/agent-question/agent_question.py`; the Node twin's generated page is byte-identical): a
sticky header with the person's name and the count of open cards (also in the tab's title); *Waiting for you* lists
the cases with an open card - a wait to decide or an advice to read - newest activity first; *History* is a scrollable
panel (45vh) with the closed cases, newest first, that keeps its scroll position across the re-render every event
causes. Checked under a minimal DOM shim run on Node: two open cards and one closed case from five rows landed where
they belong, the title read "(2) Agent questions", the panel's scroll position survived a render.
- **The React UI is the Node pack's** (Eric's rulings: the agent-question app is the backend in both packs, the React UI
the one front-end, pointed at either backend; one app to maintain in one place): the backlog thread is mercury-nodejs
`agent-question-react-ui`; this pack's README and CHANGELOG point there, the fact [[agent-question-app]] records the
rule - never a second front-end here - and the vanilla page stays as the fallback.
- **Gates:** ruff OK, basedpyright 0 errors, the agent-question suite 48 passed (the page test now checks the two
sections). CHANGELOG Unreleased/Changed 1; README.
- Opened as PR #72.

## Memory References

- Referenced: agent-question-app (edited: the person's side and the React UI's home)
- Created: (none)
- Superseded: (none)
4 changes: 3 additions & 1 deletion tests/test_agent_question.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,9 @@ async def test_the_replay_lists_every_change_since_the_cursor(
async with http.get(f"{host}/questions?since=x") as response:
assert response.status == 400
async with http.get(f"{host}/questions/app") as response:
assert response.status == 200 and "Agent questions" in await response.text()
text = await response.text()
assert response.status == 200 and "Agent questions" in text
assert 'id="history"' in text and "Waiting for you" in text, "the page separates what waits from the history"


async def test_the_stream_replays_then_follows_the_changes_with_keep_alives(
Expand Down
Loading