SQL

CREATE TABLE ui_events  (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  timestamp DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  session_id TEXT,
  relative_ms INTEGER NOT NULL DEFAULT 0,
  event_type TEXT NOT NULL,
  -- click,
  move,
  scroll,
  key,
  text,
  app_switch,
  window_focus,
  clipboard
    -- Position
    x INTEGER,
  y INTEGER,
  delta_x INTEGER,
  delta_y INTEGER,
  -- Mouse/key
    button INTEGER,
  click_count INTEGER,
  key_code INTEGER,
  modifiers INTEGER,
  -- Text content
    text_content TEXT,
  text_length INTEGER,
  -- App context
    app_name TEXT,
  app_pid INTEGER,
  window_title TEXT,
  browser_url TEXT,
  -- Element context (from accessibility APIs)
    element_role TEXT,
  element_name TEXT,
  element_value TEXT,
  element_description TEXT,
  element_automation_id TEXT,
  element_bounds TEXT,
  -- JSON: {"x":0,
  "y":0,
  "width":100,
  "height":50}
    -- Frame correlation
    frame_id INTEGER,
  -- Sync columns
    sync_id TEXT,
  machine_id TEXT,
  synced_at DATETIME
)

Columns

Column Data type Allow null Primary key Actions
id INTEGER read-only
timestamp DATETIME read-only
session_id TEXT read-only
relative_ms INTEGER read-only
event_type TEXT read-only
x INTEGER read-only
y INTEGER read-only
delta_x INTEGER read-only
delta_y INTEGER read-only
button INTEGER read-only
click_count INTEGER read-only
key_code INTEGER read-only
modifiers INTEGER read-only
text_content TEXT read-only
text_length INTEGER read-only
app_name TEXT read-only
app_pid INTEGER read-only
window_title TEXT read-only
browser_url TEXT read-only
element_role TEXT read-only
element_name TEXT read-only
element_value TEXT read-only
element_description TEXT read-only
element_automation_id TEXT read-only
element_bounds TEXT read-only
frame_id INTEGER read-only
sync_id TEXT read-only
machine_id TEXT read-only
synced_at DATETIME read-only

Indexes

Name Columns Unique SQL Drop?
idx_ui_events_app_name app_name SQL
CREATE INDEX idx_ui_events_app_name
ON ui_events(app_name)
read-only
idx_ui_events_event_type event_type SQL
CREATE INDEX idx_ui_events_event_type
ON ui_events(event_type)
read-only
idx_ui_events_frame_id frame_id SQL
CREATE INDEX idx_ui_events_frame_id
ON ui_events(frame_id)
read-only
idx_ui_events_session_id session_id SQL
CREATE INDEX idx_ui_events_session_id
ON ui_events(session_id)
read-only
idx_ui_events_sync_id sync_id SQL
CREATE INDEX idx_ui_events_sync_id
ON ui_events(sync_id)
read-only
idx_ui_events_synced_at synced_at SQL
CREATE INDEX idx_ui_events_synced_at
ON ui_events(synced_at)
read-only
idx_ui_events_timestamp timestamp SQL
CREATE INDEX idx_ui_events_timestamp
ON ui_events(timestamp)
read-only
idx_ui_events_unsynced synced_at SQL
CREATE INDEX idx_ui_events_unsynced
ON ui_events(synced_at) WHERE synced_at IS NULL
read-only

Triggers

Name SQL Drop?
ui_events_ad SQL
CREATE TRIGGER ui_events_ad AFTER DELETE ON ui_events BEGIN
    INSERT INTO ui_events_fts(ui_events_fts, rowid, text_content, app_name, window_title, element_name)
    VALUES('delete', OLD.id, OLD.text_content, OLD.app_name, OLD.window_title, OLD.element_name);
END
read-only
ui_events_au SQL
CREATE TRIGGER ui_events_au AFTER UPDATE ON ui_events BEGIN
    INSERT INTO ui_events_fts(ui_events_fts, rowid, text_content, app_name, window_title, element_name)
    VALUES('delete', OLD.id, OLD.text_content, OLD.app_name, OLD.window_title, OLD.element_name);
    INSERT INTO ui_events_fts(rowid, text_content, app_name, window_title, element_name)
    VALUES (NEW.id, NEW.text_content, NEW.app_name, NEW.window_title, NEW.element_name);
END
read-only
ui_events_ai SQL
CREATE TRIGGER ui_events_ai AFTER INSERT ON ui_events BEGIN
    INSERT OR IGNORE INTO ui_events_fts(rowid, text_content, app_name, window_title, element_name)
    VALUES (NEW.id, NEW.text_content, NEW.app_name, NEW.window_title, NEW.element_name);
END
read-only