Skip to content

Paste Pad provider and copy-based Translate Selection - #58

Closed
LivioGama wants to merge 24 commits into
fdussert:mainfrom
LivioGama:livio/paste-pad-translate-paste
Closed

LivioGama wants to merge 24 commits into
fdussert:mainfrom
LivioGama:livio/paste-pad-translate-paste

Conversation

@LivioGama

Copy link
Copy Markdown
Contributor

Summary

  • Paste Pad provider (server/src/providers/paste-pad.ts + paste-pad-native.swift): resolves the pressed button from the widget instance's own saved settings — never from the request — writes the value to the pasteboard as a transient entry (clipboard managers do not record it), and posts ⌘V, plus an optional Return, through the HID tap. CGEvent needs only Accessibility, which the helper already holds; the earlier AppleEvents path wanted the separate Automation consent and failed every press. Also fixes the instance lookup being called without the CommandContext, which made the scope check fail closed ("unknown paste-pad widget" on every press).
  • Translate Selection copy→translate→paste (selected-text.ts/.swift, openai-shellsmith.ts): when the focused app does not publish AXSelectedText (Sublime reports focus at the window, terminals/Electron expose nothing), the reader first walks the focused element's subtree, then falls back to posting ⌘C and watching NSPasteboard.changeCount. The translation is written to the pasteboard and ⌘V is posted back, replacing the still-selected text in place. secure-field and permission-required still refuse without touching the pasteboard; the tile's disclosure (EN/FR) now says the clipboard is not preserved.
  • The selection paster now throws on a native error payload instead of treating exit-0 as success.

Test plan

  • pnpm --filter server exec vitest run test/paste-pad.test.ts test/shellsmith.test.ts — 20/20 green, incl. a regression test for the ctx-less lookup
  • Live on the Edge: paste-pad buttons type their value (and Return for enter buttons); Translate Selection in Sublime copies, translates and pastes over the selection
  • CI

Generated with Devin

LivioGama and others added 24 commits October 20, 2026 21:54
Newer Claude Code versions suffix the credentials item's service by
their config dir (Claude Code-credentials-8047733a); the plainly named
item can then hold MCP data only, and the provider reported
"not available on this Mac" while the user was signed in.

Enumerate every Claude Code-credentials* service and read the first
item whose payload actually carries claudeAiOauth.accessToken.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remember canonical working directories reported by Herdr panes and open a selected folder in a new pane. Use the split response pane ID so concurrent opens target their own panes.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Run the validated target directory through safePath with the inherited PATH, so the policy-protected system directories remain first while the validated executable still outranks shadow copies elsewhere. Cover the production PATH and executable lookup with synthetic fixtures.

Co-Authored-By: Claude <noreply@anthropic.com>
The Edge dashboard window could become key, so every tap moved the keyboard
focus off the app being typed into on the main display, and a shortcut such as
Cmd-V landed in the dashboard. FirstMouseWebView already delivers the first
click through acceptsFirstMouse, so the window needs no key status. It is now a
non-activating NSPanel that refuses key and main.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Ollama Cloud speaks chat completions at https://ollama.com/v1 with a bearer key,
so it takes the same path as Groq. The host is fixed like the others; the token
never goes anywhere else. /v1/models is public, so the connection test confirms
the model exists but cannot prove the key.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Brings the helper's ILITEK digitizer decoding, display target and touch driver
profile selection over from the touch-focus working tree onto the current main.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…n id is gone

macOS renumbers displays on reconnect; TouchRemap's saved id then names nothing and the
Helitech dashboard window was never created.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A paste-pad button asks the host to type a saved value wherever the user's
keyboard focus already is. The provider resolves the button from the instance's
own saved settings — never from the request — so a widget can only paste what
its owner wrote, then a small Swift helper writes the pasteboard as a transient
entry (clipboard managers do not remember it) and presses ⌘V, and optionally
Return, through the HID tap. CGEvent posting needs only Accessibility, which
the helper already holds; the AppleEvents path it replaces wanted the separate
Automation consent nobody had been asked for.

The instance lookup is given the command's context: without it the scope check
fails closed and every press answered "unknown paste-pad widget" — which is how
this bug hid.

Co-Authored-By: Claude <noreply@anthropic.com>
…ranslation back

Editors that never publish AXSelectedText — Sublime answers its window while a
descendant carries the attribute, terminals and GPU-rendered editors expose
nothing — left Translate Selection saying there was no selection. The reader now
walks the focused element's subtree for a selection first, and when that still
comes back empty the provider posts ⌘C and watches the pasteboard's changeCount:
a bump means the app copied something, a still count means nothing was selected.
Secure fields and missing Accessibility still refuse without ever touching the
pasteboard.

The translation is then written to the pasteboard and ⌘V is posted back, so the
result replaces the still-selected source text in place; a failed write skips
the keystroke, and a failed paste leaves the translation on the board rather
than losing it. The tile's disclosure says what it does now — the clipboard is
no longer preserved — in English and French.

The paster also stops treating "the helper exited" as "it pasted": an error
payload now throws instead of reading as success.

Co-Authored-By: Claude <noreply@anthropic.com>
Each `swift file.swift` invocation costs several hundred milliseconds
in the compiler driver before the script's first line — dead time in
the middle of copy, paste and Enter sequences. resolveNative builds
each helper once under a content hash in the shared cache and runs the
binary, falling back to the interpreter when no toolchain is available.

Co-Authored-By: Claude <noreply@anthropic.com>
A Paste Pad button list or a clock's cities only reordered one chevron
step at a time. Each row now carries a grip on its left edge: holding it
arms the row's draggable so the gesture drags the row itself — the inputs
inside keep their text selection — and the drop lands it at the hovered
index as one undo step. The move cursor and a drop-effect: move read as
the four-way arrow during the gesture. The chevrons stay for keyboard
reordering.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fdussert

Copy link
Copy Markdown
Owner

Hi Livio, thanks for all of this, and sorry it sat a month without an answer. That's on us.

This PR is really a stack: besides Paste Pad and Translate Selection, it carries #48, #49, #50, #51 and #52 (in older states than those PRs' heads), recent-projects (already on main via #59, with credit), the kiosk change (already on main as a6c4030), a keychain change and a settings drag that main has since done differently (48cd355, a6cc8f7), and a new ILITEK touch profile. Merging current main into it gives 14 conflicted files, and providers/recent-projects.ts would clash with main's providers/recent-projects/. So I'll close this one and go through the pieces where they belong. Here is what would land and what would not:

  1. Already on main or superseded: recent-projects, the non-activating kiosk panel, the Claude Code-credentials-* lookup (main computes the item names instead of security dump-keychain, claude/account.ts:79), and the list drag. Please drop them.

  2. Add GitHub activity data for My Scope widgets #48, Add privacy-bounded Messages 2FA provider #49, Add a secret-backed Vercel deployment provider #50, Add ShellSmith command suggestion provider #51, Add built-in macOS window placement provider #52: let's continue in each PR at its own head. The copies here are older. For example, OpenRepoPayload here lacks instanceId, and messages-2fa.ts:45,116 still has board.clearContents() with a bare osascript at :51,:62. The open points in those reviews stand.

  3. Translate Selection and Ollama (openai-shellsmith.ts:165-207): I won't take these in core. It extends the provider we declined in Add ShellSmith command suggestion provider #51 (an AI key is one bearer header, which a widget declares). There are also two safety issues:

    • The channel isn't built-in only, so any registry widget listing it could read the frontmost app's selection, send it out and paste over it without a tap. If it were built-in only, it would put a core widget behind a third-party account, against "core ships what works with no account" (AGENTS.md).
    • ⌘V is posted up to 25 s later to whatever app has focus, with no pid pinned, and before the language check at :204-206, so a refused translation has already replaced the text.

    A registry widget that translates text typed into it would be very welcome.

  4. Paste Pad: I'd like this one in core, as a built-in widget, since it needs no account. It needs:

    • The value must not go on argv (paste-pad.ts:100, paste-pad-native.swift:52). AGENTS.md: "No secret on a command line, ever", and paste pads hold passwords. Pass it on stdin.
    • No Swift compiled or run on the user's Mac (native-tool.ts). Same reason as Add built-in macOS window placement provider #52: no CLT means the "install developer tools" dialog, the cached binary is trusted on presence alone, and the downloadable app ships none of it. The keystroke belongs in native/, built and signed with the helper (like fremkit-scan).
    • It crashes the released app on startup: paste-pad.ts:14 and selected-text.ts:9 resolve import.meta.url at module load, which is empty in the CJS bundle (same as rectangle.ts:22 in Add built-in macOS window placement provider #52).
    • paste-pad in BUILTIN_ONLY_CHANNELS, with the widget in widgets/. A provider that types into the frontmost app shouldn't be reachable by a registry package that merely takes the id paste-pad (paste-pad.ts:39).
    • Save and restore the user's clipboard instead of clearContents(), and mark the entry Concealed as well as Transient.
    • permission-required reported as such, not as provider.localOnly (:81-82), a demo fake, a user-facing CHANGELOG line and docs.

    If you'd rather we build it, we're happy to, with credit as for recent-projects.

  5. ILITEK touch (TouchDriver.swift:305-386, ILITEKDisplayTarget.swift): please open a separate issue first. The touch driver is the path the whole product depends on. As written, with an ILITEK monitor attached, the helper can seize that monitor's touch and mouse interface, and move the kiosk onto it, whenever the Edge's display is absent (ILITEKTouch.swift:20-29). It also reads another app's preferences (pd-touchbase/remap_config.json). Supporting other panels would need an explicit, off-by-default setting, no third-party prefs file, and tests for the profile choice.

Thanks again. The care in #49 and #52 especially shows, and I'd rather get these in piece by piece than leave you guessing for another month.

@fdussert fdussert closed this Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants