Skip to content

[HIGH FRONTEND] Fix browser mock functions returning fake 'available' states #500

@joelfuller2016

Description

@joelfuller2016

Summary

Severity: 🟠 HIGH
Component: Frontend Browser Preview Mocks
Category: Misleading UI State

Problem

Browser mock functions return hardcoded true for tool availability checks, making the UI claim features are available when they're not in browser preview mode.

Affected Files & Fixes

1. Workspace Mock - Fake Worktree Data

File: apps/frontend/src/renderer/lib/mocks/workspace-mock.ts:6-18

Current (WRONG):

getWorktreeStatus: async () => ({
  success: true,
  data: {
    exists: true,  // ❌ HARDCODED
    worktreePath: '/Users/demo/projects/sample-project/.worktrees/003-fix-bug', // ❌ FAKE
    branch: 'auto-claude/fix-pagination-bug',
    commitCount: 3,
    filesChanged: 5
  }
}),

Should be:

getWorktreeStatus: async () => ({
  success: true,
  data: {
    exists: false,  // ✓ Honest - no worktree in browser
    worktreePath: null,
    branch: null,
    commitCount: 0,
    filesChanged: 0
  }
}),

2. Infrastructure Mock - Ollama False Positive

File: apps/frontend/src/renderer/lib/mocks/infrastructure-mock.ts:68-85

Current (WRONG):

checkOllamaInstalled: async () => ({
  success: true,
  data: {
    installed: true,  // ❌ LYING TO UI
    path: '/usr/local/bin/ollama',
    version: '0.1.0',
  }
}),

listOllamaModels: async () => ({
  success: true,
  data: {
    models: [
      { name: 'llama2', size_gb: 3.73 },  // ❌ DEMO DATA
    ],
  }
}),

Should be:

checkOllamaInstalled: async () => ({
  success: true,
  data: {
    installed: false,  // ✓ Honest - not available in browser
    path: null,
    version: null,
  }
}),

listOllamaModels: async () => ({
  success: true,
  data: {
    models: [],  // ✓ Empty list - no models in browser
    count: 0
  }
}),

3. Global Window Pollution

File: apps/frontend/src/renderer/lib/mocks/infrastructure-mock.ts:176-189

Current (WRONG):

onDownloadProgress: (callback) => {
  (window as any).__downloadProgressCallback = callback;  // ❌ GLOBAL POLLUTION
  return () => {
    delete (window as any).__downloadProgressCallback;
  };
},

Should be:

// Use EventTarget or callback queue
const progressCallbacks = new Set<Function>();

onDownloadProgress: (callback) => {
  progressCallbacks.add(callback);
  return () => {
    progressCallbacks.delete(callback);
  };
},

Impact

  • ❌ UI shows tools as installed when they're not (confusing)
  • ❌ Users might try to use features that don't work in browser preview
  • ❌ Global object pollution can cause memory leaks or state bugs
  • ❌ Developers testing browser preview get misleading feedback

Acceptance Criteria

  • All installed: true changed to installed: false
  • All exists: true changed to exists: false for unavailable features
  • All fake paths/data replaced with null/empty
  • Global window pollution removed
  • UI correctly shows "Not available in browser preview" states
  • Browser preview documentation updated

Testing

// Test browser preview mode
const status = await window.electronAPI.workspace.getWorktreeStatus();
expect(status.data.exists).toBe(false);  // Should be false, not true

const ollama = await window.electronAPI.infrastructure.checkOllamaInstalled();
expect(ollama.data.installed).toBe(false);  // Should be false, not true

Priority

HIGH - Misleading UI state affects developer experience

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions