1 Commits

Author SHA1 Message Date
Copilot
65c0531492 feat: add Open Camera window for webcam preview, photo capture, and mirror toggle (#1064)
* feat: add Open Camera feature with live preview, photo capture, mirror toggle, and camera switching

Agent-Logs-Url: https://github.com/infinilabs/coco-app/sessions/e874b626-f179-4d54-bc6c-c239394459e3

Co-authored-by: medcl <64487+medcl@users.noreply.github.com>

* fix: address code review feedback - add error logging, remove invisible button, document eslint-disable

Agent-Logs-Url: https://github.com/infinilabs/coco-app/sessions/e874b626-f179-4d54-bc6c-c239394459e3

Co-authored-by: medcl <64487+medcl@users.noreply.github.com>

* refactor: convert camera from dedicated window to built-in extension with permission handling

- Create Open Camera built-in extension (search source in Rust)
- Add camera permission check/request via macOS permissions plugin
- Render camera inline in main Coco window (not a separate window)
- Add com.apple.security.device.camera entitlement
- Remove dedicated camera window, tray menu entry, and window commands
- Add cameraOpened state to search store for navigation support
- Handle Escape/Back navigation for camera view

Agent-Logs-Url: https://github.com/infinilabs/coco-app/sessions/bb996add-d287-464c-bc53-c69167630351

Co-authored-by: medcl <64487+medcl@users.noreply.github.com>

* fix: address code review feedback - fix permission check flow, remove duplicate cleanup, fix type

Agent-Logs-Url: https://github.com/infinilabs/coco-app/sessions/bb996add-d287-464c-bc53-c69167630351

Co-authored-by: medcl <64487+medcl@users.noreply.github.com>

* fix: camera not displaying video due to missing CSP media-src, secure context, and stream lifecycle issues

Three root causes fixed:
1. CSP missing media-src directive - Added media-src with blob: and mediastream:
   schemes to allow camera streams in the webview
2. Missing useHttpsScheme - Added to main window config to ensure secure context
   required by getUserMedia API on macOS WKWebView
3. Camera.tsx stream lifecycle - Rewrote initialization to use a single sequential
   flow (permission → getUserMedia → enumerate → assign) instead of three
   separate useEffects with circular dependency issues. Uses refs for stream
   tracking to prevent stale closure bugs in cleanup.

Agent-Logs-Url: https://github.com/infinilabs/coco-app/sessions/f3b86e6b-3ce2-423d-a5a1-c3a5f4e115f2

Co-authored-by: medcl <64487+medcl@users.noreply.github.com>

* fix: tighten CSP media-src directive and add permission polling timeout

- Remove overly permissive https:/http: from media-src (only need self/blob/mediastream)
- Remove unnecessary img-src override (falls back to default-src)
- Add 60-second timeout to camera permission polling to prevent infinite loops
- Check cancelled flag during polling to support component unmount

Agent-Logs-Url: https://github.com/infinilabs/coco-app/sessions/f3b86e6b-3ce2-423d-a5a1-c3a5f4e115f2

Co-authored-by: medcl <64487+medcl@users.noreply.github.com>

* feat: add Open Camera functionality with icon and translations

* fix: remove unused setCameraOpened from SearchResultsPanel

* feat: update platform adapters to include saveFileDialog method for Tauri and Web

* fix: streamline camera search source registration in built-in extension

* refactor: update extension icon

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: medcl <64487+medcl@users.noreply.github.com>
Co-authored-by: ayangweb <473033518@qq.com>
2026-05-13 09:16:32 +08:00