feat(canvas): retain explicit migration eligibility at the entry boundary
This commit is contained in:
@@ -14,15 +14,19 @@ export async function loadCanvasEntry(options: { request: CanvasRequest; workspa
|
||||
options.signal?.throwIfAborted();
|
||||
if (board.kind !== 'board' || !matchesRef(board, options.boardRef) || !board.workspace_id || !profile.id) throw new Error('invalid_reference');
|
||||
if(!options.readModel&&!options.transport)throw new Error('model_loader_unavailable');
|
||||
let migration:Extract<ModelLoad,{status:'migration-required'}>|undefined;
|
||||
try {
|
||||
const model = options.readModel?await options.readModel({accountId:profile.id,workspaceId:board.workspace_id,canvasId:board.id,signal:options.signal,navigationGeneration:options.navigationGeneration??0,...(options.onPreview?{onPreview:(preview:LiveModelPreview)=>options.onPreview!(preview,board,profile)}:{})}):await loadFoundryModel(options.transport!(profile.id), board.workspace_id, board.id, options.registry, options.signal);
|
||||
options.signal?.throwIfAborted();
|
||||
if (model.status === 'ready') return { mode: 'headless' as const, board, profile, model };
|
||||
// Existing projects keep their current editor until the user explicitly migrates them.
|
||||
// This read describes eligibility, not a frozen write request: the migration
|
||||
// action must drain legacy writers and refresh source versions before sending.
|
||||
migration=model;
|
||||
} catch (error) {
|
||||
options.signal?.throwIfAborted();
|
||||
if ((error as { code?: string }).code !== 'not_found') throw error;
|
||||
}
|
||||
const snapshot = decodeSnapshot(await options.request(path + '/canvas', { signal: options.signal, headers: { Accept: CANVAS_ACCEPT } }));
|
||||
return { mode: 'legacy' as const, board, profile, snapshot };
|
||||
return { mode: 'legacy' as const, board, profile, snapshot,...(migration?{migration}:{}) };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user