desktop: one read registry for every read button: single-flight per canonical key, broad reads cover narrow keys, overlapping buttons all busy and disabled (useReadState), 20 s 'read just now' memo, quota pause on the buttons, every read through the scheduler (Check again, Import apps, account Test, Read the stores, Dependencies), writes invalidate only the reads they change; tests/read-registry.test.ts; fixtures ?blocked and window.__fakeCalls

This commit is contained in:
CRTkafa 2026-10-23 11:09:51 +08:00
parent 7345de2f7c
commit c03938f9dc
14 changed files with 861 additions and 164 deletions

View file

@ -9,6 +9,7 @@ import { buildReport } from '../../../../cli/lib/report';
import { buildApps, type Overrides } from '../lib/identity';
import type { CatalogDiff, HealthSnapshot, MetricRow, Review, TestFlightStatus, ValidateResult, ScanResult } from '../lib/model';
import { editableFixture, liveFixture } from './editor-fixtures';
import { serviceDisabledMessage } from './error-fixtures';
import { APPLE_STATUS_READY, APPLE_STATUS_UNRESOLVED, consolePlan, consoleVerify, ownerDry, PLAY_STATUS } from './submit-fixtures';
import { ANALYTICS, ASO, DECLARATIONS, LISTING_TEXT, PPO, PPO_STORE, PRICE_DIFF, PRICES, renderArt, RENDERS } from './fixtures-more';
import { TOOLBOX } from '../../../../cli/lib/desktop-coverage';
@ -454,7 +455,17 @@ export function fixtureRead(method: string, id: string, args: Record<string, unk
return method.startsWith('apple.') && r.ok ? { ...r, quota: { store: 'apple', limit: 3600, remaining: 3412 } } : r;
}
/** ?blocked: every Play health read fails with Google's SERVICE_DISABLED (the portfolio's "Check again" notice). */
const blockedSwitch = (): boolean => typeof location !== 'undefined' && new URLSearchParams(location.search).has('blocked');
function read(method: string, id: string, args: Record<string, unknown> = {}): ToolResult {
const r = read0(method, id, args);
const h = r.data as HealthSnapshot | undefined;
if (method !== 'health' || !blockedSwitch() || !h?.play) return r;
return { ...r, data: { ...h, play: { error: serviceDisabledMessage('com.example.app') } } };
}
function read0(method: string, id: string, args: Record<string, unknown> = {}): ToolResult {
if (method === 'health.issue') return ok(method, ISSUE_SAMPLE(args));
if (id.startsWith('store:')) {
const play = /android:/.test(id);
@ -534,7 +545,12 @@ async function progressLines(job: string | null, lines: string[]) {
for (const line of lines) { await sleep(260); if (job) emit('sidecar-progress', { params: { requestId: 1, line, stream: 'stderr' }, job }); }
}
/** Every fake-host call, for checks that count them (window.__fakeCalls: "cmd method target args"). */
const fakeCalls: string[] = [];
if (typeof window !== 'undefined') (window as unknown as { __fakeCalls: string[] }).__fakeCalls = fakeCalls;
export async function mockInvoke<T>(cmd: string, a: Record<string, unknown>): Promise<T> {
fakeCalls.push([cmd, a.method ?? '', a.projectId ?? a.id ?? '', JSON.stringify((a.params as { args?: unknown } | null)?.args ?? a.live ?? '')].join(' '));
const r = await answer(cmd, a);
return r as T;
}