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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(appshot): drag the corner card like CleanShot X
rubenluetke10-beep02409670f56e
diff --git a/docs/appshots.md b/docs/appshots.mdindex 0ce42ee76f..39ff51500b 100644--- a/docs/appshots.md+++ b/docs/appshots.md@@ -71,7 +71,11 @@ long is `[appshot].card_seconds` (Settings → Appshots → *Corner card*: 3, 6,- **Done** or **Close** in the editor window slides the picture back intothe corner — the edited one after Done — so it stays at hand.- **Drag** the card into any app that accepts files or images (chat, mail,- Explorer/Finder) to drop the picture there.+ Explorer/Finder) to drop the picture there. As in CleanShot X, a smaller+ rounded copy lifts off and stays where you grabbed it, and a green "+"+ beside the pointer shows that the text field or window under it takes the+ picture (macOS shows its own green badge). Dropped nowhere, or cancelled+ with Esc, the card stays; after a drop it slides away.- **Right-click** dismisses it.Only the finished, privacy-filtered appshot can leave by drag — the card'sdiff --git a/jarvis/cu/indicator/renderer.py b/jarvis/cu/indicator/renderer.pyindex d69b110a97..86c127f4b7 100644--- a/jarvis/cu/indicator/renderer.py+++ b/jarvis/cu/indicator/renderer.py@@ -402,6 +402,105 @@ class _SnapWindow(QWidget):painter.end()+#: The lifted picture under the pointer while the card is dragged: smaller+#: than the card so the drop target stays visible (CleanShot X's drag).+_DRAG_PREVIEW_W = 220.0+_DRAG_PREVIEW_H = 165.0+_DRAG_PREVIEW_RADIUS = 10.0+_DRAG_PREVIEW_PAD = 12.0 # transparent margin that holds the shadow+_DRAG_PREVIEW_OPACITY = 0.94+#: The "+" badge beside the pointer over a target that takes the picture.+_DRAG_BADGE_GREEN = QColor(52, 199, 89)+++def _drag_preview(thumb: QImage, card: QRectF, grab: QPointF, dpr: float) -> tuple[QPixmap, QPoint]:+ """The lifted card for a drag, and the hotspot that keeps the grab point.++ Rounded, ringed and shadowed like the resting card, scaled down, and+ rendered at the screen's pixel ratio so it stays sharp. The hotspot is the+ spot the user pressed, mapped onto the smaller picture, so the picture+ does not jump out from under the pointer.+ """+ aspect = thumb.height() / max(1, thumb.width()) if not thumb.isNull() else 0.6+ w = _DRAG_PREVIEW_W+ h = w * aspect+ if h > _DRAG_PREVIEW_H:+ h = _DRAG_PREVIEW_H+ w = h / max(aspect, 1e-6)+ pad = _DRAG_PREVIEW_PAD+ dpr = max(1.0, float(dpr))+ size = QPointF(w + 2 * pad, h + 2 * pad)+ canvas = QPixmap(int(size.x() * dpr + 0.5), int(size.y() * dpr + 0.5))+ canvas.setDevicePixelRatio(dpr)+ canvas.fill(Qt.GlobalColor.transparent)+ painter = QPainter(canvas)+ painter.setRenderHint(QPainter.RenderHint.Antialiasing)+ painter.setRenderHint(QPainter.RenderHint.SmoothPixmapTransform)+ painter.setOpacity(_DRAG_PREVIEW_OPACITY)+ rect = QRectF(pad, pad, w, h)+ painter.setPen(Qt.PenStyle.NoPen)+ for spread, alpha in ((10.0, 16), (5.0, 28), (2.0, 44)):+ shadow = rect.adjusted(-spread, -spread + 4, spread, spread + 4)+ painter.setBrush(QColor(0, 0, 0, alpha))+ radius = _DRAG_PREVIEW_RADIUS + spread+ painter.drawRoundedRect(shadow, radius, radius)+ _paint_card(painter, rect, thumb, _DRAG_PREVIEW_RADIUS, 1.0)+ painter.end()+ fx = (grab.x() - card.x()) / max(1.0, card.width())+ fy = (grab.y() - card.y()) / max(1.0, card.height())+ hot = QPoint(+ int(pad + max(0.0, min(1.0, fx)) * w),+ int(pad + max(0.0, min(1.0, fy)) * h),+ )+ return canvas, hot+++def _drag_copy_cursor(dpr: float) -> QPixmap:+ """An arrow with a green "+" badge — the pointer over a drop target.++ The arrow tip is the pixmap's top-left corner, where Qt puts the hotspot.+ Where the platform keeps its own drag badges (macOS), Qt ignores it.+ """+ dpr = max(1.0, float(dpr))+ canvas = QPixmap(int(30 * dpr + 0.5), int(32 * dpr + 0.5))+ canvas.setDevicePixelRatio(dpr)+ canvas.fill(Qt.GlobalColor.transparent)+ painter = QPainter(canvas)+ painter.setRenderHint(QPainter.RenderHint.Antialiasing)+ arrow = QPolygonF(+ [+ QPointF(1.0, 1.0),+ QPointF(1.0, 17.5),+ QPointF(5.0, 13.8),+ QPointF(7.8, 20.2),+ QPointF(10.6, 19.0),+ QPointF(7.9, 12.8),+ QPointF(13.0, 12.8),+ ]+ )+ pen = QPen(QColor(0, 0, 0, 230))+ pen.setWidthF(1.2)+ pen.setJoinStyle(Qt.PenJoinStyle.RoundJoin)+ painter.setPen(pen)+ painter.setBrush(QColor(255, 255, 255))+ painter.drawPolygon(arrow)+ centre = QPointF(20.0, 22.0)+ ring = QPen(QColor(255, 255, 255))+ ring.setWidthF(1.6)+ painter.setPen(ring)+ painter.setBrush(_DRAG_BADGE_GREEN)+ painter.drawEllipse(centre, 8.0, 8.0)+ plus = QPen(QColor(255, 255, 255))+ plus.setWidthF(2.0)+ plus.setCapStyle(Qt.PenCapStyle.RoundCap)+ painter.setPen(plus)+ cx, cy = centre.x(), centre.y()+ painter.drawLine(QPointF(cx - 4.0, cy), QPointF(cx + 4.0, cy))+ painter.drawLine(QPointF(cx, cy - 4.0), QPointF(cx, cy + 4.0))+ painter.end()+ return canvas++def _card_rect(screen, thumb: QImage) -> QRectF:"""Where the resting card sits: the bottom-right of ``screen``'s work area.@@ -594,8 +693,8 @@ class _CardWindow(QWidget):returnmoved = event.position() - self._pressif abs(moved.x()) + abs(moved.y()) > _CARD_DRAG_SLOP:- self._press = None- self._start_drag()+ grab, self._press = self._press, None+ self._start_drag(grab)def mouseReleaseEvent(self, event) -> None: # noqa: N802if event.button() != Qt.MouseButton.LeftButton or self._press is None:@@ -615,7 +714,7 @@ class _CardWindow(QWidget):else: # "edit" or the picture itselfself._owner.card_clicked(self)- def _start_drag(self) -> None:+ def _start_drag(self, grab: QPointF) -> None:owner = self._ownerimage = owner.card_image if owner is not None else Noneif owner is None or image is None or image.isNull():@@ -630,15 +729,25 @@ class _CardWindow(QWidget):mime.setImageData(image)drag = QDrag(self)drag.setMimeData(mime)- preview = QPixmap.fromImage(- self._thumb.scaledToWidth(160, Qt.TransformationMode.SmoothTransformation)- )+ # CleanShot X's drag: the card lifts off as a smaller, rounded copy+ # held where it was grabbed, and a green "+" beside the pointer says+ # the field or window under it takes the picture.+ dpr = float(self.devicePixelRatioF() or 1.0)+ preview, hot = _drag_preview(self._thumb, self._card_area(), grab, dpr)drag.setPixmap(preview)- drag.setHotSpot(QPoint(preview.width() // 2, preview.height() // 2))+ drag.setHotSpot(hot)+ drag.setDragCursor(_drag_copy_cursor(dpr), Qt.DropAction.CopyAction)self._dismiss.stop()self.setWindowOpacity(0.35)- drag.exec(Qt.DropAction.CopyAction)+ result = drag.exec(Qt.DropAction.CopyAction)self.setWindowOpacity(1.0)+ if result == Qt.DropAction.IgnoreAction:+ # Dropped nowhere (or Esc): the card stays, like CleanShot's.+ self._hover = False+ self._hot = ""+ self._arm_dismiss(_CARD_AFTER_HOVER_MS)+ self.update()+ returnself.leave()# -- hover buttons -------------------------------------------------------diff --git a/tests/unit/cu/indicator/test_card_drag_image.py b/tests/unit/cu/indicator/test_card_drag_image.pynew file mode 100644index 0000000000..518650402e--- /dev/null+++ b/tests/unit/cu/indicator/test_card_drag_image.py@@ -0,0 +1,79 @@+"""The lifted picture and pointer badge while the appshot card is dragged.++Runs on Qt's offscreen platform; auto-skips without PySide6 (a [desktop] extra).+"""++from __future__ import annotations++import importlib.util+import os++import pytest++pytestmark = pytest.mark.skipif(+ importlib.util.find_spec("PySide6") is None,+ reason="PySide6 not installed (indicator sidecar is a [desktop] extra)",+)++[email protected](scope="module")+def qt():+ os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")+ from PySide6.QtWidgets import QApplication # noqa: PLC0415++ app = QApplication.instance() or QApplication([])+ from jarvis.cu.indicator import renderer # noqa: PLC0415++ yield renderer+ del app+++def _thumb(width: int, height: int):+ from PySide6.QtGui import QColor, QImage # noqa: PLC0415++ image = QImage(width, height, QImage.Format.Format_ARGB32)+ image.fill(QColor(200, 210, 230))+ return image+++def test_preview_is_smaller_than_the_card_and_sharp(qt) -> None:+ from PySide6.QtCore import QPointF, QRectF # noqa: PLC0415++ card = QRectF(12, 12, 320, 200)+ pixmap, _hot = qt._drag_preview(_thumb(560, 350), card, QPointF(172, 112), 2.0)+ pad = qt._DRAG_PREVIEW_PAD+ logical_w = pixmap.width() / pixmap.devicePixelRatio()+ assert pixmap.devicePixelRatio() == 2.0+ assert logical_w - 2 * pad == pytest.approx(qt._DRAG_PREVIEW_W, abs=1)+ assert logical_w - 2 * pad < card.width()+++def test_hotspot_keeps_the_grab_point(qt) -> None:+ from PySide6.QtCore import QPointF, QRectF # noqa: PLC0415++ card = QRectF(12, 12, 320, 200)+ pad = qt._DRAG_PREVIEW_PAD+ w = qt._DRAG_PREVIEW_W+ h = w * 350 / 560+ # Grabbed at the card's centre: the hotspot is the preview's centre.+ _pm, hot = qt._drag_preview(_thumb(560, 350), card, QPointF(172, 112), 1.0)+ assert (hot.x(), hot.y()) == (int(pad + w / 2), int(pad + h / 2))+ # Grabbed in the shadow margin: clamped onto the picture's corner.+ _pm, hot = qt._drag_preview(_thumb(560, 350), card, QPointF(0, 0), 1.0)+ assert (hot.x(), hot.y()) == (int(pad), int(pad))+++def test_tall_picture_is_capped_by_height(qt) -> None:+ from PySide6.QtCore import QPointF, QRectF # noqa: PLC0415++ pixmap, _hot = qt._drag_preview(_thumb(300, 900), QRectF(0, 0, 80, 240), QPointF(40, 120), 1.0)+ assert pixmap.height() - 2 * qt._DRAG_PREVIEW_PAD == pytest.approx(qt._DRAG_PREVIEW_H, abs=1)+++def test_copy_cursor_draws_the_green_badge(qt) -> None:+ pixmap = qt._drag_copy_cursor(1.0)+ image = pixmap.toImage()+ badge = image.pixelColor(20 + 6, 22) # inside the circle, off the plus+ assert (badge.red(), badge.green(), badge.blue()) == (52, 199, 89)+ tip = image.pixelColor(2, 4) # inside the white arrow, by its tip+ assert tip.alpha() > 0