fix(observer): v16 style/script strip in extractCleanStepText — CSS가 AI 응답으로 Discord 전달되는 버그 수정 (v0.5.52) #task-632

This commit is contained in:
Variet Worker
2026-04-16 21:08:52 +09:00
parent 60a2a97868
commit 62ee081ffe
4 changed files with 23 additions and 19 deletions

View File

@@ -1,7 +1,7 @@
export function generateApprovalObserverScript(_port: number): string {
return `
// ── Gravity Bridge v15: AG Native Chat Relay ──
// v15: AG Native #conversation + .leading-relaxed.select-text chat body scanning
// ── Gravity Bridge v16: AG Native Chat Relay + Style Strip ──
// v16: AG Native style/script strip + #conversation + .leading-relaxed.select-text chat body scanning
(function(){
'use strict';
var BASE='',_obs=false,_sent={},_ready=false;
@@ -10,7 +10,7 @@ export function generateApprovalObserverScript(_port: number): string {
var CLEANUP_MS=300000;
function log(m){console.log('[GB Observer] '+m);}
log('v15 Script loaded — AG Native Chat Relay');
log('v16 Script loaded — AG Native Chat Relay + Style Strip');
// DIAGNOSTIC BEACON: immediate POST to confirm script execution in renderer
try {
@@ -477,6 +477,14 @@ export function generateApprovalObserverScript(_port: number): string {
// Clone the step element so we can strip UI elements without affecting the DOM
var clone = stepEl.cloneNode(true);
// v16: Remove style/script/noscript elements FIRST — AG Native markdown injects <style> blocks
// that contain CSS rules (e.g. remark-github-blockquote-alert/alert.css) whose textContent
// gets captured as AI response text
var styleEls = clone.querySelectorAll('style, script, noscript, link[rel="stylesheet"]');
for (var si = 0; si < styleEls.length; si++) {
if (styleEls[si].parentNode) styleEls[si].parentNode.removeChild(styleEls[si]);
}
// Remove all buttons (Run, Allow, Cancel, etc.)
var buttons = clone.querySelectorAll('button');
for (var bi = 0; bi < buttons.length; bi++) {