Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

fix(website): retain copy receipts while their source text stays unchanged

tt-a1i68bc77b68037
diff --git a/website/src/scripts/start.js b/website/src/scripts/start.js
index d4314800..ba679298 100644
--- a/website/src/scripts/start.js
+++ b/website/src/scripts/start.js
@@ -25,7 +25,7 @@
var includeList = document.getElementById('include-list');
var proofLink = document.getElementById('proof-link');
var proofMeta = document.getElementById('proof-meta');
- var copyStatuses = document.querySelectorAll('.copy-status');
+ var copyReceipts = new Map();
var languageButton = document.getElementById('language');
var agentState = document.getElementById('agent-state');
var installCommand = document.getElementById('install-command');
@@ -125,7 +125,12 @@
proofMeta.textContent = language === 'zh'
? '验证成品 · ' + recipe.presentation.preset + ' · ' + recipe.presentation.motion
: 'Verified proof · ' + recipe.presentation.preset + ' · ' + recipe.presentation.motion;
- copyStatuses.forEach(function (status) { status.textContent = ''; });
+ copyReceipts.forEach(function (receipt, status) {
+ if (receipt.text !== textForStep(receipt.step)) {
+ status.textContent = '';
+ copyReceipts.delete(status);
+ }
+ });
updateUrl();
}
@@ -139,13 +144,23 @@
+ (input === 'description' ? '\n\nThen start any new chat and tell ' : '\n\nThen, in your target repository, ask ') + agentName + ':\n' + currentPrompt();
}
- async function copyText(text, step, statusId) {
+ function textForStep(step) {
+ if (step === 'global_install_copy') return installCommand.textContent.trim();
+ if (step === 'project_install_copy') return projectCommand.textContent.trim();
+ if (step === 'prompt_copy') return currentPrompt();
+ return starterText();
+ }
+
+ async function copyText(step, statusId) {
+ var text = textForStep(step);
var copyStatus = document.getElementById(statusId);
var attempt = ++copyAttempt;
copyStatus.textContent = '';
+ copyReceipts.delete(copyStatus);
var isCurrent = function () { return attempt === copyAttempt; };
var ok = await ArchifyClipboard.copy(text, isCurrent);
if (!isCurrent()) return;
+ copyReceipts.set(copyStatus, { text: text, step: step });
if (ok && step) recordStep(step);
copyStatus.textContent = ok
? (language === 'zh' ? '已复制到剪贴板。' : 'Copied to clipboard.')
@@ -154,6 +169,7 @@
document.querySelectorAll('[data-type]').forEach(function (button) {
button.addEventListener('click', function () {
+ if (type === button.dataset.type) return;
type = button.dataset.type;
render();
});
@@ -173,6 +189,7 @@
document.querySelectorAll('[data-agent]').forEach(function (button) {
button.addEventListener('click', function () {
+ if (agent === button.dataset.agent) return;
agent = button.dataset.agent;
render();
});
@@ -192,6 +209,7 @@
document.querySelectorAll('[data-input]').forEach(function (button) {
button.addEventListener('click', function () {
+ if (input === button.dataset.input) return;
input = button.dataset.input;
render();
});
@@ -212,14 +230,14 @@
document.querySelectorAll('[data-copy-source]').forEach(function (button) {
button.addEventListener('click', function () {
var step = button.dataset.copySource === 'install-command' ? 'global_install_copy' : 'project_install_copy';
- copyText(document.getElementById(button.dataset.copySource).textContent.trim(), step, button.getAttribute('aria-describedby'));
+ copyText(step, button.getAttribute('aria-describedby'));
});
});
document.getElementById('copy-prompt').addEventListener('click', function () {
- copyText(currentPrompt(), 'prompt_copy', 'copy-status');
+ copyText('prompt_copy', 'copy-status');
});
document.getElementById('copy-starter').addEventListener('click', function () {
- copyText(starterText(), 'starter_copy', 'copy-status');
+ copyText('starter_copy', 'copy-status');
});
proofLink.addEventListener('click', function () { recordStep('proof_open'); });
diff --git a/website/test/clipboard-browser.test.mjs b/website/test/clipboard-browser.test.mjs
index 11ea84d9..e85a4da6 100644
--- a/website/test/clipboard-browser.test.mjs
+++ b/website/test/clipboard-browser.test.mjs
@@ -111,6 +111,51 @@ test('real Chrome: website copy controls report real outcomes and preserve selec
assert.equal(receipt.role, 'status'); assert.equal(receipt.live, 'polite');
if (page === 'start') assert.equal(receipt.events, ok ? 1 : 0, 'only successful copies emit conversion events');
}
+ if (page === 'start') {
+ const lifecycle = await evaluate(`(async () => {
+ Object.defineProperty(navigator, 'clipboard', { configurable: true, value: { writeText: async () => {} } });
+ const get = id => document.getElementById(id);
+ const statuses = () => ['install-copy-status', 'project-copy-status', 'copy-status'].map(id => get(id).textContent);
+ const copy = async selector => {
+ const button = document.querySelector(selector); button.click();
+ const status = get(button.getAttribute('aria-describedby'));
+ for (let i = 0; !status.textContent && i < 30; i++) await new Promise(resolve => setTimeout(resolve, 10));
+ };
+ await copy('[data-copy-source="install-command"]');
+ await copy('[data-copy-source="project-command"]');
+ await copy('#copy-prompt');
+ const before = statuses();
+ for (const key of ['agent', 'type', 'input']) document.querySelector('[data-' + key + '][aria-selected="true"]').click();
+ const unchanged = statuses();
+ document.querySelector('[data-input="description"]').click();
+ const inputChanged = statuses();
+ await copy('#copy-prompt');
+ document.querySelector('[data-type="architecture"]').click();
+ const typeChanged = statuses();
+ await copy('#copy-prompt');
+ document.querySelector('[data-agent="codex"]').click();
+ const agentChanged = statuses();
+ await copy('#copy-starter');
+ document.querySelector('[data-agent="cursor"]').click();
+ const starterAgentChanged = statuses();
+ await copy('#copy-starter');
+ document.querySelector('[data-input="repository"]').click();
+ const starterInputChanged = statuses();
+ await copy('#copy-starter');
+ document.querySelector('[data-type="workflow"]').click();
+ const starterTypeChanged = statuses();
+ return { before, unchanged, inputChanged, typeChanged, agentChanged, starterAgentChanged, starterInputChanged, starterTypeChanged };
+ })()`);
+ const success = lang === 'zh' ? '已复制到剪贴板。' : 'Copied to clipboard.';
+ assert.deepEqual(lifecycle.before, [success, success, success]);
+ assert.deepEqual(lifecycle.unchanged, lifecycle.before, 'active selections preserve completed receipts');
+ assert.deepEqual(lifecycle.inputChanged, [success, success, ''], 'input changes only invalidate prompt content');
+ assert.deepEqual(lifecycle.typeChanged, [success, success, ''], 'type changes preserve unchanged installation commands');
+ assert.deepEqual(lifecycle.agentChanged, ['', '', success], 'agent change invalidates installation but not prompt-only content');
+ for (const key of ['starterAgentChanged', 'starterInputChanged', 'starterTypeChanged']) assert.deepEqual(lifecycle[key], ['', '', ''], key);
+ manifest.receipts.push({ lang, page, lifecycle });
+ fs.writeFileSync(path.join(output, 'manifest.json'), JSON.stringify(manifest, null, 2));
+ }
// Slow responses must not overwrite a newer failure, restore stale focus,
// or launch a fallback after the selected recipe/tab has been replaced.
for (const lateOutcome of ['resolve', 'reject']) {