A desktop coding agent with free access to frontier models.
TypeScript
feat: good status in the checklist
ogsamrat9f4a80d4bc95
diff --git a/apps/app/src/app/lib/good-session-integrity.ts b/apps/app/src/app/lib/good-session-integrity.tsnew file mode 100644index 00000000..4c252cd2--- /dev/null+++ b/apps/app/src/app/lib/good-session-integrity.ts@@ -0,0 +1,82 @@+// "Good session ★" from the server (GET /omnirush/integrity/:sessionId, the+// integrity record's `good_session`). The copy is settled and the same, word+// for word, as the CLI's (integrity-api-contract.md, "Good-session copy").+// Never "Good session" before the server confirms it; never a raw code.++import type { OmniRushGoodSession } from "./omnirush-server";++export const GOOD_SESSION_CONFIRMED = "Good session ★";+export const GOOD_SESSION_CHECKING = "Checking session…";+export const REWARDS_GUIDE_LABEL = "How rewards work";+export const REWARDS_GUIDE_URL = "https://omnirush.ai/console/guide/rewards";++const FIX_UPLOADS = "Keep the app open until uploads finish.";+const FIX_QUALITY = "Give the agent a real task and see it through.";+const QUALITY_FALLBACK = "it didn't pass the quality check";++const UPLOAD_REASONS: Readonly<Record<string, string>> = Object.freeze({+ trace_failed: "the session record failed to save",+ archive_no_base: "the project copy is incomplete",+ archive_gap: "the project copy is incomplete",+ archive_failed: "the project copy is incomplete",+ sequence_gaps: "parts of the session are missing",+ segment_start_missing: "parts of the session are missing",+ no_trace: "parts of the session are missing",+});++export type GoodSessionCopy =+ | { state: "good"; text: string }+ | { state: "pending"; text: string }+ | { state: "not-good"; text: string; reason: string; fix: string; link: { label: string; url: string } };++/** The reason text and its one fix; anything outside the upload table is a quality reason. */+function reasonCopy(code: string | undefined, messages: Readonly<Record<string, string>> | undefined): { reason: string; fix: string } {+ const upload = code ? UPLOAD_REASONS[code] : undefined;+ if (upload) return { reason: upload, fix: FIX_UPLOADS };+ // The server's sentence, without its own full stop (the line adds one).+ const human = code ? messages?.[code]?.trim().replace(/[.\s]+$/, "") : undefined;+ return { reason: human || QUALITY_FALLBACK, fix: FIX_QUALITY };+}++/**+ * The line for one chat: "Good session ★" (true), "Checking session…"+ * (pending, unknown, 404, 429, offline) or "Not a good session: <main+ * reason>. <one fix>" with the rewards guide (false). The main reason is the+ * first of `good_session_reasons`, else the first of `reasons`.+ */+export function goodSessionCopy(result: OmniRushGoodSession | null | undefined): GoodSessionCopy {+ if (result?.good_session === true) return { state: "good", text: GOOD_SESSION_CONFIRMED };+ if (result?.good_session !== false) return { state: "pending", text: GOOD_SESSION_CHECKING };+ const code = result.good_session_reasons[0] ?? result.reasons[0];+ const { reason, fix } = reasonCopy(code, result.messages);+ return {+ state: "not-good",+ text: `Not a good session: ${reason}. ${fix}`,+ reason,+ fix,+ link: { label: REWARDS_GUIDE_LABEL, url: REWARDS_GUIDE_URL },+ };+}++/** After a turn ends, the first check waits this long (late uploads land first). */+export const GOOD_SESSION_TURN_END_DELAY_MS = 5_000;+/** While "pending": 30 s, 1 m, 2 m, 5 m, then every 10 m. */+export const GOOD_SESSION_BACKOFF_MS: readonly number[] = Object.freeze([30_000, 60_000, 120_000, 300_000, 600_000]);+/** Pending is retried for up to a day after the last turn. */+export const GOOD_SESSION_RETRY_WINDOW_MS = 24 * 60 * 60_000;++/**+ * When to check again after `pendingChecks` answers in a row were pending:+ * the backoff step, or null once that would pass 24 h after the last turn+ * ended (or the answer is final).+ */+export function nextGoodSessionCheckMs({ result, pendingChecks, lastTurnEndedAt, now }: {+ result: OmniRushGoodSession | null | undefined;+ pendingChecks: number;+ lastTurnEndedAt: number;+ now: number;+}): number | null {+ if (result?.good_session === true || result?.good_session === false) return null;+ const step = GOOD_SESSION_BACKOFF_MS[Math.min(Math.max(pendingChecks, 1), GOOD_SESSION_BACKOFF_MS.length) - 1] ?? 600_000;+ return now + step > lastTurnEndedAt + GOOD_SESSION_RETRY_WINDOW_MS ? null : step;+}diff --git a/apps/app/src/app/lib/omnirush-server.ts b/apps/app/src/app/lib/omnirush-server.tsindex 1d72959a..2fe7df8e 100644--- a/apps/app/src/app/lib/omnirush-server.ts+++ b/apps/app/src/app/lib/omnirush-server.ts@@ -449,6 +449,17 @@ export type OmniRushVoiceStatus = {branch: string | null;};+/** GET /omnirush/integrity/:sessionId: the server's "Good session ★" for one chat ("pending" until it confirms). */+export type OmniRushGoodSession = {+ good_session: true | false | "pending";+ reasons: string[];+ good_session_reasons: string[];+ integrity: string | null;+ checked_at: string | null;+ /** The server's human message per quality reason code, when it sends them. */+ messages?: Record<string, string>;+};+export type OmniRushSubagentModelState = {setting: OmniRushSubagentModelSetting;/** Whether an omnirush.ai account is signed in (its models can run). */@@ -1933,6 +1944,8 @@ export function createOmniRushServerClient(options: { baseUrl: string; token?: s`/omnirush/voice/status${workspaceId ? `?workspace=${encodeURIComponent(workspaceId)}` : ""}`,{ token, hostToken, timeoutMs: timeouts.config },),+ getGoodSession: (sessionId: string) =>+ requestJson<OmniRushGoodSession>(baseUrl, `/omnirush/integrity/${encodeURIComponent(sessionId)}`, { token, hostToken, timeoutMs: timeouts.sessionRead }),/** Where the renderer POSTs one voice segment (multipart), and its headers; the local server adds the device bearer. */voiceTranscriptionEndpoint: () => ({url: `${baseUrl}/omnirush/voice/transcribe`,diff --git a/apps/app/src/react-app/domains/quality/good-session.tsx b/apps/app/src/react-app/domains/quality/good-session.tsxindex db5fde8f..c92aa31f 100644--- a/apps/app/src/react-app/domains/quality/good-session.tsx+++ b/apps/app/src/react-app/domains/quality/good-session.tsx@@ -57,6 +57,12 @@ import {type GoodSessionCheck,type GoodSessionTone,} from "../../../app/lib/good-session";+import {+ GOOD_SESSION_TURN_END_DELAY_MS,+ goodSessionCopy,+ nextGoodSessionCheckMs,+} from "../../../app/lib/good-session-integrity";+import type { OmniRushGoodSession, OmniRushServerClient } from "../../../app/lib/omnirush-server";import { readPref, useAccountQuality, writePref } from "../../../app/lib/quality";import { isDesktopRuntime, isWindowsPlatform } from "../../../app/utils";import { hasLiveSessionActivity, useSessionActivityStore } from "../session/status/session-activity-store";@@ -127,6 +133,8 @@ export type GoodSessionChecklistBarProps = {onFinishIt?: (prompt: string) => void;/** Send a prompt on its own (the server's auto-retry). */onAutoRetry?: (prompt: string) => void;+ /** The local server, for the server-confirmed "Good session ★" line (none without it). */+ client?: Pick<OmniRushServerClient, "getGoodSession">;};/** How long a turn's end settles before an auto-retry is judged (late Stop or error events land first). */@@ -205,6 +213,87 @@ function useServerSessionStatus(sessionId: string, active: boolean, turnRunning:return read.sessionId === sessionId ? read.status : null;}+/** Final answers (true or false) per session, until that session's next turn ends. */+const finalGoodSessions = new Map<string, OmniRushGoodSession>();++/**+ * The server's "Good session ★" for the open session (GET+ * /omnirush/integrity/:sessionId): once when it opens, once about 5 s after+ * each turn ends, and while "pending" again at 30 s, 1 m, 2 m, 5 m, then+ * every 10 m, up to 24 h after the last turn. True and false are final+ * until the next turn ends. Null while unknown (shown as pending).+ */+function useGoodSession(+ client: Pick<OmniRushServerClient, "getGoodSession"> | undefined,+ sessionId: string,+ active: boolean,+ turnRunning: boolean,+ endedAt: number | null,+): OmniRushGoodSession | null {+ const [read, setRead] = useState<{ sessionId: string; result: OmniRushGoodSession | null }>(() => ({+ sessionId,+ result: finalGoodSessions.get(sessionId) ?? null,+ }));+ const edge = useRef({ sessionId, running: turnRunning });+ const lastEnd = useRef(endedAt);+ lastEnd.current = endedAt;+ useEffect(() => {+ const previous = edge.current;+ edge.current = { sessionId, running: turnRunning };+ if (!client || !active || turnRunning) return;+ const turnEnded = previous.sessionId === sessionId && previous.running;+ if (turnEnded) finalGoodSessions.delete(sessionId);+ const known = finalGoodSessions.get(sessionId) ?? null;+ setRead({ sessionId, result: known });+ if (known) return;+ const lastTurnEndedAt = turnEnded ? Date.now() : lastEnd.current ?? Date.now();+ let cancelled = false;+ let timer: number | undefined;+ let pendingChecks = 0;+ const check = async () => {+ const result = await client.getGoodSession(sessionId).catch(() => null);+ if (cancelled) return;+ if (result && result.good_session !== "pending") finalGoodSessions.set(sessionId, result);+ setRead({ sessionId, result });+ pendingChecks += 1;+ const wait = nextGoodSessionCheckMs({ result, pendingChecks, lastTurnEndedAt, now: Date.now() });+ if (wait !== null) timer = window.setTimeout(() => void check(), wait);+ };+ timer = window.setTimeout(() => void check(), turnEnded ? GOOD_SESSION_TURN_END_DELAY_MS : 0);+ return () => {+ cancelled = true;+ window.clearTimeout(timer);+ };+ }, [active, client, sessionId, turnRunning]);+ return read.sessionId === sessionId ? read.result : null;+}++/** "Good session ★", "Checking session…" (muted) or why not, with the rewards guide. */+export function GoodSessionLine({ result }: { result: OmniRushGoodSession | null }) {+ const copy = goodSessionCopy(result);+ return (+ <p role="status" data-testid="good-session-confirmed" data-state={copy.state} className="mx-auto max-w-[800px] pb-1 text-[11px] leading-4">+ {copy.state === "good" ? (+ <span className="font-medium text-foreground">{copy.text}</span>+ ) : copy.state === "pending" ? (+ <span className="text-muted-foreground">{copy.text}</span>+ ) : (+ <span className="text-amber-11">+ {copy.text}{" "}+ <button+ type="button"+ data-testid="good-session-rewards-link"+ className="font-medium underline underline-offset-2"+ onClick={() => void openDesktopUrl(copy.link.url).catch(() => undefined)}+ >+ {copy.link.label}+ </button>+ </span>+ )}+ </p>+ );+}+const TONE_TEXT: Record<GoodSessionTone, string> = { amber: "text-amber-11", red: "text-red-11" };const TONE_BOX: Record<GoodSessionTone, string> = {amber: "border-amber-7/40 bg-amber-2/30 text-amber-11",@@ -263,6 +352,7 @@ export function GoodSessionChecklistBar(props: GoodSessionChecklistBarProps) {}), [facts, nativeWindows, props.isRemoteWorkspace, props.turnRunning, props.workspaceRoot, windowsCounts]);const hasPrompt = props.messages.some((message) => message.role === "user");const server = useServerSessionStatus(props.sessionId, hasPrompt, props.turnRunning);+ const goodSession = useGoodSession(props.client, props.sessionId, hasPrompt, props.turnRunning, facts.endedAt);// /me/quality's client grade only while the server says nothing about this session.const serverGood = useServerGood(props.sessionId, local.onTrack && !serverStatusUsable(server));const checklist = useMemo(@@ -388,6 +478,7 @@ export function GoodSessionChecklistBar(props: GoodSessionChecklistBarProps) {{checklist.reasons.map((reason) => <p key={reason} className="text-amber-11">{reason}</p>)}</div>) : null}+ {props.client ? <GoodSessionLine result={goodSession} /> : null}<div className="mx-auto flex max-w-[800px] items-center gap-2 pb-1.5"><divclassName="flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-0.5 rounded-full border border-border bg-popover/60 px-2.5 py-1 text-[11px] leading-4 text-muted-foreground"diff --git a/apps/app/src/react-app/domains/session/surface/session-surface.tsx b/apps/app/src/react-app/domains/session/surface/session-surface.tsxindex d826a8ce..d08f563b 100644--- a/apps/app/src/react-app/domains/session/surface/session-surface.tsx+++ b/apps/app/src/react-app/domains/session/surface/session-surface.tsx@@ -3339,6 +3339,7 @@ export function SessionSurface(props: SessionSurfaceProps) {turnRunning={chatStreaming || (effectiveActivityStatus !== "idle" && effectiveActivityStatus !== "error")}onFinishIt={handleMessageListSetPrompt}onAutoRetry={handleAutoRetry}+ client={props.client}/><ReactSessionComposerrunModeControl={<WorkspaceRunModeMenu client={props.client} workspaceId={props.workspaceId} busy={chatStreaming || preparingCloudTools || Boolean(props.activePermission || props.activeQuestion)} />}diff --git a/apps/app/tests/good-session-integrity.test.tsx b/apps/app/tests/good-session-integrity.test.tsxnew file mode 100644index 00000000..85fd2d43--- /dev/null+++ b/apps/app/tests/good-session-integrity.test.tsx@@ -0,0 +1,110 @@+import { describe, expect, test } from "bun:test";+import { renderToStaticMarkup } from "react-dom/server";++import {+ GOOD_SESSION_BACKOFF_MS,+ GOOD_SESSION_RETRY_WINDOW_MS,+ goodSessionCopy,+ nextGoodSessionCheckMs,+} from "../src/app/lib/good-session-integrity";+import type { OmniRushGoodSession } from "../src/app/lib/omnirush-server";+import { GoodSessionLine } from "../src/react-app/domains/quality/good-session";++function result(input: Partial<OmniRushGoodSession> & Pick<OmniRushGoodSession, "good_session">): OmniRushGoodSession {+ return { reasons: [], good_session_reasons: [], integrity: null, checked_at: null, ...input };+}++const notGood = (reasons: string[], extra: Partial<OmniRushGoodSession> = {}) =>+ goodSessionCopy(result({ good_session: false, good_session_reasons: reasons, ...extra })).text;++const UPLOADS = "Keep the app open until uploads finish.";+const QUALITY = "Give the agent a real task and see it through.";++describe("goodSessionCopy", () => {+ test("true is the only Good session ★", () => {+ expect(goodSessionCopy(result({ good_session: true, integrity: "ok" }))).toEqual({ state: "good", text: "Good session ★" });+ });++ test("pending, unknown, 404, 429 and offline read Checking session…", () => {+ for (const value of [result({ good_session: "pending", reasons: ["archive_uploading"] }), null, undefined]) {+ expect(goodSessionCopy(value)).toEqual({ state: "pending", text: "Checking session…" });+ }+ });++ test("every row of the reason table", () => {+ expect(notGood(["trace_failed"])).toBe(`Not a good session: the session record failed to save. ${UPLOADS}`);+ for (const code of ["archive_no_base", "archive_gap", "archive_failed"]) {+ expect(notGood([code])).toBe(`Not a good session: the project copy is incomplete. ${UPLOADS}`);+ }+ for (const code of ["sequence_gaps", "segment_start_missing", "no_trace"]) {+ expect(notGood([code])).toBe(`Not a good session: parts of the session are missing. ${UPLOADS}`);+ }+ expect(notGood(["not_usable"])).toBe(`Not a good session: it didn't pass the quality check. ${QUALITY}`);+ expect(notGood(["too_short"])).toBe(`Not a good session: it didn't pass the quality check. ${QUALITY}`);+ expect(notGood([])).toBe(`Not a good session: it didn't pass the quality check. ${QUALITY}`);+ });++ test("false links the rewards guide", () => {+ const copy = goodSessionCopy(result({ good_session: false, good_session_reasons: ["trace_failed"] }));+ expect(copy).toMatchObject({ state: "not-good", link: { label: "How rewards work", url: "https://omnirush.ai/console/guide/rewards" } });+ });++ test("the main reason: good_session_reasons first, then reasons", () => {+ expect(notGood(["archive_gap", "trace_failed"], { reasons: ["trace_failed"] })).toContain("the project copy is incomplete.");+ expect(goodSessionCopy(result({ good_session: false, reasons: ["trace_failed", "archive_gap"] })).text)+ .toBe(`Not a good session: the session record failed to save. ${UPLOADS}`);+ });++ test("a quality reason uses the server's human message when there is one", () => {+ const messages = { too_short: "the session was too short.", trace_failed: "ignored" };+ expect(notGood(["too_short"], { messages })).toBe(`Not a good session: the session was too short. ${QUALITY}`);+ expect(notGood(["padding"], { messages })).toBe(`Not a good session: it didn't pass the quality check. ${QUALITY}`);+ // Upload reasons keep the table's words.+ expect(notGood(["trace_failed"], { messages })).toBe(`Not a good session: the session record failed to save. ${UPLOADS}`);+ });++ test("never shows a raw code", () => {+ const codes = ["trace_failed", "archive_no_base", "sequence_gaps", "no_trace", "not_usable", "too_short", "quality_unavailable", "trace_not_in_s3"];+ for (const code of codes) {+ for (const value of [true, false, "pending"] as const) {+ const text = goodSessionCopy(result({ good_session: value, reasons: [code], good_session_reasons: [code] })).text;+ expect(text).not.toContain(code);+ }+ }+ });++ test("the line renders each state", () => {+ expect(renderToStaticMarkup(<GoodSessionLine result={result({ good_session: true })} />)).toContain("Good session ★");+ const pending = renderToStaticMarkup(<GoodSessionLine result={null} />);+ expect(pending).toContain("Checking session…");+ expect(pending).toContain("text-muted-foreground");+ expect(pending).not.toContain("<svg");+ const bad = renderToStaticMarkup(<GoodSessionLine result={result({ good_session: false, good_session_reasons: ["no_trace"] })} />);+ expect(bad).toContain("Not a good session: parts of the session are missing.");+ expect(bad).toContain("How rewards work");+ });+});++describe("nextGoodSessionCheckMs", () => {+ const ended = 1_000_000;++ test("pending backs off 30 s, 1 m, 2 m, 5 m, then 10 m", () => {+ const waits = [1, 2, 3, 4, 5, 6, 9].map((pendingChecks) => nextGoodSessionCheckMs({ result: null, pendingChecks, lastTurnEndedAt: ended, now: ended }));+ expect(waits).toEqual([30_000, 60_000, 120_000, 300_000, 600_000, 600_000, 600_000]);+ expect(GOOD_SESSION_BACKOFF_MS).toEqual([30_000, 60_000, 120_000, 300_000, 600_000]);+ expect(nextGoodSessionCheckMs({ result: result({ good_session: "pending" }), pendingChecks: 1, lastTurnEndedAt: ended, now: ended })).toBe(30_000);+ });++ test("true and false are final", () => {+ for (const value of [true, false] as const) {+ expect(nextGoodSessionCheckMs({ result: result({ good_session: value }), pendingChecks: 1, lastTurnEndedAt: ended, now: ended })).toBeNull();+ }+ });++ test("stops 24 h after the last turn", () => {+ const late = ended + GOOD_SESSION_RETRY_WINDOW_MS - 600_000;+ expect(nextGoodSessionCheckMs({ result: null, pendingChecks: 9, lastTurnEndedAt: ended, now: late })).toBe(600_000);+ expect(nextGoodSessionCheckMs({ result: null, pendingChecks: 9, lastTurnEndedAt: ended, now: late + 1 })).toBeNull();+ expect(nextGoodSessionCheckMs({ result: null, pendingChecks: 1, lastTurnEndedAt: ended, now: ended + 3 * GOOD_SESSION_RETRY_WINDOW_MS })).toBeNull();+ });+});diff --git a/apps/server/src/omnirush-good-session.test.ts b/apps/server/src/omnirush-good-session.test.tsnew file mode 100644index 00000000..68e0c1d5--- /dev/null+++ b/apps/server/src/omnirush-good-session.test.ts@@ -0,0 +1,55 @@+import { describe, expect, test } from "bun:test";++import { PENDING_GOOD_SESSION, readGoodSession } from "./omnirush-good-session.js";++const ID = "ses_good_session_1";++function answer(response: Response | Error) {+ const calls: Array<{ sessionId: string; summary: boolean }> = [];+ const read = async (sessionId: string, options: { summary: boolean }) => {+ calls.push({ sessionId, summary: options.summary });+ if (response instanceof Error) throw response;+ return response;+ };+ return { read, calls };+}++describe("GET /omnirush/integrity/:sessionId", () => {+ test("passes a 200 through as the compact status, in summary mode", async () => {+ const { read, calls } = answer(Response.json({+ session_id: ID,+ integrity: "ok",+ reasons: [],+ segments: [],+ quality: { verdict: "not_usable", reasons: ["too_short"], messages: { too_short: "The session was too short." } },+ good_session: false,+ good_session_reasons: ["too_short"],+ checked_at: "2026-10-10T10:00:00+00:00",+ }));+ expect(await readGoodSession(read, ID)).toEqual({+ good_session: false,+ reasons: [],+ good_session_reasons: ["too_short"],+ integrity: "ok",+ checked_at: "2026-10-10T10:00:00+00:00",+ messages: { too_short: "The session was too short." },+ });+ expect(calls).toEqual([{ sessionId: ID, summary: true }]);+ const good = await readGoodSession(answer(Response.json({ integrity: "ok", reasons: [], good_session: true, good_session_reasons: [], checked_at: "t" })).read, ID);+ expect(good).toEqual({ good_session: true, reasons: [], good_session_reasons: [], integrity: "ok", checked_at: "t" });+ });++ test("404, 429, errors, odd bodies, no account and bad ids read pending", async () => {+ expect(await readGoodSession(answer(Response.json({ detail: "session_not_found" }, { status: 404 })).read, ID)).toEqual(PENDING_GOOD_SESSION);+ expect(await readGoodSession(answer(Response.json({ detail: "rate_limited" }, { status: 429, headers: { "Retry-After": "30" } })).read, ID)).toEqual(PENDING_GOOD_SESSION);+ expect(await readGoodSession(answer(new Response("oops", { status: 500 })).read, ID)).toEqual(PENDING_GOOD_SESSION);+ expect(await readGoodSession(answer(new TypeError("fetch failed")).read, ID)).toEqual(PENDING_GOOD_SESSION);+ expect(await readGoodSession(answer(new Response("not json", { status: 200 })).read, ID)).toEqual(PENDING_GOOD_SESSION);+ expect(await readGoodSession(answer(Response.json({ good_session: "yes" })).read, ID)).toEqual(PENDING_GOOD_SESSION);+ expect(await readGoodSession(null, ID)).toEqual(PENDING_GOOD_SESSION);+ const bad = answer(Response.json({ good_session: true }));+ expect(await readGoodSession(bad.read, "short")).toEqual(PENDING_GOOD_SESSION);+ expect(await readGoodSession(bad.read, "ses/../x1234")).toEqual(PENDING_GOOD_SESSION);+ expect(bad.calls).toEqual([]);+ });+});diff --git a/apps/server/src/omnirush-good-session.ts b/apps/server/src/omnirush-good-session.tsnew file mode 100644index 00000000..2e4678f7--- /dev/null+++ b/apps/server/src/omnirush-good-session.ts@@ -0,0 +1,86 @@+/**+ * "Good session ★" for one chat, from the server's integrity record (GET+ * `<gateway root>/me/sessions/{id}/integrity?summary=1`, through the+ * broker's limiter). The app's checklist bar reads it from+ * GET /omnirush/integrity/:sessionId. Anything but a usable 200 (404, 429,+ * offline, signed out, an odd body) is "pending", never an error.+ */++export const GOOD_SESSION_ID_PATTERN = /^[A-Za-z0-9._:-]{8,128}$/;++export type GoodSessionStatus = {+ good_session: true | false | "pending";+ reasons: string[];+ good_session_reasons: string[];+ integrity: string | null;+ checked_at: string | null;+ /** The server's human message per quality reason code, when it sends them. */+ messages?: Record<string, string>;+};++export const PENDING_GOOD_SESSION: GoodSessionStatus = Object.freeze({+ good_session: "pending",+ reasons: [],+ good_session_reasons: [],+ integrity: null,+ checked_at: null,+});++function isRecord(value: unknown): value is Record<string, unknown> {+ return typeof value === "object" && value !== null && !Array.isArray(value);+}++function codes(value: unknown): string[] {+ return Array.isArray(value) ? value.filter((code): code is string => typeof code === "string" && code.length > 0).slice(0, 32) : [];+}++function text(value: unknown): string | null {+ return typeof value === "string" && value.trim() ? value.trim() : null;+}++function messages(...sources: unknown[]): Record<string, string> | undefined {+ const out: Record<string, string> = {};+ for (const source of sources) {+ if (!isRecord(source)) continue;+ for (const [code, message] of Object.entries(source)) {+ const value = text(message);+ if (value && !(code in out)) out[code] = value.slice(0, 300);+ }+ }+ return Object.keys(out).length ? out : undefined;+}++/** The compact status from one integrity answer; "pending" for anything but a well-formed 200. */+export async function goodSessionFromResponse(response: Response): Promise<GoodSessionStatus> {+ if (response.status !== 200) {+ await response.body?.cancel().catch(() => undefined);+ return PENDING_GOOD_SESSION;+ }+ const body: unknown = await response.json().catch(() => null);+ if (!isRecord(body)) return PENDING_GOOD_SESSION;+ const good = body.good_session;+ if (good !== true && good !== false && good !== "pending") return PENDING_GOOD_SESSION;+ const quality = isRecord(body.quality) ? body.quality : null;+ const human = messages(body.messages, quality?.messages);+ return {+ good_session: good,+ reasons: codes(body.reasons),+ good_session_reasons: codes(body.good_session_reasons),+ integrity: text(body.integrity),+ checked_at: text(body.checked_at),+ ...(human ? { messages: human } : {}),+ };+}++/** Reads one chat's status; any failure (no account, offline, limited) is "pending". */+export async function readGoodSession(+ sessionIntegrity: ((sessionId: string, options: { summary: boolean }) => Promise<Response>) | null,+ sessionId: string,+): Promise<GoodSessionStatus> {+ if (!sessionIntegrity || !GOOD_SESSION_ID_PATTERN.test(sessionId)) return PENDING_GOOD_SESSION;+ try {+ return await goodSessionFromResponse(await sessionIntegrity(sessionId, { summary: true }));+ } catch {+ return PENDING_GOOD_SESSION;+ }+}diff --git a/apps/server/src/server.ts b/apps/server/src/server.tsindex 8df606e1..ea12f72f 100644--- a/apps/server/src/server.ts+++ b/apps/server/src/server.ts@@ -197,6 +197,7 @@ import { buildOpencodeProxyUrl, engineTarget, type EngineTarget } from "./sessioimport { OmniRushGatewayBroker } from "./omnirush-gateway-broker.js";import { awaitOmniRushModelCatalogSettled, startOmniRushModelCatalogSync } from "./omnirush-model-catalog-sync.js";import { OmniRushVoiceService, voiceProjectContext } from "./omnirush-voice.js";+import { GOOD_SESSION_ID_PATTERN, readGoodSession } from "./omnirush-good-session.js";import { PROJECT_ARCHIVE_BASE_IDLE_MS, PROJECT_ARCHIVE_BASE_MAX_DEFER_MS, projectArchiveSettings } from "./project-archive.js";import type { ArchiveApiRequestInit } from "./session-archive/upload.js";import { runtimeStorageDir } from "./runtime-db.js";@@ -222,6 +223,8 @@ const commandAdmissionsByServer = new WeakMap<ServerConfig, Map<string, { fingerconst captureServicesByServer = new WeakMap<ServerConfig, CaptureService>();/** Voice dictation's broker hop (omnirush-voice.ts), per server. */const voiceServicesByServer = new WeakMap<ServerConfig, OmniRushVoiceService>();+/** The broker's integrity read (rate-limited there), per server, for the checklist bar's "Good session ★". */+const sessionIntegrityByServer = new WeakMap<ServerConfig, OmniRushGatewayBroker["sessionIntegrity"]>();/** Recent gateway fallbacks per sub-agent session, for the swarm plugin's task-result note. */const subagentGatewayFallbacks = new WeakMap<ServerConfig, Map<string, Array<Record<string, unknown>>>>();@@ -1059,6 +1062,7 @@ export async function startServer(config: ServerConfig): Promise<ServeResult> {});},});+ if (gatewayBroker.enabled) sessionIntegrityByServer.set(config, (sessionId, options) => gatewayBroker.sessionIntegrity(sessionId, options));voiceServicesByServer.set(config, new OmniRushVoiceService(gatewayBroker, {log: (level, message, attributes) => logger.log(level, message, attributes),}));@@ -3879,6 +3883,14 @@ function createRoutes(return voice.transcribe(ctx.request);});+ // "Good session ★" for one chat (omnirush-good-session.ts): never an error+ // the bar would show; 404, 429, offline or signed out read "pending".+ addRoute(routes, "GET", "/omnirush/integrity/:sessionId", "client", async (ctx) => {+ const sessionId = ctx.params.sessionId ?? "";+ if (!GOOD_SESSION_ID_PATTERN.test(sessionId)) throw new ApiError(400, "invalid_session_id", "A valid session id is required");+ return jsonResponse(await readGoodSession(sessionIntegrityByServer.get(config) ?? null, sessionId));+ });+addRoute(routes, "GET", "/managed-policy", "client", async () =>jsonResponse({ policy: await managedDesktopPolicy(config).current() }));addRoute(routes, "POST", "/managed-policy/evaluate", "policy", async (ctx) => {