Skip to content

Commit 1720b3e

Browse files
committed
Readd file viewer link again
1 parent 295c72a commit 1720b3e

File tree

2 files changed

+113
-31
lines changed

2 files changed

+113
-31
lines changed

src/extension.ts

Lines changed: 71 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,8 +2111,12 @@ class CopilotTokenTracker implements vscode.Disposable {
21112111
const foundPaths: string[] = [];
21122112
for (let i = 0; i < allVSCodePaths.length; i++) {
21132113
const codeUserPath = allVSCodePaths[i];
2114-
if (fs.existsSync(codeUserPath)) {
2115-
foundPaths.push(codeUserPath);
2114+
try {
2115+
if (fs.existsSync(codeUserPath)) {
2116+
foundPaths.push(codeUserPath);
2117+
}
2118+
} catch (checkError) {
2119+
this.warn(`Could not check path ${codeUserPath}: ${checkError}`);
21162120
}
21172121
// Update progress
21182122
if ((i + 1) % 5 === 0 || i === allVSCodePaths.length - 1) {
@@ -2130,53 +2134,89 @@ class CopilotTokenTracker implements vscode.Disposable {
21302134

21312135
// Workspace storage sessions
21322136
const workspaceStoragePath = path.join(codeUserPath, 'workspaceStorage');
2133-
if (fs.existsSync(workspaceStoragePath)) {
2134-
const workspaceDirs = fs.readdirSync(workspaceStoragePath);
2135-
2136-
for (const workspaceDir of workspaceDirs) {
2137-
const chatSessionsPath = path.join(workspaceStoragePath, workspaceDir, 'chatSessions');
2138-
if (fs.existsSync(chatSessionsPath)) {
2139-
const sessionFiles2 = fs.readdirSync(chatSessionsPath)
2140-
.filter(file => file.endsWith('.json') || file.endsWith('.jsonl'))
2141-
.map(file => path.join(chatSessionsPath, file));
2142-
if (sessionFiles2.length > 0) {
2143-
this.log(`📄 Found ${sessionFiles2.length} session files in ${pathName}/workspaceStorage/${workspaceDir}`);
2144-
sessionFiles.push(...sessionFiles2);
2137+
try {
2138+
if (fs.existsSync(workspaceStoragePath)) {
2139+
try {
2140+
const workspaceDirs = fs.readdirSync(workspaceStoragePath);
2141+
2142+
for (const workspaceDir of workspaceDirs) {
2143+
const chatSessionsPath = path.join(workspaceStoragePath, workspaceDir, 'chatSessions');
2144+
try {
2145+
if (fs.existsSync(chatSessionsPath)) {
2146+
try {
2147+
const sessionFiles2 = fs.readdirSync(chatSessionsPath)
2148+
.filter(file => file.endsWith('.json') || file.endsWith('.jsonl'))
2149+
.map(file => path.join(chatSessionsPath, file));
2150+
if (sessionFiles2.length > 0) {
2151+
this.log(`📄 Found ${sessionFiles2.length} session files in ${pathName}/workspaceStorage/${workspaceDir}`);
2152+
sessionFiles.push(...sessionFiles2);
2153+
}
2154+
} catch (readError) {
2155+
this.warn(`Could not read chat sessions in ${chatSessionsPath}: ${readError}`);
2156+
}
2157+
}
2158+
} catch (checkError) {
2159+
this.warn(`Could not check chat sessions path ${chatSessionsPath}: ${checkError}`);
2160+
}
21452161
}
2162+
} catch (readError) {
2163+
this.warn(`Could not read workspace storage in ${workspaceStoragePath}: ${readError}`);
21462164
}
21472165
}
2166+
} catch (checkError) {
2167+
this.warn(`Could not check workspace storage path ${workspaceStoragePath}: ${checkError}`);
21482168
}
21492169

21502170
// Global storage sessions (legacy emptyWindowChatSessions)
21512171
const globalStoragePath = path.join(codeUserPath, 'globalStorage', 'emptyWindowChatSessions');
2152-
if (fs.existsSync(globalStoragePath)) {
2153-
const globalSessionFiles = fs.readdirSync(globalStoragePath)
2154-
.filter(file => file.endsWith('.json') || file.endsWith('.jsonl'))
2155-
.map(file => path.join(globalStoragePath, file));
2156-
if (globalSessionFiles.length > 0) {
2157-
this.log(`📄 Found ${globalSessionFiles.length} session files in ${pathName}/globalStorage/emptyWindowChatSessions`);
2158-
sessionFiles.push(...globalSessionFiles);
2172+
try {
2173+
if (fs.existsSync(globalStoragePath)) {
2174+
try {
2175+
const globalSessionFiles = fs.readdirSync(globalStoragePath)
2176+
.filter(file => file.endsWith('.json') || file.endsWith('.jsonl'))
2177+
.map(file => path.join(globalStoragePath, file));
2178+
if (globalSessionFiles.length > 0) {
2179+
this.log(`📄 Found ${globalSessionFiles.length} session files in ${pathName}/globalStorage/emptyWindowChatSessions`);
2180+
sessionFiles.push(...globalSessionFiles);
2181+
}
2182+
} catch (readError) {
2183+
this.warn(`Could not read global storage in ${globalStoragePath}: ${readError}`);
2184+
}
21592185
}
2186+
} catch (checkError) {
2187+
this.warn(`Could not check global storage path ${globalStoragePath}: ${checkError}`);
21602188
}
21612189

21622190
// GitHub Copilot Chat extension global storage
21632191
const copilotChatGlobalPath = path.join(codeUserPath, 'globalStorage', 'github.copilot-chat');
2164-
if (fs.existsSync(copilotChatGlobalPath)) {
2165-
this.log(`📄 Scanning ${pathName}/globalStorage/github.copilot-chat`);
2166-
this.scanDirectoryForSessionFiles(copilotChatGlobalPath, sessionFiles);
2192+
try {
2193+
if (fs.existsSync(copilotChatGlobalPath)) {
2194+
this.log(`📄 Scanning ${pathName}/globalStorage/github.copilot-chat`);
2195+
this.scanDirectoryForSessionFiles(copilotChatGlobalPath, sessionFiles);
2196+
}
2197+
} catch (checkError) {
2198+
this.warn(`Could not check Copilot Chat global storage path ${copilotChatGlobalPath}: ${checkError}`);
21672199
}
21682200
}
21692201

21702202
// Check for Copilot CLI session-state directory (new location for agent mode sessions)
21712203
const copilotCliSessionPath = path.join(os.homedir(), '.copilot', 'session-state');
2172-
if (fs.existsSync(copilotCliSessionPath)) {
2173-
const cliSessionFiles = fs.readdirSync(copilotCliSessionPath)
2174-
.filter(file => file.endsWith('.json') || file.endsWith('.jsonl'))
2175-
.map(file => path.join(copilotCliSessionPath, file));
2176-
if (cliSessionFiles.length > 0) {
2177-
this.log(`📄 Found ${cliSessionFiles.length} session files in Copilot CLI directory`);
2178-
sessionFiles.push(...cliSessionFiles);
2204+
try {
2205+
if (fs.existsSync(copilotCliSessionPath)) {
2206+
try {
2207+
const cliSessionFiles = fs.readdirSync(copilotCliSessionPath)
2208+
.filter(file => file.endsWith('.json') || file.endsWith('.jsonl'))
2209+
.map(file => path.join(copilotCliSessionPath, file));
2210+
if (cliSessionFiles.length > 0) {
2211+
this.log(`📄 Found ${cliSessionFiles.length} session files in Copilot CLI directory`);
2212+
sessionFiles.push(...cliSessionFiles);
2213+
}
2214+
} catch (readError) {
2215+
this.warn(`Could not read Copilot CLI session path in ${copilotCliSessionPath}: ${readError}`);
2216+
}
21792217
}
2218+
} catch (checkError) {
2219+
this.warn(`Could not check Copilot CLI session path ${copilotCliSessionPath}: ${checkError}`);
21802220
}
21812221

21822222
// Log summary

src/webview/logviewer/main.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,15 @@ function renderLayout(data: SessionLogData): void {
357357
transform: translateY(-2px);
358358
box-shadow: 0 6px 16px rgba(0,0,0,0.4), 0 2px 4px rgba(0,0,0,0.2);
359359
}
360+
.filename-link {
361+
cursor: pointer;
362+
color: #60a5fa;
363+
text-decoration: underline;
364+
transition: color 0.2s;
365+
}
366+
.filename-link:hover {
367+
color: #93c5fd;
368+
}
360369
.summary-label {
361370
font-size: 14px;
362371
color: #b8b8c0;
@@ -678,6 +687,36 @@ function renderLayout(data: SessionLogData): void {
678687
<div class="summary-value">${usageContextTotal}</div>
679688
<div class="summary-sub">#file ${usageContextRefs.file || 0} · @vscode ${usageContextRefs.vscode || 0} · @workspace ${usageContextRefs.workspace || 0}</div>
680689
</div>
690+
<div class="summary-card">
691+
<div class="summary-label">📁 File Name</div>
692+
<div class="summary-value" style="font-size: 16px;"><span class="filename-link" id="open-file-link">${escapeHtml(getFileName(data.file))}</span></div>
693+
<div class="summary-sub">Click to open in editor</div>
694+
</div>
695+
<div class="summary-card">
696+
<div class="summary-label">💻 Editor</div>
697+
<div class="summary-value" style="font-size: 20px;">${escapeHtml(data.editorName)}</div>
698+
<div class="summary-sub">Source editor</div>
699+
</div>
700+
<div class="summary-card">
701+
<div class="summary-label">📦 File Size</div>
702+
<div class="summary-value">${formatFileSize(data.size)}</div>
703+
<div class="summary-sub">Total size on disk</div>
704+
</div>
705+
<div class="summary-card">
706+
<div class="summary-label">🕒 Modified</div>
707+
<div class="summary-value" style="font-size: 14px;">${formatDate(data.modified)}</div>
708+
<div class="summary-sub">Last file modification</div>
709+
</div>
710+
<div class="summary-card">
711+
<div class="summary-label">▶️ First Interaction</div>
712+
<div class="summary-value" style="font-size: 14px;">${formatDate(data.firstInteraction)}</div>
713+
<div class="summary-sub">Session started</div>
714+
</div>
715+
<div class="summary-card">
716+
<div class="summary-label">⏹️ Last Interaction</div>
717+
<div class="summary-value" style="font-size: 14px;">${formatDate(data.lastInteraction)}</div>
718+
<div class="summary-sub">Most recent activity</div>
719+
</div>
681720
</div>
682721
683722
<div class="turns-header">
@@ -713,6 +752,9 @@ function renderLayout(data: SessionLogData): void {
713752
e.preventDefault();
714753
vscode.postMessage({ command: 'openRawFile' });
715754
});
755+
document.getElementById('open-file-link')?.addEventListener('click', () => {
756+
vscode.postMessage({ command: 'openRawFile' });
757+
});
716758

717759
// Wire tool call clicks after DOM render so listeners bind correctly
718760
document.querySelectorAll('.tool-call-link').forEach(link => {

0 commit comments

Comments
 (0)