Skip to content

Clipboard history: pins, type filters, OCR and action panel - #17595

Open
M4Marvin wants to merge 1 commit into
omacom:quattrofrom
M4Marvin:clipboard-features
Open

M4Marvin wants to merge 1 commit into
omacom:quattrofrom
M4Marvin:clipboard-features

Conversation

@M4Marvin

@M4Marvin M4Marvin commented Nov 4, 2026 •

Copy link
Copy Markdown

What

Expands the built-in clipboard picker into a fuller history manager.

  • Type detection and filters (Ctrl+P): Text, Images, Files, Links, Emails and Colors. Multi-file copies stay one entry.
  • Pins (Ctrl+.), rename (Ctrl+E) and inline edit content. Pinned entries sort first and are exempt from retention.
  • Action panel (Ctrl+K): paste/copy/open, copy text from image (OCR), copy text from QR code, copy colors as HEX/RGB/HSL, edit, rename, pin, delete entry, delete recent entries by time window, delete all, open settings.
  • Settings at ~/.config/omarchy/clipboard.json: retentionDays, maxEntries, primaryAction, textRecognition, disabledApps. Password managers that mark the clipboard sensitive stay excluded.
  • Search covers titles, OCR text, paths and source app. OCR uses the packaged Tesseract/zbar; it runs only when an image is captured or the action is invoked, so idle shells start no new processes.
  • Metadata: timestamps and source app are read from ToplevelManager.activeToplevel in QML. capture.sh and its output/tests are untouched.
  • Chrome follows the menu tokens: Color.menu.* including selected-border, Border.surfaceSpec("menu", ...), Style.font.menuFamily, Style.cornerRadius and Style.spacing.*. Search uses the shared FilterInput, so IME and the hidden caret behave like the Omarchy menu.

Testing

  • bash test/shell.d/clipboard-test.sh — all existing checks, plus new model cases for pins, retention, kinds, colors, filters, OCR search, edits, time-window deletion, settings validation and removed captures, and a copy-helper check.
  • bash test/shell.d/i18n-test.sh — passes, including the embedded-literal scan.
  • qmllint shell/plugins/clipboard/Clipboard.qml — clean.
  • Live verification: the same QML was loaded as a third-party clone with only the plugin paths changed. Checked the type filters, pin/rename/edit, action panel, OCR, QR copy, color formats, pin ordering, empty state and delete. Full-screen screenshots were inspected for clipping, focus and theme tokens. The branch shell itself was not restarted; the clone runs the same file.

Screenshots

Clipboard history picker with type, file, colour, link and OCR rows

Clipboard action panel

Notes

Expand the clipboard picker beyond text and image history:

- detect files, links, emails and colours, with a Ctrl+P type filter
- pin, rename and edit entries; pinned entries survive retention
- action panel for OCR, QR codes, colour formats and bulk deletion
- retention, entry cap, disabled apps and primary-action settings
- match the menu chrome through the shared tokens and FilterInput

Entry timestamps and the source app come from the focused toplevel in QML,
so capture.sh keeps its existing output and tests.
@greptile-apps

greptile-apps Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 0/5

[Medium impact] The changes affect the local clipboard history workflow in the Omarchy shell.

Do not merge until private text stays out of process arguments, edits keep their intended target, and startup pruning and backups are ordered safely.

Findings

  1. P1 Security Private text enters command lines ▶
  2. P1 Edits change the wrong entry ▶
  3. P1 Startup drops saved entries ▶
  4. P1 Backup can save emptied history ▶
  5. P2 Backup cannot restore images ▶
  6. P2 Opaque colors become transparent ▶
  7. P2 Selected actions leave the screen ▶
  8. P2 Security QR secrets enter text history ▶
  9. P2 Time labels ignore chosen language ▶

Summary

Expands clipboard history with pins, type filters, editable entries, settings, OCR, QR decoding, and an action panel.

  • The picker sorts clipboard entries by type and finds them by more details.
  • Pinned entries stay at the top while settings control history limits and capture details.
  • The action panel lets people use and manage entries without leaving the picker.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Capture[Clipboard capture] --> Add[Add entry and metadata]
  Settings[Settings file] --> Prune[Apply retention and entry limit]
  Add --> Prune
  Prune --> History[Saved history]
  Add --> OCR[Queue image OCR]
  OCR --> History
  History --> Picker[Search and type filters]
  Picker --> Actions[Action panel]
  Actions --> Copy[Copy or paste]
  Actions --> Edit[Edit or rename]
  Edit --> History
  Actions --> Backup[Back up history JSON]
  Backup --> Delete[Delete entries and image files]
  Delete --> History
Loading

Reviews (1) · Last reviewed commit: "Add pinning, filters, OCR and actions to..." · Reviewed by Greptile

function copyText(text) {
var value = String(text || "")
if (value.length === 0) return
Quickshell.execDetached([root.copyArgScript, value])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security Private text enters command lines

If other local users can read process command lines, copyText exposes recognized image text and decoded QR values to them. Copying a password or setup code passes the full value as an argument to copy-arg.sh. Send the text through standard input instead.

How this was verified: Both OCR and QR results reach execDetached([root.copyArgScript, value]), which puts the full value in the helper's command line.

}

function saveEdit() {
var next = ClipboardHistory.updateEntry(root.history, root.dialogIndex, { text: String(root.dialogValue || "") })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Edits change the wrong entry

saveEdit and saveRename use the array index saved when the dialog opened. Clipboard watchers keep running, and addEntry inserts new captures at the front. If a capture arrives before save, the old index points to another entry, so saving overwrites that entry's text or title. Keep the target's key and resolve its current index when saving.

Comment on lines +119 to +121
var next = ClipboardHistory.pruneHistory(parsed, root.settings, Date.now())
root.history = next
if (next.length !== parsed.length) root.saveHistory()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Startup drops saved entries

applyHistory prunes and saves history before checking whether the user's settings have loaded. The two FileView objects load independently. If history loads first, the default limit of 500 can delete older entries even when the user set maxEntries: 0 or a larger limit. Wait until settings have loaded or failed before pruning or accepting captures.

// wipe the whole history. The file is plain JSON, so recovery is `cp` back.
function backupHistory() {
if (root.history.length === 0) return
Quickshell.execDetached(["cp", "-f", "--", root.historyPath, root.historyPath + ".bak"])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Backup can save emptied history

backupHistory starts cp without waiting, then both delete flows immediately overwrite the source file. If that write finishes before cp opens the source, the backup contains the already-deleted history, possibly []. Finish the backup successfully before saving the destructive change.

Comment on lines +141 to +142
for (var i = 0; i < removed.length; i++) {
Quickshell.execDetached(["rm", "-f", "--", removed[i]])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Backup cannot restore images

The backup copies only the history JSON, but commitHistory then deletes every removed image file. Even when the backup succeeds, restoring it brings back image rows whose files no longer exist. Preserve the images referenced by the backup, or back them up before removing them.

return null
}
} else if ((match = text.match(/^rgba?\(\s*([^)]+)\)$/i))) {
var parts = match[1].split(/[,\s/]+/)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Opaque colors become transparent

parseColor treats a valid trailing space inside rgb() or hsl() as an empty alpha value. For example, rgb(255, 0, 0 ) becomes rgba(255, 0, 0, 0), so an opaque red is previewed and copied as fully transparent. Trim the captured components before splitting, and reject empty components instead of converting them to zero.

Comment on lines +1283 to +1287
height: parent.height - Style.space(24)
model: root.actionItems
spacing: 2
clip: true
boundsBehavior: Flickable.StopAtBounds

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Selected actions leave the screen

Keyboard navigation changes actionIndex, but never moves actionList to that row. On shorter screens or with larger theme spacing, users can select hidden actions, including deletion actions, while Enter still runs them. Bind currentIndex to actionIndex and scroll the selected row into view.

}
stderr: StdioCollector { waitForEnd: true }
onExited: function(exitCode) {
if (exitCode === 0) root.copyText(String(qrOut.text || "").trim())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 security QR secrets enter text history

Decoded QR values use plain wl-copy, so the clipboard watchers record them as new text entries. QR codes can contain setup secrets such as otpauth:// values; the existing QR capture command deliberately uses --sensitive to keep those out of history. Give QR copies a sensitive copy path instead of the shared plain-text helper.

How this was verified: The QR completion handler calls copyText, whose helper omits --sensitive, while capture.sh excludes copies marked sensitive.

Comment on lines +570 to +575
if (delta < hour) value = Math.floor(delta / minute) + "m"
else if (delta < day) value = Math.floor(delta / hour) + "h"
else if (delta < week) value = Math.floor(delta / day) + "d"
else if (delta < 5 * week) value = Math.floor(delta / week) + "w"
else {
try { return new Date(stamp).toLocaleDateString() } catch (e) { return "" }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Time labels ignore chosen language

relativeTime writes English unit letters and plain digits directly into displayed text. It also formats older dates using the process's locale. The repository's translation guide requires catalog strings, I18n.formatNumber, and the selected I18n.formatLocale for displayed numbers and dates. Pass the needed formatters into the model so these labels follow the chosen language. This repository requirement must be satisfied before merging.

File Used: docs/i18n.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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.

1 participant