@notis_ai/cli 0.2.27 → 0.2.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/config/notis_app_design_rules.json +5 -123
- package/dist/agent-hooks/notis-agent-hook.mjs +453 -109
- package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-spaces/SKILL.md +13 -19
- package/dist/base-skills/notis-spaces/references/design.md +11 -45
- package/dist/base-skills/notis-spaces/references/sdk.md +94 -68
- package/dist/base-skills/notis-spaces/references/views.md +12 -1
- package/dist/sdk/src/components/NotisCommentBoundary.tsx +43 -83
- package/dist/sdk/src/components/NotisSelectionBoundary.tsx +28 -8
- package/dist/sdk/src/components/SelectionActionBar.tsx +383 -0
- package/dist/sdk/src/components/selectionId.ts +6 -0
- package/dist/sdk/src/hooks/useCollectionInteractions.ts +5 -2
- package/dist/sdk/src/runtime.ts +5 -0
- package/dist/sdk/src/space.ts +4 -0
- package/dist/sdk/src/ui/icons.tsx +11 -2
- package/dist/sdk/src/words/actions.ts +9 -1
- package/dist/sdk/src/words/keymap.ts +3 -0
- package/dist/space-harness/host.js +181 -141
- package/dist/space-sdk/dist/{chunk-BWHAORT4.js → chunk-BFGB6XXC.js} +2 -2
- package/dist/space-sdk/dist/index.js +2 -2
- package/dist/space-sdk/dist/ui.js +14 -11
- package/dist/space-sdk/src/components/NotisCommentBoundary.d.ts +0 -10
- package/dist/space-sdk/src/components/NotisSelectionBoundary.d.ts +7 -0
- package/dist/space-sdk/src/runtime.d.ts +5 -0
- package/dist/space-sdk/src/space.ts +4 -0
- package/dist/space-sdk/src/tailwind-candidates.d.ts +126 -17
- package/dist/space-sdk/src/ui/blocks/DataTable.d.ts +86 -0
- package/dist/space-sdk/src/ui/blocks/InfoTip.d.ts +25 -0
- package/dist/space-sdk/src/ui/blocks/Meter.d.ts +39 -0
- package/dist/space-sdk/src/ui/blocks/blocks.d.ts +1 -1
- package/dist/space-sdk/src/ui/blocks/index.d.ts +6 -0
- package/dist/space-sdk/src/ui/charts/Chart.d.ts +15 -2
- package/dist/space-sdk/src/ui/charts/StatRow.d.ts +4 -3
- package/dist/space-sdk/src/ui/charts/chartData.d.ts +6 -0
- package/dist/space-sdk/src/ui/comments/useComments.d.ts +19 -1
- package/dist/space-sdk/src/ui/icons.d.ts +1 -1
- package/dist/space-sdk/src/ui/index.d.ts +2 -2
- package/dist/space-sdk/src/ui/list/Row.d.ts +10 -3
- package/dist/space-sdk/src/ui/period/dateFormat.d.ts +14 -0
- package/dist/space-sdk/src/words/actions.ts +9 -1
- package/dist/space-sdk/src/words/keymap.ts +3 -0
- package/dist/view-renderer/dist/host.js +253 -213
- package/dist/view-renderer/src/renderer.js +38 -2
- package/package.json +3 -3
- package/src/command-specs/computer.js +3 -3
- package/src/command-specs/spaces.js +28 -8
- package/src/command-specs/tools.js +1 -1
- package/src/runtime/app-platform.js +74 -11
- package/src/runtime/space-fixture-broker.js +23 -2
- package/src/runtime/space-verification.js +62 -10
- package/template/components/ui/button.tsx +1 -1
- package/template/components/ui/native-select.tsx +1 -1
|
@@ -26,6 +26,8 @@ function publicSnapshot(snapshot) {
|
|
|
26
26
|
|
|
27
27
|
const PNG_LIMIT = 32 * 1024 * 1024;
|
|
28
28
|
const CAPTURE = { type: 'png', animations: 'disabled', caret: 'hide', scale: 'css' };
|
|
29
|
+
// Room a bounded ready wait leaves for the screenshot and the final authority check.
|
|
30
|
+
const CAPTURE_MARGIN_MS = 3000;
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
* Chromium rasterizes everything a screenshot captures beyond the viewport, so a
|
|
@@ -95,6 +97,11 @@ function diagnosticFailure(error, stage, fallback = 'render_failed') {
|
|
|
95
97
|
// Private in-process diagnostics only. Public JSON/error projections cannot
|
|
96
98
|
// enumerate a browser exception, which may contain source or request data.
|
|
97
99
|
Object.defineProperties(failure, { cause: { value: error }, stage: { value: stage } });
|
|
100
|
+
// A view that was not ready in time keeps the screenshot of what it showed, released after the final authority check.
|
|
101
|
+
if (error instanceof ViewRenderError && error.screenshot) {
|
|
102
|
+
Object.defineProperties(failure, { screenshot: { value: error.screenshot }, mounted: { value: error.mounted === true },
|
|
103
|
+
waitedSeconds: { value: error.waitedSeconds }, blocked: { value: Array.isArray(error.blocked) ? error.blocked : [] } });
|
|
104
|
+
}
|
|
98
105
|
return failure;
|
|
99
106
|
}
|
|
100
107
|
|
|
@@ -108,15 +115,26 @@ function diagnosticFailure(error, stage, fallback = 'render_failed') {
|
|
|
108
115
|
* - `measure: { regions }` answers reads as usual and returns `skeleton_measure`, the bones measured inside each
|
|
109
116
|
* region box before the page is expanded for a full-page capture.
|
|
110
117
|
* - `locale` ('en' or 'fr') overrides the snapshot locale; `skeleton` is injected as `descriptor.context.skeleton`.
|
|
118
|
+
*
|
|
119
|
+
* `readyTimeoutMs`, shorter than the render timeout, bounds the wait for the view to finish loading its data (mounted,
|
|
120
|
+
* no read pending, quiet for 100 ms: the signal every capture waits for). A view still loading then fails with
|
|
121
|
+
* `render_not_ready`, carrying a viewport `screenshot` of what it showed (and whether it had `mounted`), released only
|
|
122
|
+
* after the final authority check, with the seconds it waited (`waitedSeconds`) and the calls it blocked (`blocked`).
|
|
123
|
+
* The wait also ends early enough to leave the capture room before the render timeout.
|
|
124
|
+
* Without it the wait runs to the render timeout, which fails with nothing captured.
|
|
111
125
|
*/
|
|
112
126
|
export async function renderView({ broker, outputs, width, timeoutMs, signal, pool, host, maxHeight = 60000, maxPixels = 80000000, sliceHeight = 2048, maxPngBytes = PNG_LIMIT,
|
|
113
|
-
pending = false, measure, locale, skeleton }) {
|
|
127
|
+
pending = false, measure, locale, skeleton, readyTimeoutMs }) {
|
|
114
128
|
const config = inputs({ outputs, width, timeoutMs });
|
|
129
|
+
if (readyTimeoutMs !== undefined && (!Number.isInteger(readyTimeoutMs) || readyTimeoutMs < 1000 || readyTimeoutMs >= config.timeoutMs)) {
|
|
130
|
+
throw new TypeError('Bound the ready wait below the render timeout.');
|
|
131
|
+
}
|
|
115
132
|
if (pending && measure) throw new TypeError('Choose a pending or a measuring render, not both.');
|
|
116
133
|
if (locale !== undefined && !['en', 'fr'].includes(locale)) throw new TypeError('Override the locale with en or fr.');
|
|
117
134
|
if (measure !== undefined && !Array.isArray(measure?.regions)) throw new TypeError('Measure a list of skeleton regions.');
|
|
118
135
|
if (!Number.isInteger(sliceHeight) || sliceHeight < 256 || sliceHeight > 16384) throw new TypeError('Use a bounded screenshot slice height.');
|
|
119
136
|
if (!Number.isInteger(maxPngBytes) || maxPngBytes < 1 || maxPngBytes > PNG_LIMIT) throw new TypeError('Use a PNG limit within the render transport limit.');
|
|
137
|
+
const deadlineAt = Date.now() + config.timeoutMs;
|
|
120
138
|
const deadline = AbortSignal.timeout(config.timeoutMs);
|
|
121
139
|
const cancellation = signal ? AbortSignal.any([signal, deadline]) : deadline;
|
|
122
140
|
// Fail authorization before opening a browser or exposing cached page data.
|
|
@@ -266,7 +284,25 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
|
|
|
266
284
|
rendered_at: new Date().toISOString() };
|
|
267
285
|
}
|
|
268
286
|
stage = 'host_ready';
|
|
269
|
-
|
|
287
|
+
const ready = () => window.__notisRenderState?.mounted && window.__notisRenderState.pending === 0 && performance.now() - window.__notisRenderState.lastActivity > 100;
|
|
288
|
+
// The bounded wait also leaves the capture and the final authority check room before the render deadline.
|
|
289
|
+
const readyWait = readyTimeoutMs === undefined ? config.timeoutMs
|
|
290
|
+
: Math.max(1, Math.min(readyTimeoutMs, deadlineAt - Date.now() - CAPTURE_MARGIN_MS));
|
|
291
|
+
const readyStarted = Date.now();
|
|
292
|
+
try { await page.waitForFunction(ready, undefined, { timeout: readyWait }); }
|
|
293
|
+
catch (error) {
|
|
294
|
+
if (readyTimeoutMs === undefined || cancellation.aborted || error?.name !== 'TimeoutError') throw error;
|
|
295
|
+
stage = 'not_ready_capture';
|
|
296
|
+
const mounted = await page.evaluate(() => Boolean(window.__notisRenderState?.mounted));
|
|
297
|
+
const png = await page.screenshot(CAPTURE);
|
|
298
|
+
await complete();
|
|
299
|
+
const seconds = Math.max(1, Math.round((Date.now() - readyStarted) / 1000));
|
|
300
|
+
const failure = new ViewRenderError('render_not_ready', `This view had not finished loading its data after ${seconds} s.`, 504);
|
|
301
|
+
Object.defineProperties(failure, { mounted: { value: mounted }, waitedSeconds: { value: seconds }, blocked: { value: [...blocked] },
|
|
302
|
+
screenshot: { value: { mime_type: 'image/png', viewport_width: config.width,
|
|
303
|
+
data_base64: png.toString('base64'), width: png.readUInt32BE(16), height: png.readUInt32BE(20) } } });
|
|
304
|
+
throw failure;
|
|
305
|
+
}
|
|
270
306
|
// A committed data response must settle React layout and browser fonts.
|
|
271
307
|
stage = 'fonts_layout';
|
|
272
308
|
await page.evaluate(async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@notis_ai/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.29",
|
|
4
4
|
"description": "Agent-first Notis CLI for Spaces, Skills and generic tool execution",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"react-dom": "19.3.0"
|
|
53
53
|
},
|
|
54
54
|
"notisRelease": {
|
|
55
|
-
"sourceSha": "
|
|
55
|
+
"sourceSha": "ca87a334f8e4899af09347a9c5362d62856c6e7c",
|
|
56
56
|
"channel": "stable"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "ca87a334f8e4899af09347a9c5362d62856c6e7c"
|
|
59
59
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// With neither, the command sets up when needed, waits for the computer and
|
|
9
9
|
// runs ssh.
|
|
10
10
|
//
|
|
11
|
-
// `notis computer status | restart | recover` (CC-150, CC-
|
|
11
|
+
// `notis computer status | restart | recover` (CC-150, CC-245) go through
|
|
12
12
|
// LOCAL_NOTIS_GET_CLOUD_COMPUTER and LOCAL_NOTIS_MANAGE_CLOUD_COMPUTER, so the
|
|
13
13
|
// server keeps every check. Restart and recover preview first and ask.
|
|
14
14
|
|
|
@@ -241,8 +241,8 @@ export const computerCommandSpecs = [{
|
|
|
241
241
|
},
|
|
242
242
|
}, {
|
|
243
243
|
command_path: ['computer', 'restart'],
|
|
244
|
-
summary: 'Restart
|
|
245
|
-
when_to_use: '
|
|
244
|
+
summary: 'Restart your Cloud Computer, awake or not responding. Its files are kept.',
|
|
245
|
+
when_to_use: 'When it is stuck, slow or not responding. Whatever was running on it stops; it answers again in 1 to 2 minutes. An asleep one has nothing to restart.',
|
|
246
246
|
args_schema: { arguments: [], options: [YES_OPTION] },
|
|
247
247
|
examples: ['notis computer restart', 'notis computer restart --yes'],
|
|
248
248
|
mutates: true, idempotent: false, require_auth: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { scaffoldSpaceCollection } from '../runtime/space-collection-scaffold.js';
|
|
2
|
-
import { appFilesDigest, pullAppSource, resolveProjectDir, saveSpacePendingScreenshots, saveSpaceVerification, spacePublicationIntent, syncSpaceSdk } from '../runtime/app-platform.js';
|
|
2
|
+
import { appFilesDigest, clearSpaceScreenshots, pullAppSource, resolveProjectDir, saveSpacePendingScreenshots, saveSpaceScreenshots, saveSpaceVerification, spacePublicationIntent, syncSpaceSdk } from '../runtime/app-platform.js';
|
|
3
3
|
import { buildSpaceArtifact, prepareSpaceRelease, requireSpaceIcon } from '../runtime/space-platform.js';
|
|
4
4
|
import { verifySpaceRelease } from '../runtime/space-verification.js';
|
|
5
5
|
import { loadSelectedSpace } from '../runtime/space-source.js';
|
|
@@ -131,10 +131,22 @@ function describePendingChanges(summary) {
|
|
|
131
131
|
|
|
132
132
|
const SKELETON_FILE = 'bundle/skeleton.json';
|
|
133
133
|
|
|
134
|
+
/** Reviewable: where the screenshots of the loaded view are, and each width that had not finished loading its data. */
|
|
135
|
+
function describeScreenshots(render) {
|
|
136
|
+
const renders = render?.renders || [];
|
|
137
|
+
const paths = renders.filter(value => value.loaded && value.screenshot_path).map(value => value.screenshot_path);
|
|
138
|
+
const parts = paths.length ? [`Screenshots after the data loaded: ${paths.join(', ')}.`] : [];
|
|
139
|
+
for (const value of renders.filter(item => item.loaded === false)) {
|
|
140
|
+
const message = value.message;
|
|
141
|
+
if (message) parts.push(value.screenshot_path ? `${message.replace(/\.$/, '')}; ${value.screenshot_path} shows what it showed then.` : message);
|
|
142
|
+
}
|
|
143
|
+
return parts.length ? ` ${parts.join(' ')}` : '';
|
|
144
|
+
}
|
|
145
|
+
|
|
134
146
|
/** Reviewable: the measured loading skeleton, its warnings and where the loading screenshots are. */
|
|
135
147
|
function describeSkeleton(skeleton) {
|
|
136
148
|
if (!skeleton) return '';
|
|
137
|
-
const parts = [skeleton.status === 'captured' ? `Loading skeleton measured for ${skeleton.regions.join(', ')}.`
|
|
149
|
+
const parts = [skeleton.status === 'captured' ? `Loading skeleton measured for ${skeleton.regions.join(', ')}${skeleton.audience === 'public' ? ', as the public sees the view' : ''}.`
|
|
138
150
|
: skeleton.status === 'failed' ? 'The loading skeleton could not be measured; the view keeps its fallback skeleton.' : ''];
|
|
139
151
|
const findings = skeleton.findings || [];
|
|
140
152
|
if (findings.length) {
|
|
@@ -159,6 +171,9 @@ async function sourceRelease(ctx, publish, stageOnly = false) {
|
|
|
159
171
|
const { directory, key } = selected(ctx);
|
|
160
172
|
if (!ctx.options.spaceId) throw usageError('Pass --space-id <id> for the existing Space.');
|
|
161
173
|
const intentKey = publish ? requestId(ctx) : null;
|
|
174
|
+
// A verify that stops at any point (a build older than its source, a refused source check, a cancelled render), or
|
|
175
|
+
// a release without a loading skeleton, leaves no image of an older build.
|
|
176
|
+
clearSpaceScreenshots(directory, key);
|
|
162
177
|
const release = await prepareSpaceRelease(directory, key);
|
|
163
178
|
try {
|
|
164
179
|
if (publish) requireSpaceIcon(release.manifest, key);
|
|
@@ -196,14 +211,19 @@ async function sourceRelease(ctx, publish, stageOnly = false) {
|
|
|
196
211
|
// Test seam only: the command context never carries it from user options.
|
|
197
212
|
...(typeof ctx.loadSpaceRenderer === 'function' ? { loadRenderer: ctx.loadSpaceRenderer } : {}) }); }
|
|
198
213
|
finally { process.removeListener('SIGINT', cancel); process.removeListener('SIGTERM', cancel); }
|
|
214
|
+
const saved = saveSpaceScreenshots(directory, key, render.screenshots || []);
|
|
215
|
+
if (render.renders) render.renders = render.renders.map(value => {
|
|
216
|
+
const path = saved.find(item => item.width === value.width)?.path;
|
|
217
|
+
return path ? { ...value, screenshot_path: path } : value;
|
|
218
|
+
});
|
|
199
219
|
if (render.skeleton) {
|
|
200
|
-
const paths = saveSpacePendingScreenshots(directory, render.pendingScreenshots || []);
|
|
220
|
+
const paths = saveSpacePendingScreenshots(directory, key, render.pendingScreenshots || []);
|
|
201
221
|
render.skeleton.pending_screenshots = render.skeleton.pending_screenshots.map((value, index) => ({ ...value, ...(paths[index] ? { path: paths[index] } : {}) }));
|
|
202
222
|
}
|
|
203
223
|
const diagnosticPath = saveSpaceVerification(directory, { ...render, space_id: body.space_id });
|
|
204
224
|
if (!['passed', 'not_applicable_container'].includes(render.status)) {
|
|
205
225
|
const reason = render.errors?.find(value => value.phase === 'fixture')?.message;
|
|
206
|
-
throw usageError(`The built Space did not pass offline render verification. Nothing was published.${reason ? ` ${reason}` : ''}`,
|
|
226
|
+
throw usageError(`The built Space did not pass offline render verification. Nothing was published.${reason ? ` ${reason}` : ''}${describeScreenshots(render)}`,
|
|
207
227
|
{ render, diagnostic_path: diagnosticPath });
|
|
208
228
|
}
|
|
209
229
|
// The measured skeleton joins the release in memory, replacing any file at its path; nothing is written to disk.
|
|
@@ -246,12 +266,12 @@ async function sourceRelease(ctx, publish, stageOnly = false) {
|
|
|
246
266
|
: serverVerification;
|
|
247
267
|
if (publish && !ctx.options.dryRun && !stageOnly) recordPublication(directory, local, result);
|
|
248
268
|
const data = { ...result, render, diagnostic_path: diagnosticPath, ...(local.summary ? { local_changes: local.summary } : {}) };
|
|
249
|
-
const skeletonSummary = describeSkeleton(render.skeleton);
|
|
269
|
+
const skeletonSummary = describeSkeleton(render.skeleton), screenshotSummary = describeScreenshots(render);
|
|
250
270
|
return ctx.output.emitSuccess({ command: ctx.spec.command_path.join(' '), data,
|
|
251
271
|
humanSummary: publish && !ctx.options.dryRun
|
|
252
|
-
? stageOnly ? `Prepared ${key} as revision ${result.candidate_revision}. ${result.preview_url || 'This container has no executable preview.'} Live source was not changed.${describePendingChanges(local.summary).replace(/\.$/, '; they go live with notis spaces promote.')}`
|
|
253
|
-
: `Published ${key} as revision ${result.published_revision}${result.replayed ? ' (confirmed retry)' : ''}.${describeAppliedChanges(result)}${describeViewerReads(serverVerification.capabilities)}${describeCloudComputer(serverVerification.capabilities)}${skeletonSummary}`
|
|
254
|
-
: `Verified ${key}'s frozen source${render.status === 'passed' ? ', rendered fixtures' : ' (container)'} and current authorizations; nothing was published.${describePendingChanges(local.summary)}${describeViewerReads(serverVerification.capabilities)}${describeCloudComputer(serverVerification.capabilities)}${skeletonSummary}`,
|
|
272
|
+
? stageOnly ? `Prepared ${key} as revision ${result.candidate_revision}. ${result.preview_url || 'This container has no executable preview.'} Live source was not changed.${describePendingChanges(local.summary).replace(/\.$/, '; they go live with notis spaces promote.')}${screenshotSummary}`
|
|
273
|
+
: `Published ${key} as revision ${result.published_revision}${result.replayed ? ' (confirmed retry)' : ''}.${describeAppliedChanges(result)}${describeViewerReads(serverVerification.capabilities)}${describeCloudComputer(serverVerification.capabilities)}${screenshotSummary}${skeletonSummary}`
|
|
274
|
+
: `Verified ${key}'s frozen source${render.status === 'passed' ? ', rendered fixtures' : ' (container)'} and current authorizations; nothing was published.${describePendingChanges(local.summary)}${describeViewerReads(serverVerification.capabilities)}${describeCloudComputer(serverVerification.capabilities)}${screenshotSummary}${skeletonSummary}`,
|
|
255
275
|
warnings: skeletonWarnings.length ? [...(local.warnings || []), ...skeletonWarnings] : local.warnings, meta: { mutating: publish && !ctx.options.dryRun } });
|
|
256
276
|
} finally { release.close(); }
|
|
257
277
|
}
|
|
@@ -201,7 +201,7 @@ export function classifyToolMutation(toolName, args = {}) {
|
|
|
201
201
|
const normalized = localNotisToolSlug(toolName).toUpperCase();
|
|
202
202
|
if (normalized === 'LOCAL_NOTIS_SANDBOX_PREVIEW') {
|
|
203
203
|
if (args.action === 'status') return false;
|
|
204
|
-
if (['register', 'open', 'heartbeat', 'stop'].includes(args.action)) return true;
|
|
204
|
+
if (['register', 'open', 'heartbeat', 'stop', 'delete'].includes(args.action)) return true;
|
|
205
205
|
return null;
|
|
206
206
|
}
|
|
207
207
|
if (normalized.includes('EXECUTE_SQL') && typeof args.query === 'string') {
|
|
@@ -1973,9 +1973,18 @@ export function freezeSourceWorkspace(projectDir, sourceFiles) {
|
|
|
1973
1973
|
return withAppReleaseWorkspace(projectDir, workspace => freezePinnedArtifactSnapshot(workspace, {}, sourceFiles), { create: true });
|
|
1974
1974
|
}
|
|
1975
1975
|
|
|
1976
|
+
/** Whether a Space key is safe to put in a file name under .notis. */
|
|
1977
|
+
function isSpaceKey(key) {
|
|
1978
|
+
return typeof key === 'string' && /^[a-z][a-z0-9_-]{0,99}$/.test(key);
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
function assertSpaceKey(key, message) {
|
|
1982
|
+
if (!isSpaceKey(key)) throw usageError(message);
|
|
1983
|
+
return key;
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1976
1986
|
function selectedBuildName(key) {
|
|
1977
|
-
|
|
1978
|
-
return `space-build-${key}.json`;
|
|
1987
|
+
return `space-build-${assertSpaceKey(key, 'Choose a valid selected build key.')}.json`;
|
|
1979
1988
|
}
|
|
1980
1989
|
|
|
1981
1990
|
/** Immutable bytes, not another authoring project or installed dependency tree. */
|
|
@@ -1988,6 +1997,8 @@ export function saveSelectedBuild(projectDir, key, release) {
|
|
|
1988
1997
|
writeFileSync(temporary, JSON.stringify(snapshot), { flag: 'wx', mode: 0o600 });
|
|
1989
1998
|
renameSync(temporary, name);
|
|
1990
1999
|
} finally { rmSync(temporary, { force: true }); }
|
|
2000
|
+
// The verify images showed the build this one replaces.
|
|
2001
|
+
removeSpaceImages(key);
|
|
1991
2002
|
return join(projectDir, NOTIS_DIR, name);
|
|
1992
2003
|
}, { create: true });
|
|
1993
2004
|
}
|
|
@@ -2022,16 +2033,68 @@ export function saveSpaceVerification(projectDir, diagnostic) {
|
|
|
2022
2033
|
});
|
|
2023
2034
|
}
|
|
2024
2035
|
|
|
2025
|
-
/**
|
|
2026
|
-
|
|
2036
|
+
/** Replace one verify image in the pinned .notis directory (the working directory) without following a planted link. */
|
|
2037
|
+
function replaceVerifyImage(name, png) {
|
|
2038
|
+
rmSync(name, { force: true });
|
|
2039
|
+
if (png) writeFileSync(name, png, { flag: 'wx', mode: 0o600 });
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
const VERIFY_WIDTHS = [390, 1440], VERIFY_LOCALES = ['en', 'fr'];
|
|
2043
|
+
/** Each Space's verify images carry its key, so two Spaces verified from one folder never share a file. */
|
|
2044
|
+
function viewImageName(key, width) {
|
|
2045
|
+
if (!VERIFY_WIDTHS.includes(width)) throw usageError('Unsafe screenshot name.');
|
|
2046
|
+
return `view-${assertSpaceKey(key, 'Unsafe screenshot name.')}-${width}.png`;
|
|
2047
|
+
}
|
|
2048
|
+
function pendingImageName(key, width, locale) {
|
|
2049
|
+
if (!VERIFY_WIDTHS.includes(width) || !VERIFY_LOCALES.includes(locale)) throw usageError('Unsafe pending screenshot name.');
|
|
2050
|
+
return `pending-${assertSpaceKey(key, 'Unsafe pending screenshot name.')}-${width}-${locale}.png`;
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
/**
|
|
2054
|
+
* Remove this Space's verify images before a new verify, so one that stops at any point (its build refused as stale
|
|
2055
|
+
* included), or a release without a loading skeleton, leaves no image of an older build. Images named before they
|
|
2056
|
+
* carried a key say no Space, so they go too.
|
|
2057
|
+
*/
|
|
2058
|
+
export function clearSpaceScreenshots(projectDir, key) {
|
|
2059
|
+
// A key no build accepts has no images, and a folder never built has no .notis; the release step says why.
|
|
2060
|
+
if (!isSpaceKey(key) || !lstatSync(join(projectDir, NOTIS_DIR), { throwIfNoEntry: false })) return;
|
|
2061
|
+
withAppReleaseWorkspace(projectDir, () => removeSpaceImages(key));
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
/** Remove one Space's verify images, and the unnamed ones, from the pinned .notis directory (the working directory). */
|
|
2065
|
+
function removeSpaceImages(key) {
|
|
2066
|
+
for (const width of VERIFY_WIDTHS) {
|
|
2067
|
+
replaceVerifyImage(viewImageName(key, width));
|
|
2068
|
+
replaceVerifyImage(`view-${width}.png`);
|
|
2069
|
+
for (const locale of VERIFY_LOCALES) {
|
|
2070
|
+
replaceVerifyImage(pendingImageName(key, width, locale));
|
|
2071
|
+
replaceVerifyImage(`pending-${width}-${locale}.png`);
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
/** The loading-state screenshots of the last verify, `pending-<key>-<width>-<locale>.png` beside the diagnostic. */
|
|
2077
|
+
export function saveSpacePendingScreenshots(projectDir, key, screenshots) {
|
|
2027
2078
|
if (!screenshots?.length) return [];
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2079
|
+
// Every name is checked before any file is written.
|
|
2080
|
+
const names = screenshots.map(({ width, locale }) => pendingImageName(key, width, locale));
|
|
2081
|
+
return withAppReleaseWorkspace(projectDir, (workspace) => screenshots.map(({ png }, index) => {
|
|
2082
|
+
replaceVerifyImage(names[index], png);
|
|
2083
|
+
return join(workspace.projectDir, NOTIS_DIR, names[index]);
|
|
2084
|
+
}));
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
/**
|
|
2088
|
+
* The screenshots of the last verify, `view-<key>-<width>.png` beside the diagnostic, taken once the view had loaded
|
|
2089
|
+
* its data (or of what it showed when it had not).
|
|
2090
|
+
*/
|
|
2091
|
+
export function saveSpaceScreenshots(projectDir, key, screenshots) {
|
|
2092
|
+
// One image per width, every name checked before any file is written.
|
|
2093
|
+
const kept = new Map((screenshots || []).map(value => [value.width, value]));
|
|
2094
|
+
const names = new Map([...kept.keys()].map(width => [width, viewImageName(key, width)]));
|
|
2095
|
+
return withAppReleaseWorkspace(projectDir, (workspace) => [...kept].map(([width, { png }]) => {
|
|
2096
|
+
replaceVerifyImage(names.get(width), png);
|
|
2097
|
+
return { width, path: join(workspace.projectDir, NOTIS_DIR, names.get(width)) };
|
|
2035
2098
|
}));
|
|
2036
2099
|
}
|
|
2037
2100
|
|
|
@@ -5,12 +5,33 @@ import { usageError } from './errors.js';
|
|
|
5
5
|
const object = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
6
6
|
const exact = (value, keys) => object(value) && Object.keys(value).sort().join(',') === [...keys].sort().join(',');
|
|
7
7
|
|
|
8
|
+
/** At most this many extra param sets are measured for loading skeletons. */
|
|
9
|
+
export const SKELETON_PARAM_SETS_MAX = 4;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The extra view params whose loading skeletons are measured too (fixtures `context.skeletonParams`): each is a
|
|
13
|
+
* flat object of string values, such as a tab the view opens on. Anything else is ignored.
|
|
14
|
+
*/
|
|
15
|
+
export function fixtureSkeletonParams(release) {
|
|
16
|
+
let list;
|
|
17
|
+
try { list = createSpaceFixtureEngine(release).context.skeletonParams; } catch { return []; }
|
|
18
|
+
if (!Array.isArray(list)) return [];
|
|
19
|
+
return list.filter(item => object(item) && Object.values(item).every(value => typeof value === 'string'))
|
|
20
|
+
.slice(0, SKELETON_PARAM_SETS_MAX).map(item => structuredClone(item));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* `audience: 'public'` draws the view as the public sees it: the editor's descriptor with View as the public on, so
|
|
25
|
+
* the page applies the public floors itself (no editor-only lists, actions, params or columns), as in the Portal.
|
|
26
|
+
*/
|
|
8
27
|
export function createSpaceFixtureBroker({ release, capabilities, width, outputs = ['markdown', 'screenshot'],
|
|
9
|
-
authorizationMode = 'authorize_missing', unavailableActions = [], onFailure }) {
|
|
28
|
+
authorizationMode = 'authorize_missing', unavailableActions = [], onFailure, params: paramsOverride, audience = 'editor' }) {
|
|
10
29
|
const engine = createSpaceFixtureEngine(release);
|
|
11
30
|
const frozen = spaceHarnessSnapshot(release, capabilities, engine, { authorizationMode, unavailableActions });
|
|
31
|
+
if (audience === 'public') frozen.descriptor.space.viewAs = 'public';
|
|
12
32
|
const calls = [];
|
|
13
|
-
|
|
33
|
+
// Skeleton capture may open the view with other params (a tab), on top of the fixture's own.
|
|
34
|
+
const params = structuredClone({ ...(engine.context.params || {}), ...(paramsOverride || {}) });
|
|
14
35
|
// The fixture's own "now" pins the browser clock, so a view that asks for the
|
|
15
36
|
// last hour sends the exact inputs its fixtures recorded.
|
|
16
37
|
const now = engine.context.now;
|
|
@@ -3,7 +3,7 @@ import { createHash } from 'node:crypto';
|
|
|
3
3
|
import { existsSync, readFileSync } from 'node:fs';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { appFilesDigest } from './app-platform.js';
|
|
6
|
-
import { createSpaceFixtureBroker } from './space-fixture-broker.js';
|
|
6
|
+
import { createSpaceFixtureBroker, fixtureSkeletonParams } from './space-fixture-broker.js';
|
|
7
7
|
|
|
8
8
|
// Kept for the standalone legacy worker's lifecycle tests while that diagnostic
|
|
9
9
|
// entrypoint is retired. The primary verifier below never starts that worker.
|
|
@@ -66,19 +66,38 @@ export async function verifySpaceRelease(release, { capabilities, timeoutMs = 45
|
|
|
66
66
|
await acquire(signal); held = true;
|
|
67
67
|
const library = await loadRenderer(); rendererDigest = library.rendererDigest;
|
|
68
68
|
pool = library.createBrowserPool({ concurrency: 2, maxQueue: 2 });
|
|
69
|
+
// The screenshots kept for the agent are taken once the view has finished loading its data, as `spaces screenshot`
|
|
70
|
+
// waits; a view still loading after the bounded wait keeps a screenshot of what it showed, and says so.
|
|
71
|
+
const readyTimeoutMs = readyWait(timeoutMs);
|
|
72
|
+
const screenshots = [];
|
|
69
73
|
const observations = await Promise.allSettled(brokers.map(async ({ width, broker, stop }) => {
|
|
70
74
|
const cancel = signal ? AbortSignal.any([signal, stop.signal]) : stop.signal;
|
|
71
|
-
const result = await library.renderView({ broker, pool, outputs: ['markdown', 'screenshot'], width, timeoutMs, signal: cancel
|
|
75
|
+
const result = await library.renderView({ broker, pool, outputs: ['markdown', 'screenshot'], width, timeoutMs, signal: cancel,
|
|
76
|
+
...(readyTimeoutMs ? { readyTimeoutMs } : {}) });
|
|
72
77
|
const blocked = result.blocked_calls || [];
|
|
73
|
-
|
|
78
|
+
const png = Buffer.from(result.screenshot.data_base64, 'base64');
|
|
79
|
+
screenshots.push({ width, png });
|
|
80
|
+
return { width, mounted: true, status: blocked.length ? 'failed' : 'passed', loaded: true,
|
|
74
81
|
markdown_sha256: createHash('sha256').update(result.markdown).digest('hex'),
|
|
75
|
-
screenshot_sha256:
|
|
82
|
+
screenshot_sha256: sha256(png),
|
|
76
83
|
screenshot_width: result.screenshot.width, screenshot_height: result.screenshot.height,
|
|
77
84
|
rendered_at: result.rendered_at, blocked_calls: blocked };
|
|
78
85
|
}));
|
|
79
|
-
const renders = observations.map((value, index) =>
|
|
80
|
-
|
|
86
|
+
const renders = observations.map((value, index) => {
|
|
87
|
+
if (value.status === 'fulfilled') return value.value;
|
|
88
|
+
const width = brokers[index].width, shot = value.reason?.code === 'render_not_ready' ? value.reason.screenshot : null;
|
|
89
|
+
if (!shot?.data_base64) return { width, mounted: false, status: 'failed', error: value.reason?.code || 'render_failed' };
|
|
90
|
+
const png = Buffer.from(shot.data_base64, 'base64');
|
|
91
|
+
screenshots.push({ width, png });
|
|
92
|
+
const mounted = value.reason.mounted === true;
|
|
93
|
+
const seconds = value.reason.waitedSeconds || Math.round((readyTimeoutMs || 0) / 1000);
|
|
94
|
+
return { width, mounted, status: 'failed', error: 'render_not_ready', loaded: false,
|
|
95
|
+
message: mounted ? `At ${width} px the view had not finished loading its data after ${seconds} s.`
|
|
96
|
+
: `At ${width} px the view had not shown anything after ${seconds} s.`,
|
|
97
|
+
screenshot_sha256: sha256(png), screenshot_width: shot.width, screenshot_height: shot.height,
|
|
98
|
+
blocked_calls: Array.isArray(value.reason.blocked) ? value.reason.blocked : [] };
|
|
81
99
|
});
|
|
100
|
+
screenshots.sort((left, right) => left.width - right.width);
|
|
82
101
|
const runtimeCalls = brokers.flatMap(({ width, broker }) => broker.calls.map(call => ({ width, ...call })));
|
|
83
102
|
const passed = renders.every(value => value.status === 'passed') && runtimeCalls.every(call => call.ok);
|
|
84
103
|
// Each distinct fixture reason once (both widths usually hit the same one), ahead of the generic line.
|
|
@@ -86,10 +105,13 @@ export async function verifySpaceRelease(release, { capabilities, timeoutMs = 45
|
|
|
86
105
|
.map(call => [call.error, { phase: 'fixture', operation: call.operation,
|
|
87
106
|
...(call.recordKey ? { record_key: call.recordKey } : {}), ...(call.actionId ? { action_id: call.actionId } : {}),
|
|
88
107
|
message: call.error }])).values()].slice(0, 10);
|
|
108
|
+
const notReady = renders.filter(value => value.error === 'render_not_ready')
|
|
109
|
+
.map(value => ({ phase: 'renderer', width: value.width, message: value.message }));
|
|
89
110
|
const result = { ...diagnostic, status: passed ? 'passed' : 'failed', mounted: renders.every(value => value.mounted),
|
|
90
111
|
fixture_digest: brokers[0].broker.fixtureDigest, renderer_digest: rendererDigest,
|
|
91
112
|
render_count: renders.length, browser_count: 1, renders, runtimeCalls,
|
|
92
|
-
errors: passed ? [] : [...fixtureErrors, { phase: 'renderer', message: 'At least one width or read-only fixture failed verification.' }] };
|
|
113
|
+
errors: passed ? [] : [...fixtureErrors, ...notReady, { phase: 'renderer', message: 'At least one width or read-only fixture failed verification.' }] };
|
|
114
|
+
Object.defineProperty(result, 'screenshots', { value: screenshots, enumerable: false });
|
|
93
115
|
// The skeleton is measured only from a view that rendered cleanly, with a renderer that can measure it.
|
|
94
116
|
if (passed && typeof library.buildSkeletonDocument === 'function') {
|
|
95
117
|
const capture = await captureSpaceSkeleton({ library, pool, release, capabilities, timeoutMs, signal, authorizationMode, unavailableActions });
|
|
@@ -108,6 +130,10 @@ export async function verifySpaceRelease(release, { capabilities, timeoutMs = 45
|
|
|
108
130
|
}
|
|
109
131
|
}
|
|
110
132
|
const FIXTURE_FAILURE_GRACE_MS = 1_500;
|
|
133
|
+
// How long verify waits for the view to finish loading its data before it shoots what it shows: the render timeout less
|
|
134
|
+
// a margin for that screenshot and the final checks (40 s of the default 45 s, about what the whole render left before).
|
|
135
|
+
const READY_MARGIN_MS = 5_000;
|
|
136
|
+
const readyWait = timeoutMs => (timeoutMs - READY_MARGIN_MS >= 1_000 ? timeoutMs - READY_MARGIN_MS : undefined);
|
|
111
137
|
|
|
112
138
|
const sha256 = bytes => createHash('sha256').update(bytes).digest('hex');
|
|
113
139
|
const captureFailure = (width, locale, error) => ({ check: 'capture_failed', severity: 'warning', width, locale,
|
|
@@ -122,8 +148,13 @@ async function captureSpaceSkeleton({ library, pool, release, capabilities, time
|
|
|
122
148
|
const findings = [], screenshots = [], combos = [];
|
|
123
149
|
let failed = false, document = null;
|
|
124
150
|
const widths = library.SKELETON_WIDTHS || [390, 1440], locales = library.SKELETON_LOCALES || ['en', 'fr'];
|
|
125
|
-
|
|
126
|
-
|
|
151
|
+
// One skeleton is shown to everyone who opens the Space, Site visitors included. When the Space marks parts of its
|
|
152
|
+
// view editor-only, it is measured from the view the public sees, so it never draws the editors' page for them. A
|
|
153
|
+
// view that is wholly editor-only does not exist for the public: it keeps the editors' skeleton.
|
|
154
|
+
const marks = release.manifest.editors_only;
|
|
155
|
+
const audience = marks && !marks.view ? 'public' : 'editor';
|
|
156
|
+
const render = (width, options, params) => library.renderView({ broker: createSpaceFixtureBroker({ release, capabilities, width,
|
|
157
|
+
outputs: ['markdown'], authorizationMode, unavailableActions, params, audience }), pool, outputs: ['markdown'], width, timeoutMs, signal, ...options });
|
|
127
158
|
// Both widths of one locale run together: the pool holds two renders at a time.
|
|
128
159
|
const each = async (step) => {
|
|
129
160
|
for (const locale of locales) {
|
|
@@ -147,6 +178,27 @@ async function captureSpaceSkeleton({ library, pool, release, capabilities, time
|
|
|
147
178
|
});
|
|
148
179
|
const measurements = {};
|
|
149
180
|
for (const combo of combos) if (combo.final) (measurements[combo.width] ||= {})[combo.locale] = { regions: combo.final.regions };
|
|
181
|
+
// Regions a view shows only under other params (a tab it can open on), declared in the fixtures as
|
|
182
|
+
// context.skeletonParams: measured the same way and added beside the opening view's own regions. A failure here
|
|
183
|
+
// is a warning and never drops the regions already measured.
|
|
184
|
+
for (const params of fixtureSkeletonParams(release)) {
|
|
185
|
+
for (const locale of locales) {
|
|
186
|
+
const settled = await Promise.allSettled(widths.map(async (width) => {
|
|
187
|
+
const pending = (await render(width, { pending: true, locale }, params))?.pending;
|
|
188
|
+
const known = new Set((measurements[width]?.[locale]?.regions || []).map(region => region.key));
|
|
189
|
+
const valid = pending?.static ? [] : (pending?.regions || []).filter(region => region.valid && !known.has(region.key));
|
|
190
|
+
if (!valid.length) return;
|
|
191
|
+
const final = (await render(width, { measure: { regions: valid }, locale }, params)).skeleton_measure;
|
|
192
|
+
const added = (final?.regions || []).filter(region => !known.has(region.key));
|
|
193
|
+
if (!added.length) return;
|
|
194
|
+
const entry = ((measurements[width] ||= {})[locale] ||= { regions: [] });
|
|
195
|
+
entry.regions = [...entry.regions, ...added];
|
|
196
|
+
}));
|
|
197
|
+
settled.forEach((value, index) => {
|
|
198
|
+
if (value.status === 'rejected') findings.push(captureFailure(widths[index], locale, value.reason));
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
150
202
|
const app = release.files[release.manifest.bundle?.js || 'bundle/app.js'];
|
|
151
203
|
if (Object.keys(measurements).length && typeof app === 'string') {
|
|
152
204
|
document = library.buildSkeletonDocument({ sourceHash: sha256(Buffer.from(app, 'base64')), measurements });
|
|
@@ -182,6 +234,6 @@ async function captureSpaceSkeleton({ library, pool, release, capabilities, time
|
|
|
182
234
|
screenshots.push({ width: combo.width, locale: combo.locale, png, sha256: sha256(png) });
|
|
183
235
|
}
|
|
184
236
|
const status = document ? 'captured' : failed ? 'failed' : 'none';
|
|
185
|
-
return { document, screenshots, skeleton: { status, regions: document ? Object.keys(document.regions).sort() : [], findings,
|
|
237
|
+
return { document, screenshots, skeleton: { status, audience, regions: document ? Object.keys(document.regions).sort() : [], findings,
|
|
186
238
|
pending_screenshots: screenshots.map(({ width, locale, sha256: digest }) => ({ width, locale, sha256: digest })) } };
|
|
187
239
|
}
|
|
@@ -5,7 +5,7 @@ import { cva, type VariantProps } from 'class-variance-authority';
|
|
|
5
5
|
import { cn } from '@/lib/utils';
|
|
6
6
|
|
|
7
7
|
const buttonVariants = cva(
|
|
8
|
-
'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium
|
|
8
|
+
'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors disabled:pointer-events-none disabled:opacity-50',
|
|
9
9
|
{
|
|
10
10
|
variants: {
|
|
11
11
|
variant: {
|
|
@@ -10,7 +10,7 @@ const NativeSelect = React.forwardRef<HTMLSelectElement, React.SelectHTMLAttribu
|
|
|
10
10
|
<span className={cn('relative inline-flex', className)}>
|
|
11
11
|
<select
|
|
12
12
|
ref={ref}
|
|
13
|
-
className="h-9 w-full appearance-none rounded-md bg-muted pl-3 pr-8 text-sm text-foreground outline-hidden transition-colors hover:bg-muted/70
|
|
13
|
+
className="h-9 w-full appearance-none rounded-md bg-muted pl-3 pr-8 text-sm text-foreground outline-hidden transition-colors hover:bg-muted/70"
|
|
14
14
|
{...props}
|
|
15
15
|
>
|
|
16
16
|
{children}
|