Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions desktop/Desktop/Sources/Chat/ChatPrompts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ struct ChatPrompts {
"ocrText": "Full OCR-extracted text from the screen",
"focusStatus": "Whether user was focused or distracted (focused/distracted)",
"skippedForBattery": "OCR was skipped on battery; text may be missing",
"deviceName": "Computer/device name that captured this screenshot (for multi-device queries)",
],
"action_items": [
"description": "The task text shown to the user",
Expand Down
8 changes: 8 additions & 0 deletions desktop/Desktop/Sources/Rewind/Core/RewindDatabase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2156,6 +2156,14 @@ actor RewindDatabase {
}
}

migrator.registerMigration("addDeviceName") { db in
try db.alter(table: "screenshots") { t in
t.add(column: "deviceName", .text)
}
}
}
}

try migrator.migrate(queue)
}

Expand Down
7 changes: 6 additions & 1 deletion desktop/Desktop/Sources/Rewind/Core/RewindModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ struct Screenshot: Codable, FetchableRecord, PersistableRecord, Identifiable, Eq
/// Whether OCR was skipped because the Mac was on battery (needs backfill when AC reconnects)
var skippedForBattery: Bool

/// Computer/device name that captured this screenshot (for multi-device disambiguation)
var deviceName: String?

static let databaseTableName = "screenshots"

// MARK: - Storage Type
Expand All @@ -72,7 +75,8 @@ struct Screenshot: Codable, FetchableRecord, PersistableRecord, Identifiable, Eq
focusStatus: String? = nil,
extractedTasksJson: String? = nil,
adviceJson: String? = nil,
skippedForBattery: Bool = false
skippedForBattery: Bool = false,
deviceName: String? = nil
) {
self.id = id
self.timestamp = timestamp
Expand All @@ -88,6 +92,7 @@ struct Screenshot: Codable, FetchableRecord, PersistableRecord, Identifiable, Eq
self.extractedTasksJson = extractedTasksJson
self.adviceJson = adviceJson
self.skippedForBattery = skippedForBattery
self.deviceName = deviceName
}

// MARK: - Persistence Callbacks
Expand Down
16 changes: 12 additions & 4 deletions desktop/Desktop/Sources/Rewind/Services/RewindIndexer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import Foundation
actor RewindIndexer {
static let shared = RewindIndexer()

/// Capture-time computer name for new screenshots created by this app session.
private let currentComputerName = Host.current().localizedName

private var isInitialized = false
private var isInitializing = false

Expand Down Expand Up @@ -212,7 +215,8 @@ actor RewindIndexer {
ocrText: ocrText,
ocrDataJson: ocrDataJson,
isIndexed: isIndexed,
skippedForBattery: skippedForBattery
skippedForBattery: skippedForBattery,
deviceName: currentComputerName
)

let inserted = try await RewindDatabase.shared.insertScreenshot(screenshot)
Expand Down Expand Up @@ -293,7 +297,8 @@ actor RewindIndexer {
ocrText: ocrText,
ocrDataJson: ocrDataJson,
isIndexed: isIndexed,
skippedForBattery: skippedForBattery
skippedForBattery: skippedForBattery,
deviceName: currentComputerName
)

let inserted = try await RewindDatabase.shared.insertScreenshot(screenshot)
Expand Down Expand Up @@ -398,7 +403,8 @@ actor RewindIndexer {
focusStatus: focusStatus,
extractedTasksJson: tasksJson,
adviceJson: adviceJson,
skippedForBattery: skippedForBattery
skippedForBattery: skippedForBattery,
deviceName: currentComputerName
)

let inserted = try await RewindDatabase.shared.insertScreenshot(screenshot)
Expand Down Expand Up @@ -613,7 +619,9 @@ actor RewindIndexer {
frameOffset: frame.frameOffset,
ocrText: nil,
ocrDataJson: nil,
isIndexed: false // Will need re-OCR
isIndexed: false, // Will need re-OCR
// Rebuild provenance is unknown for historical frames recovered from disk.
deviceName: nil
)

try await RewindDatabase.shared.insertScreenshot(screenshot)
Expand Down
5 changes: 4 additions & 1 deletion desktop/Desktop/Sources/ScreenActivitySyncService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ actor ScreenActivitySyncService {
// Query screenshots that have embeddings and are newer than our cursor
let rows: [[String: Any]] = try await dbPool.read { [lastSyncedId, batchSize] db in
let sql = """
SELECT id, timestamp, appName, windowTitle, ocrText, embedding
SELECT id, timestamp, appName, windowTitle, ocrText, embedding, deviceName
FROM screenshots
WHERE id > ? AND embedding IS NOT NULL
ORDER BY id ASC
Expand All @@ -103,6 +103,9 @@ actor ScreenActivitySyncService {
dict["appName"] = (row["appName"] as? String) ?? ""
dict["windowTitle"] = (row["windowTitle"] as? String) ?? ""
dict["ocrText"] = (row["ocrText"] as? String) ?? ""
if let deviceName = row["deviceName"] as? String {
dict["deviceName"] = deviceName
}

// Convert embedding BLOB to [Double] array
let blobValue = row["embedding"] as DatabaseValue
Expand Down
Loading