Clipboard history with image preview

Hello there, first of all I would like to praise everyone that made this possible so far! I really like using kit and tweaking few scripts here and there for productivity.

I was using an adapted version of the community-available clipboard history but I was struggling with some errors regarding the database from time to time and this was also causing processes not being finished properly and running forever and forcing me to restart kit. The db file was also randomly deleted at times and other not so nice things that were basically making me having to come back from time to time.

[2023-05-22 08:51:17.374] [warn]  ☠️ ERROR PROMPT SHOULD SHOW ☠️
[2023-05-22 08:51:17.393] [warn]  Error: ENOENT: no such file or directory, rename '/Users/aldo/.kenv/db/.clipboard-history.json.tmp' -> '/Users/aldo/.kenv/db/clipboard-history.json'

After dealing with it for few months, I realized we now have the getClipboardHistory function when the watcher is enabled so I'd like to share this with everyone so that we have a proper history paste with image preview that doesn't require the managing of a json file.

// Name: Clipboard history
// Author: Aldo Preciado
// GitHub: @aldirrix
// Shortcut: command shift v
import "@johnlindquist/kit";
const history = await getClipboardHistory();
let { value, type } = await arg("What to paste?", () => {
return history.map(({ value, type, timestamp, maybeSecret }) => {
const multilinePreview = value.includes("\n")
? `<div class="font-mono text-xs">${value
.split("\n")
.map((line) => `<p>${line}</p>`)
.join("")}<div>`
: null;
const preview = type === "image" ? `<img src="${value}" alt="${value}">` : multilinePreview;
return {
type,
name: maybeSecret ? value.slice(0, 2).padEnd(10, "*") : value,
value: {
value,
type,
},
description: timestamp,
preview,
};
});
});
if (type === "text") {
await setSelectedText(value);
}
if (type === "image") {
await copyPathAsImage(value);
await keystroke("command v");
}

On the same note, is there a way for us to configure the maybeSecret property in the kit app? It seems like there has not been any discussion around it and I was wondering