File size: 1,042 Bytes
ec067d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from pathlib import Path

path = Path("app/product/final_product_ui.py")
text = path.read_text(encoding="utf-8-sig")
text = text.replace("\ufeff", "")

binding_js = r'''
// Phase 40B: expose button functions globally
window.uploadDocument = uploadDocument;
window.refreshDocuments = refreshDocuments;
window.newChat = newChat;
window.reindexSelectedDocument = reindexSelectedDocument;
window.buildGraph = buildGraph;
window.openGraphViewer = openGraphViewer;
window.clearWorkspaceCache = clearWorkspaceCache;
window.deleteSelectedDocument = deleteSelectedDocument;
window.sendMessage = sendMessage;
window.handleKeyDown = handleKeyDown;
window.selectDocument = selectDocument;
window.openSource = openSource;
'''

if "Phase 40B: expose button functions globally" not in text:
    text = text.replace("renderDocuments();\n</script>", binding_js + "\nrenderDocuments();\n</script>")
    print("Added global button bindings.")
else:
    print("Bindings already present.")

path.write_text(text, encoding="utf-8")
print("Phase 40B complete.")