Skip to content
Merged
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
6 changes: 6 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ const rendererCrossFileGlobals = {
planPanel: 'readonly',
memoryViewer: 'readonly',
memoryPanel: 'readonly',
workFilesContent: 'readonly',
workFilesViewer: 'readonly',
workFilesPanel: 'readonly',
statsViewer: 'readonly',
statsViewerBody: 'readonly',
settingsViewer: 'readonly',
Expand Down Expand Up @@ -173,6 +176,9 @@ const rendererCrossFileGlobals = {
loadStats: 'readonly',
loadMemories: 'readonly',
renderMemories: 'readonly',
loadWorkFiles: 'readonly',
renderWorkFiles: 'readonly',
openWorkFile: 'readonly',
clearNotifications: 'readonly',
setSessionMcpActive: 'readonly',
destroySession: 'readonly',
Expand Down
125 changes: 125 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { app, BrowserWindow, dialog, ipcMain, Menu, screen, shell } = require('electron');
const { Worker } = require('worker_threads');

Check warning on line 2 in main.js

View workflow job for this annotation

GitHub Actions / test (22)

'Worker' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 2 in main.js

View workflow job for this annotation

GitHub Actions / test (20)

'Worker' is assigned a value but never used. Allowed unused vars must match /^_/u
const { execFile } = require('child_process');
const path = require('path');
const fs = require('fs');
Expand All @@ -16,7 +16,7 @@
}

// getFolderIndexMtimeMs moved to session-cache.js
const { startMcpServer, shutdownMcpServer, shutdownAll: shutdownAllMcp, resolvePendingDiff, rekeyMcpServer, cleanStaleLockFiles } = require('./mcp-bridge');

Check warning on line 19 in main.js

View workflow job for this annotation

GitHub Actions / test (22)

'cleanStaleLockFiles' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 19 in main.js

View workflow job for this annotation

GitHub Actions / test (20)

'cleanStaleLockFiles' is assigned a value but never used. Allowed unused vars must match /^_/u
const { fetchAndTransformUsage } = require('./claude-auth');
log.transports.file.level = app.isPackaged ? 'info' : 'debug';
log.transports.console.level = app.isPackaged ? 'info' : 'debug';
Expand All @@ -36,7 +36,7 @@
);

// Shell profiles → shell-profiles.js
const { discoverShellProfiles, getShellProfiles, resolveShell, isWindows, isWslShell, windowsToWslPath, shellArgs } = require('./shell-profiles');

Check warning on line 39 in main.js

View workflow job for this annotation

GitHub Actions / test (22)

'isWindows' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 39 in main.js

View workflow job for this annotation

GitHub Actions / test (22)

'discoverShellProfiles' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 39 in main.js

View workflow job for this annotation

GitHub Actions / test (20)

'isWindows' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 39 in main.js

View workflow job for this annotation

GitHub Actions / test (20)

'discoverShellProfiles' is assigned a value but never used. Allowed unused vars must match /^_/u
const { startScheduler } = require('./schedule-runner');
const { encodeProjectPath } = require('./encode-project-path');

Expand Down Expand Up @@ -73,7 +73,7 @@
getMeta, getAllMeta, toggleStar, setName, setArchived,
isCachePopulated, getAllCached, getCachedByFolder, getCachedByParent, getCachedFolder, getCachedSession, upsertCachedSessions,
deleteCachedSession, deleteCachedFolder,
getFolderMeta, getAllFolderMeta, setFolderMeta,

Check warning on line 76 in main.js

View workflow job for this annotation

GitHub Actions / test (22)

'getFolderMeta' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 76 in main.js

View workflow job for this annotation

GitHub Actions / test (20)

'getFolderMeta' is assigned a value but never used. Allowed unused vars must match /^_/u
upsertSearchEntries, updateSearchTitle, deleteSearchSession, deleteSearchFolder, deleteSearchType,
searchByType, isSearchIndexPopulated, searchFtsRecreated,
getSetting, setSetting, deleteSetting,
Expand Down Expand Up @@ -289,8 +289,8 @@
setFolderMeta, getAllFolderMeta, getAllMeta, getAllCached, getSetting, getMeta, setName,
},
});
const { readSessionFile, readFolderFromFilesystem, refreshFolder, populateCacheFromFilesystem,

Check warning on line 292 in main.js

View workflow job for this annotation

GitHub Actions / test (22)

'populateCacheFromFilesystem' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 292 in main.js

View workflow job for this annotation

GitHub Actions / test (22)

'readFolderFromFilesystem' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 292 in main.js

View workflow job for this annotation

GitHub Actions / test (22)

'readSessionFile' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 292 in main.js

View workflow job for this annotation

GitHub Actions / test (20)

'populateCacheFromFilesystem' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 292 in main.js

View workflow job for this annotation

GitHub Actions / test (20)

'readFolderFromFilesystem' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 292 in main.js

View workflow job for this annotation

GitHub Actions / test (20)

'readSessionFile' is assigned a value but never used. Allowed unused vars must match /^_/u
buildProjectsFromCache, notifyRendererProjectsChanged, sendStatus, populateCacheViaWorker } = sessionCache;

Check warning on line 293 in main.js

View workflow job for this annotation

GitHub Actions / test (22)

'sendStatus' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 293 in main.js

View workflow job for this annotation

GitHub Actions / test (20)

'sendStatus' is assigned a value but never used. Allowed unused vars must match /^_/u
const { resolveJsonlPath } = require('./read-session-file');


Expand Down Expand Up @@ -891,6 +891,131 @@
}
});

// --- IPC: get-work-files ---
// Walks <projectPath>/.work-files/ recursively for all known projects.
// Returns { projects: WorkFilesProject[] } — empty projects are skipped.
// Caps at WORK_FILES_CAP files per project (most recent by mtime) to guard
// against huge .work-files trees (e.g. tagpay has ~39k files).
const WORK_FILES_CAP = 200;

function walkWorkFiles(dir, baseDir, results) {
let entries;
try {
entries = fs.readdirSync(dir, { withFileTypes: true });
} catch {
return;
}
for (const e of entries) {
const fullPath = path.join(dir, e.name);
if (e.isDirectory()) {
walkWorkFiles(fullPath, baseDir, results);
} else if (e.isFile()) {
try {
const stat = fs.statSync(fullPath);
const relativePath = path.relative(baseDir, fullPath);
results.push({
filename: e.name,
filePath: fullPath,
relativePath,
modified: stat.mtime.toISOString(),
size: stat.size,
});
} catch {}
}
}
}

ipcMain.handle('get-work-files', () => {
const global = getSetting('global') || {};
const hiddenProjects = new Set(global.hiddenProjects || []);
const projects = [];

try {
if (fs.existsSync(PROJECTS_DIR)) {
const folders = fs.readdirSync(PROJECTS_DIR, { withFileTypes: true })
.filter(d => d.isDirectory() && d.name !== '.git')
.map(d => d.name);

for (const folder of folders) {
const folderPath = path.join(PROJECTS_DIR, folder);
const projectPath = deriveProjectPath(folderPath, folder);
if (!projectPath) continue;
if (hiddenProjects.has(projectPath)) continue;

const workFilesDir = path.join(projectPath, '.work-files');
if (!fs.existsSync(workFilesDir)) continue;

const shortName = projectPath.split('/').filter(Boolean).slice(-2).join('/');

const allFiles = [];
walkWorkFiles(workFilesDir, workFilesDir, allFiles);

// Sort by modified desc
allFiles.sort((a, b) => new Date(b.modified) - new Date(a.modified));

const totalCount = allFiles.length;
const files = allFiles.slice(0, WORK_FILES_CAP);

if (files.length > 0) {
projects.push({ projectPath, shortName, files, totalCount });
}
}
}
} catch (err) {
console.error('Error scanning work-files:', err);
}

// Sort projects by most recent file modified date
projects.sort((a, b) => {
const aMax = a.files.length > 0 ? new Date(a.files[0].modified).getTime() : 0;
const bMax = b.files.length > 0 ? new Date(b.files[0].modified).getTime() : 0;
return bMax - aMax;
});

// Index for FTS — text files ≤ 64KB, skip .jsonl
try {
deleteSearchType('work-file');
const TEXT_MAX = 64 * 1024;
const entries = projects.flatMap(proj =>
proj.files.map(f => {
let body = '';
if (!f.relativePath.endsWith('.jsonl') && f.size <= TEXT_MAX) {
try { body = fs.readFileSync(f.filePath, 'utf8'); } catch {}
}
return {
id: f.filePath, type: 'work-file', folder: null,
title: proj.shortName + ' ' + f.relativePath,
body,
};
})
);
upsertSearchEntries(entries);
} catch {}

return { projects };
});

// --- IPC: read-work-file ---
ipcMain.handle('read-work-file', (_event, filePath) => {
try {
const resolved = path.resolve(filePath);
// Security: path must contain /.work-files/ segment
if (!resolved.includes('/.work-files/') && !resolved.includes('\\.work-files\\')) {
return '[access denied]';
}
if (!fs.existsSync(resolved)) return '';
const stat = fs.statSync(resolved);
if (stat.size > 2 * 1024 * 1024) return '[file too large to display]';
// Detect binary: try reading as utf8; if it fails or contains null bytes, treat as binary
const buf = fs.readFileSync(resolved);
if (buf.includes(0)) return '[binary file]';
return buf.toString('utf8');
} catch (err) {
console.error('Error reading work file:', err);
return '';
}
});

// --- IPC: search ---
ipcMain.handle('search', (_event, type, query, titleOnly) => {
return searchByType(type, query, 50, !!titleOnly);
Expand Down Expand Up @@ -1148,7 +1273,7 @@
// WSL profiles only work for plain terminals — Claude CLI sessions need the
// Windows shell because session data lives on the Windows filesystem.
const requestedProfile = resolveShell(effectiveProfileId);
const useWslProfile = isWslShell(requestedProfile.path) && isPlainTerminal;

Check warning on line 1276 in main.js

View workflow job for this annotation

GitHub Actions / test (22)

'useWslProfile' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 1276 in main.js

View workflow job for this annotation

GitHub Actions / test (20)

'useWslProfile' is assigned a value but never used. Allowed unused vars must match /^_/u
const shellProfile = (isWslShell(requestedProfile.path) && !isPlainTerminal)
? resolveShell('auto')
: requestedProfile;
Expand Down
2 changes: 2 additions & 0 deletions preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ contextBridge.exposeInMainWorld('api', {
getMemories: () => ipcRenderer.invoke('get-memories'),
readMemory: (filePath) => ipcRenderer.invoke('read-memory', filePath),
saveMemory: (filePath, content) => ipcRenderer.invoke('save-memory', filePath, content),
getWorkFiles: () => ipcRenderer.invoke('get-work-files'),
readWorkFile: (filePath) => ipcRenderer.invoke('read-work-file', filePath),
getProjects: (showArchived) => ipcRenderer.invoke('get-projects', showArchived),
rebuildCache: () => ipcRenderer.invoke('rebuild-cache'),
getActiveSessions: () => ipcRenderer.invoke('get-active-sessions'),
Expand Down
18 changes: 18 additions & 0 deletions public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ const memoryPanel = new ViewerPanel(memoryViewer, {
language: 'markdown', storageKey: 'markdownPreviewMode',
onSave: (filePath, content) => window.api.saveMemory(filePath, content),
});
const workFilesContent = document.getElementById('work-files-content');
const workFilesViewer = document.getElementById('work-files-viewer');
const workFilesPanel = new ViewerPanel(workFilesViewer, {
copyPath: true, copyContent: true,
language: 'auto', storageKey: 'workFilesPreviewMode',
});
const terminalArea = document.getElementById('terminal-area');
const settingsViewer = document.getElementById('settings-viewer');
const globalSettingsBtn = document.getElementById('global-settings-btn');
Expand Down Expand Up @@ -453,6 +459,8 @@ function clearSearch() {
renderPlans(cachedPlans);
} else if (activeTab === 'memory') {
renderMemories();
} else if (activeTab === 'work-files') {
renderWorkFiles();
}
}

Expand Down Expand Up @@ -492,6 +500,10 @@ async function runSearchQuery() {
const results = await window.api.search('memory', query, searchTitlesOnly);
const matchIds = new Set(results.map(r => r.id));
renderMemories(matchIds);
} else if (activeTab === 'work-files') {
const results = await window.api.search('work-file', query, searchTitlesOnly);
const matchIds = new Set(results.map(r => r.id));
renderWorkFiles(matchIds);
}
} catch {
if (activeTab === 'sessions') {
Expand Down Expand Up @@ -874,6 +886,7 @@ document.querySelectorAll('.sidebar-tab').forEach(tab => {
plansContent.style.display = 'none';
statsContent.style.display = 'none';
memoryContent.style.display = 'none';
workFilesContent.style.display = 'none';
sessionFilters.style.display = 'none';
searchBar.style.display = 'none';

Expand Down Expand Up @@ -922,6 +935,11 @@ document.querySelectorAll('.sidebar-tab').forEach(tab => {
searchInput.placeholder = 'Search agent files...';
memoryContent.style.display = '';
loadMemories();
} else if (tabName === 'work-files') {
searchBar.style.display = '';
searchInput.placeholder = 'Search work files...';
workFilesContent.style.display = '';
loadWorkFiles();
}
});
});
Expand Down
1 change: 1 addition & 0 deletions public/icons.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<button class="sidebar-tab active" data-tab="sessions" title="Sessions"><svg width="18" height="18" viewBox="0 0 1200 1200" fill="#d97757" stroke="none"><path d="M 233.959793 800.214905 L 468.644287 668.536987 L 472.590637 657.100647 L 468.644287 650.738403 L 457.208069 650.738403 L 417.986633 648.322144 L 283.892639 644.69812 L 167.597321 639.865845 L 54.926208 633.825623 L 26.577238 627.785339 L 3.3e-05 592.751709 L 2.73832 575.27533 L 26.577238 559.248352 L 60.724873 562.228149 L 136.187973 567.382629 L 249.422867 575.194763 L 331.570496 580.026978 L 453.261841 592.671082 L 472.590637 592.671082 L 475.328857 584.859009 L 468.724915 580.026978 L 463.570557 575.194763 L 346.389313 495.785217 L 219.543671 411.865906 L 153.100723 363.543762 L 117.181267 339.060425 L 99.060455 316.107361 L 91.248367 266.01355 L 123.865784 230.093994 L 167.677887 233.073853 L 178.872513 236.053772 L 223.248367 270.201477 L 318.040283 343.570496 L 441.825592 434.738342 L 459.946411 449.798706 L 467.194672 444.64447 L 468.080597 441.020203 L 459.946411 427.409485 L 392.617493 305.718323 L 320.778564 181.932983 L 288.80542 130.630859 L 280.348999 99.865845 C 277.369171 87.221436 275.194641 76.590698 275.194641 63.624268 L 312.322174 13.20813 L 332.8591 6.604126 L 382.389313 13.20813 L 403.248352 31.328979 L 434.013519 101.71814 L 483.865753 212.537048 L 561.181274 363.221497 L 583.812134 407.919434 L 595.892639 449.315491 L 600.40271 461.959839 L 608.214783 461.959839 L 608.214783 454.711609 L 614.577271 369.825623 L 626.335632 265.61084 L 637.771851 131.516846 L 641.718201 93.745117 L 660.402832 48.483276 L 697.530334 24.000122 L 726.52356 37.852417 L 750.362549 72 L 747.060486 94.067139 L 732.886047 186.201416 L 705.100708 330.52356 L 686.979919 427.167847 L 697.530334 427.167847 L 709.61084 415.087341 L 758.496704 350.174561 L 840.644348 247.490051 L 876.885925 206.738342 L 919.167847 161.71814 L 946.308838 140.29541 L 997.61084 140.29541 L 1035.38269 196.429626 L 1018.469849 254.416199 L 965.637634 321.422852 L 921.825562 378.201538 L 859.006714 462.765259 L 819.785278 530.41626 L 823.409424 535.812073 L 832.75177 534.92627 L 974.657776 504.724915 L 1051.328979 490.872559 L 1142.818848 475.167786 L 1184.214844 494.496582 L 1188.724854 514.147644 L 1172.456421 554.335693 L 1074.604126 578.496765 L 959.838989 601.449829 L 788.939636 641.879272 L 786.845764 643.409485 L 789.261841 646.389343 L 866.255127 653.637634 L 899.194702 655.409424 L 979.812134 655.409424 L 1129.932861 666.604187 L 1169.154419 692.537109 L 1192.671265 724.268677 L 1188.724854 748.429688 L 1128.322144 779.194641 L 1046.818848 759.865845 L 856.590759 714.604126 L 791.355774 698.335754 L 782.335693 698.335754 L 782.335693 703.731567 L 836.69812 756.885986 L 936.322205 846.845581 L 1061.073975 962.81897 L 1067.436279 991.490112 L 1051.409424 1014.120911 L 1034.496704 1011.704712 L 924.885986 929.234924 L 882.604126 892.107544 L 786.845764 811.48999 L 780.483276 811.48999 L 780.483276 819.946289 L 802.550415 852.241699 L 919.087341 1027.409424 L 925.127625 1081.127686 L 916.671204 1098.604126 L 886.469849 1109.154419 L 853.288696 1103.114136 L 785.073914 1007.355835 L 714.684631 899.516785 L 657.906067 802.872498 L 650.979858 806.81897 L 617.476624 1167.704834 L 601.771851 1186.147705 L 565.530212 1200 L 535.328857 1177.046997 L 519.302124 1139.919556 L 535.328857 1066.550537 L 554.657776 970.792053 L 570.362488 894.68457 L 584.536926 800.134277 L 592.993347 768.724976 L 592.429626 766.630859 L 585.503479 767.516968 L 514.22821 865.369263 L 405.825531 1011.865906 L 320.053711 1103.677979 L 299.516815 1111.812256 L 263.919525 1093.369263 L 267.221497 1060.429688 L 287.114136 1031.114136 L 405.825531 880.107361 L 477.422913 786.52356 L 523.651062 732.483276 L 523.328918 724.671265 L 520.590698 724.671265 L 205.288605 929.395935 L 149.154434 936.644409 L 124.993355 914.01355 L 127.973183 876.885986 L 139.409409 864.80542 L 234.201385 799.570435 L 233.879227 799.8927 Z"/></svg></button>
<button class="sidebar-tab" data-tab="plans" title="Plans"><svg width="18" height="18" viewBox="0 0 17 17" fill="currentColor" stroke="currentColor" stroke-width="0"><path d="M14 2v-2h-13v17h13v-2h2v-13h-2zM2 16v-15h2v15h-2zM13 16h-8v-15h8v15zM15 14h-1v-3h1v3zM15 10h-1v-3h1v3zM14 6v-3h1v3h-1zM6 4h5v1h-5v-1zM6 6h4v1h-4v-1z"/></svg></button>
<button class="sidebar-tab" data-tab="memory" title="Agent Files"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"/><path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"/><path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"/><path d="M17.599 6.5a3 3 0 0 0 .399-1.375"/><path d="M6.003 5.125A3 3 0 0 0 6.401 6.5"/><path d="M3.477 10.896a4 4 0 0 1 .585-.396"/><path d="M19.938 10.5a4 4 0 0 1 .585.396"/><path d="M6 18a4 4 0 0 1-1.967-.516"/><path d="M19.967 17.484A4 4 0 0 1 18 18"/></svg></button>
<button class="sidebar-tab" data-tab="work-files" title="Work Files"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"/></svg></button>
<button class="sidebar-tab" data-tab="stats" title="Stats"><svg width="18" height="18" viewBox="0 0 512 512" fill="currentColor" stroke="currentColor" stroke-width="0"><path d="M128 496H48V304h80zm224 0h-80V208h80zm112 0h-80V96h80zm-224 0h-80V16h80z"/></svg></button>
<button id="global-settings-btn" title="Global settings"></button>
<button id="sidebar-collapse-btn" title="Hide sidebar"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" height="20" width="20" xmlns="http://www.w3.org/2000/svg"><path d="M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm0 2h-9v14h9a1 1 0 0 0 .993 -.883l.007 -.117v-12a1 1 0 0 0 -.883 -.993l-.117 -.007zm-2.293 4.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.292 1.293l1.292 1.293a1 1 0 0 1 .083 1.32l-.083 .094a1 1 0 0 1 -1.32 .083l-.094 -.083l-2 -2a1 1 0 0 1 -.083 -1.32l.083 -.094l2 -2a1 1 0 0 1 1.414 0z"></path></svg></button>
Expand All @@ -42,6 +43,7 @@
<div class="plans-empty">Click the Stats tab to view activity heatmap.</div>
</div>
<div id="memory-content" style="display:none;"></div>
<div id="work-files-content" style="display:none;"></div>
</div>
<div id="sidebar-resize-handle"></div>
<div id="main">
Expand All @@ -55,6 +57,7 @@
<div id="stats-viewer-body"></div>
</div>
<div id="memory-viewer" style="display:none;"></div>
<div id="work-files-viewer" style="display:none;"></div>
<div id="plan-viewer" style="display:none;"></div>
<div id="settings-viewer" style="display:none;">
<div id="settings-viewer-header">
Expand Down
Loading
Loading