Skip to content

Comments

feat: Added copy text to clipboard from kvm using OCR#1207

Open
tvinhas wants to merge 1 commit intojetkvm:devfrom
tvinhas:copy-and-paste-ocr
Open

feat: Added copy text to clipboard from kvm using OCR#1207
tvinhas wants to merge 1 commit intojetkvm:devfrom
tvinhas:copy-and-paste-ocr

Conversation

@tvinhas
Copy link

@tvinhas tvinhas commented Feb 18, 2026

Summary

  • Adds a "Copy text" button to that allows the user to select any text in the window, and OCR will transform that in text in a modal popup in the browser that the user can copy to his local clipboard. Supports indentation for copying code as well.

Checklist

  • Ran make test_e2e locally and passed
  • Linked to issue(s) above by issue number (e.g. Closes #<issue-number>)
  • One problem per PR (no unrelated changes)
  • Lints pass; CI green
  • Tricky parts are commented in code

@tvinhas
Copy link
Author

tvinhas commented Feb 18, 2026

image

@tvinhas
Copy link
Author

tvinhas commented Feb 18, 2026

image

Copy link
Contributor

@adamshiervani adamshiervani left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time developing this!

{status === "result" &&
createPortal(
<div className="pointer-events-none fixed inset-0 z-50 flex items-center justify-center">
<div className="pointer-events-auto mx-4 flex max-h-[80%] w-full max-w-md flex-col rounded-lg border border-slate-200 bg-white shadow-xl dark:border-slate-700 dark:bg-slate-800">
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use <ConfirmDialog>, which uses <Modal> which contains the mounting animations too, so no react motion needed here.

</button>
</div>
<div className="px-4 py-3">
<TextArea
Copy link
Contributor

Choose a reason for hiding this comment

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

If possible, make this readonly and highlight all the text. I know Ctrl+C works, but it feels weird if i'm copying a non-selected text.

If you can highlight the text, you don't don't need to the copy hint below

style={selectionStyle}
>
{selectionRect.width >= 10 && selectionRect.height >= 10 && (
<div className="absolute right-0 -bottom-6 rounded bg-black/70 px-1.5 py-0.5 text-[10px] font-medium text-white tabular-nums">
Copy link
Contributor

Choose a reason for hiding this comment

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

Use the <Card />

rows={Math.min(10, ocrResult.split("\n").length + 1)}
/>
</div>
<div className="border-t border-slate-200 px-4 py-3 dark:border-slate-700">
Copy link
Contributor

Choose a reason for hiding this comment

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

The <ConfirmDialog> pushes for this, but just as a note - it doesn't have any X, and uses CTA's for the main actions.

I would suggest removing this label, and have two CTAs - Cancel and Copy. They both also get corresponding shortcuts - Esc and CMD+C/ Ctrl+C

onTouchEnd={handlePointerUp}
>
{/* Semi-transparent background */}
<div className="absolute inset-0 bg-black/20" />
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't go all the way to the border end of the viewport

)}

{/* Processing indicator */}
{status === "processing" && (
Copy link
Contributor

Choose a reason for hiding this comment

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

The OCR can take some time, this is too tiny to indicate processing. Additionally, users might want to cancel the processing. You could use the same <ConfirmDialog> as the result status, but with a:

  • Skelleton Loading with label on top to indicate processing
  • Disabled Copy CTA - only Cancel

onClick={() => setTerminalType(terminalType === "kvm" ? "none" : "kvm")}
/>
)}
<Button
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: The Action bar is already too crowded. You don't need to change anything here, but once I get time I'll rethink the action bar, so. just letting you know that I'll probably move after it merges with dev.

@@ -49,6 +49,7 @@
"access_update_tls_settings": "Update TLS Settings",
Copy link
Contributor

Choose a reason for hiding this comment

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

Once the Review comments have been addressed make sure to machine translate to other languages too. See DEVELOPMENT.md for details.

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