diff --git a/dashboard.html b/dashboard.html
index 796d2ce..ef445e6 100644
--- a/dashboard.html
+++ b/dashboard.html
@@ -39,6 +39,18 @@
document.querySelectorAll('button[data-copy]').forEach(function(b){
b.addEventListener('click',function(){
var t=b.getAttribute('data-copy');
+ if(Array.from(t).length>50000){
+ var status=b.parentNode.querySelector('.copy-budget');
+ if(!status){status=document.createElement('p');status.className='copy-budget';
+ status.setAttribute('role','status');b.insertAdjacentElement('afterend',status);}
+ if(status.dataset.url)URL.revokeObjectURL(status.dataset.url);
+ status.textContent='Not copied: request exceeds 50,000 characters. '+
+ 'Download the complete request and attach it to your coding chat. ';
+ var link=document.createElement('a');
+ link.href=URL.createObjectURL(new Blob([t],{type:'text/plain;charset=utf-8'}));
+ status.dataset.url=link.href;link.download='dashboard-request.txt';
+ link.textContent='Download complete request';status.appendChild(link);return;
+ }
var done=function(){b.classList.add('copied');setTimeout(function(){b.classList.remove('copied')},1200)};
if(navigator.clipboard){navigator.clipboard.writeText(t).then(done,function(){})}
});
diff --git a/eyes/board.py b/eyes/board.py
index dea6f50..bcf97bf 100644
--- a/eyes/board.py
+++ b/eyes/board.py
@@ -378,15 +378,30 @@ def render_markdown(views) -> str:
code{color:var(--accent)}
"""
+# Eyes renders without a Brain checkout. Match the family clipboard budget in
+# PyAutoBrain/board/_theme.py; keep this standalone guard for that offline path.
+MAX_PROMPT_CHARS = 50_000
JS = """
document.querySelectorAll('button[data-copy]').forEach(function(b){
b.addEventListener('click',function(){
var t=b.getAttribute('data-copy');
+ if(Array.from(t).length>__MAX_PROMPT_CHARS__){
+ var status=b.parentNode.querySelector('.copy-budget');
+ if(!status){status=document.createElement('p');status.className='copy-budget';
+ status.setAttribute('role','status');b.insertAdjacentElement('afterend',status);}
+ if(status.dataset.url)URL.revokeObjectURL(status.dataset.url);
+ status.textContent='Not copied: request exceeds 50,000 characters. '+
+ 'Download the complete request and attach it to your coding chat. ';
+ var link=document.createElement('a');
+ link.href=URL.createObjectURL(new Blob([t],{type:'text/plain;charset=utf-8'}));
+ status.dataset.url=link.href;link.download='dashboard-request.txt';
+ link.textContent='Download complete request';status.appendChild(link);return;
+ }
var done=function(){b.classList.add('copied');setTimeout(function(){b.classList.remove('copied')},1200)};
if(navigator.clipboard){navigator.clipboard.writeText(t).then(done,function(){})}
});
});
-"""
+""".replace("__MAX_PROMPT_CHARS__", str(MAX_PROMPT_CHARS))
def _e(value) -> str:
diff --git a/tests/test_board.py b/tests/test_board.py
index 8248a4e..73c9258 100644
--- a/tests/test_board.py
+++ b/tests/test_board.py
@@ -3,6 +3,8 @@
import json
import os
import re
+import shutil
+import subprocess
import urllib.parse
from pathlib import Path
@@ -11,6 +13,42 @@
from eyes import board, context, registry
+@pytest.mark.parametrize("length", [50_000, 50_001])
+def test_review_copy_budget_retains_complete_unicode_request(length):
+ node = shutil.which("node")
+ if not node:
+ pytest.skip("Node is needed for the browser clipboard contract")
+ script = (
+ r"""
+const assert=require('assert');
+let click,status,downloaded,writes=0;
+const text='🌌'.repeat(LENGTH);
+const b={getAttribute:()=>text,addEventListener:(event,fn)=>click=fn,
+ parentNode:{querySelector:()=>status},insertAdjacentElement:(where,s)=>status=s,
+ classList:{add(){},remove(){}}};
+global.document={querySelectorAll:()=>[b],
+ createElement:()=>({dataset:{},setAttribute(){},appendChild(){}})};
+Object.defineProperty(global,'navigator',{value:{clipboard:{writeText:async()=>{writes++}}}});
+global.URL={createObjectURL:blob=>{downloaded=blob;return 'blob:test'},revokeObjectURL(){}};
+global.setTimeout=()=>{};
+"""
+ + board.JS
+ + r"""
+click();assert.equal(writes,LENGTH<=50000?1:0);
+if(LENGTH>50000){
+ assert.match(status.textContent,/Not copied/);
+ downloaded.text().then(value=>assert.equal(value,text));
+}
+"""
+ )
+ subprocess.run(
+ [node, "-e", script.replace("LENGTH", str(length))],
+ check=True,
+ capture_output=True,
+ text=True,
+ )
+
+
@pytest.fixture
def views(registry_file, project):
instances = registry.load(registry_file)