Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/zcode-context/dist/context.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugins/zcode-context/dist/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31379,7 +31379,7 @@ function createContextServer() {
HTML_URI,
{
mimeType: "text/html;profile=mcp-app",
_meta: { ui: { csp: { connectDomains: [], resourceDomains: [] } } }
_meta: { ui: { csp: { connectDomains: [], resourceDomains: [] }, permissions: { clipboardWrite: {} } } }
},
async () => ({ contents: [{ uri: HTML_URI, mimeType: "text/html;profile=mcp-app", text: await readFile(new URL("./context.html", import.meta.url), "utf8") }] })
);
Expand Down
4 changes: 3 additions & 1 deletion src/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ const HTML_URI = "ui://zcode-context/panel.html";
const reader = createReader(() => new Worker(new URL("./worker.mjs", import.meta.url), { workerData: { paths: resolveDataPaths() }, resourceLimits: { maxOldGenerationSizeMb: 256 } }));
export function createContextServer() {
const server = new McpServer({name:"zcode-context",version:"0.3.10"});
// clipboardWrite is what the panel's copy buttons need: the host gates clipboard-write on what the resource
// declares, and a sandboxed frame is not the host origin that feature defaults to.
server.registerResource("context_panel", HTML_URI, { mimeType:"text/html;profile=mcp-app",
_meta:{ui:{csp:{connectDomains:[],resourceDomains:[]}}} },
_meta:{ui:{csp:{connectDomains:[],resourceDomains:[]},permissions:{clipboardWrite:{}}}} },
async () => ({contents:[{uri:HTML_URI,mimeType:"text/html;profile=mcp-app",text:await readFile(new URL("./context.html",import.meta.url),"utf8")}]})
);
const wrap = method => async (args,extra) => {
Expand Down
12 changes: 11 additions & 1 deletion ui/app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,18 @@ function loadOlder() {
olderLoad={generation:expected,promise};
return promise;
}
// The panel runs in a sandboxed frame; the host's Permissions-Policy blocks clipboard-write for it, so the
// async Clipboard API rejects and only the execCommand path can still reach the clipboard.
async function copy(text) {
try{await navigator.clipboard.writeText(text);flash("copied");}catch{flash("copyFailed");}
try{await navigator.clipboard.writeText(text);flash("copied");return;}catch{}
const scratch=document.createElement("textarea");
scratch.value=text;scratch.setAttribute("readonly","");
scratch.style.position="fixed";scratch.style.top="-1000px";scratch.style.left="-1000px";scratch.style.opacity="0";
document.body.append(scratch);scratch.select();scratch.setSelectionRange(0,text.length);
let ok=false;
try{ok=document.execCommand("copy");}catch{ok=false;}
scratch.remove();
flash(ok?"copied":"copyFailed");
}
// "Previous turn" is resolved by the service over its whole cache, not only the steps this panel has loaded.
function baselineArgs() {
Expand Down