AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.
Rust agent-memoryai-agentsbm25claude-codeclicode-searchcursordatabaseelasticsearchfull-text-searchhybrid-searchjsonllocal-firstmcpmcp-servermodel-context-protocolragrustsearch-enginevector-search
fix(landing): report clipboard failures honestly (#2091, from #2068)
xerj-org9c87d2899e0c
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 731d33286..2ad34569e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -31,6 +31,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0missing or cyclic template references keep the blank fallback. Customdashboard layout overrides also survive reloading the page.+- Landing-page copy buttons report `COPY FAILED` when clipboard access is+ denied or the legacy copy command fails, and retain their original label+ after repeated clicks. A failed copy can be retried.+- `xerj search` and a plain-string `xerj_search` rank a file that containsthe query as an exact phrase (a pasted error message or log line) at thetop. The bag-of-words leg alone let a short `defs` list sharing two of thediff --git a/landing/interact.js b/landing/interact.jsindex 18ec737d0..52109d122 100644--- a/landing/interact.js+++ b/landing/interact.js@@ -22,15 +22,17 @@The value is read from the attribute so HTML-escaped quotes are restoredbefore it reaches the clipboard. */$$('[data-copy]').forEach(btn => {+ const label = btn.textContent;+ let resetTimer;btn.addEventListener('click', () => {const text = btn.getAttribute('data-copy');- const done = () => {- const orig = btn.textContent;- btn.textContent = 'COPIED';- setTimeout(() => { btn.textContent = orig; }, 1400);+ const done = copied => {+ clearTimeout(resetTimer);+ btn.textContent = copied ? 'COPIED' : 'COPY FAILED';+ resetTimer = setTimeout(() => { btn.textContent = label; }, 1400);};if (navigator.clipboard && navigator.clipboard.writeText) {- navigator.clipboard.writeText(text).then(done, done);+ navigator.clipboard.writeText(text).then(() => done(true), () => done(false));} else {const ta = document.createElement('textarea');ta.value = text;@@ -39,9 +41,10 @@ta.style.left = '-9999px';document.body.appendChild(ta);ta.select();- try { document.execCommand('copy'); } catch (_) {}+ let copied = false;+ try { copied = document.execCommand('copy'); } catch (_) {}document.body.removeChild(ta);- done();+ done(copied);}});});diff --git a/scripts/landing/test_interact.cjs b/scripts/landing/test_interact.cjsnew file mode 100644index 000000000..ee8cf9bc4--- /dev/null+++ b/scripts/landing/test_interact.cjs@@ -0,0 +1,81 @@+// Exercise the shipped script through its DOM click handler, without a browser dependency.+const assert = require('node:assert/strict');+const fs = require('node:fs');+const path = require('node:path');+const vm = require('node:vm');+const { test } = require('node:test');+const source = fs.readFileSync(path.join(__dirname, '../../landing/interact.js'), 'utf8');++function fixture(modern, succeeds) {+ let click;+ let success = succeeds;+ const timers = new Map();+ const children = [];+ const writes = [];+ const button = {+ textContent: 'COPY THE PROMPT',+ getAttribute: () => 'a "quoted" prompt',+ addEventListener: (_, handler) => { click = handler; },+ };+ const document = {+ documentElement: {},+ querySelectorAll: selector => selector === '[data-copy]' ? [button] : [],+ createElement: () => ({ style: {}, setAttribute() {}, select() {} }),+ body: {+ appendChild: element => children.push(element),+ removeChild: element => children.splice(children.indexOf(element), 1),+ },+ execCommand: command => {+ assert.equal(command, 'copy');+ writes.push(children[0].value);+ if (success === 'throw') throw Error('clipboard denied');+ return success;+ },+ };+ const navigator = modern ? { clipboard: { writeText: text => {+ writes.push(text);+ return success ? Promise.resolve() : Promise.reject(Error('clipboard denied'));+ } } } : {};+ let nextTimer = 0;+ vm.runInNewContext(source, {+ document, navigator,+ setTimeout: handler => { timers.set(++nextTimer, handler); return nextTimer; },+ clearTimeout: id => timers.delete(id),+ });+ return {+ button, children, writes,+ async click() { click(); await Promise.resolve(); await Promise.resolve(); },+ succeed() { success = true; },+ expire() { const pending = [...timers.values()]; timers.clear(); pending.forEach(handler => handler()); },+ };+}++for (const [name, modern, success] of [+ ['modern rejection', true, false],+ ['legacy false result', false, false],+ ['legacy exception', false, 'throw'],+]) {+ test(`${name} reports failure and allows a successful retry`, async () => {+ const page = fixture(modern, success);+ await page.click();+ assert.equal(page.button.textContent, 'COPY FAILED');+ assert.equal(page.children.length, 0);+ page.succeed();+ await page.click();+ assert.equal(page.button.textContent, 'COPIED');+ assert.deepEqual(page.writes, ['a "quoted" prompt', 'a "quoted" prompt']);+ page.expire();+ assert.equal(page.button.textContent, 'COPY THE PROMPT');+ });+}+for (const modern of [true, false]) {+ test(`${modern ? 'modern' : 'legacy'} successful copies restore the original label after repeated clicks`, async () => {+ const page = fixture(modern, true);+ await page.click();+ assert.equal(page.button.textContent, 'COPIED');+ await page.click();+ page.expire();+ assert.equal(page.button.textContent, 'COPY THE PROMPT');+ assert.equal(page.children.length, 0);+ });+}diff --git a/scripts/seo/README.md b/scripts/seo/README.mdindex 1004dca49..38025ac82 100644--- a/scripts/seo/README.md+++ b/scripts/seo/README.md@@ -22,6 +22,13 @@ from `landing/`. Custom dashboards inherit their template's data and renderfunctions while keeping their own layout overrides. Clones can themselves becloned; missing or cyclic template references produce the blank fallback.+The shared marketing-page copy controls in `landing/interact.js` display+`COPIED` only after the clipboard API or legacy copy command succeeds. A denied+copy displays `COPY FAILED`; visitors can retry or select the command manually.+The temporary feedback restores the original button label. Run the interaction+regressions with `node --test scripts/landing/test_interact.cjs` (Node 18+; no+packages are required).+## 1. Architecture```