Skip to content

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

feat(mcp): add MCP Apps UI support with interactive search dashboard

Louis Beaumontcf33e00a0cea
diff --git a/content/docs-mintlify-mig-tmp/docs.json b/content/docs-mintlify-mig-tmp/docs.json
index 6baeb0c22..58307b25e 100644
--- a/content/docs-mintlify-mig-tmp/docs.json
+++ b/content/docs-mintlify-mig-tmp/docs.json
@@ -27,7 +27,7 @@
},
{
"group": "guides",
- "pages": ["plugins", "mcp-server"]
+ "pages": ["plugins", "mcp-server", "mcp-apps"]
},
{
"group": "integrations",
diff --git a/content/docs-mintlify-mig-tmp/mcp-apps.mdx b/content/docs-mintlify-mig-tmp/mcp-apps.mdx
new file mode 100644
index 000000000..4b7e6c8fa
--- /dev/null
+++ b/content/docs-mintlify-mig-tmp/mcp-apps.mdx
@@ -0,0 +1,302 @@
+---
+title: "MCP apps - create interactive UIs for screenpipe"
+sidebarTitle: "mcp apps"
+description: "Build interactive UI components that render in Claude, ChatGPT, VS Code, and other AI assistants using the MCP Apps protocol."
+icon: "window"
+---
+
+MCP Apps let you create interactive UIs that render directly inside AI chat interfaces. Instead of plain text responses, your tools can return dashboards, forms, visualizations, and more.
+
+## how it works
+
+```
+┌─────────────────────────────────────────────────────────────┐
+│ 1. Tool declares a UI resource │
+│ { _meta: { ui: { resourceUri: "ui://search" } } } │
+│ │
+│ 2. Host fetches the HTML from the MCP server │
+│ GET ui://search → Returns HTML/JS bundle │
+│ │
+│ 3. Host renders in sandboxed iframe │
+│ <iframe sandbox="allow-scripts" srcdoc={html} /> │
+│ │
+│ 4. Bidirectional communication via postMessage │
+│ Host ◄──── JSON-RPC ────► App │
+└─────────────────────────────────────────────────────────────┘
+```
+
+your UI works in:
+- Claude Desktop & Web
+- ChatGPT
+- VS Code
+- Goose
+- screenpipe's built-in chat
+
+## creating an MCP app
+
+### 1. create your HTML UI
+
+create a single HTML file with embedded CSS and JavaScript:
+
+```html
+<!-- screenpipe-integrations/screenpipe-mcp/ui/my-app.html -->
+<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ * { box-sizing: border-box; margin: 0; padding: 0; }
+ body {
+ font-family: system-ui, sans-serif;
+ padding: 16px;
+ background: #0a0a0a;
+ color: #fafafa;
+ }
+ .container { max-width: 600px; margin: 0 auto; }
+ h1 { font-size: 18px; margin-bottom: 16px; }
+ .card {
+ background: #1a1a1a;
+ border: 1px solid #333;
+ border-radius: 8px;
+ padding: 16px;
+ margin-bottom: 12px;
+ }
+ button {
+ background: #fff;
+ color: #000;
+ border: none;
+ padding: 8px 16px;
+ border-radius: 6px;
+ cursor: pointer;
+ font-weight: 500;
+ }
+ button:hover { background: #e0e0e0; }
+ input {
+ width: 100%;
+ padding: 10px;
+ border: 1px solid #333;
+ border-radius: 6px;
+ background: #1a1a1a;
+ color: #fff;
+ margin-bottom: 12px;
+ }
+ </style>
+</head>
+<body>
+ <div class="container">
+ <h1>my screenpipe app</h1>
+ <input type="text" id="query" placeholder="search your recordings..." />
+ <button onclick="search()">search</button>
+ <div id="results"></div>
+ </div>
+
+ <script>
+ // MCP App communication
+ const app = {
+ // call an MCP tool from the UI
+ callTool: (name, args) => {
+ window.parent.postMessage({
+ jsonrpc: '2.0',
+ method: 'tools/call',
+ params: { name, arguments: args }
+ }, '*');
+ },
+
+ // send a message to the chat
+ sendMessage: (text) => {
+ window.parent.postMessage({
+ jsonrpc: '2.0',
+ method: 'message/send',
+ params: { content: text }
+ }, '*');
+ }
+ };
+
+ // listen for tool results from host
+ window.addEventListener('message', (event) => {
+ if (event.data?.method === 'tool/result') {
+ displayResults(event.data.params.result);
+ }
+ });
+
+ function search() {
+ const query = document.getElementById('query').value;
+ app.callTool('search-content', { q: query, limit: 10 });
+ }
+
+ function displayResults(results) {
+ const container = document.getElementById('results');
+ container.innerHTML = results.map(r => `
+ <div class="card">
+ <strong>${r.type}</strong> - ${r.app_name || 'unknown'}
+ <p>${r.text?.substring(0, 200) || r.transcription?.substring(0, 200) || ''}</p>
+ </div>
+ `).join('');
+ }
+ </script>
+</body>
+</html>
+```
+
+### 2. register the UI resource
+
+in your MCP server, add the UI as a resource:
+
+```typescript
+// add to RESOURCES array
+{
+ uri: "ui://my-app",
+ name: "My App",
+ description: "Interactive search interface",
+ mimeType: "text/html",
+}
+```
+
+### 3. serve the HTML
+
+in the `ReadResourceRequestSchema` handler:
+
+```typescript
+case "ui://my-app":
+ // read from file or embed directly
+ const html = fs.readFileSync(
+ path.join(__dirname, 'ui/my-app.html'),
+ 'utf-8'
+ );
+ return {
+ contents: [{
+ uri,
+ mimeType: "text/html",
+ text: html,
+ }],
+ };
+```
+
+### 4. declare UI in tool response
+
+when a tool returns results, include the UI reference:
+
+```typescript
+return {
+ content: [{ type: "text", text: "Search results" }],
+ _meta: {
+ ui: { resourceUri: "ui://my-app" }
+ }
+};
+```
+
+## contributing an MCP app
+
+want to add your UI to screenpipe? here's how:
+
+### file structure
+
+```
+screenpipe-integrations/screenpipe-mcp/
+├── src/
+│ └── index.ts # MCP server
+├── ui/
+│ ├── search.html # search dashboard UI
+│ ├── timeline.html # timeline viewer UI
+│ └── your-app.html # your new UI
+└── package.json
+```
+
+### submission checklist
+
+1. **create your HTML file** in the `ui/` directory
+2. **keep it self-contained** - all CSS/JS should be inline
+3. **use dark theme** - match screenpipe's aesthetic
+4. **test locally** with MCP Inspector
+5. **submit a PR** with:
+ - your HTML file
+ - updates to `index.ts` to register and serve it
+ - a screenshot in the PR description
+
+### design guidelines
+
+| aspect | guideline |
+|--------|-----------|
+| background | `#0a0a0a` (dark) |
+| cards | `#1a1a1a` with `#333` border |
+| text | `#fafafa` (light) |
+| accent | `#fff` buttons, `#666` secondary |
+| font | `system-ui, sans-serif` |
+| radius | `6-8px` for cards and buttons |
+
+### example UIs to build
+
+- **timeline viewer** - scroll through your day visually
+- **meeting notes** - display transcriptions with speakers
+- **activity chart** - visualize app usage over time
+- **search dashboard** - rich search with filters
+- **memory cards** - google photos-style flashbacks
+
+## testing your app
+
+use MCP Inspector to test:
+
+```bash
+cd screenpipe-integrations/screenpipe-mcp
+npm run build
+npx @modelcontextprotocol/inspector node dist/index.js
+```
+
+1. open the inspector at http://localhost:5173
+2. navigate to **resources**
+3. click your `ui://` resource
+4. verify the HTML renders correctly
+
+## api reference
+
+### host → app messages
+
+```typescript
+// tool result delivered to app
+{
+ jsonrpc: "2.0",
+ method: "tool/result",
+ params: {
+ toolName: "search-content",
+ result: { /* tool output */ }
+ }
+}
+```
+
+### app → host messages
+
+```typescript
+// call an MCP tool
+{
+ jsonrpc: "2.0",
+ method: "tools/call",
+ params: { name: "search-content", arguments: { q: "meeting" } }
+}
+
+// send message to chat
+{
+ jsonrpc: "2.0",
+ method: "message/send",
+ params: { content: "Found 5 results" }
+}
+
+// open external link
+{
+ jsonrpc: "2.0",
+ method: "link/open",
+ params: { url: "https://example.com" }
+}
+```
+
+## security
+
+MCP Apps run in sandboxed iframes with:
+- no access to parent DOM
+- no cookies or localStorage from host
+- restricted permissions (`allow-scripts` only)
+- all communication via postMessage
+
+## resources
+
+- [MCP Apps specification](https://blog.modelcontextprotocol.io/posts/2026-01-26-mcp-apps/)
+- [ext-apps SDK](https://github.com/modelcontextprotocol/ext-apps)
+- [screenpipe MCP source](https://github.com/mediar-ai/screenpipe/tree/main/screenpipe-integrations/screenpipe-mcp)
diff --git a/screenpipe-integrations/screenpipe-mcp/package.json b/screenpipe-integrations/screenpipe-mcp/package.json
index 7f0b0744a..9fb8be9b4 100644
--- a/screenpipe-integrations/screenpipe-mcp/package.json
+++ b/screenpipe-integrations/screenpipe-mcp/package.json
@@ -1,6 +1,6 @@
{
"name": "screenpipe-mcp",
- "version": "0.4.1",
+ "version": "0.5.0",
"description": "MCP server for screenpipe - search your screen recordings, audio transcriptions, and control your computer",
"main": "dist/index.js",
"bin": {
diff --git a/screenpipe-integrations/screenpipe-mcp/src/index.ts b/screenpipe-integrations/screenpipe-mcp/src/index.ts
index 0cace3d54..cdd67b7cf 100644
--- a/screenpipe-integrations/screenpipe-mcp/src/index.ts
+++ b/screenpipe-integrations/screenpipe-mcp/src/index.ts
@@ -51,7 +51,7 @@ const SCREENPIPE_API = `http://localhost:${port}`;
const server = new Server(
{
name: "screenpipe",
- version: "0.4.0",
+ version: "0.5.0",
},
{
capabilities: {
@@ -466,6 +466,12 @@ const RESOURCES = [
description: "How to use screenpipe search effectively",
mimeType: "text/markdown",
},
+ {
+ uri: "ui://search",
+ name: "Search Dashboard",
+ description: "Interactive search UI for exploring screen recordings and audio transcriptions",
+ mimeType: "text/html",
+ },
];
// List resources handler
@@ -543,6 +549,56 @@ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
],
};
+ case "ui://search": {
+ // MCP App UI - Interactive search dashboard
+ const uiHtmlPath = path.join(__dirname, "..", "ui", "search.html");
+ let htmlContent: string;
+ try {
+ htmlContent = fs.readFileSync(uiHtmlPath, "utf-8");
+ } catch {
+ // Fallback: serve embedded minimal UI if file not found
+ htmlContent = `<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ body { font-family: system-ui; background: #0a0a0a; color: #fff; padding: 20px; }
+ input { width: 100%; padding: 10px; margin-bottom: 10px; background: #1a1a1a; border: 1px solid #333; color: #fff; border-radius: 6px; }
+ button { padding: 10px 20px; background: #fff; color: #000; border: none; border-radius: 6px; cursor: pointer; }
+ #results { margin-top: 20px; }
+ .result { background: #1a1a1a; padding: 12px; margin: 8px 0; border-radius: 8px; border: 1px solid #333; }
+ </style>
+</head>
+<body>
+ <h2>screenpipe search</h2>
+ <input id="q" placeholder="search..." onkeydown="if(event.key==='Enter')search()"/>
+ <button onclick="search()">search</button>
+ <div id="results"></div>
+ <script>
+ function search() {
+ window.parent.postMessage({jsonrpc:'2.0',method:'tools/call',params:{name:'search-content',arguments:{q:document.getElementById('q').value,limit:20}}},'*');
+ }
+ window.addEventListener('message',e=>{
+ if(e.data?.result||e.data?.method==='tool/result'){
+ const r=e.data.result||e.data.params?.result;
+ const d=r?.data||r||[];
+ document.getElementById('results').innerHTML=d.map(x=>'<div class="result"><b>'+((x.type||'')+'</b> '+(x.content?.app_name||'')+': '+(x.content?.text||x.content?.transcription||'').substring(0,200))+'</div>').join('');
+ }
+ });
+ </script>
+</body>
+</html>`;
+ }
+ return {
+ contents: [
+ {
+ uri,
+ mimeType: "text/html",
+ text: htmlContent,
+ },
+ ],
+ };
+ }
+
default:
throw new Error(`Unknown resource: ${uri}`);
}
diff --git a/screenpipe-integrations/screenpipe-mcp/ui/search.html b/screenpipe-integrations/screenpipe-mcp/ui/search.html
new file mode 100644
index 000000000..b4d863509
--- /dev/null
+++ b/screenpipe-integrations/screenpipe-mcp/ui/search.html
@@ -0,0 +1,559 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>screenpipe search</title>
+ <style>
+ * {
+ box-sizing: border-box;
+ margin: 0;
+ padding: 0;
+ }
+
+ body {
+ font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
+ background: #0a0a0a;
+ color: #fafafa;
+ padding: 16px;
+ min-height: 100vh;
+ }
+
+ .container {
+ max-width: 700px;
+ margin: 0 auto;
+ }
+
+ .header {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ margin-bottom: 20px;
+ }
+
+ .header h1 {
+ font-size: 18px;
+ font-weight: 600;
+ }
+
+ .logo {
+ width: 24px;
+ height: 24px;
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+ border-radius: 6px;
+ }
+
+ .search-box {
+ display: flex;
+ gap: 8px;
+ margin-bottom: 16px;
+ }
+
+ .search-input {
+ flex: 1;
+ padding: 12px 16px;
+ border: 1px solid #333;
+ border-radius: 8px;
+ background: #1a1a1a;
+ color: #fff;
+ font-size: 14px;
+ outline: none;
+ transition: border-color 0.2s;
+ }
+
+ .search-input:focus {
+ border-color: #666;
+ }
+
+ .search-input::placeholder {
+ color: #666;
+ }
+
+ .btn {
+ padding: 12px 20px;
+ border: none;
+ border-radius: 8px;
+ font-size: 14px;
+ font-weight: 500;
+ cursor: pointer;
+ transition: all 0.2s;
+ }
+
+ .btn-primary {
+ background: #fff;
+ color: #000;
+ }
+
+ .btn-primary:hover {
+ background: #e0e0e0;
+ }
+
+ .btn-secondary {
+ background: #1a1a1a;
+ color: #fff;
+ border: 1px solid #333;
+ }
+
+ .btn-secondary:hover {
+ background: #252525;
+ }
+
+ .filters {
+ display: flex;
+ gap: 8px;
+ margin-bottom: 20px;
+ flex-wrap: wrap;
+ }
+
+ .filter-btn {
+ padding: 6px 14px;
+ border: 1px solid #333;
+ border-radius: 20px;
+ background: transparent;
+ color: #888;
+ font-size: 13px;
+ cursor: pointer;
+ transition: all 0.2s;
+ }
+
+ .filter-btn:hover {
+ border-color: #555;
+ color: #fff;
+ }
+
+ .filter-btn.active {
+ background: #fff;
+ color: #000;
+ border-color: #fff;
+ }
+
+ .stats {
+ display: flex;
+ gap: 20px;
+ padding: 12px 16px;
+ background: #1a1a1a;
+ border-radius: 8px;
+ margin-bottom: 20px;
+ font-size: 13px;
+ }
+
+ .stat {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ }
+
+ .stat-value {
+ font-weight: 600;
+ color: #fff;
+ }
+
+ .stat-label {
+ color: #666;
+ }
+
+ .results {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ }
+
+ .result-card {
+ background: #1a1a1a;
+ border: 1px solid #252525;
+ border-radius: 10px;
+ padding: 16px;
+ transition: border-color 0.2s;
+ }
+
+ .result-card:hover {
+ border-color: #333;
+ }
+
+ .result-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: flex-start;
+ margin-bottom: 10px;
+ }
+
+ .result-type {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ padding: 4px 10px;
+ border-radius: 4px;
+ font-size: 11px;
+ font-weight: 600;
+ text-transform: uppercase;
+ letter-spacing: 0.5px;
+ }
+
+ .type-ocr {
+ background: rgba(59, 130, 246, 0.2);
+ color: #60a5fa;
+ }
+
+ .type-audio {
+ background: rgba(34, 197, 94, 0.2);
+ color: #4ade80;
+ }
+
+ .type-ui {
+ background: rgba(168, 85, 247, 0.2);
+ color: #c084fc;
+ }
+
+ .result-time {
+ font-size: 12px;
+ color: #666;
+ }
+
+ .result-app {
+ font-size: 13px;
+ color: #888;
+ margin-bottom: 8px;
+ }
+
+ .result-text {
+ font-size: 14px;
+ line-height: 1.5;
+ color: #ccc;
+ }
+
+ .result-actions {
+ display: flex;
+ gap: 8px;
+ margin-top: 12px;
+ padding-top: 12px;
+ border-top: 1px solid #252525;
+ }
+
+ .action-btn {
+ padding: 6px 12px;
+ border: 1px solid #333;
+ border-radius: 6px;
+ background: transparent;
+ color: #888;
+ font-size: 12px;
+ cursor: pointer;
+ transition: all 0.2s;
+ }
+
+ .action-btn:hover {
+ border-color: #555;
+ color: #fff;
+ }
+
+ .empty-state {
+ text-align: center;
+ padding: 60px 20px;
+ color: #666;
+ }
+
+ .empty-state h3 {
+ font-size: 16px;
+ margin-bottom: 8px;
+ color: #888;
+ }
+
+ .loading {
+ display: flex;
+ justify-content: center;
+ padding: 40px;
+ }
+
+ .spinner {
+ width: 24px;
+ height: 24px;
+ border: 2px solid #333;
+ border-top-color: #fff;
+ border-radius: 50%;
+ animation: spin 0.8s linear infinite;
+ }
+
+ @keyframes spin {
+ to { transform: rotate(360deg); }
+ }
+
+ .hidden {
+ display: none;
+ }
+ </style>
+</head>
+<body>
+ <div class="container">
+ <div class="header">
+ <div class="logo"></div>
+ <h1>screenpipe search</h1>
+ </div>
+
+ <div class="search-box">
+ <input
+ type="text"
+ id="query"
+ class="search-input"
+ placeholder="search your screen history, audio, and more..."
+ onkeydown="if(event.key==='Enter')search()"
+ />
+ <button class="btn btn-primary" onclick="search()">search</button>
+ </div>
+
+ <div class="filters">
+ <button class="filter-btn active" data-type="all" onclick="setFilter('all')">all</button>
+ <button class="filter-btn" data-type="ocr" onclick="setFilter('ocr')">screen</button>
+ <button class="filter-btn" data-type="audio" onclick="setFilter('audio')">audio</button>
+ <button class="filter-btn" data-type="ui" onclick="setFilter('ui')">ui elements</button>
+ </div>
+
+ <div id="stats" class="stats hidden">
+ <div class="stat">
+ <span class="stat-value" id="result-count">0</span>
+ <span class="stat-label">results</span>
+ </div>
+ <div class="stat">
+ <span class="stat-value" id="time-range">-</span>
+ <span class="stat-label">time range</span>
+ </div>
+ </div>
+
+ <div id="loading" class="loading hidden">
+ <div class="spinner"></div>
+ </div>
+
+ <div id="results" class="results">
+ <div class="empty-state">
+ <h3>search your digital history</h3>
+ <p>type a query above to search through your screen recordings and audio transcriptions</p>
+ </div>
+ </div>
+ </div>
+
+ <script>
+ let currentFilter = 'all';
+ let pendingRequestId = null;
+
+ // MCP App communication layer
+ const mcp = {
+ requestId: 0,
+
+ callTool: function(name, args) {
+ this.requestId++;
+ pendingRequestId = this.requestId;
+ window.parent.postMessage({
+ jsonrpc: '2.0',
+ id: this.requestId,
+ method: 'tools/call',
+ params: { name, arguments: args }
+ }, '*');
+ return this.requestId;
+ },
+
+ sendMessage: function(text) {
+ window.parent.postMessage({
+ jsonrpc: '2.0',
+ method: 'message/send',
+ params: { content: text }
+ }, '*');
+ }
+ };
+
+ // listen for messages from host
+ window.addEventListener('message', (event) => {
+ const data = event.data;
+
+ // handle tool results
+ if (data?.result || data?.method === 'tool/result') {
+ hideLoading();
+ const result = data.result || data.params?.result;
+ if (result) {
+ displayResults(result);
+ }
+ }
+
+ // handle errors
+ if (data?.error) {
+ hideLoading();
+ showError(data.error.message || 'search failed');
+ }
+ });
+
+ function setFilter(type) {
+ currentFilter = type;
+ document.querySelectorAll('.filter-btn').forEach(btn => {
+ btn.classList.toggle('active', btn.dataset.type === type);
+ });
+ // re-run search with new filter if there's a query
+ const query = document.getElementById('query').value;
+ if (query) {
+ search();
+ }
+ }
+
+ function search() {
+ const query = document.getElementById('query').value;
+ showLoading();
+
+ const args = {
+ q: query || undefined,
+ content_type: currentFilter,
+ limit: 20
+ };
+
+ mcp.callTool('search-content', args);
+ }
+
+ function showLoading() {
+ document.getElementById('loading').classList.remove('hidden');
+ document.getElementById('results').innerHTML = '';
+ document.getElementById('stats').classList.add('hidden');
+ }
+
+ function hideLoading() {
+ document.getElementById('loading').classList.add('hidden');
+ }
+
+ function showError(message) {
+ document.getElementById('results').innerHTML = `
+ <div class="empty-state">
+ <h3>error</h3>
+ <p>${escapeHtml(message)}</p>
+ </div>
+ `;
+ }
+
+ function displayResults(data) {
+ const results = data.data || data || [];
+ const container = document.getElementById('results');
+ const statsEl = document.getElementById('stats');
+
+ if (!Array.isArray(results) || results.length === 0) {
+ container.innerHTML = `
+ <div class="empty-state">
+ <h3>no results found</h3>
+ <p>try a different search term or adjust your filters</p>
+ </div>
+ `;
+ statsEl.classList.add('hidden');
+ return;
+ }
+
+ // update stats
+ document.getElementById('result-count').textContent = results.length;
+
+ // calculate time range
+ const timestamps = results
+ .map(r => r.content?.timestamp)
+ .filter(Boolean)
+ .map(t => new Date(t).getTime())
+ .sort((a, b) => a - b);
+
+ if (timestamps.length > 1) {
+ const start = new Date(timestamps[0]);
+ const end = new Date(timestamps[timestamps.length - 1]);
+ document.getElementById('time-range').textContent = formatTimeRange(start, end);
+ } else {
+ document.getElementById('time-range').textContent = 'now';
+ }
+
+ statsEl.classList.remove('hidden');
+
+ // render results
+ container.innerHTML = results.map(result => {
+ const content = result.content || {};
+ const type = result.type?.toLowerCase() || 'unknown';
+ const text = content.text || content.transcription || '';
+ const app = content.app_name || content.device_name || 'unknown';
+ const window = content.window_name || '';
+ const time = content.timestamp ? formatTime(new Date(content.timestamp)) : '';
+
+ return `
+ <div class="result-card">
+ <div class="result-header">
+ <span class="result-type type-${type}">${getTypeIcon(type)} ${type}</span>
+ <span class="result-time">${time}</span>
+ </div>
+ <div class="result-app">${escapeHtml(app)}${window ? ' - ' + escapeHtml(window) : ''}</div>
+ <div class="result-text">${escapeHtml(truncate(text, 300))}</div>
+ <div class="result-actions">
+ <button class="action-btn" onclick="copyText('${escapeJs(text)}')">copy</button>
+ <button class="action-btn" onclick="askAbout('${escapeJs(text.substring(0, 100))}')">ask AI</button>
+ </div>
+ </div>
+ `;
+ }).join('');
+ }
+
+ function getTypeIcon(type) {
+ switch(type) {
+ case 'ocr': return '';
+ case 'audio': return '';
+ case 'ui': return '';
+ default: return '';
+ }
+ }
+
+ function formatTime(date) {
+ const now = new Date();
+ const diff = now - date;
+
+ if (diff < 60000) return 'just now';
+ if (diff < 3600000) return Math.floor(diff / 60000) + 'm ago';
+ if (diff < 86400000) return Math.floor(diff / 3600000) + 'h ago';
+
+ return date.toLocaleDateString('en-US', {
+ month: 'short',
+ day: 'numeric',
+ hour: 'numeric',
+ minute: '2-digit'
+ });
+ }
+
+ function formatTimeRange(start, end) {
+ const diff = end - start;
+ if (diff < 3600000) return Math.floor(diff / 60000) + ' min';
+ if (diff < 86400000) return Math.floor(diff / 3600000) + ' hours';
+ return Math.floor(diff / 86400000) + ' days';
+ }
+
+ function truncate(str, len) {
+ if (!str) return '';
+ if (str.length <= len) return str;
+ return str.substring(0, len) + '...';
+ }
+
+ function escapeHtml(str) {
+ if (!str) return '';
+ return str
+ .replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;')
+ .replace(/'/g, '&#039;');
+ }
+
+ function escapeJs(str) {
+ if (!str) return '';
+ return str
+ .replace(/\\/g, '\\\\')
+ .replace(/'/g, "\\'")
+ .replace(/"/g, '\\"')
+ .replace(/\n/g, '\\n')
+ .replace(/\r/g, '\\r');
+ }
+
+ function copyText(text) {
+ navigator.clipboard.writeText(text).then(() => {
+ // could show a toast here
+ });
+ }
+
+ function askAbout(text) {
+ mcp.sendMessage(`Tell me more about: "${text}"`);
+ }
+
+ // auto-focus search input
+ document.getElementById('query').focus();
+ </script>
+</body>
+</html>