Quality gates / quality (pull_request) Successful in 1m54s
Logging must never depend on AI availability, and an unsaved entry must not disappear when the user navigates away mid-log. - add src/vision-readiness.js so the photo flow consumes one readiness contract - when the worker is offline/disabled/unknown, offer no AI action and no analysis-consent prompt, and keep manual Bristol entry one action away - add src/draft.js and make the draft own the photo so a chosen photo and entered context survive a recoverable close or navigation, with a visible kept-draft summary and an explicit start over - drafts stay in session memory only: a photo awaiting consent is never persisted, and reload starts clean - service worker now refuses to cache image bodies in addition to analysis requests and no-store responses - tests: 2 new unit files, 3 service-worker privacy assertions (1 hold-out), 1 browser acceptance file, release-demo and CI/package assertions - release demo now visibly replays the vision-offline pass and the retained draft with synthetic data and an in-script assertion
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
// Decides whether the photo-first flow can promise AI analysis.
|
|
// When it cannot, logging must still reach manual Bristol entry in one action.
|
|
const MANUAL_LABEL = 'Continue without AI';
|
|
const DISABLED_LABEL = 'Log it manually';
|
|
|
|
export function visionReadiness(status) {
|
|
if (!status) {
|
|
return {
|
|
phase: 'checking',
|
|
ready: false,
|
|
manualOnly: true,
|
|
manualLabel: MANUAL_LABEL,
|
|
message: 'Checking the vision worker. Manual logging is already available.',
|
|
};
|
|
}
|
|
if (status.enabled === false) {
|
|
return {
|
|
phase: 'disabled',
|
|
ready: false,
|
|
manualOnly: true,
|
|
manualLabel: DISABLED_LABEL,
|
|
message: 'AI photo analysis is off in this build. Manual logging is fully available.',
|
|
};
|
|
}
|
|
if (status.providerReady !== true) {
|
|
return {
|
|
phase: 'offline',
|
|
ready: false,
|
|
manualOnly: true,
|
|
manualLabel: MANUAL_LABEL,
|
|
message: 'Vision worker offline. Manual logging is still available.',
|
|
};
|
|
}
|
|
return { phase: 'ready', ready: true, manualOnly: false, manualLabel: '', message: '' };
|
|
}
|