Skip to content

feat(demo): Stage 2 PR-3 — flagship scenario (Inbox ↔ workspace ↔ transcript)#223

Merged
luokerenx4 merged 3 commits into
feat/ui-demo-stage2-pty-replayfrom
feat/ui-demo-stage2-scenario
May 29, 2026
Merged

feat(demo): Stage 2 PR-3 — flagship scenario (Inbox ↔ workspace ↔ transcript)#223
luokerenx4 merged 3 commits into
feat/ui-demo-stage2-pty-replayfrom
feat/ui-demo-stage2-scenario

Conversation

@luokerenx4
Copy link
Copy Markdown
Contributor

Summary

Wires three demo surfaces into one coherent story for the visitor. After this lands, the demo answers "what does OpenAlice do" in under a minute via real-feeling interaction, not abstract feature copy.

Stacks on top of PR #221 and PR #222.

The scenario

  1. Visitor lands on /inbox → sees a fresh entry, 5 minutes old, from a workspace named "demo":

    📄 research-AAPL-q1.md

    I dug into Apple's Q1 earnings — see the report above.

    Key finding: services revenue growth has decelerated three quarters in a row, now at +9.1% YoY (was +14.2% last quarter)…

  2. Clicks the entry → reads the full markdown report inline (TL;DR + deceleration table + analysis + recommendation), backed by an actual file living "in" the demo workspace.

  3. Opens the workspace → terminal replays the session that wrote the report: agent reads SEC filings + market data, computes services-rev YoY across quarters, finds the three-quarter deceleration, writes the report, pushes to Inbox.

The Inbox entry's workspaceId links to the workspace, and the workspace's only session plays a transcript that ends with inbox_push: "AAPL Q1 — Hidden Deceleration Signal". The cross-reference reads itself — no UI gymnastics needed.

What changed

File Change
ui/src/demo/fixtures/inbox.ts (new) demoInboxEntry (the AAPL report entry) + demoWorkspaceFiles map (research-AAPL-q1.md → full markdown content)
ui/src/demo/fixtures/events.ts 6 historical events spanning ~5 min: agent.work.startedtool_call × 3 → inbox.entry_createdagent.work.completed
ui/src/demo/fixtures/transcripts/welcome.ts Rewritten as aaplResearchTranscript — the session that wrote the report. Same hand-crafted-frame style as PR-2's placeholder, but tells the AAPL story end-to-end (read filings → compute deceleration table → write file → inbox_push → done)
ui/src/demo/handlers/inbox.ts /api/inbox/history returns [demoInboxEntry]
ui/src/demo/handlers/workspaces.ts /api/workspaces/:id/file?path=… looks up demoWorkspaceFiles and returns {content} for matching paths
ui/src/demo/handlers/events.ts /api/events/stream SSE bursts all demoEvents on connect, then stays idle. /api/events + /api/events/recent return the same set as history

Bonus: tree-shaking fix (necessary for this PR)

Terminal.tsx now lazy-imports DemoTerminalReplay via React.lazy. With the prior static import (since PR-2), Rollup conservatively kept the transcript file in the prod main bundle because its top-level frame-building IIFE has module-scope side effects. Even though the call site is dead-code in prod, the transcript strings ("hey, what jumped out from Apple's Q1 earnings?", "research-AAPL-q1.md", etc.) leaked into dist/assets/index-*.js.

After the fix: the demo terminal is code-split into a separate DemoTerminalReplay-*.js chunk (5.7KB / 2.5KB gz). Prod never fetches it (gated at the call site). Demo build inlines it via the existing dynamic-import boundary.

Verification

Check Result
pnpm -F open-alice-ui exec tsc -b clean
pnpm -F open-alice-ui build (prod) main chunk has zero transcript / fixture / handler strings; only the "DemoTerminalReplay" module specifier remains. Separate DemoTerminalReplay-*.js chunk (5.7KB / 2.5KB gz) exists but is never fetched in prod.
pnpm -F open-alice-ui build:demo 279KB demo chunk + 2.82MB main
pnpm dev:demo + Playwright /inbox shows demo entry, markdown report renders inline, navigating to workspace plays the AAPL research transcript end-to-end with ANSI colors / bold / dim correct

Test plan

  • tsc -b clean
  • Prod build: no transcript strings in main chunk
  • Demo build still works
  • Inbox shows entry → markdown rendered
  • Workspace session plays the new transcript
  • Manual: hard-refresh deep links work on Vercel preview (deferred to user once they deploy)

What's left for Stage 2 PR-4

Secondary fixture richness — multi-UTA accounts with varied positions, realistic equity curves with random-walk-ish data, populated topology graph, news articles, cron jobs.

Boundary touch

None — no trading / auth / broker / migrations code modified.

🤖 Generated with Claude Code

Ame and others added 2 commits May 27, 2026 13:06
…nscript)

Wires three demo surfaces into a coherent story for the visitor:

1. Inbox: shows a single agent-written report from a workspace named
   "demo" timestamped 5 minutes ago — "AAPL Q1 — Hidden Deceleration
   Signal" with a fully-rendered markdown document (TL;DR + analysis
   table + recommendations) inline.
2. Workspace file handler: returns the markdown content for
   `research-AAPL-q1.md` from `demoWorkspaceFiles` map. Inbox's
   readWorkspaceFile() call pulls it live (no snapshot), matching real
   product behavior.
3. PTY replay (welcome.ts rewritten as `aaplResearchTranscript`):
   shows the session that produced the report — user asks "what jumped
   out from Apple's Q1 earnings?", agent reads filings, computes
   services-rev YoY across quarters, finds the three-quarter
   deceleration, writes the report, inbox_pushes.

Cross-link is implicit and clean: the Inbox entry has
`workspaceId: DEMO_WORKSPACE_ID`. Clicking opens the workspace, the
session terminal plays the transcript that produced the entry. No
explicit "this entry came from that session" pointer needed — the
narrative reads itself.

Also scripts the SSE event timeline (handlers/events.ts +
fixtures/events.ts): 6 historical events spanning ~5 minutes covering
agent.work.started → tool_calls → write_file → inbox.entry_created →
agent.work.completed. Emitted as one burst on stream connect to
populate the events feed.

Tree-shaking fix (the necessary side-effect of this PR): Terminal.tsx
now lazy-imports DemoTerminalReplay via React.lazy. With the prior
static import, Rollup conservatively kept the transcript file in the
prod main bundle because its top-level frame-building IIFE has module-
scope side effects. Lazy import code-splits the demo terminal into its
own 5.7KB chunk that is never fetched in prod (gated by
import.meta.env.VITE_DEMO_MODE at the call site).

Verified:
- pnpm -F open-alice-ui exec tsc -b clean
- pnpm -F open-alice-ui build (prod): main chunk has zero
  transcript / fixture / handler strings; only "DemoTerminalReplay"
  literal (the lazy-import module specifier) remains. Separate
  DemoTerminalReplay-*.js chunk (5.7KB / 2.5KB gz) exists but is never
  fetched in prod.
- pnpm -F open-alice-ui build:demo: 279KB demo chunk + 2.82MB main,
  builds clean.
- pnpm dev:demo + Playwright: Inbox shows demo entry, markdown report
  renders inline, navigating to workspace plays the AAPL research
  transcript end-to-end.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fills out the long tail of fixture content so the demo doesn't look
gutted once a visitor scrolls past the Inbox/workspace flagship flow
from PR-3.

**3 trading accounts (instead of 1)** —
- Alpaca Paper: \$52,840 NL, 4 stock positions (AAPL/NVDA/GOOG/AMD)
  with realistic avg-cost vs market-price spreads
- IBKR Demo: \$247,310 NL, mix of ETFs (SPY, QQQ, TLT) + an
  underwater AAPL options position to show non-trivial P&L
- Binance Spot: \$15,032 NL (USDT base), BTC and ETH spot positions

Equity curve generator uses a seeded random walk per UTA (30 daily
points, distinct vol + drift per account) so the Portfolio chart
shows plausible-looking lines without the numbers shifting on each
page reload — visitors who refresh see consistent state.

**6 news articles** — Reuters/Bloomberg/CNBC/WSJ/CoinDesk spread
across the last 22 hours covering AAPL Q1, NVDA capex, Fed minutes,
BTC, SPY, TLT. The AAPL article (timestamped 30m ago) ties to the
Inbox AAPL research from PR-3 (timestamped 5m ago) — "news landed →
agent dug in → wrote up the deceleration signal".

**4 cron jobs** — Morning market prep (weekdays 8:30 AM), EOD
snapshot + journal (weekdays 4:05 PM), Weekly position review
(Fridays 5 PM, disabled), AAPL watch alert (every 15m). Mix of cron-
schedule vs every-N-minutes formats; mix of enabled vs disabled.

Skipped from this PR: topology graph fake (Dev page, low marketing
value), populated agent-status log (the events SSE in PR-3 already
carries the "system is alive" signal).

Verified:
- pnpm -F open-alice-ui exec tsc -b clean
- pnpm -F open-alice-ui build (prod): zero fixture name leaks in main
  bundle (`Alpaca Paper`, `Binance Spot`, `Morning market prep`,
  `demoCronJobs`, `demoNewsArticles` — all absent)
- pnpm dev:demo + Playwright: portfolio page renders chart with the
  random-walk curve + cumulative equity numbers, news page lists all
  6 articles with badges, sidebar shows 3 trading accounts

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
feat(demo): Stage 2 PR-4 — secondary fixture richness
@luokerenx4 luokerenx4 merged commit cc5b80f into feat/ui-demo-stage2-pty-replay May 29, 2026
@luokerenx4 luokerenx4 deleted the feat/ui-demo-stage2-scenario branch May 31, 2026 06:04
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.

1 participant