First vertical slice: Even client, bridge, contract v1, tests, docs
Client (apps/even-client): pure interaction reducer with generation-based stale-result rejection, HUD renderer, measured pagination, Even Hub SDK 0.0.16 adapter, bridge HTTP client, phone pairing/status/diagnostics page. Bridge (services/bridge): device pairing and revocable expiring credentials, turn engine with idempotent submit, cancel, deadlines and restart recovery, Hermes Runs API adapter, OpenAI-compatible STT adapter, operator CLI. Contract (packages/contracts): versioned schemas, types and error codes. Tests: 122 unit/integration (fakes), 6 simulator scenarios (Even Hub simulator 0.9.5), 9 scenarios against a real Hermes v0.23.1 gateway with a stub model. No real STT, real model or physical device has been exercised; see docs/test-evidence.md and docs/device-test-plan.md. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
import type { AppState } from './reducer.ts';
|
||||
|
||||
/**
|
||||
* HUD geometry. Canvas size and line height are documented by Even
|
||||
* (576 x 288 px; 27 px fixed line height); see docs/feasibility.md, "HUD".
|
||||
* Two text containers: a body that takes the gestures, and a one-line status
|
||||
* bar pinned underneath so the recording indicator never scrolls away.
|
||||
*/
|
||||
export const HUD = {
|
||||
width: 576,
|
||||
height: 288,
|
||||
lineHeight: 27,
|
||||
padding: 4,
|
||||
bodyLines: 9,
|
||||
/** Kept well under the firmware's 999-byte create/rebuild limit. */
|
||||
pageMaxBytes: 900,
|
||||
} as const;
|
||||
|
||||
export const BODY_BOX = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: HUD.width,
|
||||
height: HUD.bodyLines * HUD.lineHeight + 2 * HUD.padding, // 251
|
||||
innerWidth: HUD.width - 2 * HUD.padding, // 568
|
||||
} as const;
|
||||
|
||||
export const STATUS_BOX = {
|
||||
x: 0,
|
||||
y: BODY_BOX.height,
|
||||
width: HUD.width,
|
||||
height: HUD.height - BODY_BOX.height, // 37: one 27 px line plus padding
|
||||
} as const;
|
||||
|
||||
export interface HudFrame {
|
||||
body: string;
|
||||
status: string;
|
||||
}
|
||||
|
||||
function clock(seconds: number): string {
|
||||
const s = Math.max(0, Math.floor(seconds));
|
||||
return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
/** Pure: the complete HUD text for a state at a moment in time. */
|
||||
export function renderHud(state: AppState, nowMs: number): HudFrame {
|
||||
switch (state.phase) {
|
||||
case 'unpaired':
|
||||
return { body: 'Hermeven\n\nNot connected.\nOpen Hermeven on your phone to pair.', status: 'Double-tap: exit' };
|
||||
|
||||
case 'ready':
|
||||
return {
|
||||
body: state.notice ? `Hermeven\n\n${state.notice}.` : 'Hermeven\n\nReady.',
|
||||
status: 'Tap: ask · Double-tap: exit',
|
||||
};
|
||||
|
||||
case 'listening': {
|
||||
const elapsed = state.captureStartedAt === null ? 0 : (nowMs - state.captureStartedAt) / 1000;
|
||||
const cap = state.captureMaxSeconds;
|
||||
return {
|
||||
body: `Listening…\n\nRecording stops by itself after ${cap} seconds.`,
|
||||
status: `● REC ${clock(elapsed)} / ${clock(cap)} · Tap: send · 2×: cancel`,
|
||||
};
|
||||
}
|
||||
|
||||
case 'transcribing':
|
||||
return { body: 'Transcribing…', status: 'Double-tap: cancel' };
|
||||
|
||||
case 'thinking':
|
||||
return { body: 'Thinking…', status: 'Double-tap: cancel' };
|
||||
|
||||
case 'approval':
|
||||
return {
|
||||
body: 'Approval required.\n\nThe agent is waiting for you to approve an action. Approve or deny it where you normally manage the agent. It cannot be approved from the glasses.',
|
||||
status: 'Waiting · Double-tap: cancel',
|
||||
};
|
||||
|
||||
case 'answer': {
|
||||
const total = state.pages.length;
|
||||
const page = state.pages[state.pageIndex] ?? '';
|
||||
const position = total > 1 ? `${state.pageIndex + 1}/${total} · Swipe: page · ` : '';
|
||||
const partial = state.partial ? 'PARTIAL · ' : '';
|
||||
return { body: page, status: `${partial}${position}Tap: ask` };
|
||||
}
|
||||
|
||||
case 'cancelled':
|
||||
return {
|
||||
body: 'Cancelled.\n\nAnything the agent had already done is not undone.',
|
||||
status: 'Tap: ask · Double-tap: back',
|
||||
};
|
||||
|
||||
case 'disconnected':
|
||||
if (state.disconnectedFrom === 'glasses') {
|
||||
return { body: 'Glasses disconnected.', status: 'Reconnect to continue' };
|
||||
}
|
||||
return state.canResend
|
||||
? { body: 'No connection to the bridge.\n\nYour request has not been sent.', status: 'Tap: retry · Double-tap: discard' }
|
||||
: { body: 'Connection lost.\n\nStill waiting for the answer…', status: 'Reconnecting · Double-tap: cancel' };
|
||||
|
||||
case 'error':
|
||||
return {
|
||||
body: `${state.error?.hud ?? 'Something went wrong.'}\n\nDetails are on your phone.`,
|
||||
status: state.error?.retryable ? 'Tap: ask again · Double-tap: back' : 'Double-tap: back',
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user