Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b442fd9
fix: harden Constructor V2 failure and keyboard semantics
Oleksii-debug Sep 29, 2026
2c0c358
test: lock Constructor V2 accessible failure boundary
Oleksii-debug Sep 29, 2026
b9e613f
merge: converge Constructor V2 safety repair onto current package head
Oleksii-debug Sep 29, 2026
0f6bb32
Reconverge #264 with packaged #265: .github/workflows/r06-constructor…
Oleksii-debug Sep 29, 2026
d915b65
Reconverge #264 with packaged #265: lanes/dev1/repair_overlay/scriptu…
Oleksii-debug Sep 29, 2026
16c089b
Reconverge #264 with packaged #265: lanes/dev1/repair_overlay/scriptu…
Oleksii-debug Sep 29, 2026
f4367e8
Reconverge #264 with packaged #265: lanes/dev1/repair_overlay/tests/t…
Oleksii-debug Sep 29, 2026
d1d4927
Reconverge #264 with packaged #265: lanes/dev1/repair_overlay/tests/t…
Oleksii-debug Sep 29, 2026
a0a5de0
Reconverge #264 with packaged #265: lanes/dev1/repair_overlay/tests/t…
Oleksii-debug Sep 29, 2026
e77678c
Reconverge #264 with packaged #267: lanes/dev1/repair_overlay/scriptu…
Oleksii-debug Sep 29, 2026
1eae1b2
Reconverge #264 with packaged #267: lanes/dev1/repair_overlay/scriptu…
Oleksii-debug Sep 29, 2026
11a84dd
Reconverge #264 with packaged #267: lanes/dev1/repair_overlay/scriptu…
Oleksii-debug Sep 29, 2026
7b68a8c
Reconverge #264 with packaged #267: lanes/dev1/repair_overlay/tests/t…
Oleksii-debug Sep 29, 2026
c5e6f72
Reconverge #264 with packaged #267: lanes/dev1/repair_overlay/tests/t…
Oleksii-debug Sep 29, 2026
69fb139
Reconverge #264 with packaged #267: lanes/dev1/repair_overlay/tests/t…
Oleksii-debug Sep 29, 2026
9b958e2
Reconverge #264 onto packaged #266 authority
Oleksii-debug Sep 29, 2026
4f2d57d
Reconverge #264 onto packaged #258 authority
Oleksii-debug Sep 29, 2026
6a7abc6
Reconverge #264 onto packaged #255 authority
Oleksii-debug Sep 29, 2026
45fe631
Reconverge #264 onto packaged #272 qualification authority
Oleksii-debug Sep 29, 2026
60d9334
merge: reconverge Constructor V2 failure safety on packaged authority
Oleksii-debug Sep 30, 2026
187bf51
merge: reconverge Constructor V2 after Content Pack integration
Oleksii-debug Sep 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 31 additions & 24 deletions lanes/dev1/repair_overlay/frontend/constructor-v2-ui.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import {chooseTransport,unwrap} from './transport.js';

const $=id=>document.getElementById(id);
let transport=null,mounted=false;
let transport=null,mounted=false,busy=false;

async function api(command,payload={}){return await unwrap(transport,command,payload)}
function announce(text){const host=$('global-status');if(host){host.textContent='';requestAnimationFrame(()=>host.textContent=text)}}
function currentDraftId(){const value=$('draft-id')?.value?.trim();if(!value)throw new Error('Спочатку відкрийте збережену чернетку.');return value}
function makeButton(label,handler){const button=document.createElement('button');button.type='button';button.textContent=label;button.onclick=handler;return button}
function announce(message,isError=false){const host=$('global-status');if(host){host.textContent='';host.dataset.state=isError?'error':'ok';requestAnimationFrame(()=>host.textContent=message)}}
function reportFailure(context,message,error){console.error(context,error);announce(message,true)}
function currentDraftId(){const input=$('draft-id');const value=input?.value?.trim();if(value)return value;announce('Спочатку відкрийте збережену чернетку.',true);input?.focus();return null}
function makeButton(label,handler){const button=document.createElement('button');button.type='button';button.textContent=label;button.dataset.constructorV2Action='true';button.disabled=busy;button.onclick=handler;return button}
function text(tag,value){const el=document.createElement(tag);el.textContent=value;return el}
function syncDraftList(){const nav=$('nav-authoring');if(nav)nav.click()}
function setBusy(value){busy=value;const panel=$('constructor-v2-panel');if(panel)panel.setAttribute('aria-busy',value?'true':'false');document.querySelectorAll('[data-constructor-v2-action="true"]').forEach(button=>{button.disabled=value})}
async function serialize(operation){if(busy)return;setBusy(true);try{await operation()}finally{setBusy(false)}}

async function refreshHistory(){
const output=$('constructor-v2-output');
if(!output)return;
output.replaceChildren();
let draftId;
try{draftId=currentDraftId()}catch(error){output.append(text('p',error.message));return}
const draftId=currentDraftId();
if(!draftId){output.append(text('p','Спочатку відкрийте збережену чернетку.'));return}
try{
const history=await api('authoring.history',{draft_id:draftId});
output.append(text('p',`Revision ${history.revision}. Undo: ${history.can_undo?'так':'ні'}. Redo: ${history.can_redo?'так':'ні'}.`));
Expand All @@ -30,12 +33,12 @@ async function refreshHistory(){
for(const row of history.snapshots||[]){
const li=document.createElement('li');
li.append(document.createTextNode(`${row.label||row.snapshot_id} · revision ${row.draft_revision??'—'} `));
li.append(makeButton('Diff до поточної',async()=>{
try{const diff=await api('authoring.diff_draft',{draft_id:draftId,from_snapshot_id:row.snapshot_id});announce(diff.changed?`Змінено шляхів: ${diff.changed_paths.length}`:'Відмінностей немає');const pre=document.createElement('pre');pre.textContent=(diff.changed_paths||[]).join('\n')||'No changes';li.append(pre)}catch(error){announce(`Constructor: ${error.message}`)}
}));
li.append(makeButton('Відновити snapshot',async()=>{
try{await api('authoring.restore_snapshot',{draft_id:draftId,snapshot_id:row.snapshot_id});announce('Snapshot відновлено як нову revision; попередній стан збережено safety snapshot. Перевідкрийте чернетку.');syncDraftList();await refreshHistory()}catch(error){announce(`Constructor: ${error.message}`)}
}));
li.append(makeButton('Diff до поточної',()=>serialize(async()=>{
try{const diff=await api('authoring.diff_draft',{draft_id:draftId,from_snapshot_id:row.snapshot_id});announce(diff.changed?`Змінено шляхів: ${diff.changed_paths.length}`:'Відмінностей немає');const pre=document.createElement('pre');pre.textContent=(diff.changed_paths||[]).join('\n')||'No changes';li.append(pre)}catch(error){reportFailure('Constructor snapshot diff failed','Не вдалося порівняти snapshot із поточною чернеткою.',error)}
})));
li.append(makeButton('Відновити snapshot',()=>serialize(async()=>{
try{await api('authoring.restore_snapshot',{draft_id:draftId,snapshot_id:row.snapshot_id});announce('Snapshot відновлено як нову revision; попередній стан збережено safety snapshot. Перевідкрийте чернетку.');syncDraftList();await refreshHistory()}catch(error){reportFailure('Constructor snapshot restore failed','Не вдалося відновити snapshot.',error)}
})));
snapshots.append(li);
}
if(!snapshots.children.length)snapshots.append(text('li','Snapshots ще немає.'));
Expand All @@ -46,37 +49,41 @@ async function refreshHistory(){
for(const row of history.versions||[]){
const li=document.createElement('li');
li.append(document.createTextNode(`${row.version_id} · source revision ${row.draft_revision??'—'} · canonical write: ні `));
li.append(makeButton('Rollback у draft',async()=>{
try{await api('authoring.rollback_version',{draft_id:draftId,version_id:row.version_id});announce('Version artifact відновлено у draft як нову revision; canonical content не змінено. Перевідкрийте чернетку.');syncDraftList();await refreshHistory()}catch(error){announce(`Constructor: ${error.message}`)}
}));
li.append(makeButton('Rollback у draft',()=>serialize(async()=>{
try{await api('authoring.rollback_version',{draft_id:draftId,version_id:row.version_id});announce('Version artifact відновлено у draft як нову revision; canonical content не змінено. Перевідкрийте чернетку.');syncDraftList();await refreshHistory()}catch(error){reportFailure('Constructor version rollback failed','Не вдалося відновити version artifact у draft.',error)}
})));
versions.append(li);
}
if(!versions.children.length)versions.append(text('li','Version artifacts ще немає.'));
output.append(versions);
}catch(error){output.append(text('p',`Не вдалося прочитати Constructor history: ${error.message}`))}
}catch(error){console.error('Constructor history refresh failed',error);output.append(text('p','Не вдалося прочитати Constructor history.'));announce('Не вдалося прочитати Constructor history.',true)}
}

async function mutate(command,message){
try{const draftId=currentDraftId();await api(command,{draft_id:draftId});announce(message);syncDraftList();await refreshHistory()}catch(error){announce(`Constructor: ${error.message}`)}
return await serialize(async()=>{
const draftId=currentDraftId();if(!draftId)return;
try{await api(command,{draft_id:draftId});announce(message);syncDraftList();await refreshHistory()}catch(error){reportFailure(`Constructor mutation failed: ${command}`,'Не вдалося виконати Constructor operation.',error)}
})
}

async function installConstructorV2Surface(){
if(mounted)return;
const form=$('authoring-form');
if(!form)return;
try{transport=chooseTransport();const bootstrap=await api('system.bootstrap');if(!bootstrap?.capabilities?.constructor_v2_history)return}catch(_error){return}
try{transport=chooseTransport();const bootstrap=await api('system.bootstrap');if(!bootstrap?.capabilities?.constructor_v2_history)return}catch(error){console.error('Constructor V2 mount failed',error);return}
mounted=true;
const actions=form.querySelector('.sticky-actions')||form;
actions.append(
makeButton('Snapshot',async()=>{try{const draftId=currentDraftId();await api('authoring.create_snapshot',{draft_id:draftId,label:'Manual snapshot'});announce('Snapshot збережено.');await refreshHistory()}catch(error){announce(`Constructor: ${error.message}`)}}),
makeButton('Snapshot',()=>serialize(async()=>{const draftId=currentDraftId();if(!draftId)return;try{await api('authoring.create_snapshot',{draft_id:draftId,label:'Manual snapshot'});announce('Snapshot збережено.');await refreshHistory()}catch(error){reportFailure('Constructor snapshot create failed','Не вдалося створити snapshot.',error)}})),
makeButton('Undo saved',()=>mutate('authoring.undo','Undo виконано як нову persisted revision. Перевідкрийте чернетку.')),
makeButton('Redo saved',()=>mutate('authoring.redo','Redo виконано як нову persisted revision. Перевідкрийте чернетку.')),
makeButton('History / versions',refreshHistory),
makeButton('Publish saved version',async()=>{
try{const draftId=currentDraftId();const compatibility=(await api('authoring.pack_compatibility',{})).compatibility;const result=await api('authoring.publish_version',{draft_id:draftId,compatibility});announce(`Version artifact ${result.version.version_id} створено. Canonical content не змінено.`);await refreshHistory()}catch(error){announce(`Constructor publish: ${error.message}`)}
}),
makeButton('History / versions',()=>serialize(refreshHistory)),
makeButton('Publish saved version',()=>serialize(async()=>{
const draftId=currentDraftId();if(!draftId)return;
try{const compatibility=(await api('authoring.pack_compatibility',{})).compatibility;const result=await api('authoring.publish_version',{draft_id:draftId,compatibility});announce(`Version artifact ${result.version.version_id} створено. Canonical content не змінено.`);await refreshHistory()}catch(error){reportFailure('Constructor publish failed','Не вдалося створити version artifact.',error)}
})),
);
const section=document.createElement('section');section.id='constructor-v2-panel';section.className='surface subtle';section.setAttribute('aria-labelledby','constructor-v2-heading');
const section=document.createElement('section');section.id='constructor-v2-panel';section.className='surface subtle';section.setAttribute('aria-labelledby','constructor-v2-heading');section.setAttribute('aria-busy','false');
const heading=text('h3','Constructor V2 — історія та версії');heading.id='constructor-v2-heading';heading.tabIndex=-1;
const note=text('p','Операції працюють лише зі збереженою draft revision. Publish створює version artifact для explicit integration review і ніколи не записує canonical source-audited corpus напряму.');
const output=document.createElement('div');output.id='constructor-v2-output';output.setAttribute('aria-live','polite');
Expand Down
20 changes: 20 additions & 0 deletions lanes/dev1/repair_overlay/tests/test_constructor_v2_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@ def test_surface_is_semantic_keyboard_native_and_never_uses_unsafe_html(self):
self.assertNotIn("eval(", self.source)
self.assertNotIn("new Function", self.source)

def test_failure_surface_is_sanitized_focusable_and_single_flight(self):
self.assertNotIn("error.message", self.source)
self.assertIn("console.error(context,error)", self.source)
self.assertIn("input?.focus()", self.source)
self.assertIn("button.dataset.constructorV2Action='true'", self.source)
self.assertIn("if(busy)return", self.source)
self.assertIn("setAttribute('aria-busy'", self.source)
self.assertIn("button.disabled=value", self.source)
self.assertIn("Спочатку відкрийте збережену чернетку.", self.source)
for message in (
"Не вдалося прочитати Constructor history.",
"Не вдалося порівняти snapshot із поточною чернеткою.",
"Не вдалося відновити snapshot.",
"Не вдалося відновити version artifact у draft.",
"Не вдалося виконати Constructor operation.",
"Не вдалося створити snapshot.",
"Не вдалося створити version artifact.",
):
self.assertIn(message, self.source)

def test_module_is_mounted_by_existing_transport_additive_pattern(self):
transport = (self.frontend / "transport.js").read_text(encoding="utf-8")
self.assertIn("./constructor-v2-ui.js", transport)
Expand Down
Loading