Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(appshot): CleanShot-style hover overlay on the corner card

rubenluetke10-beepbea786adaf77
diff --git a/docs/appshots.md b/docs/appshots.md
index 39ff51500b..23b0bdcf18 100644
--- a/docs/appshots.md
+++ b/docs/appshots.md
@@ -59,11 +59,16 @@ screen and rests there as a card — CleanShot X's Quick Access Overlay. How
long is `[appshot].card_seconds` (Settings → Appshots → *Corner card*: 3, 6,
10 or 30 seconds, or until you close it); the pointer on it keeps it.
-- **Hover** dims the picture and shows **Close** (top left), **Edit** (top
- right) and **Copy** / **Save** in the middle. Copy puts the picture on the
- clipboard and Save writes it to Downloads — both done by the main process
- (`jarvis/appshot/card_actions.py`), so the clipboard survives the overlay
- quitting on Linux; the card shows the result for a moment.
+- **Hover** frosts the picture and shows **Copy** and **Save** stacked in
+ the middle, plus four round chips in the corners: **Pin** (top left),
+ **Close** (top right), **Edit** (bottom left) and **Copy text** (bottom
+ right). The chip under the pointer names itself along the bottom edge.
+ Copy puts the picture on the clipboard, Save writes it to Downloads and
+ Copy text copies the on-screen text the appshot read (where the screen had
+ any) — all done by the main process (`jarvis/appshot/card_actions.py`), so
+ the clipboard survives the overlay quitting on Linux; the card shows the
+ result for a moment. **Pin** keeps the card until you close it, whatever
+ *Corner card* says; a pinned card shows the pin even without the pointer.
- **Click** (or Edit) opens the **appshot editor in a window of its own** in
front of you; the app behind keeps its size and what it shows. Without a
desktop shell (a browser, a headless host) the editor opens over the app's
diff --git a/jarvis/appshot/card_actions.py b/jarvis/appshot/card_actions.py
index 1147c4c4fc..745ca599c1 100644
--- a/jarvis/appshot/card_actions.py
+++ b/jarvis/appshot/card_actions.py
@@ -1,13 +1,16 @@
"""What the corner card can do besides opening the editor.
-The card (a PySide6 window in the indicator sidecar) shows Copy and Save on
-hover. The sidecar only reports the press; the work happens here in the main
-process, on the held appshot itself:
+The card (a PySide6 window in the indicator sidecar) shows Copy, Save and
+Copy text on hover. The sidecar only reports the press; the work happens here
+in the main process, on the held appshot itself:
* **Copy** goes through :mod:`jarvis.platform.clipboard_image`, which owns the
clipboard natively on every OS. A Qt clipboard in the sidecar would lose the
picture on Linux the moment the sidecar quits.
* **Save** writes a PNG into ``~/Downloads``, like every other save in the app.
+* **Copy text** puts the appshot's scrubbed on-screen text (``ui_text``) on
+ the clipboard — CleanShot's upload chip, swapped for what an assistant app
+ reads off the screen anyway.
And when the editor closes, :func:`return_to_corner` slides the (edited)
appshot back into the corner, so it stays at hand — CleanShot X's Quick Access
@@ -33,30 +36,45 @@ _LABELS: dict[str, dict[str, str]] = {
"copy": "Copy",
"save": "Save",
"close": "Close",
+ "pin": "Keep on screen",
+ "unpin": "Unpin",
+ "copy_text": "Copy text",
"copied": "Copied",
"saved": "Saved to Downloads",
"failed": "That did not work",
"gone": "No longer kept",
+ "text_copied": "Text copied",
+ "no_text": "No text found",
},
"de": {
"edit": "Bearbeiten", # i18n-allow: product UI string
"copy": "Kopieren", # i18n-allow: product UI string
"save": "Speichern", # i18n-allow: product UI string
"close": "Schließen", # i18n-allow: product UI string
+ "pin": "Am Bildschirm halten", # i18n-allow: product UI string
+ "unpin": "Nicht mehr halten", # i18n-allow: product UI string
+ "copy_text": "Text kopieren", # i18n-allow: product UI string
"copied": "Kopiert", # i18n-allow: product UI string
"saved": "In Downloads gespeichert", # i18n-allow: product UI string
"failed": "Das hat nicht geklappt", # i18n-allow: product UI string
"gone": "Nicht mehr aufbewahrt", # i18n-allow: product UI string
+ "text_copied": "Text kopiert", # i18n-allow: product UI string
+ "no_text": "Kein Text gefunden", # i18n-allow: product UI string
},
"es": {
"edit": "Editar", # i18n-allow: product UI string
"copy": "Copiar", # i18n-allow: product UI string
"save": "Guardar", # i18n-allow: product UI string
"close": "Cerrar", # i18n-allow: product UI string
+ "pin": "Mantener en pantalla", # i18n-allow: product UI string
+ "unpin": "Dejar de fijar", # i18n-allow: product UI string
+ "copy_text": "Copiar texto", # i18n-allow: product UI string
"copied": "Copiado", # i18n-allow: product UI string
"saved": "Guardado en Descargas", # i18n-allow: product UI string
"failed": "No ha funcionado", # i18n-allow: product UI string
"gone": "Ya no se conserva", # i18n-allow: product UI string
+ "text_copied": "Texto copiado", # i18n-allow: product UI string
+ "no_text": "No se encontró texto", # i18n-allow: product UI string
},
}
@@ -104,7 +122,7 @@ def save_to_downloads(png: bytes, *, folder: Path | None = None, now: float | No
async def run_card_action(action: str) -> str:
- """Do ``copy`` or ``save`` on the held appshot; the card's status line."""
+ """Do ``copy``, ``save`` or ``copy_text`` on the held appshot; the card's status line."""
from jarvis.appshot.store import get_store # noqa: PLC0415
from jarvis.core.config import load_config # noqa: PLC0415
@@ -114,6 +132,14 @@ async def run_card_action(action: str) -> str:
if shot is None:
return labels["gone"]
try:
+ if action == "copy_text":
+ text = (shot.ui_text or "").strip()
+ if not text:
+ return labels["no_text"]
+ from jarvis.platform.clipboard import write_text # noqa: PLC0415
+
+ ok = await asyncio.to_thread(write_text, text)
+ return labels["text_copied"] if ok else labels["failed"]
png = await asyncio.to_thread(as_png, shot.image)
if action == "copy":
from jarvis.platform.clipboard_image import write_png # noqa: PLC0415
diff --git a/jarvis/cu/indicator/controller.py b/jarvis/cu/indicator/controller.py
index 28d1ec0110..199d98d93a 100644
--- a/jarvis/cu/indicator/controller.py
+++ b/jarvis/cu/indicator/controller.py
@@ -405,13 +405,13 @@ class CUIndicatorController:
asyncio.get_running_loop().create_task(self._open_editor(), name="appshot-card-open")
elif event == protocol.EVENT_CARD_ACTION:
action = str(payload.get("action", ""))
- if action in ("copy", "save"):
+ if action in protocol.CARD_ACTIONS:
asyncio.get_running_loop().create_task(
self._card_action(action), name="appshot-card-action"
)
async def _card_action(self, action: str) -> None:
- """Copy or save from the card's hover buttons, then tell the card how it went."""
+ """Copy, save or copy text from the card, then tell the card how it went."""
from jarvis.appshot.card_actions import run_card_action # noqa: PLC0415
status = await run_card_action(action)
diff --git a/jarvis/cu/indicator/protocol.py b/jarvis/cu/indicator/protocol.py
index daa06468f6..0f67c2287b 100644
--- a/jarvis/cu/indicator/protocol.py
+++ b/jarvis/cu/indicator/protocol.py
@@ -62,8 +62,10 @@ ALL_COMMANDS = frozenset(
EVENT_CARD = "card"
EVENT_SNAP_OPEN = "snap_open"
-#: A hover button on the card was pressed (``action``: ``copy`` | ``save``).
+#: A hover button on the card was pressed (``action``: one of ``CARD_ACTIONS``).
EVENT_CARD_ACTION = "card_action"
+#: What the main process does for the card; pin and close stay in the sidecar.
+CARD_ACTIONS = frozenset({"copy", "save", "copy_text"})
ALL_EVENTS = frozenset({EVENT_CARD, EVENT_SNAP_OPEN, EVENT_CARD_ACTION})
#: Sidecar exit code when no usable GUI stack exists (PySide6 missing or
diff --git a/jarvis/cu/indicator/renderer.py b/jarvis/cu/indicator/renderer.py
index e0c876d259..db17eddcdb 100644
--- a/jarvis/cu/indicator/renderer.py
+++ b/jarvis/cu/indicator/renderer.py
@@ -54,6 +54,7 @@ from PySide6.QtGui import (
QPainterPath,
QPen,
QPixmap,
+ QPolygonF,
)
from PySide6.QtWidgets import QApplication, QWidget
@@ -223,9 +224,10 @@ _CARD_OUT_MS = 240
_CARD_DRAG_SLOP = 6
#: How long a status line ("Copied") stays on the card.
_CARD_STATUS_MS = 1600
-#: Hover buttons: the Copy / Save pills and the round Close / Edit chips.
-_CARD_BUTTON_H = 28.0
-_CARD_ROUND = 26.0
+#: Hover buttons: the stacked Copy / Save pills and the white corner chips.
+_CARD_BUTTON_H = 30.0
+_CARD_ROUND = 28.0
+_CARD_INSET = 8.0
#: Drag files older than this are removed the next time one is written.
_DRAG_FILE_MAX_AGE_S = 3600
@@ -561,16 +563,21 @@ _CARD_LABELS = {
"copy": "Copy",
"save": "Save",
"close": "Close",
+ "pin": "Keep on screen",
+ "unpin": "Unpin",
+ "copy_text": "Copy text",
}
class _CardWindow(QWidget):
"""The resting thumbnail, CleanShot X's Quick Access Overlay in small.
- Hover shows Close (top-left), Edit (top-right) and Copy / Save in the
- middle; a click anywhere else edits, a drag shares the picture, a
- right-click dismisses it. ``rest_ms`` is how long it stays untouched —
- ``0`` keeps it until the user closes it.
+ Hover frosts the picture and shows Copy / Save stacked in the middle and
+ four white chips in the corners: Pin (top-left, keeps the card until it is
+ closed), Close (top-right), Edit (bottom-left) and Copy text (bottom-right,
+ the on-screen text the appshot read). A click anywhere else edits, a drag
+ shares the picture, a right-click dismisses it. ``rest_ms`` is how long it
+ stays untouched — ``0`` keeps it until the user closes it.
"""
_PAD = 12 # transparent margin that holds the soft shadow
@@ -610,6 +617,8 @@ class _CardWindow(QWidget):
self._labels = {**_CARD_LABELS, **(labels or {})}
self._hover = False
self._hot = "" # the hover button under the pointer
+ self._pinned = False # pinned = stays until the user closes it
+ self._frost: QImage | None = None # blurred thumbnail behind the buttons
self._press: QPointF | None = None
self._press_button = ""
self._leaving = False
@@ -645,7 +654,7 @@ class _CardWindow(QWidget):
self._arm_dismiss(self._rest_ms)
def _arm_dismiss(self, ms: int) -> None:
- if self._rest_ms > 0 and not self._leaving:
+ if self._rest_ms > 0 and not self._leaving and not self._pinned:
self._dismiss.start(ms)
# -- lifecycle -----------------------------------------------------------
@@ -743,7 +752,11 @@ class _CardWindow(QWidget):
return # pressed a button, let go elsewhere: nothing
if pressed == "close":
self.leave()
- elif pressed in ("copy", "save"):
+ elif pressed == "pin":
+ self._pinned = not self._pinned
+ self._dismiss.stop() # the pointer is on the card; leaving re-arms it
+ self.update()
+ elif pressed in ("copy", "save", "copy_text"):
if self._owner.card_image is not None:
self._owner.card_action(pressed)
else: # "edit" or the picture itself
@@ -793,28 +806,32 @@ class _CardWindow(QWidget):
def _buttons(self) -> dict[str, QRectF]:
"""Hit areas of the hover buttons, in widget coordinates."""
rect = self._card_area()
- font = _card_font()
- metrics = QFontMetricsF(font)
- h = _CARD_BUTTON_H
+ d, inset = _CARD_ROUND, _CARD_INSET
+ left, right = rect.left() + inset, rect.right() - inset - d
+ top, bottom = rect.top() + inset, rect.bottom() - inset - d
buttons: dict[str, QRectF] = {
- "close": QRectF(rect.left() + 8, rect.top() + 8, _CARD_ROUND, _CARD_ROUND),
+ "pin": QRectF(left, top, d, d),
+ "close": QRectF(right, top, d, d),
+ "edit": QRectF(left, bottom, d, d),
}
- edit_w = metrics.horizontalAdvance(self._labels["edit"]) + 22.0
- buttons["edit"] = QRectF(rect.right() - 8 - edit_w, rect.top() + 8, edit_w, _CARD_ROUND)
if self._owner is not None and self._owner.card_image is not None:
- widths = [metrics.horizontalAdvance(self._labels[k]) + 28.0 for k in ("copy", "save")]
- width = max(widths + [86.0])
- gap = 8.0
- if width * 2 + gap <= rect.width() - 24:
+ # Only with a kept, finished appshot — the same rule as the drag.
+ buttons["copy_text"] = QRectF(right, bottom, d, d)
+ metrics = QFontMetricsF(_pill_font())
+ h, gap = _CARD_BUTTON_H, 8.0
+ widths = [metrics.horizontalAdvance(self._labels[k]) + 36.0 for k in ("copy", "save")]
+ width = max(widths + [88.0])
+ if rect.height() >= 2 * h + gap + 2 * inset:
+ # Stacked in the middle, like CleanShot's overlay.
+ x = rect.center().x() - width / 2
+ y = rect.center().y() - h - gap / 2
+ buttons["copy"] = QRectF(x, y, width, h)
+ buttons["save"] = QRectF(x, y + h + gap, width, h)
+ else: # a very flat card: side by side
+ x = rect.center().x() - width - gap / 2
y = rect.center().y() - h / 2
- left = rect.center().x() - width - gap / 2
- buttons["copy"] = QRectF(left, y, width, h)
- buttons["save"] = QRectF(left + width + gap, y, width, h)
- else:
- top = rect.center().y() - h - gap / 2
- left = rect.center().x() - width / 2
- buttons["copy"] = QRectF(left, top, width, h)
- buttons["save"] = QRectF(left, top + h + gap, width, h)
+ buttons["copy"] = QRectF(x, y, width, h)
+ buttons["save"] = QRectF(x + width + gap, y, width, h)
return buttons
def _button_at(self, pos: QPointF) -> str:
@@ -842,10 +859,14 @@ class _CardWindow(QWidget):
self._paint_scrim(painter, rect, 150)
self._paint_centered(painter, rect, self._status)
elif self._hover:
- self._paint_scrim(painter, rect, 105)
- self._paint_buttons(painter)
- if self._hint:
- self._paint_hint(painter, rect)
+ self._paint_frost(painter, rect)
+ buttons = self._buttons()
+ self._paint_buttons(painter, buttons)
+ self._paint_caption(painter, rect, buttons)
+ elif self._pinned:
+ # Pinned and at rest: the pin stays visible, so the card explains
+ # why it does not go away.
+ self._paint_chip(painter, "pin", self._buttons()["pin"])
painter.end()
def _paint_scrim(self, painter: QPainter, rect: QRectF, alpha: int) -> None:
@@ -856,51 +877,127 @@ class _CardWindow(QWidget):
painter.fillRect(rect, QColor(0, 0, 0, alpha))
painter.restore()
- def _paint_buttons(self, painter: QPainter) -> None:
- font = _card_font()
- painter.setFont(font)
- for name, area in self._buttons().items():
+ def _frosted(self) -> QImage:
+ """The thumbnail blurred like frosted glass (cached).
+
+ Shrinking in steps and growing back with smooth scaling is a cheap,
+ dependency-free blur that is plenty for a 320 px card.
+ """
+ if self._frost is None:
+ image = self._thumb
+ size = image.size()
+ for div in (4, 16):
+ image = image.scaled(
+ max(1, size.width() // div),
+ max(1, size.height() // div),
+ Qt.AspectRatioMode.IgnoreAspectRatio,
+ Qt.TransformationMode.SmoothTransformation,
+ )
+ for div in (4, 1):
+ image = image.scaled(
+ max(1, size.width() // div),
+ max(1, size.height() // div),
+ Qt.AspectRatioMode.IgnoreAspectRatio,
+ Qt.TransformationMode.SmoothTransformation,
+ )
+ self._frost = image
+ return self._frost
+
+ def _paint_frost(self, painter: QPainter, rect: QRectF) -> None:
+ clip = QPainterPath()
+ clip.addRoundedRect(rect, _SNAP_RADIUS, _SNAP_RADIUS)
+ painter.save()
+ painter.setClipPath(clip)
+ if not self._thumb.isNull():
+ painter.drawImage(rect, self._frosted())
+ # A soft dark veil, then a faint light one: frosted, not black.
+ painter.fillRect(rect, QColor(18, 16, 26, 92))
+ painter.fillRect(rect, QColor(255, 255, 255, 18))
+ painter.restore()
+ pen = QPen(QColor(255, 255, 255, 150))
+ pen.setWidthF(1.2)
+ painter.setPen(pen)
+ painter.setBrush(Qt.BrushStyle.NoBrush)
+ painter.drawRoundedRect(rect.adjusted(0.6, 0.6, -0.6, -0.6), _SNAP_RADIUS, _SNAP_RADIUS)
+
+ def _paint_buttons(self, painter: QPainter, buttons: dict[str, QRectF]) -> None:
+ painter.setFont(_pill_font())
+ for name, area in buttons.items():
+ if name not in ("copy", "save"):
+ self._paint_chip(painter, name, area)
+ continue
hot = name == self._hot
+ # Light pills on the frosted picture, like CleanShot's overlay.
painter.setPen(Qt.PenStyle.NoPen)
- if name in ("copy", "save"):
- # Light pills on the dimmed picture, like CleanShot's overlay.
- painter.setBrush(QColor(255, 255, 255, 255 if hot else 228))
- painter.drawRoundedRect(area, area.height() / 2, area.height() / 2)
- painter.setPen(QColor(20, 20, 22))
- painter.drawText(area, Qt.AlignmentFlag.AlignCenter, self._labels[name])
- continue
- painter.setBrush(QColor(28, 28, 30, 240 if hot else 200))
- painter.drawRoundedRect(area, area.height() / 2, area.height() / 2)
- if name == "close":
- pen = QPen(QColor(255, 255, 255, 235))
- pen.setWidthF(1.6)
- pen.setCapStyle(Qt.PenCapStyle.RoundCap)
- painter.setPen(pen)
- c = area.center()
- d = area.width() * 0.2
- painter.drawLine(QPointF(c.x() - d, c.y() - d), QPointF(c.x() + d, c.y() + d))
- painter.drawLine(QPointF(c.x() - d, c.y() + d), QPointF(c.x() + d, c.y() - d))
- else:
- painter.setPen(QColor(255, 255, 255, 240))
- painter.drawText(area, Qt.AlignmentFlag.AlignCenter, self._labels[name])
+ painter.setBrush(QColor(0, 0, 0, 34))
+ radius = area.height() / 2
+ painter.drawRoundedRect(area.translated(0, 1.5), radius, radius)
+ painter.setBrush(QColor(255, 255, 255, 250) if hot else QColor(238, 238, 240, 238))
+ painter.drawRoundedRect(area, radius, radius)
+ painter.setPen(QColor(20, 20, 22))
+ painter.drawText(area, Qt.AlignmentFlag.AlignCenter, self._labels[name])
+
+ def _paint_chip(self, painter: QPainter, name: str, area: QRectF) -> None:
+ """A round white corner chip with a dark icon; a set pin is inverted."""
+ hot = name == self._hot and self._hover
+ inverted = name == "pin" and self._pinned
+ painter.setPen(Qt.PenStyle.NoPen)
+ painter.setBrush(QColor(0, 0, 0, 40))
+ painter.drawEllipse(area.translated(0, 1.2))
+ if inverted:
+ # A thin light ring keeps the dark chip visible on a dark picture.
+ ring = QPen(QColor(255, 255, 255, 120))
+ ring.setWidthF(1.0)
+ painter.setPen(ring)
+ painter.setBrush(QColor(22, 22, 26, 250 if hot else 232))
+ icon = QColor(255, 255, 255)
+ else:
+ painter.setBrush(QColor(255, 255, 255, 252) if hot else QColor(240, 240, 242, 240))
+ icon = QColor(18, 18, 20)
+ painter.drawEllipse(area)
+ _paint_icon(painter, name, area, icon)
- def _paint_centered(self, painter: QPainter, rect: QRectF, text: str) -> None:
- font = _card_font()
- font.setPointSizeF(10.0)
- painter.setFont(font)
- painter.setPen(QColor(255, 255, 255, 245))
- painter.drawText(rect, Qt.AlignmentFlag.AlignCenter | Qt.TextFlag.TextWordWrap, text)
+ def _paint_caption(self, painter: QPainter, rect: QRectF, buttons: dict[str, QRectF]) -> None:
+ """What the chip under the pointer does, else the card's hint.
- def _paint_hint(self, painter: QPainter, rect: QRectF) -> None:
+ Sits between the two bottom chips, and only where it clears the pills.
+ """
+ if self._hot in ("pin", "close", "edit", "copy_text"):
+ key = "unpin" if self._hot == "pin" and self._pinned else self._hot
+ text = self._labels.get(key, "")
+ else:
+ text = self._hint
+ if not text:
+ return
font = QFont()
font.setPointSizeF(8.5)
font.setWeight(QFont.Weight.Medium)
metrics = QFontMetricsF(font)
- h = metrics.height() + 10.0
- band = QRectF(rect.x(), rect.bottom() - h, rect.width(), h)
+ h = metrics.height() + 6.0
+ side = _CARD_INSET + _CARD_ROUND + 6.0
+ band = QRectF(
+ rect.left() + side,
+ rect.bottom() - _CARD_INSET - _CARD_ROUND / 2 - h / 2,
+ rect.width() - 2 * side,
+ h,
+ )
+ pills = [buttons[k] for k in ("copy", "save") if k in buttons]
+ if band.width() <= 0 or any(p.bottom() + 2 > band.top() for p in pills):
+ return
painter.setFont(font)
- painter.setPen(QColor(255, 255, 255, 200))
- painter.drawText(band, Qt.AlignmentFlag.AlignCenter, self._hint)
+ painter.setPen(QColor(255, 255, 255, 225))
+ painter.drawText(
+ band,
+ Qt.AlignmentFlag.AlignCenter,
+ metrics.elidedText(text, Qt.TextElideMode.ElideRight, band.width()),
+ )
+
+ def _paint_centered(self, painter: QPainter, rect: QRectF, text: str) -> None:
+ font = _card_font()
+ font.setPointSizeF(10.0)
+ painter.setFont(font)
+ painter.setPen(QColor(255, 255, 255, 245))
+ painter.drawText(rect, Qt.AlignmentFlag.AlignCenter | Qt.TextFlag.TextWordWrap, text)
def _card_font() -> QFont:
@@ -910,6 +1007,73 @@ def _card_font() -> QFont:
return font
+def _pill_font() -> QFont:
+ font = QFont()
+ font.setPointSizeF(10.5)
+ font.setWeight(QFont.Weight.DemiBold)
+ return font
+
+
+def _poly(*points: tuple[float, float]) -> QPolygonF:
+ return QPolygonF([QPointF(x, y) for x, y in points])
+
+
+def _paint_icon(painter: QPainter, name: str, area: QRectF, color: QColor) -> None:
+ """Draw a corner-chip icon on a 28-unit grid centred in ``area``.
+
+ Drawn with paths instead of an icon font, so it looks the same on every
+ OS and needs no asset.
+ """
+ painter.save()
+ painter.translate(area.center())
+ scale = area.width() / 28.0
+ painter.scale(scale, scale)
+ pen = QPen(color)
+ pen.setCapStyle(Qt.PenCapStyle.RoundCap)
+ pen.setJoinStyle(Qt.PenJoinStyle.RoundJoin)
+ if name == "close":
+ pen.setWidthF(2.3)
+ painter.setPen(pen)
+ painter.drawLine(QPointF(-4.8, -4.8), QPointF(4.8, 4.8))
+ painter.drawLine(QPointF(-4.8, 4.8), QPointF(4.8, -4.8))
+ elif name == "pin":
+ # An upright push pin, tilted so the head points top-right.
+ painter.rotate(45.0)
+ painter.setPen(Qt.PenStyle.NoPen)
+ painter.setBrush(color)
+ painter.drawRoundedRect(QRectF(-4.6, -9.0, 9.2, 2.8), 1.2, 1.2)
+ painter.drawPolygon(_poly((-2.9, -6.6), (2.9, -6.6), (3.3, -1.2), (-3.3, -1.2)))
+ painter.drawPolygon(_poly((-3.3, -1.4), (3.3, -1.4), (6.2, 2.2), (-6.2, 2.2)))
+ pen.setWidthF(1.7)
+ painter.setPen(pen)
+ painter.drawLine(QPointF(0.0, 2.2), QPointF(0.0, 9.0))
+ elif name == "edit":
+ # A pencil, tip bottom-left.
+ painter.rotate(45.0)
+ painter.setPen(Qt.PenStyle.NoPen)
+ painter.setBrush(color)
+ painter.drawRoundedRect(QRectF(-2.9, -9.6, 5.8, 3.0), 1.2, 1.2)
+ painter.drawRect(QRectF(-2.9, -5.4, 5.8, 8.6))
+ painter.drawPolygon(_poly((-2.9, 4.4), (2.9, 4.4), (0.0, 9.4)))
+ elif name == "copy_text":
+ # A "T" inside scan corners: the text the appshot read.
+ pen.setWidthF(1.7)
+ painter.setPen(pen)
+ painter.setBrush(Qt.BrushStyle.NoBrush)
+ e, k = 7.0, 3.2
+ for sx, sy in ((-1, -1), (1, -1), (-1, 1), (1, 1)):
+ corner = QPainterPath()
+ corner.moveTo(sx * e, sy * (e - k))
+ corner.lineTo(sx * e, sy * e)
+ corner.lineTo(sx * (e - k), sy * e)
+ painter.drawPath(corner)
+ pen.setWidthF(2.0)
+ painter.setPen(pen)
+ painter.drawLine(QPointF(-3.2, -3.0), QPointF(3.2, -3.0))
+ painter.drawLine(QPointF(0.0, -3.0), QPointF(0.0, 3.6))
+ painter.restore()
+
+
class Renderer(QObject):
"""Owns the per-monitor windows, the animations, and the IPC slots."""
diff --git a/tests/unit/appshot/test_appshot_card.py b/tests/unit/appshot/test_appshot_card.py
index ff63191c6e..c30b8c6808 100644
--- a/tests/unit/appshot/test_appshot_card.py
+++ b/tests/unit/appshot/test_appshot_card.py
@@ -161,6 +161,40 @@ async def test_copy_from_the_card_uses_the_native_clipboard(monkeypatch) -> None
assert copied == [_png()]
+ ("ui_text", "status", "expected"),
+ [
+ (" Invoice 42\nTotal 9 EUR ", "Text copied", ["Invoice 42\nTotal 9 EUR"]),
+ ("", "No text found", []),
+ ],
+)
+async def test_copy_text_puts_the_on_screen_text_on_the_clipboard(
+ monkeypatch, ui_text: str, status: str, expected: list[str]
+) -> None:
+ import dataclasses
+
+ from jarvis.appshot import store as store_module
+ from jarvis.platform import clipboard
+
+ store = AppshotStore()
+ store.remember(dataclasses.replace(_shot(), ui_text=ui_text), keep_s=60)
+ monkeypatch.setattr(store_module, "_STORE", store)
+ copied: list[str] = []
+ monkeypatch.setattr(clipboard, "write_text", lambda text: copied.append(text) or True)
+ monkeypatch.setattr(
+ "jarvis.core.config.load_config", lambda: SimpleNamespace(ui=SimpleNamespace(language="en"))
+ )
+
+ assert await card_actions.run_card_action("copy_text") == status
+ assert copied == expected
+
+
+def test_the_sidecar_hands_every_card_action_to_the_main_process() -> None:
+ from jarvis.cu.indicator import protocol
+
+ assert {"copy", "save", "copy_text"} == protocol.CARD_ACTIONS
+
+
async def test_a_card_action_without_a_held_appshot_says_so(monkeypatch) -> None:
from jarvis.appshot import store as store_module