mirror of
https://github.com/andrepimenta/claude-code-chat.git
synced 2025-12-11 23:59:51 +00:00
File name better
This commit is contained in:
@@ -231,6 +231,9 @@ class ClaudeChatProvider {
|
||||
case 'dismissWSLAlert':
|
||||
this._dismissWSLAlert();
|
||||
return;
|
||||
case 'openFile':
|
||||
this._openFileInEditor(message.filePath);
|
||||
return;
|
||||
}
|
||||
},
|
||||
null,
|
||||
@@ -1371,6 +1374,17 @@ class ClaudeChatProvider {
|
||||
this._context.globalState.update('wslAlertDismissed', true);
|
||||
}
|
||||
|
||||
private async _openFileInEditor(filePath: string) {
|
||||
try {
|
||||
const uri = vscode.Uri.file(filePath);
|
||||
const document = await vscode.workspace.openTextDocument(uri);
|
||||
await vscode.window.showTextDocument(document, vscode.ViewColumn.One);
|
||||
} catch (error) {
|
||||
vscode.window.showErrorMessage(`Failed to open file: ${filePath}`);
|
||||
console.error('Error opening file:', error);
|
||||
}
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
if (this._panel) {
|
||||
this._panel.dispose();
|
||||
|
||||
@@ -429,7 +429,6 @@ const styles = `
|
||||
}
|
||||
|
||||
.tool-input {
|
||||
margin-top: 4px;
|
||||
padding: 12px;
|
||||
font-family: var(--vscode-editor-font-family);
|
||||
font-size: 12px;
|
||||
@@ -453,7 +452,6 @@ const styles = `
|
||||
|
||||
/* Diff display styles for Edit tool */
|
||||
.diff-container {
|
||||
margin-top: 8px;
|
||||
border: 1px solid var(--vscode-panel-border);
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
@@ -535,6 +533,50 @@ const styles = `
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
/* File path display styles */
|
||||
.diff-file-path {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid var(--vscode-panel-border);
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.file-path-short,
|
||||
.file-path-truncated {
|
||||
font-family: var(--vscode-editor-font-family);
|
||||
color: var(--vscode-foreground);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.file-path-truncated {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
padding: 2px 4px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.file-path-truncated .file-icon {
|
||||
font-size: 14px;
|
||||
opacity: 0.7;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.file-path-truncated:hover {
|
||||
color: var(--vscode-textLink-foreground);
|
||||
background-color: var(--vscode-list-hoverBackground);
|
||||
}
|
||||
|
||||
.file-path-truncated:hover .file-icon {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.file-path-truncated:active {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
.expand-btn {
|
||||
background: linear-gradient(135deg, rgba(64, 165, 255, 0.15) 0%, rgba(64, 165, 255, 0.1) 100%);
|
||||
border: 1px solid rgba(64, 165, 255, 0.3);
|
||||
|
||||
34
src/ui.ts
34
src/ui.ts
@@ -776,6 +776,12 @@ const html = `<!DOCTYPE html>
|
||||
return str;
|
||||
}
|
||||
|
||||
// Special handling for Read tool with file_path
|
||||
if (input.file_path && Object.keys(input).length === 1) {
|
||||
const formattedPath = formatFilePath(input.file_path);
|
||||
return '<div class="diff-file-path">' + formattedPath + '</div>';
|
||||
}
|
||||
|
||||
let result = '';
|
||||
let isFirst = true;
|
||||
for (const [key, value] of Object.entries(input)) {
|
||||
@@ -784,7 +790,11 @@ const html = `<!DOCTYPE html>
|
||||
if (!isFirst) result += '\\n';
|
||||
isFirst = false;
|
||||
|
||||
if (valueStr.length > 100) {
|
||||
// Special formatting for file_path in Read tool context
|
||||
if (key === 'file_path') {
|
||||
const formattedPath = formatFilePath(valueStr);
|
||||
result += '<div class="diff-file-path">' + formattedPath + '</div>';
|
||||
} else if (valueStr.length > 100) {
|
||||
const truncated = valueStr.substring(0, 97) + '...';
|
||||
const escapedValue = valueStr.replace(/"/g, '"').replace(/'/g, ''');
|
||||
result += '<strong>' + key + ':</strong> ' + truncated + ' <span class="expand-btn" data-key="' + key + '" data-value="' + escapedValue + '" onclick="toggleExpand(this)">expand</span>';
|
||||
@@ -805,7 +815,9 @@ const html = `<!DOCTYPE html>
|
||||
return formatToolInputUI(input);
|
||||
}
|
||||
|
||||
let result = '<strong>file_path:</strong> ' + input.file_path + '\\n\\n';
|
||||
// Format file path with better display
|
||||
const formattedPath = formatFilePath(input.file_path);
|
||||
let result = '<div class="diff-file-path">' + formattedPath + '</div>\\n';
|
||||
|
||||
// Create diff view
|
||||
const oldLines = input.old_string.split('\\n');
|
||||
@@ -868,6 +880,24 @@ const html = `<!DOCTYPE html>
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
function openFileInEditor(filePath) {
|
||||
vscode.postMessage({
|
||||
type: 'openFile',
|
||||
filePath: filePath
|
||||
});
|
||||
}
|
||||
|
||||
function formatFilePath(filePath) {
|
||||
if (!filePath) return '';
|
||||
|
||||
// Extract just the filename
|
||||
const parts = filePath.split('/');
|
||||
const fileName = parts[parts.length - 1];
|
||||
|
||||
return '<span class="file-path-truncated" title="' + escapeHtml(filePath) + '" onclick="openFileInEditor(\\\'' + escapeHtml(filePath) + '\\\')">' +
|
||||
'<span class="file-icon">📄</span>' + escapeHtml(fileName) + '</span>';
|
||||
}
|
||||
|
||||
function toggleDiffExpansion(diffId) {
|
||||
const hiddenDiv = document.getElementById(diffId + '_hidden');
|
||||
const button = document.querySelector('[onclick*="' + diffId + '"]');
|
||||
|
||||
Reference in New Issue
Block a user