rtl-analyzer 0.3.0 → 0.4.0
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 +76 -66
- package/dist/contextual-preview-bridge.js +16 -11
- package/dist/contextual-preview.js +3 -3
- package/dist/css-configured-proposal.js +98 -0
- package/dist/css-spacing.js +10 -9
- package/dist/dashboard-batch-review.js +37 -0
- package/dist/dashboard-client.js +28 -22
- package/dist/dashboard-contextual-preview.js +14 -6
- package/dist/dashboard-data.js +3 -3
- package/dist/dashboard-embedded-preview.js +8 -6
- package/dist/dashboard-html.js +3 -1
- package/dist/dashboard-operation-flow.js +47 -0
- package/dist/dashboard-review-navigation.js +19 -0
- package/dist/dashboard-review-workflow.js +99 -31
- package/dist/dashboard-themes.js +34 -0
- package/dist/original-preview-runtime.js +12 -2
- package/dist/page-navigation.js +17 -0
- package/dist/policy-validation.js +6 -3
- package/dist/preview-companion.js +37 -9
- package/dist/preview-configuration.js +35 -8
- package/dist/preview-runtime.js +13 -9
- package/dist/review-session.js +10 -0
- package/dist/review-workflow.js +297 -31
- package/dist/rules.js +13 -4
- package/dist/scoped-direction-evidence.js +117 -0
- package/dist/transformations.js +14 -0
- package/dist/validation.js +6 -2
- package/package.json +2 -2
|
@@ -53,7 +53,7 @@ const embeddedReview=(()=>{
|
|
|
53
53
|
current.items[0].panel.querySelector('.preview-identity').textContent='Before';current.items[1].panel.querySelector('.preview-identity').textContent='After';current.items.forEach(item=>renderPreviewBadges(item.panel.querySelector('.preview-status'),current.record,item.role));
|
|
54
54
|
}
|
|
55
55
|
function syncRoute(current){
|
|
56
|
-
if(current.record.contextual){const route=current.record.contextInfo?.route,verified=current.items.some(item=>['verified','document'].includes(item.state.dataset.contextStatus));const actual=current.items.find(item=>item.currentRoute)?.currentRoute;const label=route?'Route: '+(current.record.historical?'Current source ':'')+(actual||route.path)+' · '+(verified?'Verified target':'Configured · target unverified'):'Route: Unverified · no mapping';setText(current.workspace.querySelector('.preview-current-route'),label);const compact=current.component.querySelector('.component-toolbar > span');if(compact)setText(compact,label);return}
|
|
56
|
+
if(current.record.contextual){const route=current.record.contextInfo?.route,verified=current.items.some(item=>['verified','document'].includes(item.state.dataset.contextStatus));const actual=current.items.find(item=>item.currentRoute)?.currentRoute;const label=route?'Route: '+(current.record.historical?'Current source ':'')+(actual||route.path)+' · '+(current.record.contextInfo?.mapping?.kind==='document'?'Page context · source mapping not verified':verified?'Verified target':'Configured · target unverified'):'Route: Unverified · no mapping';setText(current.workspace.querySelector('.preview-current-route'),label);const compact=current.component.querySelector('.component-toolbar > span');if(compact)setText(compact,label);return}
|
|
57
57
|
const route=current.items.find(item=>item.currentRoute)?.currentRoute;const label='Route: '+(route||'Unverified');setText(current.workspace.querySelector('.preview-current-route'),label);const compact=current.component.querySelector('.component-toolbar > span');if(compact)setText(compact,label);
|
|
58
58
|
}
|
|
59
59
|
function removeView(){if(view){closeWorkspace(view);clearInterval(view.poll);for(const item of view.items){clearTimeout(item.timeout);item.observer.disconnect()}view=null}}
|
|
@@ -96,10 +96,10 @@ const embeddedReview=(()=>{
|
|
|
96
96
|
function load(item,url,record,f,hash){
|
|
97
97
|
if(!originAllowed(url,item.role))throw Error('UNAPPROVED_PREVIEW_ORIGIN');
|
|
98
98
|
if(item.url===url&&item.expectedHash===hash&&item.frame&&(!record.contextual||item.loadedRuntimeSessionId===item.context?.runtimeSessionId)&&(!record.contextual||!item.contextReport||item.contextReport.dir===record.mode)&&(item.role==='original'||item.runtimeSessionId===record.session?.id)){item.frame.dataset.sessionId=record.session?.id||'before-only';return}
|
|
99
|
-
clearTimeout(item.timeout);item.ready=null;item.contextReport=null;item.lastVerifiedReport=null;item.url=url;item.currentRoute=new URL(url).pathname;item.expectedHash=hash;item.runtimeSessionId=record.session?.id;item.loadedRuntimeSessionId=item.context?.runtimeSessionId;item.nonce=crypto.randomUUID();
|
|
99
|
+
clearTimeout(item.timeout);item.ready=null;item.contextReport=null;item.lastVerifiedReport=null;item.url=url;item.currentRoute=new URL(url).pathname;item.expectedHash=hash;item.runtimeSessionId=record.session?.id;item.loadedRuntimeSessionId=item.context?.runtimeSessionId;item.nonce=crypto.randomUUID();item.directionRevision=0;
|
|
100
100
|
item.state.textContent='Loading live '+item.role+' route…';item.state.dataset.state='loading';
|
|
101
101
|
const pending=()=>{clearTimeout(item.timeout);item.ready=null;item.state.dataset.state='loading';if(record.contextual)item.state.dataset.contextStatus='loading-route';item.state.textContent='Checking the live application and current contextual target…';item.timeout=setTimeout(()=>{if(live(record,item.box)&&!item.ready){item.state.textContent=item.contextReport?item.state.textContent:'Embedding blocked or local preview bridge unavailable. Retry context or restart the scoped application runtime.';item.state.dataset.state='error';if(record.contextual){if(!item.contextReport)item.state.dataset.contextStatus='runtime-unavailable';updateCandidateAction(view)}}},12000)};
|
|
102
|
-
const frame=document.createElement('iframe');frame.title=item.role==='original'?(record.historical?'Current source: application route':'Before: original application route'):'After: isolated candidate application route';frame.dataset.findingId=f.id;frame.dataset.sessionId=record.session?.id||'before-only';frame.setAttribute('sandbox','allow-scripts allow-same-origin allow-forms');if(record.contextual)frame.name='rtl-preview:'+record.dataId;frame.src=url;item.frame=frame;item.box.replaceChildren(frame);resize(item,record);frame.onload=()=>{pending();probe(item,record,f)};
|
|
102
|
+
const frame=document.createElement('iframe');frame.title=item.role==='original'?(record.historical?'Current source: application route':'Before: original application route'):'After: isolated candidate application route';frame.dataset.findingId=f.id;frame.dataset.sessionId=record.session?.id||'before-only';frame.setAttribute('sandbox','allow-scripts allow-same-origin allow-forms');if(record.contextual)frame.name='rtl-preview:'+record.dataId;frame.src=url;item.frame=frame;item.box.replaceChildren(frame);resize(item,record);frame.onload=()=>{if(item.frame!==frame)return;item.nonce=crypto.randomUUID();item.directionRevision=0;item.ready=null;item.contextReport=null;item.lastVerifiedReport=null;item.verifiedMapping=null;pending();probe(item,record,f)};
|
|
103
103
|
pending();
|
|
104
104
|
}
|
|
105
105
|
${contextualPreviewClientSource}
|
|
@@ -160,7 +160,7 @@ const embeddedReview=(()=>{
|
|
|
160
160
|
const restored=payload.workflow||!button?null:sessionStorage.getItem('rtl-preview:'+identity);
|
|
161
161
|
if(restored&&!record.session){button.disabled=true;request('/review/sessions/'+encodeURIComponent(restored)).then(info=>{if(info.source!==f.path||info.originalSha256!==payload.sourceSha256||info.findingId!==f.id||!info.candidateSha256)throw Error('STALE_PREVIEW_SESSION');record.session=info;record.patched={candidateSha256:info.candidateSha256};record.runtime=info.runtime?.status==='healthy'?{id:info.id,runtime:info.runtime,candidateOrigin:info.runtime.origin}:null;if(live(record,button)){button.textContent=record.runtime?'Open candidate preview':'Retry candidate preview';routes(record,f,current)}}).catch(()=>sessionStorage.removeItem('rtl-preview:'+identity)).finally(()=>{if(live(record,button))button.disabled=false})}
|
|
162
162
|
}
|
|
163
|
-
const style=el('style');style.textContent="\n.component-frame:has(.embedded-state:not([data-context-status=verified])){background:#18283e!important;border-color:#4a627f!important;color:#c8d5e7!important}.component-frame:has(.embedded-state[data-state=error]){border-color:#c15b70!important}.after-card{background:#18283e!important;border-color:#4a627f!important}.after-card pre{color:#d1deef!important}\n.embedded-viewport{position:relative;overflow:hidden;width:100%;min-height:0;background:#fff;border-radius:5px}\n.embedded-viewport iframe{display:block;border:0;max-width:none!important;background:white}\n.embedded-state{margin:5px 0!important;min-height:25px}\n.component-frame{overflow:hidden}.component-after{background:#18283e!important;border-color:#4a627f!important;color:#dce7fb!important}.component-frame h3{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.preview-identity{font-size:12px}.preview-status{display:flex;gap:4px;flex-wrap:wrap;color:#b8c9df;font-size:10px;letter-spacing:0;text-transform:none;font-weight:500;flex:1}.preview-badge{border:1px solid #4a627f;border-radius:99px;padding:2px 6px;background:#182b44}.preview-badge[data-status=Passed]{color:#6fe4b2;border-color:#398668}.preview-badge[data-status=Failed]{color:#ff99a8;border-color:#a64b5a}.preview-badge[data-status~=Limited]{color:#ffd166;border-color:#987524}.component-frame h3 .context-instance{order:3;margin-left:auto}.component-frame h3 .preview-frame-expand{order:4}.context-preview-controls .context-retry{background:transparent;border-color:transparent;color:#a9bbd3;text-decoration:underline;text-underline-offset:3px}.context-preview-controls button{background:#142944;color:#c5d0e0;border:1px solid #405775;border-radius:5px;padding:4px 6px;font-size:10px}.preview-diagnostics{margin:4px 0;color:#b9c9df;font-size:10px}.preview-diagnostics summary{cursor:pointer}.component-review .component-helper{display:block!important}\n.component-review .component-compare{grid-template-columns:minmax(0,1fr) auto minmax(0,1fr)!important}\n.preview-frame-expand{flex:none;min-width:28px;min-height:26px;border:1px solid currentColor;border-radius:5px;background:transparent;color:inherit;font-size:19px;cursor:pointer}\n.preview-workspace-toolbar{display:none}\n.component-review.embedded-expanded{position:fixed!important;inset:0!important;width:auto!important;height:auto!important;max-height:none!important;z-index:10000;overflow:hidden!important;background:#0e1a2d!important;padding:8px!important;margin:0!important;border-radius:0!important;display:flex!important;flex-direction:column!important;box-sizing:border-box;gap:8px}\n.embedded-expanded>:not(.preview-workspace-toolbar):not(.component-compare){display:none!important}\n.embedded-expanded .preview-workspace-toolbar{display:flex;flex:none;align-items:center;gap:12px;flex-wrap:wrap;min-height:36px;color:#dce7fb;font-size:12px}\n.preview-workspace-toolbar button,.preview-workspace-toolbar select{min-height:32px;padding:5px 11px;border:1px solid #547297;border-radius:6px;background:#142944;color:#e9f0ff;font:inherit;cursor:pointer}\n.preview-workspace-toolbar button[aria-pressed=true]{background:#6641ae;border-color:#c5a6ff;color:white}\n.preview-view-options,.preview-direction-options{display:flex;gap:4px}\n.preview-current-route{flex:1;min-width:110px;overflow-wrap:anywhere}\n.preview-workspace-close{margin-left:auto;background:#392640!important;border-color:#bc8da9!important}\n.embedded-expanded .component-compare{flex:1;min-height:0;gap:8px;grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important}\n.embedded-expanded .component-arrow{display:none!important}\n.embedded-expanded .component-frame{min-height:0;padding:7px;gap:3px}\n.embedded-expanded .component-frame h3{flex:none;align-items:center;margin:0!important;min-height:26px;font-size:12px!important}\n.embedded-expanded .preview-frame-expand{display:none}\n.embedded-expanded .embedded-state{flex:none;min-height:16px;font-size:10px!important;margin:0 0 3px!important}\n.embedded-expanded .embedded-viewport{flex:1;min-height:0;height:auto;overflow:auto;overscroll-behavior:contain;border-radius:3px}\n.embedded-expanded[data-preview-view=before] .component-after,.embedded-expanded[data-preview-view=after] .component-before{display:none!important}\n.embedded-expanded[data-preview-view=before] .component-compare,.embedded-expanded[data-preview-view=after] .component-compare{grid-template-columns:minmax(0,1fr)!important}\n.context-preview-controls{display:flex;align-items:center;gap:5px;flex-wrap:wrap}.context-preview-controls select,.context-instance{max-width:260px;min-width:90px;border:1px solid #547297;border-radius:5px;background:#142944;color:#e9f0ff;font-size:11px;padding:4px}.context-instance{max-width:40%;min-width:70px}.preview-context-summary{color:#c8d4eb;font-size:11px;flex:1;min-width:150px}.preview-workspace-toolbar .context-preview-controls .context-retry{background:transparent;border-color:transparent;color:#a9bbd3;text-decoration:underline;text-underline-offset:3px}.context-preview-controls button{padding:4px 7px;font-size:11px}.preview-workspace-toolbar :focus-visible,.preview-frame-expand:focus-visible{outline:2px solid #dcc4ff;outline-offset:2px}@media(max-width:760px){.component-review:not(.embedded-expanded) .component-compare{grid-template-columns:minmax(0,1fr)!important}.component-review:not(.embedded-expanded) .component-arrow{transform:rotate(90deg);justify-self:center}}\n";document.head.append(style);
|
|
163
|
+
const style=el('style');style.textContent=".component-review[data-mapping-missing=true] .component-toolbar,.component-review[data-mapping-missing=true] .preview-diagnostics,.component-review[data-mapping-missing=true] .component-helper{display:none!important}.mapping-unavailable{padding:8px 0;color:#c8d5e7}.mapping-unavailable h3{font-size:14px;margin:0 0 6px}.mapping-unavailable p{line-height:1.5;margin:0}\n.component-frame:has(.embedded-state:not([data-context-status=verified])){background:#18283e!important;border-color:#4a627f!important;color:#c8d5e7!important}.component-frame:has(.embedded-state[data-state=error]){border-color:#c15b70!important}.after-card{background:#18283e!important;border-color:#4a627f!important}.after-card pre{color:#d1deef!important}\n.embedded-viewport{position:relative;overflow:hidden;width:100%;min-height:0;background:#fff;border-radius:5px}\n.embedded-viewport iframe{display:block;border:0;max-width:none!important;background:white}\n.embedded-state{margin:5px 0!important;min-height:25px}\n.component-frame{overflow:hidden}.component-after{background:#18283e!important;border-color:#4a627f!important;color:#dce7fb!important}.component-frame h3{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.preview-identity{font-size:12px}.preview-status{display:flex;gap:4px;flex-wrap:wrap;color:#b8c9df;font-size:10px;letter-spacing:0;text-transform:none;font-weight:500;flex:1}.preview-badge{border:1px solid #4a627f;border-radius:99px;padding:2px 6px;background:#182b44}.preview-badge[data-status=Passed]{color:#6fe4b2;border-color:#398668}.preview-badge[data-status=Failed]{color:#ff99a8;border-color:#a64b5a}.preview-badge[data-status~=Limited]{color:#ffd166;border-color:#987524}.component-frame h3 .context-instance{order:3;margin-left:auto}.component-frame h3 .preview-frame-expand{order:4}.context-preview-controls .context-retry{background:transparent;border-color:transparent;color:#a9bbd3;text-decoration:underline;text-underline-offset:3px}.context-preview-controls button{background:#142944;color:#c5d0e0;border:1px solid #405775;border-radius:5px;padding:4px 6px;font-size:10px}.preview-diagnostics{margin:4px 0;color:#b9c9df;font-size:10px}.preview-diagnostics summary{cursor:pointer}.component-review .component-helper{display:block!important}\n.component-review .component-compare{grid-template-columns:minmax(0,1fr) auto minmax(0,1fr)!important}\n.preview-frame-expand{flex:none;min-width:28px;min-height:26px;border:1px solid currentColor;border-radius:5px;background:transparent;color:inherit;font-size:19px;cursor:pointer}\n.preview-workspace-toolbar{display:none}\n.component-review.embedded-expanded{position:fixed!important;inset:0!important;width:auto!important;height:auto!important;max-height:none!important;z-index:10000;overflow:hidden!important;background:#0e1a2d!important;padding:8px!important;margin:0!important;border-radius:0!important;display:flex!important;flex-direction:column!important;box-sizing:border-box;gap:8px}\n.embedded-expanded>:not(.preview-workspace-toolbar):not(.component-compare){display:none!important}\n.embedded-expanded .preview-workspace-toolbar{display:flex;flex:none;align-items:center;gap:12px;flex-wrap:wrap;min-height:36px;color:#dce7fb;font-size:12px}\n.preview-workspace-toolbar button,.preview-workspace-toolbar select{min-height:32px;padding:5px 11px;border:1px solid #547297;border-radius:6px;background:#142944;color:#e9f0ff;font:inherit;cursor:pointer}\n.preview-workspace-toolbar button[aria-pressed=true]{background:#6641ae;border-color:#c5a6ff;color:white}\n.preview-view-options,.preview-direction-options{display:flex;gap:4px}\n.preview-current-route{flex:1;min-width:110px;overflow-wrap:anywhere}\n.preview-workspace-close{margin-left:auto;background:#392640!important;border-color:#bc8da9!important}\n.embedded-expanded .component-compare{flex:1;min-height:0;gap:8px;grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important}\n.embedded-expanded .component-arrow{display:none!important}\n.embedded-expanded .component-frame{min-height:0;padding:7px;gap:3px}\n.embedded-expanded .component-frame h3{flex:none;align-items:center;margin:0!important;min-height:26px;font-size:12px!important}\n.embedded-expanded .preview-frame-expand{display:none}\n.embedded-expanded .embedded-state{flex:none;min-height:16px;font-size:10px!important;margin:0 0 3px!important}\n.embedded-expanded .embedded-viewport{flex:1;min-height:0;height:auto;overflow:auto;overscroll-behavior:contain;border-radius:3px}\n.embedded-expanded[data-preview-view=before] .component-after,.embedded-expanded[data-preview-view=after] .component-before{display:none!important}\n.embedded-expanded[data-preview-view=before] .component-compare,.embedded-expanded[data-preview-view=after] .component-compare{grid-template-columns:minmax(0,1fr)!important}\n.context-preview-controls{display:flex;align-items:center;gap:5px;flex-wrap:wrap}.context-preview-controls select,.context-instance{max-width:260px;min-width:90px;border:1px solid #547297;border-radius:5px;background:#142944;color:#e9f0ff;font-size:11px;padding:4px}.context-instance{max-width:40%;min-width:70px}.preview-context-summary{color:#c8d4eb;font-size:11px;flex:1;min-width:150px}.preview-workspace-toolbar .context-preview-controls .context-retry{background:transparent;border-color:transparent;color:#a9bbd3;text-decoration:underline;text-underline-offset:3px}.context-preview-controls button{padding:4px 7px;font-size:11px}.preview-workspace-toolbar :focus-visible,.preview-frame-expand:focus-visible{outline:2px solid #dcc4ff;outline-offset:2px}@media(max-width:760px){.component-review:not(.embedded-expanded) .component-compare{grid-template-columns:minmax(0,1fr)!important}.component-review:not(.embedded-expanded) .component-arrow{transform:rotate(90deg);justify-self:center}}\n";document.head.append(style);
|
|
164
164
|
document.addEventListener('keydown',event=>{
|
|
165
165
|
if(!view?.expanded)return;
|
|
166
166
|
if(event.key==='Escape'){event.preventDefault();closeWorkspace();return}
|
|
@@ -182,14 +182,16 @@ const embeddedReview=(()=>{
|
|
|
182
182
|
const verified=item=>!!item.frame&&item.contextReport?.route===info?.route?.path&&item.contextReport?.dir===r.mode&&((['verified','document'].includes(item.state.dataset.contextStatus)||item.state.dataset.contextStatus==='target-selection-required'&&item.contextReport?.routeReady&&['verified','document'].includes(item.contextReport?.targetStatus)&&(!info?.mapping.configured||!info.mapping.sourceSelector||item.contextReport.sourceStatus==='source-rule-matched'))||panelHidden(item)&&item.lastVerifiedReport?.nonce===item.nonce&&item.lastVerifiedReport?.routeId===r.routeId&&item.lastVerifiedReport?.dir===r.mode);
|
|
183
183
|
const proof=before.verifiedMapping,p=before.contextReport,bindingVerified=!!before.frame&&panelHidden(before)&&proof?.sourceHash===before.expectedHash&&proof?.routeId===r.routeId&&p?.route===info?.route?.path&&p?.dir===r.mode&&p?.routeReady&&p?.targets?.length>0&&(!info?.mapping.configured||!info.mapping.sourceSelector||p.sourceStatus==='source-rule-matched');
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
const selectedDirection=item=>item.contextReport?.targets?.find(t=>t.index===item.instance)?.effectiveDirection;
|
|
186
|
+
const directionMatch=!!selectedDirection(before)&&selectedDirection(before)===selectedDirection(after);
|
|
187
|
+
return {resolving:!!r.contextResolving,application:info?.route?.application,routeId:r.routeId,bindingVerified:!!bindingVerified,verified:!r.contextResolving&&!!info?.route&&before.contextReport?.routeId===r.routeId&&before.contextReport?.dir===r.mode&&verified(before),blocked:['mapping-missing','source-not-loaded','target-mismatch','missing-target','unresolved'].includes(status)||status==='hidden'&&!panelHidden(before),failed:before.state.dataset.state==='error'||status==='runtime-unavailable',reason:before.state.textContent,candidateAvailable:!!info?.candidate?.available,candidateReady:verified(before)&&verified(after)&&directionMatch,candidateFailed:after.state.dataset.state==='error',candidateReason:after.state.textContent};
|
|
186
188
|
}
|
|
187
189
|
function preparation(f,value){
|
|
188
190
|
const record=records.get(key(f));if(!record||selected!==record.key||view?.record!==record)return;record.preparation=value;const current=view,after=current.items[1];after.state.dataset.preparationState=value.state;
|
|
189
191
|
current.component.querySelector('[data-preview-retry]')?.remove();if(value.state==='unsupported'&&['Rejected','Deferred','Flagged'].includes(record.decision)&&record.manualPrepare&&!record.historical){const reconsider=el('button','Reconsider preview');reconsider.dataset.previewRetry='true';reconsider.disabled=!!value.busy;reconsider.onclick=record.manualPrepare;after.state.after(reconsider);}if(value.state==='failed'){const button=el('button','Retry preview');button.dataset.previewRetry='true';button.disabled=!!value.busy;button.onclick=record.retryPreview;after.state.after(button);}
|
|
190
192
|
if(value.state!=='ready'){
|
|
191
193
|
if(['failed','unsupported'].includes(value.state)){clearTimeout(after.timeout);after.box.replaceChildren();after.frame=null;after.ready=null;clearContextTargets(after);after.state.dataset.state=value.state==='failed'?'error':'unavailable';}
|
|
192
|
-
if(!after.targetRestoreFailed)setText(after.state,value.state==='failed'?'Preview preparation failed: '+value.reason+'. Retry preview.':value.state==='unsupported'?'
|
|
194
|
+
if(!after.targetRestoreFailed)setText(after.state,value.state==='failed'?'Preview preparation failed: '+value.reason+'. Retry preview.':value.state==='unsupported'?'Manual review required · No supported candidate preview. '+value.reason:value.reason||'Preparing isolated preview…');
|
|
193
195
|
}
|
|
194
196
|
syncControls(current);
|
|
195
197
|
}
|
package/dist/dashboard-html.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { dashboardThemeTokens, dashboardThemeDefinitions } from './dashboard-themes.js';
|
|
2
|
+
import { themeClientSource } from './dashboard-themes.js';
|
|
1
3
|
import { dashboardClientSource } from './dashboard-client.js';
|
|
2
4
|
import { severityDisplayLabel, toDashboardData } from './dashboard-data.js';
|
|
3
5
|
const escapeJson = (v) => v.replace(/[<>&\u2028\u2029]/g, c => ({ '<': '\\u003c', '>': '\\u003e', '&': '\\u0026', '\u2028': '\\u2028', '\u2029': '\\u2029' }[c] ?? c));
|
|
@@ -25,4 +27,4 @@ const css = `.stats-toggle{background:linear-gradient(180deg,#8447ed,#4e1da0)!im
|
|
|
25
27
|
@media(max-width:760px){.app{grid-template-rows:auto auto auto auto 1fr}.top{flex-wrap:wrap;min-height:118px;padding:10px 14px}.brand{min-width:0;flex:1;font-size:17px}.nav{order:3;width:100%;overflow:auto}.nav button{min-height:42px}.tools{width:100%;margin-left:0}.tools input{flex:1;width:auto}.finding-filters{display:flex;padding:0 10px 10px;align-items:stretch}.filter-control{flex:1 1 calc(50% - 8px);min-width:140px}.filter-control select,.finding-filters>button{width:100%;min-height:44px}.finding-filters>button{flex:1 1 100%}.filter-summary{width:100%;margin:0}.summary{grid-template-columns:repeat(2,1fr);padding:10px}.summary .card{min-height:72px;padding:10px}.summary .card strong{font-size:21px}.severity-chart{grid-column:auto}.scope-row{padding:0 10px 10px}.scope{align-items:stretch;flex-wrap:wrap}.scope select{min-width:100%;min-height:44px}.projects{display:none}.workspace{display:flex;flex-direction:column;margin:0 10px 10px;border-radius:12px}.pane{width:100%}.head{min-height:45px}.scroll{height:calc(100% - 45px)}.details{padding:14px}.details h2{font-size:18px;overflow-wrap:anywhere}.details h3{margin-top:14px}.mobile-back{display:inline-flex!important;align-items:center;min-height:44px;margin-bottom:10px;background:#253b5d!important;border-color:#5778a9!important}.actions button,.actions a{min-height:44px}.review-diff,.code-scroll,.meta,.validation-results,.evidence-grid,.audit-grid{overflow-wrap:anywhere;word-break:break-word}.review-diff{white-space:pre-wrap;max-width:100%;overflow:auto}.screenshot-preview img{max-width:100%;height:auto}.details dialog{max-width:calc(100vw - 24px)}}
|
|
26
28
|
`;
|
|
27
29
|
const layoutOverrides = `.operations{margin:0 12px 8px;border:1px solid #8db6df;border-radius:7px;background:#0b1728}.operations>summary{cursor:pointer;padding:5px 12px;color:#e7f0ff;font-size:12px;font-weight:800;list-style:none}.operations>summary::-webkit-details-marker{display:none}.operations>summary:before{content:'▸';display:inline-block;margin-right:7px}.operations[open]>summary:before{content:'▾'}.operation-body{display:grid;grid-template-columns:1fr 1fr;gap:10px;padding:0 10px 10px}.operation-body>section{border:1px solid var(--line);border-radius:8px;background:#101e32;padding:10px}.operation-body h2{margin:0 0 5px;font-size:13px}.operation-body p{margin:4px 0;color:var(--muted);font-size:11px}.operation-body button{min-height:30px;border:1px solid #5878a5;border-radius:6px;background:#1a3152;color:#fff;padding:5px 9px;font-size:11px}.workspace{--explorer-width:210px;--findings-width:230px;grid-template-columns:var(--explorer-width) var(--findings-width) minmax(0,1fr);margin:0 12px 12px}.explorer-pane,.findings-pane{overflow:hidden}.review-pane{min-width:0}@media(max-width:1100px){.workspace{--explorer-width:170px;--findings-width:190px}}@media(max-width:800px){.workspace>.explorer-pane,.workspace>.findings-pane{height:210px}.workspace>.review-pane{height:auto;min-height:0}.workspace.panel-tree-collapsed>.explorer-pane,.workspace.panel-findings-collapsed>.findings-pane{height:40px}.workspace.panel-tree-collapsed>.explorer-pane .head,.workspace.panel-findings-collapsed>.findings-pane .head{font-size:10px;padding:0 14px}}.head{height:40px}.scroll{height:calc(100% - 40px)}.tree,.finding-list{padding:8px}.file,.finding{padding:7px}.finding strong{font-size:12px}.finding small{font-size:9px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.code{height:auto}.meta{padding:8px 12px;font-size:11px}.code-scroll{flex:0 0 120px;padding:10px 0}.line{grid-template-columns:48px minmax(0,1fr);font-size:12px;line-height:1.65}.text{padding:0 13px;overflow:hidden;text-overflow:ellipsis}.details{height:auto;overflow:visible;padding:10px}.details h2{font-size:16px;margin-bottom:10px}`;
|
|
28
|
-
export function dashboardHtml(report, includeArtifactLinks = false, snippets) { const data = escapeJson(JSON.stringify(toDashboardData(report, snippets))), links = includeArtifactLinks ? `<nav class="artifact-links" aria-label="Report artifacts"><a href="rtl-report.json">JSON report</a><a href="rtl-report.md">Markdown report</a><a href="rtl-report-structured.md">Structured report</a></nav>` : ''; return `<!doctype html><html lang="en" dir="ltr"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>RTL Migration Analyzer v3 — Code Explorer</title><style>${
|
|
30
|
+
export function dashboardHtml(report, includeArtifactLinks = false, snippets) { const data = escapeJson(JSON.stringify(toDashboardData(report, snippets))), client = dashboardThemeTokens(dashboardClientSource.replace(themeClientSource, '__THEME_CLIENT__')).replace('__THEME_CLIENT__', themeClientSource), themedCss = dashboardThemeTokens(css + layoutOverrides), definitions = dashboardThemeDefinitions(), links = includeArtifactLinks ? `<nav class="artifact-links" aria-label="Report artifacts"><a href="rtl-report.json">JSON report</a><a href="rtl-report.md">Markdown report</a><a href="rtl-report-structured.md">Structured report</a></nav>` : ''; return `<!doctype html><html lang="en" dir="ltr"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>RTL Migration Analyzer v3 — Code Explorer</title><style>${themedCss}${definitions}.artifact-links{display:flex;gap:10px;padding:8px 18px}.artifact-links a{color:#c9a9ff}.rtl-value{unicode-bidi:isolate;direction:auto}</style></head><body><div id="dashboard" aria-label="RTL code explorer"></div>${links}<script type="application/json" id="rtl-dashboard-data">${data}</script><script>${client.replace('__SEVERITY_LABELS__', JSON.stringify({ Major: severityDisplayLabel('Major'), Minor: severityDisplayLabel('Minor'), Info: severityDisplayLabel('Info') }))}</script><script>document.addEventListener('click',event=>{const target=event.target.closest('.stats-toggle');if(!target)return;const summary=document.querySelector('.summary');if(summary){summary.hidden=!summary.hidden;target.textContent=summary.hidden?'Show all statistics':'Close statistics'}})</script></body></html>\n`; }
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Dashboard operation dialogs share the persisted workflow operation identity. */
|
|
2
|
+
export const operationFlowClientSource = String.raw `
|
|
3
|
+
const operationKey='rtl-review-operation',operationStyle=el('style');operationStyle.textContent='.review-operation{box-sizing:border-box;width:min(520px,calc(100vw - 32px));max-height:calc(100vh - 32px);overflow:auto;border:1px solid #a681e8;border-radius:12px;background:#12213a;color:#f4f7ff;padding:22px}.review-operation::backdrop{background:#050a16b8}.review-operation .actions{display:flex;flex-wrap:wrap;gap:10px}.review-operation button{padding:10px 14px;background:#6330af;color:white;border:1px solid #ad8add;border-radius:6px}.review-operation code{display:block;overflow-wrap:anywhere;white-space:pre-wrap}.review-operation [role=status]{font-weight:700}.operation-spinner{display:block;width:36px;height:36px;border:4px solid var(--theme-line,#526d91);border-top-color:var(--theme-focus,#cfb0ff);border-radius:50%;animation:rtl-operation-spin .8s linear infinite;margin:0 0 14px}@keyframes rtl-operation-spin{to{transform:rotate(360deg)}}.operation-success{color:#55dc9e;font-size:30px}@media(prefers-reduced-motion:reduce){.review-operation,.operation-spinner{animation:none;transition:none}}';document.head.append(operationStyle);
|
|
4
|
+
let operationDialog=null,uncertainOperation=null;
|
|
5
|
+
function dismissOperation(){operationDialog?.close();operationDialog?.remove();operationDialog=null;r.inert=false;document.querySelector('.finding-title')?.focus({preventScroll:true});}
|
|
6
|
+
function operationWindow(title,description,locked=false){dismissOperation();const dialog=document.createElement('dialog');dialog.className='review-operation';dialog.setAttribute('aria-labelledby','operation-title');dialog.setAttribute('aria-describedby','operation-description');const heading=el('h2',title);heading.id='operation-title';const copy=el('p',description);copy.id='operation-description';copy.setAttribute('role',locked?'status':'note');if(locked)copy.setAttribute('aria-live','polite');if(locked){const spinner=el('span','','operation-spinner');spinner.setAttribute('aria-hidden','true');dialog.append(spinner)}dialog.append(heading,copy);dialog.addEventListener('cancel',event=>{event.preventDefault();if(!locked)dismissOperation()});document.body.append(dialog);operationDialog=dialog;r.inert=true;dialog.showModal();return dialog;}
|
|
7
|
+
const opButton=(dialog,label,fn)=>{let actions=dialog.querySelector('.actions');if(!actions){actions=el('div','','actions');dialog.append(actions)}const button=el('button',label);button.onclick=fn;actions.append(button);return button;};
|
|
8
|
+
const acceptedEntries=()=>workflow?.entries.filter(e=>e.decision==='Accepted'&&e.applied&&e.patch)||[];
|
|
9
|
+
function applyConfirmation(){
|
|
10
|
+
if(busy||uncertainOperation||!workflow?.applyEligibility?.eligible)return;
|
|
11
|
+
const entries=acceptedEntries(),dialog=operationWindow('Apply changes to source','Confirmation writes '+entries.length+' accepted and validated changes to original source files. Rejected, deferred, Needs review and unaccepted findings are excluded.');
|
|
12
|
+
dialog.append(el('h3','Destination project'),el('code',workflow.root),el('h3','Affected files'));for(const path of [...new Set(entries.map(e=>e.finding.path))])dialog.append(el('code',path));dialog.append(el('p','Apply creates receipt-backed recoverable backups. Protected rollback refuses later source edits.'));
|
|
13
|
+
opButton(dialog,'Apply to source',()=>{dismissOperation();runDashboardOperation('apply')});opButton(dialog,'Cancel',dismissOperation).focus();
|
|
14
|
+
}
|
|
15
|
+
function operationResult(op){
|
|
16
|
+
if(!op)return;
|
|
17
|
+
const applied=op.kind==='apply'&&workflow.state==='Applied'&&op.state==='Succeeded',passed=op.kind==='validate'&&op.state==='Succeeded'&&workflow.applyEligibility?.eligible;
|
|
18
|
+
const title=applied?'Changes applied':passed?'Validation passed':op.state==='Uncertain'||op.state==='Running'?'Operation status uncertain':op.kind==='validate'?'Validation did not pass':'Apply did not complete';
|
|
19
|
+
const message=applied?op.count+' accepted changes applied to original source. Current scan and historical operation are separate.':passed?op.count+' changes validated. Your original source files have not changed.':op.error||workflow.applyEligibility?.reason||'The request may have executed. Reconcile its server operation record before any retry.';
|
|
20
|
+
const dialog=operationWindow(title,message);if(applied||passed){const icon=el('span','✓','operation-success');icon.setAttribute('role','img');icon.setAttribute('aria-label','Success');dialog.prepend(icon)}
|
|
21
|
+
if(applied){
|
|
22
|
+
opButton(dialog,'View applied changes / operation details',()=>{dismissOperation();document.querySelector('[data-review-details]')?.click()});
|
|
23
|
+
opButton(dialog,'Start review of remaining findings',()=>{dismissOperation();startRemainingReview()});
|
|
24
|
+
if(workflow.receipts?.length)opButton(dialog,'Rollback applied changes',()=>{dismissOperation();operate(rollback,'Rollback applied changes')});
|
|
25
|
+
}else if(passed)opButton(dialog,'Apply '+op.count+' changes…',()=>{dismissOperation();applyConfirmation()});
|
|
26
|
+
else if(op.state==='Failed'&&workflow.state==='Reviewing')opButton(dialog,'Retry',()=>{dismissOperation();runDashboardOperation(op.kind)});
|
|
27
|
+
else if(op.state==='Uncertain'||op.state==='Running')opButton(dialog,'Check operation status',()=>reconcileOperation(op));
|
|
28
|
+
const back=opButton(dialog,'Back to review',dismissOperation);if(passed||applied)dialog.querySelector('.actions button')?.focus();else back.focus();
|
|
29
|
+
}
|
|
30
|
+
async function reconcileOperation(pending){
|
|
31
|
+
busy=true;busyLabel='Checking operation status';operationWindow('Checking operation status','The previous request may have executed. Checking the authoritative server record…',true);
|
|
32
|
+
try{const result=await api(endpoint+'/'+pending.workflowId),next=result.workflow;if(next?.id!==pending.workflowId)throw Error('OPERATION_SESSION_IDENTITY_MISMATCH');workflow=next;const op=next.operations?.find(o=>o.id===pending.id&&o.kind===pending.kind);if(!op)throw Error('Operation is not yet confirmed by the server. Retry status check; no duplicate mutation was submitted.');uncertainOperation=['Uncertain','Running'].includes(op.state)?pending:null;busy=false;if(op.kind==='apply'&&next.state==='Applied'&&op.state==='Succeeded'){reloadTransition(next);return}if(!uncertainOperation)sessionStorage.removeItem(operationKey);render();operationResult(op);}
|
|
33
|
+
catch(e){uncertainOperation=pending;busy=false;render();operationResult({...pending,state:'Uncertain',error:e.message+' The request may have executed; source state is not assumed.'});}
|
|
34
|
+
}
|
|
35
|
+
async function runDashboardOperation(kind){
|
|
36
|
+
if(busy||reloading||uncertainOperation||!workflow)return;
|
|
37
|
+
document.querySelector('.review-summary-dialog')?.remove();const pending={id:crypto.randomUUID(),kind,workflowId:workflow.id},count=acceptedEntries().length;
|
|
38
|
+
sessionStorage.setItem(operationKey,JSON.stringify(pending));busy=true;busyLabel=kind==='validate'?'Validating changes':'Applying changes';render();operationWindow(kind==='validate'?'Validating accepted changes':'Applying accepted changes',(kind==='validate'?'Validating ':'Applying ')+count+' accepted changes…',true);
|
|
39
|
+
try{const result=await api(endpoint+'/'+pending.workflowId+'/'+kind,{operationId:pending.id,...(kind==='apply'?{confirmation:'APPLY_CONFIRMED'}:{})});if(result.workflow?.id!==pending.workflowId)throw Error('OPERATION_SESSION_IDENTITY_MISMATCH');workflow=result.workflow;const op=workflow.operations?.find(o=>o.id===pending.id&&o.kind===kind);if(!op)throw Error('Operation receipt unavailable.');busy=false;dismissOperation();if(kind==='apply'&&workflow.state==='Applied'){reloadTransition(workflow);return}sessionStorage.removeItem(operationKey);render();operationResult(op);}
|
|
40
|
+
catch(e){await reconcileOperation(pending);}
|
|
41
|
+
}
|
|
42
|
+
async function startRemainingReview(){
|
|
43
|
+
await operate(async()=>{const result=await api(endpoint+'/'+workflow.id+'/remaining',{});for(const e of result.workflow.entries){const old=e.carriedFrom,draft=old&¬eDrafts.get(old.workflowId+':'+old.findingId);if(draft)rememberDraft(result.workflow.id+':'+e.finding.id,draft)}return result},'Start review of remaining findings');
|
|
44
|
+
sessionStorage.removeItem(operationKey);pendingSourceTransition=null;render();
|
|
45
|
+
}
|
|
46
|
+
function recoverOperationResult(){let pending;try{pending=JSON.parse(sessionStorage.getItem(operationKey)||'null')}catch{}if(pending?.workflowId===workflow?.id){document.querySelector('.workflow-screen')?.remove();app.hidden=false;document.body.style.overflow='';window.rtlEntryPending=false;const op=workflow.operations?.find(o=>o.id===pending.id&&o.kind===pending.kind);if(op&&['Succeeded','Failed'].includes(op.state)){sessionStorage.removeItem(operationKey);operationResult(op)}else reconcileOperation(pending)}}
|
|
47
|
+
`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Pure review progress model. Explorer selection and presentation filters never narrow scope. */
|
|
2
|
+
export function reviewNavigationModel(input) {
|
|
3
|
+
const { findings, decisions, currentId } = input, visible = new Set(input.visibleIds), current = findings.find(f => f.id === currentId);
|
|
4
|
+
const decision = (id) => decisions[id] || 'Pending';
|
|
5
|
+
const pending = findings.filter(f => decision(f.id) === 'Pending');
|
|
6
|
+
const unresolved = findings.filter(f => ['Pending', 'Deferred', 'Flagged'].includes(decision(f.id)));
|
|
7
|
+
const file = findings.filter(f => f.path === current?.path && visible.has(f.id)), at = file.findIndex(f => f.id === currentId);
|
|
8
|
+
const following = at >= 0 ? file[at + 1] : undefined;
|
|
9
|
+
const paths = [...new Set(findings.map(f => f.path))], pathAt = paths.indexOf(current?.path || '');
|
|
10
|
+
const orderedPaths = [...paths.slice(pathAt + 1), ...paths.slice(0, pathAt + 1)];
|
|
11
|
+
const destination = orderedPaths.flatMap(path => pending.filter(f => f.path === path && path !== current?.path));
|
|
12
|
+
const target = pending.length ? (following || destination.find(f => visible.has(f.id)) || destination[0] || pending.find(f => visible.has(f.id) && f.id !== currentId) || pending.find(f => f.id !== currentId)) : undefined;
|
|
13
|
+
const outsideFilters = !!target && !visible.has(target.id), crossFile = !!target && target.path !== current?.path;
|
|
14
|
+
const label = !target ? 'Review summary' : crossFile ? 'Continue to next file' : outsideFilters ? 'Continue outside filters' : 'Next finding';
|
|
15
|
+
return { file, at, previous: file[at - 1], target, label, crossFile, outsideFilters, pending, unresolved,
|
|
16
|
+
accepted: findings.filter(f => decision(f.id) === 'Accepted'), rejected: findings.filter(f => decision(f.id) === 'Rejected'),
|
|
17
|
+
hiddenPending: pending.filter(f => !visible.has(f.id)), hiddenUnresolved: unresolved.filter(f => !visible.has(f.id)),
|
|
18
|
+
destinationPending: target ? pending.filter(f => f.path === target.path).length : 0, total: findings.length };
|
|
19
|
+
}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import { batchReviewClientSource } from './dashboard-batch-review.js';
|
|
2
|
+
import { operationFlowClientSource } from './dashboard-operation-flow.js';
|
|
3
|
+
import { reviewNavigationModel } from './dashboard-review-navigation.js';
|
|
1
4
|
import { reviewDetailsClientSource } from './dashboard-review-details.js';
|
|
2
5
|
/** Uses the approved dashboard cards and the existing embedded route renderer. */
|
|
3
6
|
export const workflowClientSource = String.raw `
|
|
4
|
-
const workflowStyle=el('style');workflowStyle.textContent='.workflow-owned .apply-advanced,.workflow-owned .reviewer-context{display:none!important}.workflow-controls{font-size:11px;grid-column:1/-1}body:has(.review-session-toolbar){overflow-x:clip;overflow-y:visible}.workspace:has(.review-session-toolbar){overflow:clip!important}.review-session-toolbar{position:sticky;top:0;z-index:30;display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:6px 8px;margin:0 8px 6px;background:#13243a;border:1px solid #496488;border-radius:9px;box-shadow:0 5px 14px #0004}.session-identity{display:flex;align-items:center;gap:10px;flex:1;min-width:140px}.session-identity strong{font-size:12px}.session-identity span{font-size:10px;color:#adc0d8}.review-session-toolbar button,.session-overflow>button{font:600 11px Inter,system-ui;color:#e7eefb;background:#1b304c;border:1px solid #526d91;border-radius:6px;padding:6px 8px;cursor:pointer}.review-session-toolbar button:disabled{opacity:.5;cursor:default}.review-session-toolbar .session-primary{background:#6330af;border-color:#ac80ee}.session-validation{font-size:11px;color:#b8c6d9}.session-validation[data-status=Passed]{color:#5de0a6}.session-validation[data-status=Failed]{color:#ff8193}.session-validation[data-status="Limited validation"]{color:#ffd166}.session-policy{flex-basis:100%;font-size:10px;color:#b8c6d9;margin:0;max-height:70px;overflow:auto}.session-overflow{position:relative;flex:none}.session-overflow>button{list-style:none;white-space:nowrap}.session-overflow>button::-webkit-details-marker{display:none}.session-overflow>button:after{content:"⌄";margin-left:8px;color:#bdabdc}.session-overflow>button[aria-expanded=true]{border-color:#b58be9;background:#302449}.session-menu{position:fixed;inset:auto;box-sizing:border-box;width:238px;max-width:calc(100vw - 20px);margin:0;padding:6px;border:1px solid #657da2;border-radius:9px;background:#14243a;color:#e7eefb;box-shadow:0 12px 32px #0009;overflow:auto}.session-menu:popover-open{display:flex;flex-direction:column;gap:3px;height:auto;min-height:0;align-items:stretch}.session-menu button{flex:none}.session-menu small{display:block;margin-top:3px;font-weight:400;color:#bac6d7}.session-menu button{display:block;width:100%;text-align:left;white-space:normal;border:1px solid transparent;background:transparent;padding:9px 10px;margin:0;font-size:12px}.session-menu button:hover:not(:disabled),.session-menu button:focus-visible{background:#2b3b57;border-color:#a17cd5}.session-menu button:disabled{opacity:.45}.semantic-review{margin-top:6px;border-top:1px solid #304563;font-size:11px}.semantic-review>summary{padding:6px 0 1px;color:#d3bef2;cursor:pointer}.semantic-review p{margin:6px 0 0;color:#b8c9df;line-height:1.6}.semantic-review[hidden]{display:none}.review-session-toolbar :focus-visible{outline:2px solid #d5b2ff;outline-offset:2px}.workflow-controls textarea{box-sizing:border-box;width:100%;min-height:96px;padding:10px;resize:vertical;white-space:pre-wrap;overflow-x:hidden;overflow-wrap:anywhere;color:#e7eefb;background:#102039;border:1px solid #385579;border-radius:6px}.workflow-controls pre{max-height:260px;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere}.workflow-controls .actions{flex-wrap:wrap}.workflow-validation{max-height:160px;overflow:auto}.workflow-controls details{margin-top:8px}.workflow-controls summary{cursor:pointer;color:#cdb7ff}';document.head.append(workflowStyle);
|
|
7
|
+
const workflowStyle=el('style');workflowStyle.textContent='.review-pane{overflow-anchor:none}.workflow-owned .apply-advanced,.workflow-owned .reviewer-context{display:none!important}.workflow-controls{font-size:11px;grid-column:1/-1}body:has(.review-session-toolbar){overflow-x:clip;overflow-y:visible}.workspace:has(.review-session-toolbar){overflow:clip!important}.review-session-toolbar{position:sticky;top:0;z-index:30;display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:6px 8px;margin:0 8px 6px;background:#13243a;border:1px solid #496488;border-radius:9px;box-shadow:0 5px 14px #0004}.session-identity{display:flex;align-items:center;gap:10px;flex:1;min-width:140px}.session-identity strong{font-size:12px}.session-identity span{font-size:10px;color:#adc0d8}.review-session-toolbar button,.session-overflow>button{font:600 11px Inter,system-ui;color:#e7eefb;background:#1b304c;border:1px solid #526d91;border-radius:6px;padding:6px 8px;cursor:pointer}.review-session-toolbar button:disabled{opacity:.5;cursor:default}.review-session-toolbar .session-primary{background:#6330af;border-color:#ac80ee}.session-validation{font-size:11px;color:#b8c6d9}.session-validation[data-status=Passed]{color:#5de0a6}.session-validation[data-status=Failed]{color:#ff8193}.session-validation[data-status="Limited validation"]{color:#ffd166}.session-policy{flex-basis:100%;font-size:10px;color:#b8c6d9;margin:0;max-height:70px;overflow:auto}.session-overflow{position:relative;flex:none}.session-overflow>button{list-style:none;white-space:nowrap}.session-overflow>button::-webkit-details-marker{display:none}.session-overflow>button:after{content:"⌄";margin-left:8px;color:#bdabdc}.session-overflow>button[aria-expanded=true]{border-color:#b58be9;background:#302449}.session-menu{position:fixed;inset:auto;box-sizing:border-box;width:238px;max-width:calc(100vw - 20px);margin:0;padding:6px;border:1px solid #657da2;border-radius:9px;background:#14243a;color:#e7eefb;box-shadow:0 12px 32px #0009;overflow:auto}.session-menu:popover-open{display:flex;flex-direction:column;gap:3px;height:auto;min-height:0;align-items:stretch}.session-menu button{flex:none}.session-menu small{display:block;margin-top:3px;font-weight:400;color:#bac6d7}.session-menu button{display:block;width:100%;text-align:left;white-space:normal;border:1px solid transparent;background:transparent;padding:9px 10px;margin:0;font-size:12px}.session-menu button:hover:not(:disabled),.session-menu button:focus-visible{background:#2b3b57;border-color:#a17cd5}.session-menu button:disabled{opacity:.45}.semantic-review{margin-top:6px;border-top:1px solid #304563;font-size:11px}.semantic-review>summary{padding:6px 0 1px;color:#d3bef2;cursor:pointer}.semantic-review p{margin:6px 0 0;color:#b8c9df;line-height:1.6}.semantic-review[hidden]{display:none}.review-session-toolbar :focus-visible{outline:2px solid #d5b2ff;outline-offset:2px}.workflow-controls textarea{box-sizing:border-box;width:100%;min-height:96px;padding:10px;resize:vertical;white-space:pre-wrap;overflow-x:hidden;overflow-wrap:anywhere;color:#e7eefb;background:#102039;border:1px solid #385579;border-radius:6px}.workflow-controls pre{max-height:260px;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere}.workflow-controls .actions{flex-wrap:wrap}.workflow-validation{max-height:160px;overflow:auto}.workflow-controls details{margin-top:8px}.workflow-controls summary{cursor:pointer;color:#cdb7ff}';document.head.append(workflowStyle);
|
|
5
8
|
${reviewDetailsClientSource}
|
|
6
9
|
const reviewWorkflow=(()=>{
|
|
7
|
-
|
|
8
|
-
let
|
|
10
|
+
const operationEntryTransition=!!pendingSourceTransition;
|
|
11
|
+
let workflow=null,history=null,busy=false,busyLabel='',error='',scope=[],reloading=false,overflowOpen=false,restored=false;
|
|
12
|
+
let overflowUI=null;const draftStorageKey='rtl-review-drafts:'+dashboardSnapshot.inputDigest+':'+dashboardSnapshot.policyDigest,noteDrafts=new Map(),noteFeedback=new Map();
|
|
13
|
+
try{for(const [key,value] of JSON.parse(sessionStorage.getItem(draftStorageKey)||'[]'))if(typeof key==='string'&&value&&typeof value.value==='string'&&value.value.length<=4000)noteDrafts.set(key,{value:value.value,open:!!value.open})}catch{}
|
|
14
|
+
function rememberDraft(key,value){if(value===undefined)noteDrafts.delete(key);else noteDrafts.set(key,value);try{sessionStorage.setItem(draftStorageKey,JSON.stringify([...noteDrafts]))}catch{}}
|
|
15
|
+
window.rtlReviewModeState=()=>workflow?{id:workflow.id,mode:workflow.mode,label:workflow.mode==='apply-first'?'Prepare all, then review':'Review one by one',state:workflow.state,busy:busy||!!previewFlight}:null;
|
|
9
16
|
function positionOverflow(){
|
|
10
17
|
if(!overflowUI?.menu.open||!overflowUI.panel.isConnected)return;
|
|
11
18
|
const {toggle,panel}=overflowUI,anchor=toggle.getBoundingClientRect(),gap=7,edge=10;
|
|
@@ -24,7 +31,7 @@ const reviewWorkflow=(()=>{
|
|
|
24
31
|
document.addEventListener('focusin',event=>{if(overflowUI?.menu.open&&!overflowUI.menu.contains(event.target))setOverflow(false);});
|
|
25
32
|
addEventListener('resize',positionOverflow);document.addEventListener('scroll',positionOverflow,true);
|
|
26
33
|
const endpoint='/review/workflows';
|
|
27
|
-
const api=async(path,body)=>{let response;try{response=await fetch(previewOrigin+path,body===undefined?
|
|
34
|
+
const api=async(path,body)=>{let response;try{response=await fetch(previewOrigin+path,{signal:AbortSignal.timeout(600000),...(body===undefined?{}:{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify(body)})})}catch{throw Error('COMPANION_UNAVAILABLE')}const result=await response.json();if(!response.ok)throw Error(result.error||'WORKFLOW_REQUEST_FAILED');return result};
|
|
28
35
|
const state=(message,explanation)=>{
|
|
29
36
|
const card=document.querySelector('.code-diff-card');if(!card)return;let node=card.querySelector('.analysis-status');if(!node){node=el('p','','analysis-status');node.setAttribute('role','status');card.append(node)}if(node.textContent!==message)node.textContent=message;
|
|
30
37
|
const body=document.querySelector('.details-card .more-details-body')||document.querySelector('.details-card');let caveat=body?.querySelector('.semantic-review');if(body&&!caveat&&explanation){caveat=el('p','','semantic-review');body.append(caveat)}
|
|
@@ -32,17 +39,52 @@ const reviewWorkflow=(()=>{
|
|
|
32
39
|
|
|
33
40
|
};
|
|
34
41
|
function reloadTransition(next){const anchor=s.finding?{path:s.finding.path,ruleId:s.finding.ruleId,line:s.finding.line,column:s.finding.column}:null,key='rtl-source-selection:'+next.id;if(next.state==='Applied'&&anchor)sessionStorage.setItem(key,JSON.stringify(anchor));let selection=anchor;if(next.state==='Rolled Back'){try{selection=JSON.parse(sessionStorage.getItem(key))||anchor}catch{}}reloading=true;embeddedReview.select(null);sessionStorage.setItem('rtl-source-transition',JSON.stringify({workflowId:next.id,mode:next.mode,state:next.state,selection}));location.reload();}
|
|
35
|
-
async function operate(operation,label='Loading review'){if(busy||reloading)return;busy=true;busyLabel=label;error='';render();try{const result=await operation();if(result?.workflow){const changed=workflow&&workflow.state!==result.workflow.state;if(workflow&&workflow.id!==result.workflow.id)history=(await api(endpoint+'?history=1')).workflows.filter(w=>w.id!==result.workflow.id);workflow=result.workflow;if(changed&&['Applied','Rolled Back'].includes(workflow.state)){reloadTransition(workflow);return}}}catch(e){error=e.message;if(workflow?.id){try{const current=await api(endpoint+'/'+workflow.id);if(current.workflow){const changed=workflow.state!==current.workflow.state;workflow=current.workflow;if(changed&&['Applied','Rolled Back'].includes(workflow.state))reloadTransition(workflow)}}catch{}}}finally{busy=false;if(!reloading)render()}}
|
|
36
|
-
const action=(name,fn,disabled=false)=>{const b=el('button',name);b.disabled=busy||disabled;b.onclick=()=>{const menu=b.closest('.session-overflow');if(menu){setOverflow(false,true);}operate(fn,name)};return b};
|
|
42
|
+
async function operate(operation,label='Loading review'){if(busy||reloading)return;busy=true;busyLabel=label;error='';render();try{const result=await operation();if(result?.workflow){const changed=workflow&&workflow.state!==result.workflow.state;if(workflow&&workflow.id!==result.workflow.id){restored=false;history=(await api(endpoint+'?history=1')).workflows.filter(w=>w.id!==result.workflow.id);}workflow=result.workflow;if(changed&&['Applied','Rolled Back'].includes(workflow.state)){reloadTransition(workflow);return}}return result;}catch(e){error=e.message;if(workflow?.id){try{const current=await api(endpoint+'/'+workflow.id);if(current.workflow){const changed=workflow.state!==current.workflow.state;workflow=current.workflow;if(changed&&['Applied','Rolled Back'].includes(workflow.state))reloadTransition(workflow)}}catch{}}}finally{busy=false;if(!reloading)render()}}
|
|
43
|
+
const action=(name,fn,disabled=false)=>{const b=el('button',name);b.disabled=busy||!!uncertainOperation||disabled;b.onclick=()=>{const menu=b.closest('.session-overflow');if(menu){setOverflow(false,true);}operate(fn,name)};return b};
|
|
37
44
|
const change=(f,kind,notes)=>api(endpoint+'/'+workflow.id+'/change',{findingId:f.id,action:kind,notes:notes||''});
|
|
38
|
-
|
|
45
|
+
${operationFlowClientSource}
|
|
46
|
+
${batchReviewClientSource}
|
|
47
|
+
function closeApproval(dialog,restore=true){if(dialog?.open)dialog.close();dialog?.remove();if(restore&&s.finding){const heading=document.querySelector('.finding-title');heading?.focus({preventScroll:true})}}
|
|
48
|
+
const navigationModel=${reviewNavigationModel.toString()};
|
|
49
|
+
function navigation(){
|
|
50
|
+
const entries=workflow?.state==='Reviewing'&&!sourceContextError?workflow.entries:[],decisions=Object.fromEntries(entries.map(e=>[e.finding.id,e.decision]));
|
|
51
|
+
const findings=sortRows(all.filter(f=>(s.app==='all'||f.applications.includes(s.app))&&(!workflow?.scope?.length||workflow.scope.includes(f.path))));
|
|
52
|
+
return navigationModel({findings,visibleIds:match().map(f=>f.id),currentId:s.finding?.id,decisions});
|
|
53
|
+
}
|
|
54
|
+
function selectReviewFinding(f,outsideFilters=false){
|
|
55
|
+
if(!f)return;
|
|
56
|
+
if(outsideFilters){s.q='';search.value='';s.severity=s.status=s.eligibility=s.category='all';severityFilter.value=statusFilter.value=eligibilityFilter.value=categoryFilter.value='all';}
|
|
57
|
+
window.dispatchEvent(new CustomEvent('rtl-dashboard-select',{detail:f.id}));requestAnimationFrame(()=>document.querySelector('.finding-title')?.focus({preventScroll:true}));
|
|
58
|
+
}
|
|
59
|
+
function stepDescription(n){return n.target?(n.crossFile?n.target.path+' · '+n.destinationPending+' pending in destination · '+n.pending.length+' pending in project. ':'')+(n.outsideFilters?'Outside current filters. Continuing clears search and finding filters; workspace scope stays selected.':''):'';}
|
|
60
|
+
function advance(){const n=navigation();if(n.target)selectReviewFinding(n.target,n.outsideFilters);else showReviewSummary();}
|
|
61
|
+
function paintNavigation(){
|
|
62
|
+
const n=navigation();let recovery=document.querySelector('.review-filter-recovery');if(!match().length&&n.hiddenUnresolved.length){if(!recovery){recovery=el('section','','review-filter-recovery');const text=el('p'),button=el('button','Continue outside filters');recovery.append(text,button);document.querySelector('.review-pane')?.prepend(recovery)}recovery.querySelector('p').textContent=n.hiddenUnresolved.length+' unresolved findings are hidden by search or finding filters. Continuing clears those filters; workspace scope stays selected.';recovery.querySelector('button').onclick=()=>selectReviewFinding(n.hiddenPending[0]||n.hiddenUnresolved[0],true);}else recovery?.remove();for(const b of document.querySelectorAll('.review-next')){b.textContent=n.label;b.title=stepDescription(n);b.disabled=busy;b.onclick=advance;}
|
|
63
|
+
for(const b of document.querySelectorAll('.review-previous')){b.disabled=busy||!n.previous;b.onclick=()=>selectReviewFinding(n.previous);}
|
|
64
|
+
const description=document.querySelector('.decision-card .review-next-destination');if(description){description.textContent=stepDescription(n);description.hidden=!description.textContent;}
|
|
65
|
+
const counter=document.querySelector('.source-counter');if(counter)counter.textContent='In file: '+Math.max(0,n.at+1)+' of '+n.file.length+' · Project: '+n.pending.length+' pending / '+n.total;
|
|
66
|
+
}
|
|
67
|
+
window.rtlReviewNavigation=()=>navigation();
|
|
68
|
+
function showApprovalConfirmation(f){document.querySelector('.approval-confirmation')?.remove();const dialog=document.createElement('dialog');dialog.className='approval-confirmation';dialog.setAttribute('aria-labelledby','approval-title');dialog.setAttribute('aria-describedby','approval-description');const title=el('h2','Proposed change approved');title.id='approval-title';const message=el('p','Added to your accepted changes. Your project files have not changed. Validate accepted changes before applying them.');message.id='approval-description';const actions=el('div','','actions'),n=navigation(),next=el('button',n.label),stay=el('button','Stay on this finding');next.type=stay.type='button';next.onclick=()=>{dialog.close();dialog.remove();advance()};stay.onclick=()=>closeApproval(dialog,true);actions.append(next,stay);dialog.append(title,message);if(stepDescription(n))dialog.append(el('p',stepDescription(n),'review-next-destination'));dialog.append(actions);dialog.addEventListener('cancel',event=>{event.preventDefault();closeApproval(dialog,true)});dialog.addEventListener('close',()=>dialog.remove(),{once:true});document.body.append(dialog);dialog.showModal();next.focus()}
|
|
69
|
+
function summarySnapshot(){return JSON.stringify([workflow?.id,busy,workflow?.validation?.at,workflow?.applyEligibility?.eligible,workflow?.entries.map(e=>[e.finding.id,e.decision])]);}
|
|
70
|
+
function showReviewSummary(){
|
|
71
|
+
const n=navigation(),dialog=document.createElement('dialog');dialog.className='approval-confirmation review-summary-dialog';dialog.dataset.snapshot=summarySnapshot();dialog.setAttribute('aria-labelledby','summary-title');dialog.setAttribute('aria-describedby','summary-description');const title=el('h2','Review summary');title.id='summary-title';
|
|
72
|
+
const validationCopy=workflow?.state==='Applied'?'Historical operation applied. Current scan has no current candidate.':workflow?.applyEligibility?.eligible?'Validation passed for the current accepted candidate. Apply remains a separate source-write step.':workflow?.validation?'Validation is failed, unavailable or no longer fresh: '+workflow.applyEligibility?.reason:workflow?.validationInvalidation||'Validate accepted changes before Apply.';
|
|
73
|
+
const description=el('p',n.accepted.length+' accepted · '+n.rejected.length+' rejected · '+n.unresolved.length+' unresolved ('+n.pending.length+' pending). Scope: '+n.total+' reviewable findings across the selected project/workspace. '+validationCopy+' Rejected, deferred and Needs review items are not applied.');description.id='summary-description';dialog.append(title,description);
|
|
74
|
+
if(n.hiddenUnresolved.length)dialog.append(el('p',n.hiddenUnresolved.length+' unresolved findings are hidden by search or finding filters. Continuing outside filters explicitly clears those filters; workspace scope stays selected.','review-hidden-findings'));
|
|
75
|
+
const actions=el('div','','actions'),back=el('button','Review unresolved');back.disabled=!n.unresolved.length;back.onclick=()=>{let list=dialog.querySelector('.unresolved-findings');if(list){list.remove();return}list=el('div','','unresolved-findings');for(const f of n.unresolved){const hidden=!match().some(x=>x.id===f.id),decision=workflow?.entries.find(e=>e.finding.id===f.id)?.decision||'Pending',b=el('button',f.path+' · '+(decision==='Flagged'?'Needs review':decision)+(hidden?' · Continue outside filters':''));b.onclick=()=>{dialog.close();dialog.remove();selectReviewFinding(f,hidden)};list.append(b)}dialog.append(list);list.querySelector('button')?.focus()};
|
|
76
|
+
if(n.hiddenPending.length){const outside=el('button','Continue outside filters');outside.onclick=()=>{dialog.close();dialog.remove();selectReviewFinding(n.hiddenPending[0],true)};actions.append(outside)}
|
|
77
|
+
const validation=el('button',workflow?.applyEligibility?.eligible?'Apply accepted changes…':'Validate accepted changes');validation.disabled=!n.accepted.length||!!sourceContextError||busy||workflow?.state!=='Reviewing';validation.onclick=()=>{dialog.close();dialog.remove();workflow?.applyEligibility?.eligible?applyConfirmation():runDashboardOperation('validate')};const stay=el('button','Close summary');stay.onclick=()=>{dialog.close();dialog.remove()};actions.prepend(back);actions.append(validation,stay);dialog.append(actions);dialog.addEventListener('cancel',event=>{event.preventDefault();dialog.close();dialog.remove()});document.body.append(dialog);dialog.showModal();(back.disabled?stay:back).focus();
|
|
78
|
+
}
|
|
79
|
+
async function approve(f,notes){if(busy||f.id!==s.finding?.id)return;const result=await operate(()=>change(f,'Accepted',notes));if(result?.workflow?.entries?.some(e=>e.finding.id===f.id&&e.decision==='Accepted'))showApprovalConfirmation(f)}
|
|
80
|
+
const rollback=()=>{if(!window.confirm('Rollback this workflow? Later user edits will block rollback.'))return;return api(endpoint+'/'+(workflow.continuedFrom||workflow.id)+'/rollback',{confirmation:'ROLLBACK_CONFIRMED'})};
|
|
39
81
|
|
|
40
82
|
const previewAttempts=new Map();let previewFlight=null;
|
|
41
83
|
const previewKey=(f,c)=>[workflow?.id,d.inputDigest,d.policyDigest,f.id,c?.application,c?.routeId,workflow?.session?.runtime?.status||'not-started',workflow?.entries.filter(e=>e.applied).map(e=>e.finding.id).join(',')].join('|');
|
|
42
84
|
const paintPreview=(f,state,reason='')=>embeddedReview.preparation(f,{state,reason,busy:busy||!!previewFlight});
|
|
43
85
|
function retryPreview(f){if(busy||previewFlight||s.finding?.id!==f.id)return;previewAttempts.delete(previewKey(f,embeddedReview.capability(f)));embeddedReview.refresh(f);}
|
|
44
86
|
async function automaticPreview(){
|
|
45
|
-
const f=s.finding;if(!f||!workflow||sourceContextError||reloading)return;
|
|
87
|
+
const f=s.finding;if(!f||!workflow||sourceContextError||reloading||uncertainOperation||window.rtlEntryPending||batchOpen||(busy&&!previewFlight))return;
|
|
46
88
|
const e=workflow.entries.find(e=>e.finding.id===f.id),c=embeddedReview.capability(f);
|
|
47
89
|
if(workflow.state!=='Reviewing'||!e?.patch||['Rejected','Deferred','Flagged'].includes(e.decision)){paintPreview(f,'unsupported',workflow.state!=='Reviewing'?'Historical review; current candidate preparation is unavailable.':!e?.patch?e?.reason||'Finding outside the current review scope.':e.decision+' decision; automatic preparation will not restore this patch.');return;}
|
|
48
90
|
const key=previewKey(f,c),attempt=previewAttempts.get(key),runtimeCurrent=workflow.session?.runtime?.status==='healthy';
|
|
@@ -60,7 +102,7 @@ const reviewWorkflow=(()=>{
|
|
|
60
102
|
const owner=workflow.id,operation={state:'preparing',reason:''};previewAttempts.set(key,operation);previewFlight=operation;busy=true;render();paintPreview(f,'preparing','Preparing the isolated candidate and starting its verified application route…');
|
|
61
103
|
try{
|
|
62
104
|
const result=await api(endpoint+'/'+owner+'/prepare-preview',{findingId:f.id,application:c.application,routeId:c.routeId,inputDigest:d.inputDigest,policyDigest:d.policyDigest});
|
|
63
|
-
if(workflow?.id===owner){workflow=result.workflow;operation.state='prepared';
|
|
105
|
+
if(workflow?.id===owner){workflow=result.workflow;operation.state='prepared';const next=previewKey(f,c);/* The candidate now shows this finding; the pre-prepare key can recur when another finding takes the preview focus, so it must not keep a stale 'prepared' attempt. */if(next!==key)previewAttempts.delete(key);previewAttempts.set(next,operation);}
|
|
64
106
|
}catch(failure){
|
|
65
107
|
operation.state='failed';operation.reason=failure.message;
|
|
66
108
|
// A runtime failure may follow a successful isolated patch. Reconcile that exact workflow before retry.
|
|
@@ -68,22 +110,29 @@ const reviewWorkflow=(()=>{
|
|
|
68
110
|
}finally{previewFlight=null;busy=false;if(!reloading)render();}
|
|
69
111
|
}
|
|
70
112
|
window.addEventListener('rtl-context-preview-updated',event=>{if(workflow?.id===event.detail.workflowId&&s.finding?.id===event.detail.findingId)automaticPreview();});
|
|
113
|
+
function ensureSessionDetails(){
|
|
114
|
+
const host=document.querySelector('.panel-controls');if(!host)return;
|
|
115
|
+
let button=host.querySelector('[data-review-details]');if(!button){button=el('button','Session details','panel-toggle-btn');button.dataset.reviewDetails='true';const findings=host.querySelector('[aria-label="Findings"]');if(findings)findings.after(button);else host.append(button)}
|
|
116
|
+
button.hidden=!workflow&&!history?.length;button.onclick=()=>reviewDetails.open(button,workflow?.state==='Reviewing'?workflow:null,workflow?.state!=='Reviewing'?[workflow,...(history||[])].filter(Boolean):history);
|
|
117
|
+
}
|
|
71
118
|
function sessionToolbar(){
|
|
119
|
+
ensureSessionDetails();
|
|
72
120
|
const source=document.querySelector('.code-scroll'),code=source?.parentElement,pane=code?.parentElement,meta=code?.querySelector('.meta');if(!pane||!code||!source)return;if(meta)pane.insertBefore(meta,code);const previous=pane.querySelector('.review-session-toolbar'),menuOpen=previous?.querySelector('.session-overflow')?.open??overflowOpen,focused=previous?.contains(document.activeElement)?document.activeElement:null,focusKey=focused?.dataset.sessionAction,focusLabel=focused?.textContent,focusPrimary=focused?.classList.contains('session-primary');previous?.remove();
|
|
73
121
|
const bar=el('section','','review-session-toolbar');bar.setAttribute('aria-label','Review session');bar.setAttribute('aria-busy',String(busy));pane.insertBefore(bar,code);
|
|
74
|
-
const historical=sourceContextError||workflow?.state!=='Reviewing',current=
|
|
75
|
-
const identity=el('div','','session-identity');identity.title=workflow?(workflow.mode==='one-by-one'?'One by one review':'Prepare all, then review'):'Review session';identity.append(el('strong','Current review · '+(workflow?.mode==='apply-first'?'Prepare all, then review':'One by one')),el('span',selected+' accepted'+(historical?' · '+(workflow?.state||'Loading'):''),'workflow-summary'));bar.append(identity);
|
|
76
|
-
const status=current?.validationPresentation?.status||'Not run',summary=el('span','Validation: '+status,'workflow-validation session-validation');summary.dataset.status=status;summary.title=current?.validationPresentation?.explanation||'Historical validation cannot validate this review.';bar.append(summary);
|
|
77
|
-
|
|
122
|
+
const historical=sourceContextError||workflow?.state!=='Reviewing',current=workflow,selected=workflow?.entries.filter(e=>e.decision==='Accepted').length||0;
|
|
123
|
+
const identity=el('div','','session-identity');identity.title=workflow?(workflow.mode==='one-by-one'?'One by one review':'Prepare all, then review'):'Review session';identity.append(el('strong',(historical?'Historical operation · '+workflow?.state+' · ':restored?'Restored review · ':'Current review · ')+(workflow?.mode==='apply-first'?'Prepare all, then review':'One by one')),el('span',selected+' accepted'+(historical?' · '+(workflow?.state||'Loading'):''),'workflow-summary'));bar.append(identity);
|
|
124
|
+
const status=current?.validationPresentation?.status||'Not run',summary=el('span',(historical?'Historical validation: ':'Validation: ')+status,'workflow-validation session-validation');summary.dataset.status=status;summary.title=current?.validationPresentation?.explanation||'Historical validation cannot validate this review.';bar.append(summary);
|
|
125
|
+
|
|
78
126
|
const eligible=!sourceContextError&&workflow?.applyEligibility?.eligible;
|
|
79
127
|
const applyLabel=selected===1?'Apply 1 accepted change to source':'Apply '+selected+' accepted changes to source';
|
|
80
128
|
const validateLabel='Validate changes';
|
|
81
|
-
const primary=eligible?
|
|
129
|
+
const primary=el('button',eligible?applyLabel:validateLabel);primary.disabled=busy||!!uncertainOperation||!!historical||!selected;primary.onclick=()=>eligible?applyConfirmation():runDashboardOperation('validate');
|
|
82
130
|
primary.className='session-primary';if(busy)primary.textContent=previewFlight?'Preparing preview…':busyLabel.startsWith('Validate')?'Validating changes…':busyLabel.startsWith('Apply')?(selected===1?'Applying accepted change…':'Applying accepted changes…'):busyLabel+'…';bar.append(primary);
|
|
83
131
|
const menu=el('div','','session-overflow'),toggle=el('button','Review actions'),panel=el('div','','session-menu');toggle.setAttribute('aria-label','Review actions');toggle.setAttribute('aria-haspopup','menu');toggle.setAttribute('aria-controls','review-session-menu');toggle.dataset.sessionAction='overflow';panel.id='review-session-menu';panel.setAttribute('popover','manual');panel.setAttribute('role','menu');panel.setAttribute('aria-label','Review actions');menu.append(toggle,panel);bar.append(menu);overflowUI={menu,toggle,panel};
|
|
84
|
-
const rollbackButton=action('Rollback applied changes',rollback,!['Applied','Applying'].includes(
|
|
85
|
-
rollbackButton.setAttribute('aria-label','Rollback applied changes');if(!['Applied','Applying'].includes(
|
|
132
|
+
const rollbackOwner=workflow?.continuedFrom?(history||[]).find(w=>w.id===workflow.continuedFrom):workflow;const rollbackButton=action('Rollback applied changes',rollback,!['Applied','Applying'].includes(rollbackOwner?.state)||!rollbackOwner?.receipts?.length),restartButton=action('Start new review',()=>api(endpoint,{inputDigest:d.inputDigest,policyDigest:d.policyDigest,mode:workflow.mode,scope:workflow.scope,restart:true}),!workflow||!!sourceContextError||workflow.state==='Applying');
|
|
133
|
+
rollbackButton.setAttribute('aria-label','Rollback applied changes');if(!['Applied','Applying'].includes(rollbackOwner?.state)||!rollbackOwner?.receipts?.length)rollbackButton.append(el('small','Available after Apply'));
|
|
86
134
|
for(const [key,button] of [['rollback',rollbackButton],['restart',restartButton]]){button.dataset.sessionAction=key;button.setAttribute('role','menuitem');panel.append(button);}
|
|
135
|
+
const summaryButton=el('button','Review summary');summaryButton.setAttribute('role','menuitem');summaryButton.onclick=()=>{setOverflow(false);showReviewSummary()};panel.append(summaryButton);
|
|
87
136
|
toggle.onclick=event=>{event.preventDefault();setOverflow(!menu.open);};
|
|
88
137
|
toggle.onkeydown=event=>{if(['ArrowDown','ArrowUp'].includes(event.key)){event.preventDefault();setOverflow(true,true);if(event.key==='ArrowUp')[...panel.querySelectorAll('button')].filter(b=>!b.disabled).at(-1)?.focus();}};
|
|
89
138
|
panel.onkeydown=event=>{const buttons=[...panel.querySelectorAll('button')].filter(b=>!b.disabled),index=buttons.indexOf(document.activeElement);if(['ArrowDown','ArrowUp','Home','End'].includes(event.key)){event.preventDefault();buttons[event.key==='Home'?0:event.key==='End'?buttons.length-1:(index+(event.key==='ArrowUp'?-1:1)+buttons.length)%buttons.length]?.focus();}if(event.key==='Tab'){setOverflow(false,true);}};
|
|
@@ -93,8 +142,20 @@ const reviewWorkflow=(()=>{
|
|
|
93
142
|
if(current?.validationPresentation?.status==='Failed'||current?.validationPresentation?.status==='Unavailable'){bar.append(el('p',workflow.applyEligibility?.reason||current.validationPresentation.explanation,'session-policy'));}
|
|
94
143
|
const focusTarget=focusPrimary?primary:[...bar.querySelectorAll('button,summary')].find(n=>focusKey?n.dataset.sessionAction===focusKey:n.textContent===focusLabel);if(focused)(focusTarget&&!focusTarget.disabled?focusTarget:toggle).focus({preventScroll:true});
|
|
95
144
|
}
|
|
145
|
+
function updateDecisionIndicators(){
|
|
146
|
+
for(const row of document.querySelectorAll('.finding[data-finding-id]')){
|
|
147
|
+
const decision=!sourceContextError&&workflow?.state==='Reviewing'?workflow.entries.find(e=>e.finding.id===row.dataset.findingId)?.decision||'Pending':'Pending';
|
|
148
|
+
const [label,symbol,tone]=({Accepted:['Accepted','✓','accepted'],Rejected:['Rejected','×','rejected'],Deferred:['Deferred','◷','deferred'],Flagged:['Needs review','◇','flagged'],Pending:['Pending','○','pending']})[decision]||['Pending','○','pending'];
|
|
149
|
+
let icon=row.querySelector('.finding-decision');if(!icon){icon=el('span','','finding-decision');icon.setAttribute('role','img');row.append(icon)}icon.textContent=symbol;icon.dataset.decision=decision;icon.dataset.tone=tone;icon.setAttribute('aria-label',label);icon.title=label;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
window.rtlRenderReviewIndicators=()=>{updateDecisionIndicators();paintNavigation()};
|
|
153
|
+
const indicatorStyle=el('style');indicatorStyle.textContent='.finding{position:relative;padding-inline-end:34px!important}.finding>strong,.finding>small{overflow-wrap:anywhere;min-width:0}.finding-decision{position:absolute;inset-inline-end:10px;top:50%;transform:translateY(-50%);width:18px;text-align:center;font:700 17px/1.2 system-ui;color:#a3adbb;pointer-events:none}.finding-decision[data-tone=accepted]{color:#55dc9e}.finding-decision[data-tone=rejected]{color:#ff8193}.finding-decision[data-tone=deferred]{color:#ffd166}.finding-decision[data-tone=flagged]{color:#c39aff}';document.head.append(indicatorStyle);
|
|
96
154
|
function render(){
|
|
97
|
-
|
|
155
|
+
ensureSessionDetails();renderBatch();
|
|
156
|
+
const summaryDialog=document.querySelector('.review-summary-dialog');if(summaryDialog&&summaryDialog.dataset.snapshot!==summarySnapshot()){const label=document.activeElement?.textContent;summaryDialog.close();summaryDialog.remove();showReviewSummary();[...document.querySelectorAll('.review-summary-dialog button')].find(b=>b.textContent===label&&!b.disabled)?.focus();}
|
|
157
|
+
workflowButton.disabled=busy||!!previewFlight||!!uncertainOperation;updateDecisionIndicators();paintNavigation();
|
|
158
|
+
const f=s.finding;if(!localStorage.getItem('rtl-review-workflow')&&window.rtlEntryPending||batchOpen)return;if(!f){sessionToolbar();reviewDetails.update(workflow?.state==='Reviewing'?workflow:null,workflow?.state!=='Reviewing'?[workflow,...(history||[])].filter(Boolean):history);return;}
|
|
98
159
|
normalizeComponentReview();normalizeDecision();sessionToolbar();
|
|
99
160
|
const card=document.querySelector('.decision-card'),component=document.querySelector('.component-review');if(!card)return;
|
|
100
161
|
card.classList.add('workflow-owned');card.querySelectorAll('.workflow-controls').forEach(n=>n.remove());
|
|
@@ -103,49 +164,56 @@ const reviewWorkflow=(()=>{
|
|
|
103
164
|
if(sourceContextError){state((workflow?.state==='Rolled Back'||pendingSourceTransition?.state==='Rolled Back'?'Rollback succeeded. Rescan failed: ':'Source context blocked: ')+sourceContextError+'. Displayed report is a stale snapshot; current analysis is unavailable.');document.querySelector('.after-card pre').textContent='Fresh suggestion unavailable until rescan succeeds.';controls.append(el('p','Source context blocked: '+sourceContextError,'source-context-status'),action('Retry rescan',()=>{sessionStorage.setItem('rtl-source-transition',JSON.stringify(pendingSourceTransition||{mode:workflow?.mode||localStorage.getItem('rtl-review-workflow')}));reloading=true;location.reload()}));if(workflow){}return;}
|
|
104
165
|
if(error){state('Blocked: '+error);controls.append(action('Retry connection',()=>restore(true)));}
|
|
105
166
|
if(!workflow){if(!error)state(busy?'Analyzing scan and codemod inventory…':'Start a review workflow to analyze this report.');return;}
|
|
106
|
-
const historical=workflow.state!=='Reviewing',e=historical?null:workflow.entries.find(e=>e.finding.id===f.id),locked=historical;
|
|
167
|
+
const historical=workflow.state!=='Reviewing',e=historical?null:workflow.entries.find(e=>e.finding.id===f.id),locked=historical||!!uncertainOperation;
|
|
107
168
|
reviewDetails.update(historical?null:workflow,historical?[workflow,...(history||[])]:history);
|
|
108
169
|
const selected=workflow.entries.filter(e=>e.decision==='Accepted').length;
|
|
109
170
|
|
|
110
171
|
const feedbackKey='rtl-rollback-feedback:'+workflow.id;
|
|
111
172
|
if(workflow.resumedFrom&&!historical&&!workflow.validation&&workflow.entries.every(e=>e.decision==='Pending'&&!e.history.length)&&!sessionStorage.getItem(feedbackKey)){const feedback=el('p','Rollback succeeded · Automatic rescan complete · Fresh review ready. ','source-context-status');const dismiss=el('button','Dismiss');dismiss.setAttribute('aria-label','Dismiss rollback notification');dismiss.onclick=()=>{sessionStorage.setItem(feedbackKey,'dismissed');render()};feedback.append(dismiss);controls.append(feedback);}
|
|
112
173
|
|
|
174
|
+
if(!historical&&workflow.continuedFrom)controls.prepend(el('p','Current remaining-finding review. Historical validation and Apply are available in Session details. Only reliably unchanged non-accepted decisions/notes were carried forward; other findings require a new review.'));
|
|
175
|
+
const codeGrid=document.querySelector('.diff-grid'),beforeCard=document.querySelector('.before-card'),afterCard=document.querySelector('.after-card'),diffArrow=document.querySelector('.diff-arrow');document.querySelector('.manual-source-note')?.remove();if(!e?.patch||historical){if(beforeCard){beforeCard.querySelector('h3').textContent=historical?'Current source':'Before';beforeCard.querySelector('pre').textContent=f.original||'Source unavailable'}if(afterCard){afterCard.style.display='';afterCard.dataset.state=historical?'no-candidate':e?'manual-review-required':'unavailable';afterCard.querySelector('h3').textContent=historical?'After (No current candidate)':e?'After (Manual review required)':'After (Unavailable)';afterCard.querySelector('pre').textContent=historical?'Current source · No current candidate.':e?'Manual review required. No supported candidate patch exists for this finding.\n'+[f.rationale,f.treatment].filter(Boolean).join(' '):'Finding is outside the selected workflow scope; no candidate is prepared.'}if(diffArrow)diffArrow.style.display='';if(codeGrid)codeGrid.style.gridTemplateColumns='minmax(0,1fr) auto minmax(0,1fr)'}else{beforeCard.querySelector('h3').textContent='Before';beforeCard.querySelector('pre').textContent=e.finding.original;afterCard.style.display='';afterCard.dataset.state='candidate';afterCard.querySelector('h3').textContent='After (Supported candidate)';afterCard.querySelector('pre').textContent=e.patch.replacement;diffArrow.style.display='';if(codeGrid)codeGrid.style.gridTemplateColumns='minmax(0,1fr) auto minmax(0,1fr)'}
|
|
176
|
+
if(historical&&workflow.state==='Applied'){const remaining=el('button','Start review of remaining findings');remaining.onclick=startRemainingReview;controls.prepend(remaining);controls.prepend(el('p','Historical operation: '+workflow.entries.filter(e=>e.decision==='Accepted').length+' accepted changes applied. Current scan: remaining findings, no current candidate. Historical Before/After is in Session details.'));const beforeHeading=document.querySelector('.before-card h3');if(beforeHeading)beforeHeading.textContent='Current source';document.querySelectorAll('.component-before h3').forEach(h=>{for(const n of h.childNodes)if(n.nodeType===3&&n.textContent.includes('BEFORE'))n.textContent='Current source '});}
|
|
113
177
|
if(historical){['Approve fix','Reject fix','Defer','Needs review'].forEach(label=>actions.append(action(label,()=>{},true)));controls.append(el('p',workflow.state==='Rolled Back'?'Source restored · Start a fresh review.':workflow.state==='Applying'?'Source apply incomplete · Use Rollback to recover. History: Session details.':'Source applied · Current source shown. History and recovery: Session details.','source-context-status'));document.querySelector('.after-card pre').textContent='Current source · No current candidate. '+((f.eligibilityBlockers||[]).join('; ')||'Review this finding separately.');}if(sourceContextError)controls.append(el('p','Source context blocked: '+sourceContextError,'source-context-status'));
|
|
114
178
|
if(e){
|
|
115
|
-
document.querySelector('.before-card pre').textContent=e.finding.original;
|
|
116
|
-
document.querySelector('.after-card pre').textContent=e.patch?e.patch.replacement:'No supported automatic fix. '+e.reason;
|
|
117
179
|
if(!error)state(e.applied?(e.decision==='Accepted'?'Accepted · In accepted review set':'Preview ready · Pending approval'):e.decision+' · Not in review preview',e.reason);
|
|
118
|
-
const noteKey=workflow.id+':'+f.id,draft=noteDrafts.get(noteKey),notes=el('textarea');notes.maxLength=4000;notes.setAttribute('aria-label','Review note');notes.value=draft?.value??e.notes;notes.disabled=busy;
|
|
180
|
+
const noteKey=workflow.id+':'+f.id,draft=noteDrafts.get(noteKey),notes=el('textarea');notes.maxLength=4000;notes.setAttribute('aria-label','Review note');notes.value=draft?.value??e.notes;notes.disabled=busy||!!uncertainOperation;
|
|
119
181
|
const noteBox=el('details','','workflow-notes'),noteSummary=el('summary',e.notes?'Edit review note':'Add review note');noteBox.open=draft?.open||false;noteBox.append(noteSummary,notes);
|
|
120
|
-
notes.oninput=()=>{
|
|
121
|
-
noteBox.ontoggle=()=>{const current=noteDrafts.get(noteKey);if(noteBox.isConnected)
|
|
182
|
+
notes.oninput=()=>{rememberDraft(noteKey,{value:notes.value,open:true});noteFeedback.delete(noteKey);feedback.textContent='Unsaved draft retained for this finding.'};
|
|
183
|
+
noteBox.ontoggle=()=>{const current=noteDrafts.get(noteKey);if(noteBox.isConnected)rememberDraft(noteKey,{value:current?.value??notes.value,open:noteBox.open})};
|
|
122
184
|
const feedback=el('p',noteFeedback.get(noteKey)|| (draft&&draft.value!==e.notes?'Unsaved draft retained for this finding.':''));feedback.setAttribute('role','status');
|
|
123
|
-
noteBox.append(action('Save note',async()=>{const result=await change(f,'notes',notes.value);
|
|
124
|
-
const cancel=el('button','Cancel');cancel.disabled=busy;cancel.onclick=()=>{
|
|
125
|
-
|
|
185
|
+
noteBox.append(action('Save note',async()=>{const result=await change(f,'notes',notes.value);rememberDraft(noteKey);noteFeedback.set(noteKey,'Note saved.');return result;}));
|
|
186
|
+
const cancel=el('button','Cancel');cancel.disabled=busy;cancel.onclick=()=>{rememberDraft(noteKey);noteFeedback.set(noteKey,'Unsaved edits discarded. Saved note retained.');render()};noteBox.append(cancel);controls.append(noteBox,feedback);
|
|
187
|
+
const approveButton=action(e.decision==='Accepted'?'Already accepted':f.ruleId==='RTL.CSS.PHYSICAL'?'Approve proposed change':'Approve fix',()=>{},locked||!e.patch||!e.applied||e.decision==='Accepted');
|
|
188
|
+
// approve owns the save operation so its persisted result can open the dialog.
|
|
189
|
+
approveButton.onclick=()=>approve(f,e.notes);actions.append(approveButton);
|
|
190
|
+
const n=navigation(),nextStep=el('button',n.label);nextStep.type='button';nextStep.disabled=locked;nextStep.className='persistent-next-finding review-next';nextStep.title=stepDescription(n);nextStep.onclick=advance;actions.append(nextStep);const destination=el('p',stepDescription(n),'review-next-destination');destination.hidden=!destination.textContent;controls.prepend(destination);
|
|
126
191
|
actions.append(action('Reject fix',()=>change(f,'Rejected',e.notes),locked));
|
|
127
192
|
actions.append(action('Defer',()=>change(f,'Deferred',e.notes),locked));
|
|
128
193
|
actions.append(action('Needs review',()=>change(f,'Flagged',e.notes),locked));
|
|
129
|
-
[...actions.
|
|
194
|
+
[...actions.querySelectorAll('button')].filter(button=>!button.classList.contains('persistent-next-finding')).forEach((button,index)=>button.setAttribute('aria-pressed',String(['Accepted','Rejected','Deferred','Flagged'][index]===e.decision)));card.querySelector('.decision-heading span:last-child').textContent=e.decision;
|
|
130
195
|
embeddedReview.configure(f,{onRetryPreview:()=>retryPreview(f),...(e.patch?{patch:e.patch,onApply:()=>operate(async()=>{const result=await change(f,'apply');previewAttempts.clear();return result;})}:{}),workflow});
|
|
131
196
|
const previewButton=[...card.querySelectorAll('button')].find(b=>['Apply & Preview','Prepare candidate','Open candidate preview','Retry candidate preview'].includes(b.textContent));if(previewButton)previewButton.disabled=busy||locked;
|
|
132
197
|
}else{if(!error)state(historical?'Current source · No current candidate · Validation Not run. History: Session details.':'Finding outside selected workflow scope.');embeddedReview.configure(f,{workflow});}
|
|
133
198
|
const validation=el('p','Current review · '+(e?.decision||'Pending')+' · '+(e?.applied?(e.decision==='Accepted'?'Accepted for validation':'Review preview only'):'Not in review preview'),'current-review-status workflow-decision');controls.append(validation);
|
|
134
199
|
// These legacy one-patch operations remain available to API regressions; this workflow owns its distinct lifecycle.
|
|
135
200
|
card.querySelectorAll('.reviewer-context,.apply-advanced').forEach(n=>n.hidden=true);
|
|
201
|
+
// A context event received during a mutation must be retried after the busy state clears.
|
|
202
|
+
if(!busy&&!batchOpen)queueMicrotask(automaticPreview);
|
|
136
203
|
}
|
|
137
204
|
async function restore(create=false,mode=localStorage.getItem('rtl-review-workflow')){
|
|
138
205
|
if(!mode)return;const result=await api(pendingSourceTransition?.workflowId?endpoint+'/'+pendingSourceTransition.workflowId:endpoint+'?'+new URLSearchParams({inputDigest:dashboardSnapshot.inputDigest,policyDigest:dashboardSnapshot.policyDigest,mode}));
|
|
139
|
-
if(result.workflow){workflow=result.workflow;history=(await api(endpoint+'?history=1')).workflows.filter(w=>w.id!==workflow.id);scope=workflow.scope;if(!sourceContextError&&workflow.state==='Rolled Back'){history=[workflow,...history.filter(w=>w.id!==workflow.id)];const next=await api(endpoint+'/'+workflow.id+'/resume',{});workflow=next.workflow;pendingSourceTransition=null;return next;}if(!sourceContextError)pendingSourceTransition=null;return result;}
|
|
140
|
-
if(create){const next=await api(endpoint,{inputDigest:d.inputDigest,policyDigest:d.policyDigest,mode,scope});workflow=next.workflow;return next;}
|
|
206
|
+
if(result.workflow&&!entryRestart){restored=true;workflow=result.workflow;history=(await api(endpoint+'?history=1')).workflows.filter(w=>w.id!==workflow.id);scope=workflow.scope;if(!sourceContextError&&workflow.state==='Rolled Back'){history=[workflow,...history.filter(w=>w.id!==workflow.id)];const next=await api(endpoint+'/'+workflow.id+'/resume',{});workflow=next.workflow;pendingSourceTransition=null;return next;}if(!sourceContextError)pendingSourceTransition=null;return result;}
|
|
207
|
+
if(create){restored=false;const next=await api(endpoint,{inputDigest:d.inputDigest,policyDigest:d.policyDigest,mode,scope,restart:!!entryRestart});workflow=next.workflow;return next;}
|
|
141
208
|
if(!sourceContextError)showWorkflowScreen();
|
|
142
209
|
}
|
|
143
210
|
// Companion health/recovery also rebuilds detail directly. Restore workflow and Before after every rebuild.
|
|
144
211
|
const workflowDetail=detail;detail=f=>{reviewDetails.close();embeddedReview.select(null);workflowDetail(f);render()};
|
|
145
|
-
window.addEventListener('rtl-review-
|
|
212
|
+
let entryRestart=false;window.addEventListener('rtl-review-resume',()=>{window.rtlEntryPending=false;if(workflow)localStorage.setItem('rtl-review-workflow',workflow.mode);if(workflow?.mode==='apply-first'&&workflow.state==='Reviewing'&&!sourceContextError){if(workflow.batchPreparedAt)batchOpen=true;else{operate(prepareBatchOverview,'Preparing batch').then(()=>{if(operationDialog?.querySelector('h2')?.textContent==='Preparing batch')dismissOperation();render()});return}}render();if(workflow?.state==='Applied')operationResult(workflow.operations?.filter(o=>o.kind==='apply').at(-1));else recoverOperationResult()});
|
|
213
|
+
window.addEventListener('rtl-review-workflow-entered',event=>{window.rtlEntryPending=false;entryRestart=!!event.detail.restart;embeddedReview.select(null);batchOpen=false;workflow=null;history=null;scope=event.detail.scope;if(event.detail.mode==='apply-first')operationWindow('Preparing batch','Preparing supported fixes in an isolated candidate…',true);operate(async()=>{const result=await restore(true,event.detail.mode);workflow=result.workflow;entryRestart=false;if(workflow.mode==='apply-first'){operationWindow('Preparing batch','Preparing supported fixes in an isolated candidate…',true);return await prepareBatchOverview()}return result},'Preparing review').then(()=>{if(operationDialog?.querySelector('h2')?.textContent==='Preparing batch')dismissOperation();render()})});
|
|
146
214
|
window.addEventListener('rtl-context-runtime-request',event=>{if(workflow?.id===event.detail.workflowId)operate(()=>api(endpoint+'/'+workflow.id+'/runtime',{application:event.detail.application}))});
|
|
147
215
|
// Reload restores persisted state without initiating batch application again.
|
|
148
|
-
setTimeout(()=>{
|
|
216
|
+
setTimeout(async()=>{await operate(()=>restore(false,localStorage.getItem('rtl-review-workflow')||'one-by-one'));if(operationEntryTransition){window.rtlEntryPending=false;recoverOperationResult()}else if(sessionStorage.getItem(operationKey)){window.rtlEntryPending=false;recoverOperationResult()}else{window.rtlEntryPending=true;showWorkflowScreen()}},0);
|
|
149
217
|
return{render};
|
|
150
218
|
})();
|
|
151
219
|
`;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Semantic colors shared by generated CSS and the dynamic dashboard surfaces. */
|
|
2
|
+
export const themes = [
|
|
3
|
+
{ id: 'studio', name: 'Studio Dark', bg: '#060d1a', surface: '#0e1a2e', raised: '#182b46', text: '#f4f7ff', muted: '#bdc9dc', line: '#526d91', accent: '#7541bc', focus: '#cfb0ff', ok: '#5de0a6', warn: '#ffd166', bad: '#ff8193', before: '#321c2a', after: '#12382f' },
|
|
4
|
+
{ id: 'dracula', name: 'Dracula', bg: '#282a36', surface: '#30323f', raised: '#44475a', text: '#f8f8f2', muted: '#d1cde1', line: '#73748d', accent: '#7548ad', focus: '#bd93f9', ok: '#50fa7b', warn: '#f1fa8c', bad: '#ff777f', before: '#4b283b', after: '#203e37' },
|
|
5
|
+
{ id: 'nord', name: 'Nord', bg: '#2e3440', surface: '#353e4d', raised: '#434c5e', text: '#eceff4', muted: '#c7d1df', line: '#75869d', accent: '#5263a4', focus: '#88c0d0', ok: '#b0d69b', warn: '#ebcb8b', bad: '#f09ba0', before: '#493643', after: '#304740' },
|
|
6
|
+
{ id: 'solarized', name: 'Solarized Light', bg: '#fdf6e3', surface: '#fffbed', raised: '#eee8d5', text: '#263f46', muted: '#4d6268', line: '#8b9997', accent: '#6b45a3', focus: '#5c319d', ok: '#286843', warn: '#795400', bad: '#a3292c', before: '#fbe6e0', after: '#e4f0d9' },
|
|
7
|
+
{ id: 'github', name: 'GitHub Light', bg: '#ffffff', surface: '#f6f8fa', raised: '#eaeef2', text: '#1f2328', muted: '#505b66', line: '#8c959f', accent: '#6638aa', focus: '#6633bb', ok: '#216e39', warn: '#795000', bad: '#b4232b', before: '#ffebe9', after: '#dafbe1' },
|
|
8
|
+
];
|
|
9
|
+
const colors = new Set();
|
|
10
|
+
/** Every legacy literal retains its exact default, with a semantic alternate per theme. */
|
|
11
|
+
export function dashboardThemeTokens(source) { return source.replace(/#[\da-f]{8}\b|#[\da-f]{6}\b|#[\da-f]{4}\b|#[\da-f]{3}\b/gi, color => { colors.add(color.toLowerCase()); return 'var(--rtl-' + color.slice(1).toLowerCase() + ')'; }); }
|
|
12
|
+
function semantic(hex) { let s = hex.slice(1); if (s.length <= 4)
|
|
13
|
+
s = s.split('').map(c => c + c).join(''); const [r, g, b] = [0, 2, 4].map(i => parseInt(s.slice(i, i + 2), 16) / 255), max = Math.max(r, g, b), min = Math.min(r, g, b); if (max > .7 && max - min < .27)
|
|
14
|
+
return 'text'; if (max < .27)
|
|
15
|
+
return 'bg'; if (max < .48)
|
|
16
|
+
return 'surface'; if (max - min < .18)
|
|
17
|
+
return 'muted'; if (r > g * 1.3 && b > g * 1.2)
|
|
18
|
+
return max > .7 ? 'focus' : 'accent'; if (g > r * 1.2 && g > b * .85)
|
|
19
|
+
return 'ok'; if (r > g * 1.4 && r > b)
|
|
20
|
+
return 'bad'; if (r > .6 && g > .45 && b < g * .8)
|
|
21
|
+
return 'warn'; return max > .66 ? 'muted' : 'line'; }
|
|
22
|
+
export function dashboardThemeDefinitions() { return ':root{' + [...colors].map(c => '--rtl-' + c.slice(1) + ':' + c).join(';') + '}' + themes.filter(t => t.id !== 'studio').map(t => 'html[data-theme="' + t.id + '"]{' + [...colors].map(c => '--rtl-' + c.slice(1) + ':' + t[semantic(c)]).join(';') + '}').join('') + themes.map(t => 'html[data-theme="' + t.id + '"]{color-scheme:' + (['github', 'solarized'].includes(t.id) ? 'light' : 'dark') + ';' + Object.entries(t).filter(([k]) => !['id', 'name'].includes(k)).map(([k, v]) => '--theme-' + k + ':' + v).join(';') + '}').join('') + '.workflow-screen{background:var(--theme-bg)!important;color:var(--theme-text)!important}.workflow-screen header{background:var(--theme-surface)!important;border-color:var(--theme-line)!important}.workflow-screen h1,.workflow-screen h2,.workflow-screen p,.workflow-screen strong{color:var(--theme-text)!important}.workflow-screen .workflow-mode-status,.workflow-screen .workflow-card p,.workflow-screen .workflow-reassurance{color:var(--theme-muted)!important}.workflow-screen .workflow-card{background:var(--theme-surface)!important;border-color:var(--theme-line)!important;box-shadow:none!important}.workflow-screen .workflow-card.workflow-selected{background:color-mix(in srgb,var(--theme-accent) 20%,var(--theme-surface))!important;border-color:var(--theme-accent)!important}.workflow-screen .workflow-card button{background:var(--theme-accent)!important;border-color:var(--theme-focus)!important;color:#fff!important}.workflow-screen .workflow-reassurance{background:var(--theme-raised)!important;border-color:var(--theme-line)!important}.workflow-screen .workflow-scan{color:var(--theme-ok)!important}.workflow-screen .workflow-scan small{color:var(--theme-muted)!important}.workflow-screen .color-theme-trigger{margin-left:auto}@media(max-width:700px){.workflow-screen header{padding:10px 16px!important;gap:12px!important}.workflow-screen .color-theme-trigger{margin-left:0}.workflow-screen .workflow-brand strong{font-size:20px!important}}'; }
|
|
23
|
+
export const themeClientSource = String.raw `
|
|
24
|
+
(()=>{const themes=__RTL_THEMES__;let saved=localStorage.getItem('rtl-color-theme')||'studio';if(!themes.some(t=>t.id===saved))saved='studio';const root=document.documentElement;root.dataset.theme=saved;const style=document.createElement('style');style.textContent='body,.app{background:var(--theme-bg)!important;color:var(--theme-text)!important}.theme-menu{position:fixed;inset:auto;z-index:120;width:260px;max-width:calc(100vw - 24px);padding:8px;border:1px solid var(--theme-line);border-radius:10px;background:var(--theme-surface);color:var(--theme-text);box-shadow:0 10px 30px #0005}.theme-menu button{display:flex;align-items:center;gap:8px;width:100%;padding:10px;border:1px solid transparent;background:transparent;color:var(--theme-text);text-align:left}.theme-menu button:focus-visible,.theme-menu button:hover{outline:2px solid var(--theme-focus);outline-offset:-2px;background:var(--theme-raised)}.theme-swatch{display:inline-block;width:14px;height:14px;border-radius:50%;border:1px solid var(--theme-line)}.theme-check{margin-left:auto}.color-theme-trigger{min-width:38px;min-height:38px;border:1px solid var(--theme-line);border-radius:8px;background:var(--theme-surface);color:var(--theme-text);font-size:22px}.panel-controls{flex-wrap:wrap}.review-section,.batch-review,.batch-panel,.review-operation,.review-details-dialog,.approval-confirmation{background:var(--theme-surface)!important;color:var(--theme-text)!important;border-color:var(--theme-line)!important}.before-card{background:var(--theme-before)!important}.after-card{background:var(--theme-after)!important}.before-card pre,.after-card pre,.line,.finding-title{color:var(--theme-text)!important}.finding-range{background:var(--theme-accent)!important;color:#fff!important;border-color:var(--theme-focus)!important}html[data-theme] .panel-controls .panel-toggle-btn{transition:none!important;background:var(--theme-raised)!important;color:var(--theme-text)!important;border-color:var(--theme-line)!important}html[data-theme] .panel-controls .panel-toggle-btn[aria-expanded=true],html[data-theme] .nav button.active,html[data-theme] .logo,html[data-theme] .workflow-brand>span,html[data-theme] [role=tab][aria-selected=true],html[data-theme] .workflow-screen .workflow-card button{background:var(--theme-accent)!important;color:#fff!important;border-color:var(--theme-focus)!important}.session-primary,.actions button,.batch-primary,.review-operation button{background:var(--theme-accent)!important;color:#fff!important;border-color:var(--theme-focus)!important}.session-validation[data-status=Passed],.operation-success{color:var(--theme-ok)!important}.session-validation[data-status=Failed]{color:var(--theme-bad)!important}.review-operation::backdrop,.approval-confirmation::backdrop{background:#050a16b8!important}:focus-visible{outline:2px solid var(--theme-focus)!important;outline-offset:2px}';document.head.append(style);
|
|
25
|
+
style.textContent+='html[data-theme] body{background:var(--theme-bg)!important}html[data-theme] .top{background:var(--theme-surface)!important;box-shadow:0 1px 0 var(--theme-line)!important}html[data-theme] .brand:before{box-shadow:0 2px 8px color-mix(in srgb,var(--theme-accent) 28%,transparent)!important}html[data-theme] .nav .active{background:var(--theme-raised)!important;border-color:var(--theme-accent)!important;box-shadow:inset 0 -2px 0 var(--theme-accent)!important}html[data-theme] .nav button:not(:disabled):hover{background:var(--theme-raised)!important;color:var(--theme-text)!important}html[data-theme] .summary .card,html[data-theme] .scope,html[data-theme] .project{background:var(--theme-surface)!important;box-shadow:none!important;border-color:var(--theme-line)!important}html[data-theme] .workspace{background:var(--theme-line)!important;box-shadow:none!important}html[data-theme] .pane,html[data-theme] .details{background:var(--theme-surface)!important}html[data-theme] .head{background:var(--theme-raised)!important;color:var(--theme-muted)!important}html[data-theme] .finding:hover,html[data-theme] .file:hover{background:var(--theme-raised)!important}html[data-theme] .finding.selected,html[data-theme] .file.selected{background:color-mix(in srgb,var(--theme-accent) 22%,var(--theme-surface))!important;border-color:var(--theme-accent)!important;box-shadow:inset 3px 0 var(--theme-focus)!important}html[data-theme] .search-wrap{background:var(--theme-surface)!important;border-color:var(--theme-line)!important}html[data-theme] .status{color:var(--theme-ok)!important}html[data-theme] .batch-review{box-shadow:none!important}html[data-theme] .batch-panel{background:var(--theme-surface)!important}html[data-theme] .batch-review th{color:var(--theme-muted)!important}html[data-theme] .batch-review tbody tr:hover{background:color-mix(in srgb,var(--theme-raised) 72%,transparent)!important}html[data-theme] .batch-review tbody tr:last-child td{border-bottom:0}html[data-theme] .batch-footer{background:var(--theme-surface)!important;box-shadow:0 -1px 0 var(--theme-line)}';const trigger=el('button','🎨','color-theme-trigger');trigger.title='Color theme';trigger.setAttribute('aria-label','Color theme');trigger.setAttribute('aria-haspopup','menu');trigger.setAttribute('aria-expanded','false');const host=document.querySelector('.search-wrap');host?.after(trigger);const menu=el('div','','theme-menu');menu.setAttribute('popover','manual');menu.setAttribute('role','menu');menu.setAttribute('aria-label','Color theme');document.body.append(menu);let open=false,activeTrigger=trigger;
|
|
26
|
+
function close(focus=false){if(!open)return;open=false;menu.hidePopover();root.dataset.theme=saved;activeTrigger.setAttribute('aria-expanded','false');if(focus)activeTrigger.focus()}
|
|
27
|
+
function position(anchor=activeTrigger){const box=anchor.getBoundingClientRect(),width=Math.min(260,innerWidth-24),height=menu.offsetHeight,left=Math.max(12,Math.min(box.left,innerWidth-width-12)),below=box.bottom+8,top=below+height<=innerHeight-12?below:Math.max(12,box.top-height-8);menu.style.left=left+'px';menu.style.top=top+'px'}
|
|
28
|
+
function openFor(anchor){if(open)close(false);activeTrigger=anchor;for(const button of buttons){const checked=button.dataset.themeId===saved;button.setAttribute('aria-checked',String(checked));button.querySelector('.theme-check').textContent=checked?'✓':''}open=true;menu.showPopover();activeTrigger.setAttribute('aria-expanded','true');position(activeTrigger)}
|
|
29
|
+
const buttons=themes.map(t=>{const button=el('button');button.setAttribute('role','menuitemradio');button.dataset.themeId=t.id;for(const color of [t.bg,t.accent,t.text]){const swatch=el('span','','theme-swatch');swatch.style.background=color;swatch.setAttribute('aria-hidden','true');button.append(swatch)}const check=el('span','','theme-check');check.setAttribute('aria-hidden','true');button.append(el('span',t.name),check);button.onpointerenter=()=>{root.dataset.theme=t.id};button.onfocus=()=>{root.dataset.theme=t.id};button.onclick=()=>{saved=t.id;localStorage.setItem('rtl-color-theme',saved);close(true)};menu.append(button);return button});
|
|
30
|
+
trigger.onclick=()=>{if(open){close(true);return}openFor(trigger)};trigger.onkeydown=e=>{if(['ArrowDown','ArrowUp'].includes(e.key)){e.preventDefault();if(!open)openFor(trigger);buttons[e.key==='ArrowDown'?0:buttons.length-1].focus()}};
|
|
31
|
+
menu.onkeydown=e=>{const i=buttons.indexOf(document.activeElement);if(['ArrowDown','ArrowUp','Home','End'].includes(e.key)){e.preventDefault();buttons[e.key==='Home'?0:e.key==='End'?buttons.length-1:(i+(e.key==='ArrowUp'?-1:1)+buttons.length)%buttons.length].focus()}if(e.key==='Escape'){e.preventDefault();close(true)}if(e.key==='Tab')close(false)};document.addEventListener('pointerdown',e=>{if(open&&!menu.contains(e.target)&&!e.target.closest('.color-theme-trigger'))close(false)});document.addEventListener('keydown',e=>{if(e.key==='Escape'&&open){e.preventDefault();close(true)}});addEventListener('resize',()=>{if(open)position(activeTrigger)});document.addEventListener('scroll',()=>{if(open)position(activeTrigger)},true);
|
|
32
|
+
document.addEventListener('rtl-workflow-screen-ready',()=>{const chooser=document.querySelector('.workflow-screen header');if(chooser&&!chooser.querySelector('.chooser-theme-trigger')){const chooserTrigger=document.createElement('button');chooserTrigger.type='button';chooserTrigger.className='color-theme-trigger chooser-theme-trigger';chooserTrigger.textContent='🎨';chooserTrigger.title='Color theme';chooserTrigger.setAttribute('aria-label','Color theme');chooserTrigger.setAttribute('aria-haspopup','menu');chooserTrigger.setAttribute('aria-expanded','false');chooserTrigger.onclick=()=>openFor(chooserTrigger);chooserTrigger.onkeydown=e=>{if(['ArrowDown','ArrowUp'].includes(e.key)){e.preventDefault();openFor(chooserTrigger);buttons[e.key==='ArrowDown'?0:buttons.length-1].focus()}};chooser.insertBefore(chooserTrigger,chooser.lastElementChild)}},{once:true});
|
|
33
|
+
})();
|
|
34
|
+
`.replace('__RTL_THEMES__', JSON.stringify(themes));
|