-
Notifications
You must be signed in to change notification settings - Fork 873
feat: AI Ghost Mode - Invisible agent that learns from user browsing patterns #341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This commit introduces the foundation for AI Ghost Mode - a feature that passively observes user browsing patterns and suggests automations. Key components added: - RFC_GHOST_MODE.md: Comprehensive design document - ghost_mode_types.h: Core data models (RecordedAction, ActionSequence) - ghost_mode_prefs.cc/h: User preferences and settings - action_recorder.cc/h: Records user interactions with web pages - action_store.h: SQLite-based persistence layer - pattern_detector.h: Algorithm for detecting repeated patterns - sensitive_detector.cc/h: Privacy-first field detection (never records passwords, etc.) Privacy considerations: - All processing happens locally on-device - Sensitive fields are automatically excluded - Banking/healthcare sites excluded by default - User can disable at any time Related: browseros-ai#336
Phase 2 of AI Ghost Mode adds: ActionStore (SQLite persistence layer): - Full CRUD operations for recorded actions - Pattern storage and retrieval - Automatic cleanup based on retention settings - Schema versioning for future migrations - Indexed queries by session, timestamp, URL pattern PatternDetector (Core algorithm): - Session grouping with time gap detection - Subsequence extraction (length 3-20) - Sequence normalization (strips variable data) - Hash-based occurrence counting - Confidence scoring based on: - Occurrence frequency - Time distribution regularity - Selector stability (data-testid > id > class) - Observer pattern for async notifications PatternMatcher (Fuzzy matching): - URL pattern generation with wildcard support - URL similarity calculation - CSS selector normalization - Levenshtein distance for string comparison - Detection of dynamic IDs (UUID, numeric, CSS-in-JS) ghost_mode_types.cc (Serialization): - ActionType to/from string conversion - RecordedAction JSON serialization - ActionSequence JSON serialization - Human-readable action summaries Also adds PatternStatus enum for pattern lifecycle. Related: browseros-ai#336
Phase 3 of AI Ghost Mode adds: SuggestionController (User notification system): - PatternDetector observer integration - Pending suggestions queue management - URL-based suggestion matching - User response handling (accept/dismiss/later/customize) - Cooldown and confidence thresholds - Periodic detection scheduling WorkflowGenerator (Pattern to Workflow conversion): - Full BrowserOS Workflow JSON generation - Step conversion with selectors and fallbacks - Parameter extraction for customizable inputs - Trigger configuration (URL match, manual) - Timing hints from recorded delays - Workflow validation and JSON export/import GhostExecutor (Background execution engine): - Workflow execution queue with concurrency control - Step-by-step execution with status tracking - Pause/resume/cancel support - Observer pattern for UI updates - Error handling per-step (continue/stop/retry) - Execution result tracking with timing Key workflow format features: - Source attribution (pattern_id, confidence) - Multiple selector fallbacks - Text-based element matching - Configurable timeouts and retries - Parameter substitution support Related: browseros-ai#336
…vice Factory This commit completes Phase 4 of Ghost Mode implementation: ## Unit Tests - sensitive_detector_unittest.cc: Tests for password/CC/SSN detection - pattern_detector_unittest.cc: Tests for pattern detection and confidence - pattern_matcher_unittest.cc: Tests for URL/selector matching - workflow_generator_unittest.cc: Tests for JSON workflow generation - action_recorder_unittest.cc: Tests for WebContentsObserver recording ## Settings UI (following browseros_prefs_page pattern) - ghost_mode_page.html: Settings page with toggle, stats, patterns list - ghost_mode_page.ts: TypeScript component with PrefsMixin - workflow_editor.html: Visual workflow editor with drag-and-drop - workflow_editor.ts: Editor component for modifying workflow steps ## InfoBar Suggestion UI - ghost_mode_suggestion_infobar_delegate.h/cc: ConfirmInfoBarDelegate - Shows pattern suggestion with Accept/Dismiss/Later options - Identifier: GHOST_MODE_SUGGESTION_INFOBAR_DELEGATE (131) ## Service Layer - ghost_mode_service.h/cc: KeyedService coordinating all components - ghost_mode_service_factory.h/cc: Per-profile service factory - Handles pattern detection, workflow generation, and execution ## WebUI Handler - ghost_mode_handler.h/cc: Settings page message handler - Handles chrome.send calls from Settings UI - Syncs stats, patterns, and workflow operations ## Updated BUILD.gn - Added all new source files - Added unit test dependencies - Added settings page resources Closes browseros-ai#336
Converted ghost_mode_page and workflow_editor files from diff format to proper source files by removing git diff headers and + prefixes. Note: TypeScript errors in VS Code are expected - these are Chromium WebUI files that use chrome:// imports and Polymer base classes which only resolve in the Chromium build environment.
- Fix typo: InMillisecondsFSinceUnixEpoch -> InMillisecondsSinceUnixEpoch - Use stable FrameTreeNodeId for tab ID instead of title hash - Remove 'hidden' from blocked input types to allow CSRF tokens - Use UUID for subsession IDs instead of sequential numbers
Greptile OverviewGreptile SummaryThis PR implements AI Ghost Mode, a privacy-first feature that silently observes user browsing patterns and suggests automations. The implementation spans ~8,600 lines across 40 files including C++ backend services, SQLite storage, pattern detection algorithms, UI components, and comprehensive unit tests. Key Changes:
Critical Issue Found:
Minor Issues:
Privacy & Security:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Browser
participant ActionRecorder
participant SensitiveDetector
participant ActionStore
participant PatternDetector
participant SuggestionController
participant WorkflowGenerator
participant GhostExecutor
Note over User,Browser: Phase 1: Recording User Actions
User->>Browser: Performs actions (click, type, navigate)
Browser->>ActionRecorder: Capture action event
ActionRecorder->>SensitiveDetector: IsSensitiveField(field_info)
alt Sensitive field detected
SensitiveDetector-->>ActionRecorder: true (skip recording)
else Safe to record
SensitiveDetector-->>ActionRecorder: false (continue)
ActionRecorder->>ActionRecorder: NormalizeUrl, GenerateSelectors
ActionRecorder->>ActionStore: AddAction(recorded_action)
ActionStore->>ActionStore: Store to SQLite
end
Note over PatternDetector,ActionStore: Phase 2: Pattern Detection (periodic)
PatternDetector->>ActionStore: GetActionsInRange(last_7_days)
ActionStore-->>PatternDetector: List of RecordedActions
PatternDetector->>PatternDetector: GroupBySession
PatternDetector->>PatternDetector: ExtractSubsequences
PatternDetector->>PatternDetector: NormalizeSequence & HashSequence
PatternDetector->>PatternDetector: CalculateConfidence
PatternDetector->>PatternDetector: FilterByThreshold (≥3 occurrences, ≥0.8 confidence)
PatternDetector->>ActionStore: SavePattern(detected_pattern)
Note over User,SuggestionController: Phase 3: Suggestion to User
PatternDetector->>SuggestionController: OnPatternDetected(pattern)
SuggestionController->>Browser: ShowInfoBar("Automate this workflow?")
Browser->>User: Display suggestion
User->>Browser: Click "Accept"
Browser->>SuggestionController: OnSuggestionAccepted
Note over WorkflowGenerator,GhostExecutor: Phase 4: Workflow Generation & Execution
SuggestionController->>WorkflowGenerator: ConvertToWorkflow(pattern)
WorkflowGenerator->>WorkflowGenerator: Map actions to workflow graph JSON
WorkflowGenerator-->>SuggestionController: workflow_json
SuggestionController->>GhostExecutor: ExecuteWorkflow(workflow_json)
GhostExecutor->>Browser: Create background tab
GhostExecutor->>Browser: Execute automation steps
Browser->>User: Show completion notification
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6 files reviewed, 1 comment
packages/browseros/chromium_patches/chrome/browser/browseros/ghost_mode/ghost_mode_service.cc
Show resolved
Hide resolved
…host_mode/ghost_mode_service.cc Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
🔍 Code Validation ReportI performed a manual code review and structural validation on this PR. Here's what passed: ✅ Checks Performed
📊 Code Metrics
|
Fixed critical bug where ActionRecorder was created but immediately destroyed because it wasn't stored in recorders_ map. Now properly: - Calls StartRecording() on the new recorder - Stores recorder in recorders_ map with std::move()
…nd wildcard matching - action_recorder: Add scroll event throttling (500ms interval + 50px min delta) - action_recorder: Implement multiple selector strategies for robustness (data-testid > id > aria-label > class-based fallbacks) - ghost_mode_prefs: Add wildcard matching for domain exclusions (*.example.com matches sub.example.com and example.com) Resolves TODOs in action_recorder.cc and ghost_mode_prefs.cc
|
Hey, we cannot check in code without testing it using build. The structural validation is not enough. |
|
Give me like 48 hours would be tested thoroughly and provided report then we can think of merging |
🔮 AI Ghost Mode
Closes #336
Overview
AI Ghost Mode is a revolutionary privacy-first feature that silently observes user browsing patterns and learns to suggest automations. Think of it as having an invisible AI assistant that understands your workflows without you ever teaching it.
✨ Key Features
🏗️ Implementation
Core Components (C++)
ghost_mode_types.h/ccghost_mode_prefs.h/ccaction_recorder.h/ccaction_store.h/ccpattern_detector.h/ccpattern_matcher.h/ccsensitive_detector.h/ccsuggestion_controller.h/ccworkflow_generator.h/ccghost_executor.h/ccService Layer
ghost_mode_service.h/ccghost_mode_service_factory.h/ccUI Components
ghost_mode_suggestion_infobar_delegate.h/ccghost_mode_page.html/tsworkflow_editor.html/tsghost_mode_handler.h/cc🧪 Testing
Includes comprehensive unit tests:
sensitive_detector_unittest.cc- Tests for privacy filteringpattern_detector_unittest.cc- Tests for pattern detectionpattern_matcher_unittest.cc- Tests for fuzzy matchingworkflow_generator_unittest.cc- Tests for workflow generationaction_recorder_unittest.cc- Tests for action recording📁 Files Changed
47 new files added to
packages/browseros/chromium_patches/chrome/browser/browseros/ghost_mode/This PR introduces ~8,600 lines of new code implementing a complete AI Ghost Mode feature for BrowserOS.