Skip to content

[Spec 2045] The Tower page's right panel as a Site view - #2059

Open
waleedkadous wants to merge 109 commits into
mainfrom
builder/aspir-2045
Open

waleedkadous wants to merge 109 commits into
mainfrom
builder/aspir-2045

Conversation

@waleedkadous

@waleedkadous waleedkadous commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The Tower landing page's right panel becomes a Site tab, built for a programmer running several workspaces:

  1. A machine line: load against CPUs, memory, lowest free disk, Codev version, harnesses, and "Machine details". It is muted when all is well. When a figure needs attention it turns the warning colour and says what is wrong in words.
  2. Decisions: one list of every running workspace's open items, oldest first. A row opens in place to the Decisions tab's own card, draft store and POST …/api/decisions/rule, so there is no second ruling path. Porch gates and agents' questions are not rows here.
  3. Workspace → architect → builder tree (React Aria Tree). Each row has a state glyph and word, a gate chip, a PR chip and two open icons: Dashboard, and Codev IDE (a builder's IDE icon opens its worktree). The tree also has a filter, expansion remembered per browser, and live updates that keep what is open, the scroll position and focus.
  4. Stopped workspaces sit in one collapsed group, each with Start, the panel's only action.

Home's cards, Stop, Restart, New Shell, copy path, the Launch form and Recent are gone; the routes and afx commands stay. The Site Manager pane offers only Start, and only while it is not running.

Closes #2045

Changes

  • Contracts and SDK (packages/types, packages/sdk): SiteAgentsReport, SiteDecisionsReport, R12 fields on SiteStatus (decisionsFile, openDecisions, decisionsReason, spawnedByArchitect). New helpers siteActivityState (a gated builder's own activity, read from the raw facts), isSiteFinishedBuilder, formatAgeWords.
  • Tower (packages/codev/src/agent-farm/servers):
    • GET /api/site/agents runs the overview's own discovery, builders table, served state and live architects. It never calls the forge, and its builds are shared per burst as in the overview cache fix of Sidebar refetches and redraws on every agent tool call; the web IDE shows a permanent refresh spinner #2036.
    • GET /api/site/decisions reads through a parse cache keyed by mtime, size and inode. /api/site's counts use the same cache.
    • Hashed, immutable, gzipped /pane/* files (pane-assets.ts).
    • live-agents.ts and shared-builds.ts are extracted so the overview and the Site read share one copy.
  • Shared Decisions pieces (packages/workspace-views):
    • DecisionCard, DecisionsMarkdown, HeldDrafts, useRulingState and createDecisionsHost are exported.
    • Cards carry a stable anchor, and the dashboard accepts ?tab=decisions&item=<id>.
    • A new held-draft reason covers an item whose workspace stopped.
  • The Site view (apps/web/src/site/, in the pane bundle):
    • Pure model modules: order, tree, expansion, filter, decisions list, machine line, targets, reads, age clock.
    • React components on top of them.
    • Shape checks on every field a read feeds the view.
  • tower.html:
    • Mounts codevSiteManagerPane.site.
    • Shows its own escape hatch (#site-hatch) when the script is missing or the view fails.
    • Peers moves to the Machine tab.
    • An overview-changed event no longer toasts.
    • Home's markup and code are removed.
  • Docs, both trees: the Site Manager's role, arch.md, both agent-farm.md, the afx skill's four copies, testing-guide.md.

For the architect

  • Stopped-workspace rows have no open icons. This is ruled (3 Dec): the issue gives a stopped row "its name and one Start button", so R7 and R9 are amended to say a stopped row is name, chips and Start. No code change.
  • R11 is checked on the real workbench (3 Dec, with your go-ahead and within your limits):
    • It ran in my own Playwright profile. Your Tower page was loaded with every request aborted except its document, /api/status and the mint, so no pane bundle or terminal socket loaded.
    • The page's own mint and ideTargetUrl opened this builder's worktree in the Codev IDE workbench. The window is titled aspir-2045 — Codev, the Explorer lists the worktree, and the Codev sidebar reads Connected.
    • It opened in Restricted Mode, with no trust prompt and no error. Nothing was started or stopped, and the screenshot stays local.
  • Two commits were not re-reviewed in their phase, so please look at them here:
    • e1d1bdf: after a ruling, the decisions read already under way is aborted and a fresh read starts at once. It landed at porch's three-iteration ceiling.
    • 23e097b: Claude's small phase 6 notes, taken after it had approved.
  • R19a amended (your ruling): a workspace-path image loads only through the workspace image route, while an http(s) <img> loads as the Decisions tab loads it today (images in decision items, Decisions tab: show images from the workspace inline in decision items #1938). The tradeoff: on the local page the browser fetches the third-party URL, while under Codev Cloud img-src 'self' refuses it. The item's author is the person's own agent.
  • Contract change: the Site view's host is {openIde, startWorkspace, selectTab, showFallback}, and site.unmount() is new. React render failures reach the hatch through onUncaughtError. An error thrown inside a React event handler does not: the view stays usable, and that one action fails with a console error.
  • For Codev Cloud:
    • /pane/* now answers Content-Encoding: gzip, so the proxy must pass the body as it is, without compressing it again.
    • The cloud's policy has allowed blob: in img-src since 3 Dec (staging and production), so decision images load there now. Under a policy without blob:, the card shows its "Image not loaded" note and the item can still be ruled; the e2e test covers that case against the stand-in's img-src 'self' data:.
  • An unreadable pane file now answers 500; it used to answer 404. A missing file is still 404.

Deviations from the plan

  • IDE availability comes from the agents read (SiteAgentsReport.ide), not from /api/status through update(). That keeps one source, read on the rows' own cadence, and R13 agrees.
  • Component files are named MachineLineView.tsx and SiteTreeView.tsx, because MachineLine.tsx would differ from machineLine.ts only in case, which macOS treats as one file.
  • The page's pane references are rewritten by their quoted attribute. PaneAssets is kept in a module-level map, not a new RouteContext field.
  • Asking rows use describeNeedsInput's words, per your ruling of 3 Dec.
  • R13 was amended per your ruling: through the cloud, Tower checks the IDE's port over loopback, and holds the answer for 10 s.
  • The full list, phase by phase, is in the review.

Adjacent fixes:

  • A pane whose first update threw stopped the rest of mountPanes(); that first update now goes through the guarded path.
  • The hatch no longer drops keyboard focus on every status poll.
  • afx workspace remove's dry-run said a workspace "leaves Recent"; it now says it "is no longer listed".
  • testing-guide.md's example drove the removed Launch form on port 4100.
  • Found in the PR review: the Decisions card, shared with the dashboard's tab, let an item's markup load URLs outside the workspace image route or restyle the page. The sanitizer kept <style> elements, SVG, <picture>/<source>, media, <table background>, <input type=image> and style attributes.
    • By your ruling, item HTML now passes a second DOMPurify pass with an allow list of what markdown writes, so <img src> is the only attribute that fetches.
    • The list was agreed line by line before anything was cut: tabindex, s, ol start and h3–h6 kept; table alignment carried as align; data-line, data-row and id cut.
    • The only class kept is a code block's language-*, so an item cannot take one of the page's own classes, such as the dashboard's confirm-dialog backdrop.
  • The pre-review lists test, from PR [Air #2057] feat: pre-review lists in builder phase prompts #2058, failed on Windows: it compared checked-out Markdown with LF, and a Windows checkout is CRLF. It now reads the list files and the prompt porch renders as LF. This is a test-only fix in its own commit (9cb2747), made on your ruling; porch's rendering and the files' line endings are unchanged.
    • Tests: one per refused kind, one for an unknown element and attribute, and one that everything markdown writes survives.

Bundle size (accepted in planning)

before after
Pane JS, gzip 191,826 B 317,218 B
Pane JS, raw 711,783 B 1,067,158 B
Pane CSS, gzip 2,680 B 9,674 B
Pane CSS, raw 7,605 B 52,256 B

It is still one script and one stylesheet, with no eval, no new Function, no data: font and nothing loaded from another host. React Aria Components 1.23.0 and lucide-react 1.86.0 are pinned exactly, and Lucide icons are imported one at a time.

Testing

  • Unit tests:
    • apps/web: the site model, reads, shape checks, components, pane API and fallback.

    • workspace-views: the shared Decisions pieces, held drafts, the anchor.

    • packages/codev: both reads, the parse cache, the held IDE check, pane assets, template tests of the page.

    • sdk: the site helpers.

    • Budget at 50 known and 15 running workspaces:

      read warm cold
      /api/site/decisions 0.6 ms 21 ms
      /api/site/agents 6.1 ms 7.2 ms
      /api/site with the R12 fields 1.7 ms —
  • Playwright, spec-2045-site-view (17 passed, plus 1 screenshot test that runs only when asked):
    • Ruling through the real route, with colliding ids across two workspaces, a refusal, and a held draft.
    • Start on a stopped workspace, and the hatch with the pane script blocked.
    • Keyboard use of the tree.
    • A live update that keeps expansion, scroll and focus.
    • The filter.
    • Every icon's target, locally and under the prefix stand-in.
    • The layout at 360 px.
    • R19a (item content stays inert), the image under the cloud's CSP, and R19c over raw HTTP.
  • Spec 2041 browser suites: two-pane 8, parity 14, proxy-prefix 5, pane 2, machine-tab 7.
  • CI on code head 6a54a84, which carries every code change. Later commits touch only docs and porch's status.yaml.
    • Windows: run 47055145791, green. That covers unit tests, CLI tests, install verification, and both probes.
    • dashboard-e2e: run 47055149871, green. It runs tower-integration and dashboard-bugs, which a worktree cannot run.
    • The PR's own checks are green as well.

Screenshots (kept local, as the spec requires; not attached)

A fixture Tower with four running workspaces and three stopped ones, at 1440, 1024, 700 and 360 px. Each shot shows:

  • the machine line with signed-out harnesses as warnings;
  • three open decisions from two workspaces, one opened to its card;
  • codev with main working, review idle and the stopped owner ide;
  • builders at the pr gate, working, idle and exited, and a finished fold opened;
  • a workspace with "no architect";
  • an asking architect, with "at a permission prompt: Bash npm run deploy:preview";
  • an idle-2-days workspace collapsed;
  • the stopped group with Start.

Three more shots: two at 1440 px with the filter (mobile, which matches a workspace's own name, and 2044, which matches a builder), and one at 700 px where an asking builder's prompt wraps.

Flaky Tests

These existed before this branch, fail sometimes for reasons unrelated to it, and were left running:

  • tunnel-edge-cases.test.ts, "handles 10 rapid connect/disconnect cycles without resource leaks": ERR_INTERNAL_ASSERTION in ClientHttp2Session.destroy, raised as an unhandled error while every test passes.
  • bugfix-2021-codex-isolation.test.ts, "runs the bundled CLI through its launcher": 5 s timeout under the full suite.
  • spec-2041-workspace-remove.test.ts, "in a submodule" and "git stash list failing counts as unsaved, and removal is refused without --force": 5 s timeouts under load near 28. The file passes 53/53 when run alone.

Spec

codev/specs/2045-tower-page-redesign-the-right-.md

Review

codev/reviews/2045-tower-page-redesign-the-right-.md

… facts, and the report's owner field

- GET /api/site/agents (SiteAgentsReport): every known workspace and each running one's
  architects and builders, from the overview's own code (listWorkspaceBuilders, live-agents.ts),
  titles and drafts from OverviewCache.peekForgeFacts, never a forge call; one build shared
  across callers for 1 s (SharedBuilds, extracted from OverviewCache); IDE availability per request.
- OverviewBuilder.pr from the last pr_history entry; discoverBuilders can report an unreadable
  .builders/ as the workspace's error in the site read.
- SiteAgent.spawnedByArchitect (R12) on /api/site and afx site --json.
- Tower's broadcast hook renamed dropSharedBuilds(); drops both shared builds.
…nly builders fail, tab id doc, IDE reason tests

- An unreadable .builders/ is the workspace's error but no longer hides its live architects.
- SiteArchitectRow.tabId documented as the dashboard's rule (first listed is 'architect').
- ideAvailabilityWithReason: reasons, no connect locally, exactly one loopback connect via the tunnel.
…for 10 s (R13 amended)

The architect's ruling on the phase 3 review: R13's 'no network call' means no call off this
machine; one loopback check of the IDE's port is allowed for tunneled requests only, its answer
held about 10 s so a dead port costs its 1 s timeout at most once per period.

- HeldPortCheck and siteIdeAvailability (the route's IDE field); /api/status keeps its unheld check.
- Tests: the held check's rules, and the full tunneled report path over a real socket.
- Spec R13 and plan phase 3 amended; rebuttal recorded.
… in the shipped skill history

The afx skill's afx site paragraph now names the open-decisions fields, so codev update must know
this version as one Codev shipped (generate-skill-hashes).
…als fake the way Tower does

Found by the Windows workflow: the fake keyed each workspace's terminals by its raw path, while the
read asks under workspaceKey(), which on Windows expands the runner's 8.3 temp folder (RUNNER~1)
to its long name. Every running workspace then carried 'no terminals entry' and 10 of 15 tests
failed. Tower's own map writes and reads under workspaceKey(), so the product was right.
…nt list, its Peers place and the Launch form

From Claude's phase 9 review:
- afx workspace remove said a removed workspace 'leaves Recent', the Home tab's list that is gone:
  it is no longer listed. In its dry-run output, both agent-farm.md copies, all four afx skill copies
  (shipped skill history regenerated) and the removal module's comment.
- agent-farm.md (both trees): Peers is on the landing page's Machine tab.
- testing-guide.md's example filled the removed Launch form on port 4100 and named a script that
  does not exist: it now starts a stopped workspace from the Site view, on a throwaway Tower.
- spec-2045-site-view matches the real Tower's stopped group by pattern, as spec-2041-parity does,
  so a workspace an earlier suite left behind does not fail it on a count.
…spaces under Tower's own spelling

The Windows rerun (47044722733) left 4 of 15 failing: the test's temp folder kept the runner's
8.3 short name (RUNNER~1), so the builders rows it wrote carried worktree paths that the read,
which lists builders under the canonical long name, did not match (owners read as null, worktree
paths spelled differently). Tower registers workspaces under normalizeWorkspacePath(), so the test
now creates its folder that way, as the repo's other Windows-run tests do. The product is unchanged.
…er; arch.md places Peers on the Machine tab

Claude's iteration 2 nits: the four-width shots now use the default fixture (air-2044 working,
docs-site's main asking), with the asking builder as its own 700 px shot; the Spec 1967 block in
arch.md names the landing page's Machine tab.
@waleedkadous

Copy link
Copy Markdown
Contributor Author

Re-dispatched on this PR's head (2294615), since commits after the earlier green runs touch CSS, docs, a dry-run string and an e2e fixture:

Results will be posted here when they finish.

… as <img>, through the workspace route (R19a)

The sanitizer keeps attributes that make the browser fetch a URL by itself:
<picture>'s and a medium's <source>, <video poster>, <audio>/<track src>,
<table background>, SVG <image href>, <input type=image src>, and inline styles
with url(). decisionsHtml now drops them on every element but <img> and <a>,
and drops a style that holds a CSS function or escape. Shared with the
dashboard's Decisions tab, which had the same gap. Also a stray blank line at
the end of SiteTreeView.test.tsx.
… R11 checked on the real workbench, one image-route test per element kind
…hat markdown writes (R19a)

The architect's ruling, after two review rounds each found a hole in a list of
things to strip (round 2: <style> elements, HTML's and SVG's, survive the
renderer's sanitizer). DecisionsMarkdown now runs DOMPurify a second time with
ALLOWED_TAGS/ALLOWED_ATTR naming only what markdown writes, so <img src> is the
only attribute left that fetches and the image route rule is the whole rule.
Agreed before cutting: tabindex, s, ol start and h3-h6 kept; table alignment
carried as align; data-line, data-row and id cut. The iteration-1 strip lists
are gone. dompurify declared in workspace-views (the same 3.4.8). One test per
refused kind, an unknown element and attribute dropped, and everything markdown
writes kept; leaks() now reads text too.
…he Decisions tab loads them; the allow list), review and lessons
…Windows checkout passes

Adjacent fix for the pre-review lists merged from main (PR #2058). A Windows
checkout writes the shipped Markdown with CRLF and porch carries it through the
included list into the prompt, while the test's expected text is LF: all 30 of
its exact-text checks failed on the Windows runner (run 47052758797). The test
now reads the list files and the rendered prompt as LF. Test only: porch's
rendering and the files' line endings are unchanged. Checked locally with every
protocol Markdown file converted to CRLF: 85 of 85 pass.
…, a code block's language

Claude's round-3 note: with class allowed on any element, an item could take one
of the page's own classes (the dashboard's fixed, full-screen confirm-dialog
backdrop) and dress up as the page. Markdown writes one class, language-* on
<code>; any other is dropped after the allow-list pass.
@waleedkadous

Copy link
Copy Markdown
Contributor Author

CI on the final head 04b2279, at the pr gate. It carries every code change; commits after 6a54a84 touch only docs and porch's status.yaml. All of these are green:

The branch is up to date with main. One extra Codex PR review on this head, run outside porch, returned APPROVE with no issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tower page: redesign the right panel as a Site view (needs you, then workspace → architect → builder, with open-in icons)

1 participant