Files
gcontext/web/src/Copy.jsx
T
bernatsamperaandClaude Fable 5 e15e45dd61 Flat layout, agent-executed setup, write approvals, and the display arc
One name per role: src/gcontext moves to gcontext/ (flat layout), the
instructions files split into framework-instructions.md (G0) and the
project's agent.md (G1). Adds the built-in describe-first setup prompt,
state files as MCP resources (gcontext://<path>), and --version.

Exec: run_script splits into run_script and run_adhoc_script; results are
plain readable text with a status line, output_schema=None on all six
tools kills the {"result": ...} wrapper. 100k-char stream caps.

Writes: connection.yaml is agent-writable (only secrets.env stays
blocked), write_file returns a unified diff and warns on index.md drift,
and the instructions require user approval before every write. New
learn-from-errors rule records fail-then-fix lessons where they belong.

Fixes: secrets.load() strips surrounding quotes (quoted tokens caused
misleading 401s). Tests: 61 passing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-01 16:47:28 +02:00

31 lines
1.7 KiB
React

import React from "react";
import { C, mono, useHover, useUi } from "./ui.jsx";
import { copyText } from "./lib.js";
// The one action surface in the app: copy a resource reference for the agent,
// fire a toast. The dashboard SEES the project; the agent (via MCP) USES it,
// so every action hands an @server:gcontext://path reference to the clipboard.
// full pill -> <CopyPrompt text=… /> (⧉ Copy reference, terracotta)
// icon only -> <CopyPrompt text=… icon /> (26x26 ⧉, list rows)
export default function CopyPrompt({ text, label = "Copy reference", toast = "Copied, paste it into your agent", title, icon, style }) {
const ui = useUi();
const [h, hp] = useHover();
const copy = (e) => {
e?.stopPropagation?.();
copyText(text);
ui.toast(toast);
};
if (icon) {
return (
<button {...hp} onClick={copy} title={title || label}
style={{ width: 26, height: 26, flexShrink: 0, display: "inline-flex", alignItems: "center", justifyContent: "center", fontSize: 13, lineHeight: 1, borderRadius: 7, border: `1px solid ${C.accentBorder}`, background: h ? C.accentBgHover : C.accentBg, color: C.accent, cursor: "pointer", transition: "all .12s", ...style }}></button>
);
}
return (
<button {...hp} onClick={copy} title={title}
style={{ flexShrink: 0, display: "inline-flex", alignItems: "center", gap: 7, fontFamily: mono, fontSize: 12.5, fontWeight: 600, lineHeight: 1, padding: "9px 15px", borderRadius: 9, border: `1px solid ${h ? C.accent : C.accentBorderStrong}`, background: h ? C.accentBgHover : C.accentBg, color: C.accent, cursor: "pointer", transition: "all .12s", whiteSpace: "nowrap", ...style }}>
<span style={{ fontSize: 13, lineHeight: 1 }}></span> {label}
</button>
);
}