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
19 changes: 17 additions & 2 deletions apps/browser-consumer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,22 @@ Browser-targeted consumer façade for downstream apps such as `youaskm3`.

Canonical home: **`traverse-framework/reference-apps`** (`apps/browser-consumer/`).

It reuses the approved live browser adapter client from [`apps/react-demo/`](../react-demo/) and exposes a browser-safe subscription flow. Runtime ordering, trace visibility, and terminal outcomes come from Traverse public surfaces — not private app logic.
It owns a copy of the approved live browser adapter client under
[`src/browser-adapter-client.js`](./src/browser-adapter-client.js) and exposes a
browser-safe subscription flow. Runtime ordering, trace visibility, and terminal
outcomes come from Traverse public surfaces — not private app logic and not from
other demo app trees.

## Specs 001 / 002

Session chrome uses Spec 001 presentation states
(`idle|loading|loaded|blocked|ended|error`) via `presentationState` on consumer
state (mapped from subscription lifecycle evidence). Capability/progress UI must
follow Spec 002: show invoke/result evidence from the stream — never invent
business fields locally.

See [`docs/event-ui-conformance-harness.md`](../../docs/event-ui-conformance-harness.md)
for the shared fixture contract used by primary shells.

## Quick Start

Expand All @@ -16,7 +31,7 @@ node -e "const client = require('./apps/browser-consumer'); console.log(client.A

Offline façade load is covered by `bash scripts/ci/youaskm3_starter_kit_smoke.sh`.

Live adapter path (requires `TRAVERSE_REPO`):
Live adapter path (requires `TRAVERSE_REPO`; talks to `browser-adapter serve` directly):

```bash
export TRAVERSE_REPO=/path/to/Traverse
Expand Down
45 changes: 40 additions & 5 deletions apps/browser-consumer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

if (typeof require === "function") {
try {
baseClient = require("../react-demo/src/browser-adapter-client.js");
baseClient = require("./src/browser-adapter-client.js");
} catch {
baseClient = null;
}
}

if (!baseClient && typeof globalThis !== "undefined" && globalThis.TraverseReactDemoClient) {
baseClient = globalThis.TraverseReactDemoClient;
if (!baseClient && typeof globalThis !== "undefined" && globalThis.TraverseBrowserAdapterClient) {
baseClient = globalThis.TraverseBrowserAdapterClient;
}

if (!baseClient) {
Expand All @@ -29,15 +29,44 @@
);
}

/** Spec 001 presentation states for session chrome. */
const PRESENTATION_STATES = Object.freeze([
"idle",
"loading",
"loaded",
"blocked",
"ended",
"error",
]);

const APPROVED_BROWSER_CONSUMER_SESSION = {
...baseClient.APPROVED_BROWSER_DEMO_SESSION,
title: "Traverse Browser Consumer",
summary:
"Traverse's browser-targeted consumer facade for downstream browser-hosted apps like youaskm3.",
};

function presentationStateFromPhase(phase) {
switch (phase) {
case "idle":
return "idle";
case "streaming":
return "loading";
case "completed":
return "loaded";
case "error":
return "error";
default:
return "loading";
}
}

function createBrowserConsumerState() {
return baseClient.createLiveDemoState();
const state = baseClient.createLiveDemoState();
return {
...state,
presentationState: presentationStateFromPhase(state.phase),
};
}

function buildBrowserConsumerSubscriptionRequest() {
Expand All @@ -49,7 +78,11 @@
}

function applyBrowserConsumerMessage(state, message, created) {
return baseClient.applyBrowserSubscriptionMessage(state, message, created);
const next = baseClient.applyBrowserSubscriptionMessage(state, message, created);
return {
...next,
presentationState: presentationStateFromPhase(next.phase),
};
}

function browserConsumerTraceSummary(trace, terminalResult) {
Expand All @@ -58,10 +91,12 @@

return {
APPROVED_BROWSER_CONSUMER_SESSION,
PRESENTATION_STATES,
applyBrowserConsumerMessage,
browserConsumerTraceSummary,
buildBrowserConsumerSubscriptionRequest,
createBrowserConsumerState,
presentationStateFromPhase,
runBrowserConsumerSubscription,
};
});
Loading
Loading