Claude's answers, rendered: Markdown, math, charts and diagrams drawn in the Claude Code terminal. Independent project, not affiliated with Anthropic.
TypeScript claude-code-mod
Copy: Python isolated, one mapping for a failed selection, no false outside copies
razorback16a9071ee0ab03
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e2ed286..dc98894 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -15,6 +15,9 @@ All releases of Intelligent UI for Claude Code (`cc-intelligent-ui`). Claude Cod- A long session no longer keeps the last text of each answer in memory: the mod keeps the newest 1,024, as it does for the compile results.- The picture select highlight could stop on a page whose frames went out of the page cache while its build waited. That page is now built again.- The watcher no longer sends `kill` to the PID of a child that ended (the PID can be another process's).+- On Linux, the GTK clipboard read, watch and check run Python isolated (`-I`): a `gi.py` in the session's project folder no longer runs.+- When `$.ui.selection()` fails, a `ui.copy` of picture cells and `/iui grab` copy again (before, they said that a newer copy came first).+- A clipboard read that fails (an error or the 2 s timeout), or a late read of one of the mod's last 4 copies, no longer cancels a newer copy.### Changeddiff --git a/README.md b/README.mdindex afca836..7d57ba9 100644--- a/README.md+++ b/README.md@@ -109,7 +109,7 @@ The mod sends nothing about you or your sessions anywhere.- **Clipboard, read:** a small `perl` process watches the clipboard while the mod is on and has drawn a picture (not over ssh). On macOS it reads only the change counter; when the counter changes, the mod reads the text once with a short `perl` script (PerlObjCBridge). On Linux a notifier (`wl-paste --watch`, `clipnotify` or GTK 3 from `python3`) tells it of each change, and it then reads the text with `wl-paste`, `xclip` or GTK. `/iui grab` with no mouse selection also reads the clipboard once. The text is only checked for picture cells (then a toast names `/iui grab`); it is kept in memory only and sent nowhere (`/iui dump` writes the last clipboard with picture cells to `copy-debug.json` in the cache folder). A password manager's copy is never read: on macOS a copy with a concealed or transient type, on Linux a copy that offers the `x-kde-passwordManagerHint` target, and on Wayland also a copy marked sensitive. (On Wayland, `wl-paste --watch` hands each new copy to `cat`, which drops it.)- **Clipboard, written:** only at these times: when you release a picture selection, when you click a link, a file path, a command or a copy button in a picture, on `/iui grab`, when you press the command button in a link row on the main screen, and when the mod changes a `$.ui.copy` that has picture cells to its text.- **Files:** a private cache folder in `$TMPDIR` (`cc-intelligent-ui-<uid>`, `/tmp` when `TMPDIR` is not set; mode 700, its folders deleted after 2 days). Each compile makes a folder of its own in it (the Typst root, see below) and deletes it after the compile. Also `~/.cache/cc-intelligent-ui/designs` (files deleted after 180 days) and `~/.cache/cc-intelligent-ui/fonts` (fonts copied out of a terminal app, such as Ghostty's JetBrains Mono; `$XDG_CACHE_HOME` in place of `~/.cache` when it is set). `/iui setup` on macOS changes your shell start file, only when you run it or agree to its question.-- **Processes:** `typst`, the `perl` watcher, and short helper commands such as `perl`, `sh`, `osascript`, `defaults`, `plutil`, `fc-list` and `fc-match`. On Linux also `wl-paste`, `xclip`, `clipnotify` or `python3` (GTK 3) for the clipboard.+- **Processes:** `typst`, the `perl` watcher, and short helper commands such as `perl`, `sh`, `osascript`, `defaults`, `plutil`, `fc-list` and `fc-match`. On Linux also `wl-paste`, `xclip`, `clipnotify` or `python3 -I` (GTK 3; isolated, so it loads no code from the project folder) for the clipboard.- **Typst:** each compile of an answer or a plan runs with a narrow root: a new folder with the mod's template, the theme and the images that the text names. So the code in an answer cannot read other files on your computer. The skill's `check.sh` compiles the same way.## Docsdiff --git a/hooks/lib/clipboard.ts b/hooks/lib/clipboard.tsindex c6d8a89..cc1e279 100644--- a/hooks/lib/clipboard.ts+++ b/hooks/lib/clipboard.ts@@ -98,7 +98,9 @@ export const GTK_READ_PY = ['if t is None: sys.exit(1)','sys.stdout.write(t)',].join('\n')-const GTK_ENV = ['/usr/bin/env', 'GDK_BACKEND=x11', 'PYTHONIOENCODING=utf-8']+const GTK_ENV = ['/usr/bin/env', 'GDK_BACKEND=x11']+// Python isolated (-I): no gi.py of the session's folder runs; -X utf8 for UTF-8 stdout.+const PY_ISOLATED = ['-I', '-X', 'utf8']// The way to read and watch the clipboard on Linux, from the session// (WAYLAND_DISPLAY, DISPLAY, the desktop) and the tools found (their paths).@@ -109,7 +111,9 @@ const GTK_ENV = ['/usr/bin/env', 'GDK_BACKEND=x11', 'PYTHONIOENCODING=utf-8']export function clipWayOf(o: { wayland: boolean; x11: boolean; desktop: string; found: Partial<Record<ClipTool, string>> }): ClipWay {const { found } = oconst wl = o.wayland && found['wl-paste'] ? found['wl-paste'] : ''- const gtk = found.gtk ? { read: [...GTK_ENV, found.gtk, '-c', GTK_READ_PY], watch: [...GTK_ENV, found.gtk, '-c', GTK_WATCH_PY] } : null+ const gtk = found.gtk+ ? { read: [...GTK_ENV, found.gtk, ...PY_ISOLATED, '-c', GTK_READ_PY], watch: [...GTK_ENV, found.gtk, ...PY_ISOLATED, '-c', GTK_WATCH_PY] }+ : null// xsel is no reader: it can not list the targets (a password manager's copy would be read).const reader = found.xclip ? { tool: 'xclip', read: ['sh', '-c', XCLIP_READ_SH, found.xclip] }: gtk ? { tool: 'GTK', read: gtk.read } : null@@ -133,11 +137,11 @@ export function clipWayOf(o: { wayland: boolean; x11: boolean; desktop: string;}// Prints `tool path` for each clipboard tool on the PATH, and `gtk <python3>`-// when there is no clipnotify or no xclip, and python3 loads GTK 3.+// when there is no clipnotify or no xclip, and python3 (isolated) loads GTK 3.const GTK_CHECK_PY = 'import gi; gi.require_version("Gtk", "3.0"); from gi.repository import Gtk'export const FIND_SH = [`for c in ${CLIP_TOOLS.filter(c => c !== 'gtk').join(' ')}; do p=$(command -v "$c" 2>/dev/null) && echo "$c $p"; done`,- `{ command -v clipnotify && command -v xclip; } >/dev/null 2>&1 || { p=$(command -v python3 2>/dev/null) && "$p" -c '${GTK_CHECK_PY}' >/dev/null 2>&1 && echo "gtk $p"; }`,+ `{ command -v clipnotify && command -v xclip; } >/dev/null 2>&1 || { p=$(command -v python3 2>/dev/null) && "$p" -I -c '${GTK_CHECK_PY}' >/dev/null 2>&1 && echo "gtk $p"; }`,].join('; ')// The tools of `FIND_SH`'s output, by name; only absolute paths.@@ -175,14 +179,19 @@ async function lookUp($: EngineInterface): Promise<ClipWay> {// null when it can not be read (no tool or no bridge, no text in it, or a// password manager's copy, which is never read).export async function clipboardNow($: EngineInterface): Promise<string | null> {- if (S.env?.isMac) {- const got = await exec($, ['/usr/bin/perl', '-e', READ_PL], { timeoutMs: 2000 }).catch(() => null)- return got && got.exitCode === 0 ? got.stdout : null- }+ return (await clipboardRead($)) ?? null+}++// The same read, with a failed one apart: null for no text or a password+// manager's copy (exit 1 or 3: a copy all the same); undefined when the read+// failed (no tool or no bridge, an error, the 2 s timeout).+export async function clipboardRead($: EngineInterface): Promise<string | null | undefined> {const way = S.clipWay- if (!way || !('read' in way)) return null- const got = await exec($, way.read, { timeoutMs: 2000 }).catch(() => null)- return got && got.exitCode === 0 ? got.stdout : null+ const argv = S.env?.isMac ? ['/usr/bin/perl', '-e', READ_PL] : way && 'read' in way ? way.read : null+ if (!argv) return undefined+ const got = await exec($, argv, { timeoutMs: 2000 }).catch(() => null)+ if (!got) return undefined+ return got.exitCode === 0 ? got.stdout : got.exitCode === 1 || got.exitCode === 3 ? null : undefined}// The watcher's arguments after `clip`: none on macOS (its PerlObjCBridge),diff --git a/hooks/register.tsx b/hooks/register.tsxindex 604af33..b33dfbe 100644--- a/hooks/register.tsx+++ b/hooks/register.tsx@@ -45,7 +45,7 @@ import { finalizeAll } from './lib/stream'import { knownTargets, knownWords, noteDrawn, noteDrawnAgain, noteOnScreen, wordsOf, type PageWords } from './lib/probe'import { codePointsOf, decodeSelection, hasPlaceholders, joinSegments, pageTopsOf, pickPages, textOfRun, type Drawn, type Pick, type Segment } from './lib/copy'import { pagesOf, type Drawing } from './lib/answer'-import { clipboardNow, clipWatchArgs, clipWayReady, hintText } from './lib/clipboard'+import { clipboardNow, clipboardRead, clipWatchArgs, clipWayReady, hintText } from './lib/clipboard'import { setUp } from './lib/env'import { frameFor, noteView, stopWatch, watchFrame, watchState } from './lib/frame'import { roomColumns } from './lib/terminal'@@ -313,11 +313,11 @@ function hintGrab($: EngineInterface, text: string) {toast($, 'Intelligent UI: picture cells copied; /iui grab puts their text on the clipboard')}-// The clipboard changed: one read (clipboardNow). A clipboard with no+// The clipboard changed: one read (clipboardRead). A clipboard with no// placeholders, and our own write, are never touched. A new text that no-// $.ui.copy wrote (another app's copy, Claude Code's copy on select, a-// password manager's: null) is a newer copy. A change while a read runs-// reads once more after it.+// recent $.ui.copy wrote (another app's copy, Claude Code's copy on select, a+// password manager's: null) is a newer copy; a failed read is none. A change+// while a read runs reads once more after it.async function readClipboard($: EngineInterface) {if (clip.busy) {clip.again = true@@ -327,10 +327,10 @@ async function readClipboard($: EngineInterface) {try {do {clip.again = false- const text = await clipboardNow($)- if (text === clip.seen) continue+ const text = await clipboardRead($)+ if (text === undefined || text === clip.seen) continueclip.seen = text- if (text !== copiedText) copies+++ if (text === null || !copiedTexts.includes(text)) copies++if (text === null || text === clip.wrote || !hasPlaceholders(text)) continuehintGrab($, text)} while (clip.again)@@ -376,19 +376,24 @@ async function updateState($: EngineInterface): Promise<UpdateState> {// The newest copy (a grab, a click, an up, any $.ui.copy, or a copy from// outside that the watcher sees): an older one that still reads its text-// when a newer one starts copies nothing. `copiedText`: the text of the-// last $.ui.copy (its clipboard change is no copy from outside).+// when a newer one starts copies nothing. `copiedTexts`: the texts of the+// last 4 $.ui.copy calls (their changes, even read late, are no copy from outside).let copies = 0-let copiedText: string | undefined+const copiedTexts: string[] = []+function noteCopied(text: string) {+ copiedTexts.push(text)+ if (copiedTexts.length > 4) copiedTexts.shift()+}// A copy's turn: its number and the native selection when it began.type Turn = { n: number; native: Promise<string> }const nativeKey = (s: { text: string; requestId?: string } | undefined) => (s ? `${s.requestId ?? ''}|${s.text}` : '')function nativeNow($: EngineInterface): Promise<string> {try {- return Promise.resolve(uiSelection($)).then(nativeKey, () => '?')+ // A failed read is no selection, as grab and the ui.copy hook take it.+ return Promise.resolve(uiSelection($)).then(nativeKey, () => nativeKey(undefined))} catch {- return Promise.resolve('?')+ return Promise.resolve(nativeKey(undefined))}}const takeTurn = ($: EngineInterface, native?: Promise<string>): Turn => ({ n: ++copies, native: native ?? nativeNow($) })@@ -707,7 +712,7 @@ export const register: Register = on => {// hold no placeholders and pass on as they are. Any copy is the newest:// one with placeholders whose words are read when a newer one came is refused.on('ui.copy', async ($, e, next) => {- copiedText = e.text+ noteCopied(e.text)if (!hasPlaceholders(e.text) || !drawnAnswers.size) {copies++return next(e)@@ -724,7 +729,7 @@ export const register: Register = on => {// The clipboard change of this write is not read again.clip.wrote = read.textclip.seen = read.text- copiedText = read.text+ noteCopied(read.text)return next({ ...e, text: read.text })}).catch(($, e, next) => next(e))diff --git a/tests/copy.test.ts b/tests/copy.test.tsindex 91884cb..03badf2 100644--- a/tests/copy.test.ts+++ b/tests/copy.test.ts@@ -587,10 +587,10 @@ const inputsOf = (argv: readonly string[]) => Object.fromEntries(argv.flatMap((a// The world beneath the mod: a cache at /c, a typst whose compile writes a// 1568 x 512 page per segment and whose query of page n gives the fixture's// marks on page n (`hold` holds the next query until `release`; a kill ends-// it; `holdReads` the clipboard reads until `releaseReads`), the watcher (WATCH_PL: its PID, then with `clip` the change count at+// it; `holdReads` the clipboard reads until `releaseReads`, each with the clipboard of its start), the watcher (WATCH_PL: its PID, then with `clip` the change count at// its start and at each change of the clipboard; `clip none` with// `noBridge`), the read (READ_PL) giving `clipboard` (exit 3 for a-// password manager's copy: `concealed`), and the copies, toasts and+// password manager's copy: `concealed`; refused with `readFails`), and the copies, toasts and// selection the test sees. `copy` is a native copy (a drag over text and// pictures, the main screen's terminal copy): while `selects`, picture cells// are this session's selection too; the text goes on the clipboard, one@@ -603,11 +603,12 @@ const inputsOf = (argv: readonly string[]) => Object.fromEntries(argv.flatMap((a// written, `blits` the blits asked (`deny`: each refused with it), `logs`// the debug log lines. `noPerl`: perl can not start; `beforeWrite` runs// before each frame write; `refused`: the cache folder sweep refuses that folder.+// `selectionFails`: each $.ui.selection is refused.function world(on: any,o: {failFirst?: boolean; noBridge?: boolean; env?: Record<string, string>; tty?: string; version?: string; deny?: string; noPerl?: boolean; beforeWrite?: () => Promise<void>- refused?: string; marks?: readonly object[]+ refused?: string; marks?: readonly object[]; selectionFails?: boolean} = {},) {forgetBlits()@@ -631,7 +632,7 @@ function world(const w = {clock, files, compiles, queries, kills, watchers, vars, envSets,ran: [] as string[][], spawned: [] as string[][], reads: [] as string[],- clipboard: 'nothing yet', secret: false, count: 40, pastes: 0, copies: [] as string[], toasts: [] as string[], traces: [] as string[], logs: [] as string[],+ clipboard: 'nothing yet', secret: false, readFails: false, count: 40, pastes: 0, copies: [] as string[], toasts: [] as string[], traces: [] as string[], logs: [] as string[],frames: [] as { path: string; old: string[]; png: Uint8Array }[], blits: [] as any[], writes: 0, selectionReads: 0,selection: undefined as { text: string; requestId?: string } | undefined,selects: true,@@ -732,9 +733,12 @@ function world(if (cmd.includes('od -An')) return ok(argv.filter(a => a.endsWith('.png')).map(() => `${HEAD}\n@\n`).join(''))if (argv[0] === '/usr/bin/perl' && argv[2] === READ_PL) {w.pastes+++ const { clipboard, secret } = wif (w.readGate) await w.readGate+ // A read that failed (an error, the 2 s timeout).+ if (w.readFails) return { deny: 'timed out' }// A password manager's copy: exit 3, its text not read.- return w.secret ? ok('', 3) : ok(w.clipboard)+ return secret ? ok('', 3) : ok(clipboard)}return ok('', 1)})@@ -762,6 +766,7 @@ function world(})on('ui.selection', async () => {w.selectionReads+++ if (o.selectionFails) return { deny: 'no selection' }return { value: w.selection }})on('ui.blit', async ($: any, e: any) => {@@ -2167,6 +2172,61 @@ test('/iui grab that copies nothing (no selection, no picture cells) does not caexpect(w.clipboard).toBe('https://example.com')})+test('a clipboard read that fails (an error, the 2 s timeout) is no copy from outside: a click whose words are still read still copies', async ($, on) => {+ const { w } = await drawTargets($, on)+ w.hold()+ const slow = await drawAnswer($, w, 'ans-2', `${TARGETS_MD}\n\nOne more line.`)+ await click(slow, 6, 3)+ await settle(w)+ const pastes = w.pastes+ w.readFails = true+ w.change()+ await settle(w)+ expect(w.pastes).toBe(pastes + 1)+ w.release()+ await settle(w)+ expect(w.copies).toEqual(['https://example.com'])+ expect(w.clipboard).toBe('https://example.com')+})++test('our own older write, read late by the watcher, does not cancel a newer click whose words are still read', async ($, on) => {+ const { w, ui } = await drawTargets($, on)+ await hover(ui, 52, 4)+ await settle(w)+ // Two clicks on the ready page; the read of the first one's change (its text 'ls -la') is held.+ w.holdReads()+ await click(ui, 52, 4)+ await settle(w)+ await click(ui, 6, 3)+ await settle(w)+ expect(w.copies).toEqual(['ls -la', 'https://example.com'])+ w.hold()+ const slow = await drawAnswer($, w, 'ans-2', `${TARGETS_MD}\n\nOne more line.`)+ await click(slow, 52, 4)+ await settle(w)+ // The late read gives the older write, then the read again the newer one: neither is a copy from outside.+ w.releaseReads()+ await settle(w)+ w.release()+ await settle(w)+ expect(w.copies).toEqual(['ls -la', 'https://example.com', 'ls -la'])+ expect(w.clipboard).toBe('ls -la')+})++test('a $.ui.selection that fails is no selection at both ends of a copy: a $.ui.copy of picture cells and /iui grab still copy', { plugins: [COPIER] }, async ($, on) => {+ const w = world(on, { selectionFails: true })+ await $.command.run({ command: 'iui', args: '' } as any)+ await drawAnswer($, w)+ const got = await $.command.run({ command: 'cp', args: COPY } as any)+ expect(JSON.parse(got.text!)).toEqual({ isCopied: true })+ expect(w.copies).toEqual([COPIED])+ // A native copy of the cells: /iui grab reads them from the clipboard.+ w.foreign(COPY)+ await w.clock.settle()+ expect(await grab($)).toBe(GRABBED)+ expect(w.copies).toEqual([COPIED, COPIED])+})+test('a password manager\'s copy is never read: no hint, no /iui grab, nothing in dump; the read looks at the marks first', async ($, on) => {const w = world(on)await $.command.run({ command: 'iui', args: '' } as any)diff --git a/tests/linux.test.ts b/tests/linux.test.tsindex f0199d0..c9af3a8 100644--- a/tests/linux.test.ts+++ b/tests/linux.test.ts@@ -6,7 +6,7 @@ import {type ClipWay,} from '../hooks/register'import { CACHE_SH } from '../hooks/lib/env'-import { clipboardNow, clipWatchArgs, clipWayReady, findClipWay } from '../hooks/lib/clipboard'+import { clipboardNow, clipboardRead, clipWatchArgs, clipWayReady, findClipWay } from '../hooks/lib/clipboard'import { S } from '../hooks/lib/state'import { SMALL_MARKS, SMALL_MD } from './copy-fixture'@@ -44,8 +44,8 @@ test('GNOME on Wayland (no data-control): the X11 tools through Xwayland come fi// Only GTK (a GNOME desktop with no other tool): GTK reads and watches.const gtk = clipWayOf({ wayland: true, x11: true, desktop: 'GNOME', found: { gtk: '/usr/bin/python3' } }) as Extract<ClipWay, { name: string }>expect(gtk.name).toBe('GTK (X11, Xwayland)')- expect(gtk.read).toEqual(['/usr/bin/env', 'GDK_BACKEND=x11', 'PYTHONIOENCODING=utf-8', '/usr/bin/python3', '-c', GTK_READ_PY])- expect(gtk.watch).toEqual(['/usr/bin/env', 'GDK_BACKEND=x11', 'PYTHONIOENCODING=utf-8', '/usr/bin/python3', '-c', GTK_WATCH_PY])+ expect(gtk.read).toEqual(['/usr/bin/env', 'GDK_BACKEND=x11', '/usr/bin/python3', '-I', '-X', 'utf8', '-c', GTK_READ_PY])+ expect(gtk.watch).toEqual(['/usr/bin/env', 'GDK_BACKEND=x11', '/usr/bin/python3', '-I', '-X', 'utf8', '-c', GTK_WATCH_PY])// No X tool: wl-paste (its --watch can fail; then the copy is off).expect(clipWayOf({ wayland: true, x11: true, desktop: 'GNOME', found: { 'wl-paste': '/w' } })).toMatchObject({ name: 'wl-paste --watch (Wayland)', wayland: true })})@@ -55,7 +55,7 @@ test('X11: clipnotify or GTK sees the changes; xclip or GTK reads (xsel can notoff: 'xsel can not see a password manager\'s copy: install xclip',})expect(clipWayOf({ wayland: false, x11: true, desktop: 'XFCE', found: { xsel: '/x/xsel', clipnotify: '/x/cn', gtk: '/p' } })).toMatchObject({- name: 'clipnotify and GTK (X11)', read: ['/usr/bin/env', 'GDK_BACKEND=x11', 'PYTHONIOENCODING=utf-8', '/p', '-c', GTK_READ_PY],+ name: 'clipnotify and GTK (X11)', read: ['/usr/bin/env', 'GDK_BACKEND=x11', '/p', '-I', '-X', 'utf8', '-c', GTK_READ_PY],})expect(clipWayOf({ wayland: false, x11: true, desktop: '', found: { xclip: '/x/xclip', gtk: '/p' } })).toMatchObject({name: 'GTK and xclip (X11)', read: ['sh', '-c', XCLIP_READ_SH, '/x/xclip'],@@ -71,6 +71,19 @@ test('X11: clipnotify or GTK sees the changes; xclip or GTK reads (xsel can notexpect(X11_WATCH_SH).toBe('echo; while "$0" -s clipboard -l; do echo; done')})+test('python runs isolated (-I): a gi.py in the session\'s folder never runs; UTF-8 out with -X utf8', () => {+ for (const found of [{ gtk: '/usr/bin/python3' }, { xsel: '/x/xsel', clipnotify: '/x/cn', gtk: '/usr/bin/python3' }, { xclip: '/x/xclip', gtk: '/usr/bin/python3' }]) {+ const way = clipWayOf({ wayland: false, x11: true, desktop: 'XFCE', found }) as Extract<ClipWay, { name: string }>+ for (const argv of [way.read, way.watch].filter(a => a.includes('/usr/bin/python3'))) {+ expect(argv.slice(argv.indexOf('/usr/bin/python3') + 1, -2)).toEqual(['-I', '-X', 'utf8'])+ expect(argv.some(a => a.startsWith('PYTHON'))).toBe(false)+ }+ }+ // The check that python3 loads GTK 3 is isolated too.+ expect(FIND_SH).toContain(`"$p" -I -c 'import gi;`)+ expect(FIND_SH.match(/"\$p" (-\S+ )*-c/g)).toEqual([`"$p" -I -c`])+})+test('the GTK scripts: X11 events, a line at the start, a text read that fails with no text', () => {expect(GTK_WATCH_PY).toContain('Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD).connect("owner-change", say)')expect(GTK_WATCH_PY).toContain('sys.stdout.write("\\n"); sys.stdout.flush()')@@ -180,6 +193,18 @@ test('the clipboard now: PerlObjCBridge on macOS, the way found on Linux; null wexpect(none.argvs).toEqual([])})+test('the watcher\'s read: null for no text or a password manager\'s copy (a copy all the same); undefined for a read that failed', async () => {+ expect(await withClip(false, WL_WAY, () => clipboardRead(fake$({ exitCode: 0, stdout: 'text' }).$))).toBe('text')+ for (const isMac of [true, false]) {+ for (const exitCode of [1, 3]) expect(await withClip(isMac, WL_WAY, () => clipboardRead(fake$({ exitCode, stdout: 'x' }).$))).toBe(null)+ // No bridge (2), another error, the 2 s timeout (a rejection), no tool.+ expect(await withClip(isMac, WL_WAY, () => clipboardRead(fake$({ exitCode: 2, stdout: '' }).$))).toBe(undefined)+ expect(await withClip(isMac, WL_WAY, () => clipboardRead(fake$({ exitCode: 127, stdout: '' }).$))).toBe(undefined)+ expect(await withClip(isMac, WL_WAY, () => clipboardRead(fake$(new Error('timeout')).$))).toBe(undefined)+ }+ expect(await withClip(false, null, () => clipboardRead(fake$({ exitCode: 0, stdout: 'x' }).$))).toBe(undefined)+})+test('looking up the clipboard way sets S.clipWay from the display, the desktop and the tools found; clipWayReady waits for it', async () => {const found = fake$({ exitCode: 0, stdout: 'xclip /usr/bin/xclip\nclipnotify /usr/bin/clipnotify\n' }, { DISPLAY: ':0', XDG_CURRENT_DESKTOP: 'XFCE' })const was = S.clipWay