YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
refactor: move shortcut metrics to Swift WebSocket, add enterprise license TS binding
Louis Beaumontb0f93393be78
diff --git a/apps/screenpipe-app-tauri/src-tauri/build.rs b/apps/screenpipe-app-tauri/src-tauri/build.rsindex 58198400d..565796ad8 100644--- a/apps/screenpipe-app-tauri/src-tauri/build.rs+++ b/apps/screenpipe-app-tauri/src-tauri/build.rs@@ -440,8 +440,6 @@ typedef void (*action_callback_t)(const char*);void shortcut_set_action_callback(action_callback_t cb) { (void)cb; }int shortcut_show(const char* json) { (void)json; return -2; }int shortcut_hide(void) { return -2; }-int shortcut_update_metrics(const char* json) { (void)json; return -2; }-int shortcut_update_shortcuts(const char* json) { (void)json; return -2; }int shortcut_is_available(void) { return 0; }"#,)diff --git a/apps/screenpipe-app-tauri/src-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/src-tauri/lib/utils/tauri.tsindex 13805b7fd..2a5a4e331 100644--- a/apps/screenpipe-app-tauri/src-tauri/lib/utils/tauri.ts+++ b/apps/screenpipe-app-tauri/src-tauri/lib/utils/tauri.ts@@ -192,6 +192,14 @@ async getAudioDevices() : Promise<Result<AudioDeviceInfo[], string>> {async isEnterpriseBuildCmd() : Promise<boolean> {return await TAURI_INVOKE("is_enterprise_build_cmd");},+/**+ * Read the enterprise license key from `enterprise.json` next to the executable.+ * Admins push this file via Intune/MDM to a protected directory (e.g. Program Files)+ * that employees cannot modify. Returns None if the file doesn't exist or is invalid.+ */+async getEnterpriseLicenseKey() : Promise<string | null> {+ return await TAURI_INVOKE("get_enterprise_license_key");+},async getDiskUsage(forceRefresh: boolean | null, dataDir: string | null) : Promise<Result<JsonValue, string>> {try {return { status: "ok", data: await TAURI_INVOKE("get_disk_usage", { forceRefresh, dataDir }) };diff --git a/apps/screenpipe-app-tauri/src-tauri/src/native_shortcut_reminder.rs b/apps/screenpipe-app-tauri/src-tauri/src/native_shortcut_reminder.rsindex 187a914ac..c9dd37241 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/native_shortcut_reminder.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/native_shortcut_reminder.rs@@ -4,6 +4,8 @@//! FFI bridge to the SwiftUI shortcut reminder panel on macOS.//! On non-macOS platforms, all functions return false / are no-ops.+//! Note: metrics (audio/screen) are fetched by Swift via WebSocket directly,+//! so no Rust-side update_metrics/update_shortcuts calls are needed.#[cfg(target_os = "macos")]mod ffi {@@ -14,8 +16,6 @@ mod ffi {pub fn shortcut_is_available() -> c_int;pub fn shortcut_show(json: *const c_char) -> c_int;pub fn shortcut_hide() -> c_int;- pub fn shortcut_update_metrics(json: *const c_char) -> c_int;- pub fn shortcut_update_shortcuts(json: *const c_char) -> c_int;pub fn shortcut_set_action_callback(cb: Option<extern "C" fn(*const c_char)>,);@@ -42,22 +42,6 @@ mod ffi {unsafe { shortcut_hide() == 0 }}- pub fn update_metrics(json: &str) -> bool {- if let Ok(c) = CString::new(json) {- unsafe { shortcut_update_metrics(c.as_ptr()) == 0 }- } else {- false- }- }-- pub fn update_shortcuts(json: &str) -> bool {- if let Ok(c) = CString::new(json) {- unsafe { shortcut_update_shortcuts(c.as_ptr()) == 0 }- } else {- false- }- }-pub fn set_action_callback(cb: extern "C" fn(*const c_char)) {unsafe {shortcut_set_action_callback(Some(cb));@@ -70,8 +54,6 @@ mod ffi {pub fn is_available() -> bool { false }pub fn show(_json: Option<&str>) -> bool { false }pub fn hide() -> bool { false }- pub fn update_metrics(_json: &str) -> bool { false }- pub fn update_shortcuts(_json: &str) -> bool { false }pub fn set_action_callback(_cb: extern "C" fn(*const std::os::raw::c_char)) {}}diff --git a/apps/screenpipe-app-tauri/src-tauri/swift/notification_panel.swift b/apps/screenpipe-app-tauri/src-tauri/swift/notification_panel.swiftindex e7ca07109..7fd3acda1 100644--- a/apps/screenpipe-app-tauri/src-tauri/swift/notification_panel.swift+++ b/apps/screenpipe-app-tauri/src-tauri/swift/notification_panel.swift@@ -535,8 +535,11 @@ class NotificationPanelController: NSObject {}private func createPanel() {+ // Panel is 360x220 to give room for the shadow (20px radius).+ // The SwiftUI content is padded inward so the visible notification+ // is still 320x180 with shadow extending into the padding area.let p = NSPanel(- contentRect: NSRect(x: 0, y: 0, width: 320, height: 180),+ contentRect: NSRect(x: 0, y: 0, width: 360, height: 220),styleMask: [.nonactivatingPanel, .borderless],backing: .buffered,defer: false@@ -557,7 +560,7 @@ class NotificationPanelController: NSObject {p.sharingType = .readOnly// Use a custom tracking view as the content view- let tracking = HoverTrackingView(frame: NSRect(x: 0, y: 0, width: 320, height: 180))+ let tracking = HoverTrackingView(frame: NSRect(x: 0, y: 0, width: 360, height: 220))tracking.controller = selftracking.autoresizingMask = [.width, .height]p.contentView = tracking@@ -573,12 +576,15 @@ class NotificationPanelController: NSObject {if NSMouseInRect(mouseLocation, screen.frame, false) {let frame = screen.framelet visible = screen.visibleFrame- let margin: CGFloat = 20- // Use screen.frame for X (right edge) — visibleFrame may be- // inset by the Dock and cause wrong positioning- let x = frame.origin.x + frame.size.width - 320 - margin- // Use visibleFrame for Y (top edge) — avoids menu bar / notch- let y = visible.origin.y + visible.size.height - 180 - margin+ let margin: CGFloat = 16+ let shadowPad: CGFloat = 20 // padding inside panel for shadow+ // Content (320x180) is centered in panel (360x220) with 20px padding.+ // Right edge of content = panel.x + shadowPad + 320+ // We want that right edge to be `margin` from screen right edge:+ // panel.x + shadowPad + 320 = screen.right - margin+ // panel.x = screen.right - margin - shadowPad - 320+ let x = frame.origin.x + frame.size.width - margin - shadowPad - 320+ let y = visible.origin.y + visible.size.height - margin - shadowPad - 180panel.setFrameOrigin(NSPoint(x: x, y: y))break}@@ -590,7 +596,7 @@ class NotificationPanelController: NSObject {let prog = self.progresslet hovered = self.isHovered- let view = NotificationContentView(+ let innerView = NotificationContentView(payload: payload,progress: prog,isHovered: hovered,@@ -606,6 +612,10 @@ class NotificationPanelController: NSObject {}})+ // Wrap in padding so shadow has room to render within the oversized panel+ let view = innerView+ .frame(width: 320, height: 180)+ .padding(20)let contentView = panel.contentView!if let hosting = hostingView {diff --git a/apps/screenpipe-app-tauri/src-tauri/swift/shortcut_reminder.swift b/apps/screenpipe-app-tauri/src-tauri/swift/shortcut_reminder.swiftindex bffb12e1a..bd7d99045 100644--- a/apps/screenpipe-app-tauri/src-tauri/swift/shortcut_reminder.swift+++ b/apps/screenpipe-app-tauri/src-tauri/swift/shortcut_reminder.swift@@ -162,7 +162,7 @@ struct ScreenMatrixView: View {// MARK: - Main shortcut reminder view// Concept #4: Audio-reactive pill that expands on hover-private let kCollapsedW: CGFloat = 44+private let kCollapsedW: CGFloat = 62private let kCollapsedH: CGFloat = 22private let kExpandedW: CGFloat = 200private let kExpandedH: CGFloat = 26@@ -195,7 +195,7 @@ struct ShortcutReminderView: View {}}- // MARK: - Collapsed pill (live audio viz)+ // MARK: - Collapsed pill (live audio + screen viz)private var collapsedView: some View {HStack(spacing: 3) {// App icon tiny@@ -206,7 +206,22 @@ struct ShortcutReminderView: View {}// Mini audio barsAudioEqualizerView(active: metrics.audioActive, speechRatio: metrics.speechRatio)- .frame(width: 20, height: 12)+ .frame(width: 18, height: 12)+ // Mini screen capture viz+ ScreenMatrixView(active: metrics.screenActive, captureFps: metrics.captureFps)+ .frame(width: 18, height: 12)+ .clipShape(RoundedRectangle(cornerRadius: 1))+ // Meeting indicator+ ZStack {+ Image(systemName: "phone.fill")+ .font(.system(size: 6))+ .foregroundColor(metrics.meetingActive ? .white : .white.opacity(0.2))+ if metrics.meetingActive {+ Circle().fill(.white)+ .frame(width: 4, height: 4)+ .offset(x: 5, y: -5)+ }+ }}.padding(.horizontal, 5).frame(height: kCollapsedH)@@ -218,15 +233,15 @@ struct ShortcutReminderView: View {private var expandedView: some View {HStack(spacing: 0) {// Shortcut buttons- ShortcutCellButton(icon: "rectangle", label: overlayShortcut, colW: nil) {+ ShortcutCellButton(icon: "rectangle", label: overlayShortcut, colW: nil, edge: .leading) {onAction("open_timeline")}Rectangle().fill(.white.opacity(0.15)).frame(width: 0.5)- ShortcutCellButton(icon: "bubble.left", label: chatShortcut, colW: nil) {+ ShortcutCellButton(icon: "bubble.left", label: chatShortcut, colW: nil, edge: nil) {onAction("open_chat")}Rectangle().fill(.white.opacity(0.15)).frame(width: 0.5)- ShortcutCellButton(icon: "magnifyingglass", label: searchShortcut, colW: nil) {+ ShortcutCellButton(icon: "magnifyingglass", label: searchShortcut, colW: nil, edge: nil) {onAction("open_search")}@@ -245,16 +260,17 @@ struct ShortcutReminderView: View {Rectangle().fill(.white.opacity(0.15)).frame(width: 0.5)// Meeting + close- HoverIconButton(icon: "phone.fill", isActive: metrics.meetingActive) {+ HoverIconButton(icon: "phone.fill", isActive: metrics.meetingActive, edge: nil) {onAction("toggle_meeting")}- HoverIconButton(icon: "xmark", isActive: false) {+ HoverIconButton(icon: "xmark", isActive: false, edge: .trailing) {onAction("close")}}.frame(height: kExpandedH).background(Capsule().fill(Color.black.opacity(0.8))).overlay(Capsule().stroke(.white.opacity(0.15), lineWidth: 0.5))+ .clipShape(Capsule()) // clip hover highlights to capsule shape}}@@ -265,6 +281,7 @@ struct ShortcutCellButton: View {let icon: Stringlet label: Stringlet colW: CGFloat?+ let edge: HorizontalEdge? // .leading = left cap, .trailing = right cap, nil = middlelet action: () -> Void@State private var hovered = false@@ -281,9 +298,8 @@ struct ShortcutCellButton: View {.fixedSize()}.padding(.horizontal, 6)- .padding(.vertical, 3)- .frame(width: colW)- .background(hovered ? Color.white.opacity(0.1) : Color.clear)+ .frame(width: colW).frame(maxHeight: .infinity)+ .background(hovered ? Color.white.opacity(0.12) : Color.clear).contentShape(Rectangle())}.buttonStyle(.plain)@@ -295,17 +311,25 @@ struct ShortcutCellButton: View {struct HoverIconButton: View {let icon: Stringlet isActive: Bool+ let edge: HorizontalEdge?let action: () -> Void@State private var hovered = falsevar body: some View {Button(action: action) {- Image(systemName: icon)- .font(.system(size: 5, weight: icon == "xmark" ? .medium : .regular))- .foregroundColor(isActive ? .white : (hovered ? .white : .white.opacity(0.4)))- .frame(width: 10, height: 10)- .background(hovered ? Color.white.opacity(0.1) : Color.clear)- .contentShape(Rectangle())+ ZStack(alignment: .topTrailing) {+ Image(systemName: icon)+ .font(.system(size: 5, weight: icon == "xmark" ? .medium : .regular))+ .foregroundColor(isActive ? .white : (hovered ? .white : .white.opacity(0.4)))+ if isActive {+ Circle().fill(.white)+ .frame(width: 3, height: 3)+ .offset(x: 1, y: -1)+ }+ }+ .frame(width: 16).frame(maxHeight: .infinity)+ .background(hovered ? Color.white.opacity(0.12) : Color.clear)+ .contentShape(Rectangle())}.buttonStyle(.plain).onHover { h in hovered = h }@@ -329,6 +353,7 @@ class ShortcutReminderController: NSObject {@Published var isExpanded = falseprivate var wsTask: URLSessionWebSocketTask?private var wsRetryTimer: Timer?+ private var meetingPollTimer: Timer?private var prevFramesCaptured: Int?private var prevOcrCompleted: Int?@@ -345,12 +370,15 @@ class ShortcutReminderController: NSObject {panel?.orderFrontRegardless()AnimationTick.shared.start()connectWebSocket()+ startMeetingPoll()}}func hide() {AnimationTick.shared.stop()disconnectWebSocket()+ meetingPollTimer?.invalidate()+ meetingPollTimer = nilDispatchQueue.main.async { [self] inpanel?.orderOut(nil)}@@ -423,26 +451,29 @@ class ShortcutReminderController: NSObject {}}- func updateMetrics(json: String) {- // Keep the FFI method for Rust-pushed metrics if needed- guard let data = json.data(using: .utf8),- let m = try? JSONDecoder().decode(MetricsJSON.self, from: data) else { return }- DispatchQueue.main.async { [self] in- self.metrics.audioActive = (m.audio_level_rms ?? 0) > 0.001- self.metrics.speechRatio = min(1, (m.audio_level_rms ?? 0) * 15)- self.metrics.screenActive = (m.frames_captured_delta ?? 0) > 0- self.metrics.captureFps = Double(m.frames_captured_delta ?? 0) / 0.5- self.metrics.meetingActive = m.meeting_active ?? false- self.updateContent()- }- }+ // MARK: - Meeting status polling- func updateShortcuts(json: String?) {- guard let json = json else { return }- DispatchQueue.main.async { [self] in- parseShortcuts(json)- updateContent()+ private func startMeetingPoll() {+ checkMeetingStatus()+ meetingPollTimer = Timer.scheduledTimer(withTimeInterval: 5, repeats: true) { [weak self] _ in+ self?.checkMeetingStatus()}+ RunLoop.main.add(meetingPollTimer!, forMode: .common)+ }++ private func checkMeetingStatus() {+ guard let url = URL(string: "http://localhost:3030/meetings/status") else { return }+ URLSession.shared.dataTask(with: url) { [weak self] data, _, _ in+ guard let self = self, let data = data,+ let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any] else { return }+ let active = json["active"] as? Bool ?? false+ DispatchQueue.main.async {+ if self.metrics.meetingActive != active {+ self.metrics.meetingActive = active+ self.updateContent()+ }+ }+ }.resume()}private func parseShortcuts(_ json: String) {@@ -565,14 +596,6 @@ private class ReminderTrackingView: NSView {}}-// MARK: - JSON decode helper--private struct MetricsJSON: Codable {- var audio_level_rms: Double?- var frames_captured_delta: Int?- var meeting_active: Bool?-}-// MARK: - C FFI@_cdecl("shortcut_show")@@ -594,26 +617,6 @@ public func shortcutHide() -> Int32 {return -2}-@_cdecl("shortcut_update_metrics")-public func shortcutUpdateMetrics(_ jsonPtr: UnsafePointer<CChar>) -> Int32 {- let json = String(cString: jsonPtr)- if #available(macOS 13.0, *) {- ShortcutReminderController.shared.updateMetrics(json: json)- return 0- }- return -2-}--@_cdecl("shortcut_update_shortcuts")-public func shortcutUpdateShortcuts(_ jsonPtr: UnsafePointer<CChar>) -> Int32 {- let json = String(cString: jsonPtr)- if #available(macOS 13.0, *) {- ShortcutReminderController.shared.updateShortcuts(json: json)- return 0- }- return -2-}-@_cdecl("shortcut_is_available")public func shortcutIsAvailable() -> Int32 {if #available(macOS 13.0, *) {