Skip to content

Commit 47e7dcb

Browse files
mrtwebdesignclaude
andcommitted
Add IDE selector for file links in HTML reports
- Add IDE selector UI with buttons for VS Code, Cursor, Augment, and File - Position selector just above Findings section for clear context - Store user preference in localStorage for persistence across reports - Generate links with data-file and data-line attributes for dynamic switching - Support IDE URL protocols: vscode://file, cursor://file, augment://file Closes #65 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 87f9442 commit 47e7dcb

2 files changed

Lines changed: 116 additions & 3 deletions

File tree

dist/bin/json-to-html.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,13 @@ def main():
170170

171171
# Create clickable links for scanned paths
172172
abs_path = os.path.abspath(paths) if not os.path.isabs(paths) else paths
173-
paths_link = f'<a href="file://{abs_path}" style="color: #667eea;">{paths}</a>'
173+
paths_link = f'<a href="file://{abs_path}" class="ide-link" data-file="{abs_path}" style="color: #667eea;">{paths}</a>'
174174

175175
# Create clickable link for JSON log file
176176
json_log_link = ""
177177
if os.path.isfile(input_json):
178178
abs_json_path = os.path.abspath(input_json)
179-
log_link = f'<a href="file://{abs_json_path}" style="color: #667eea;">{input_json}</a>'
179+
log_link = f'<a href="file://{abs_json_path}" class="ide-link" data-file="{abs_json_path}" style="color: #667eea;">{input_json}</a>'
180180
json_log_link = f'<div style="margin-top: 8px;">JSON Log: {log_link} <button class="copy-btn" onclick="copyLogPath()" title="Copy JSON log path to clipboard">📋 Copy Path</button></div>'
181181

182182
# Determine status
@@ -217,7 +217,7 @@ def main():
217217
<span class="badge {impact}">{impact.upper()}</span>
218218
</div>
219219
<div class="finding-details">
220-
<div class="file-path"><a href="file://{abs_file}" style="color: #667eea; text-decoration: none;" title="Click to open file">{file_path}</a>:{line}</div>
220+
<div class="file-path"><a href="file://{abs_file}" class="ide-link" data-file="{abs_file}" data-line="{line}" style="color: #667eea; text-decoration: none;" title="Click to open in IDE">{file_path}</a>:{line}</div>
221221
<div class="code-snippet">{code_escaped}</div>
222222
</div>
223223
</div>'''

dist/bin/templates/report-template.html

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,57 @@
273273
border-bottom: 1px solid #dee2e6;
274274
}
275275

276+
/* IDE Selector Styles */
277+
.ide-selector {
278+
display: flex;
279+
align-items: center;
280+
gap: 8px;
281+
margin-bottom: 20px;
282+
flex-wrap: wrap;
283+
}
284+
285+
.ide-selector-label {
286+
font-size: 0.9em;
287+
color: #495057;
288+
font-weight: 500;
289+
}
290+
291+
.ide-buttons {
292+
display: flex;
293+
gap: 8px;
294+
flex-wrap: wrap;
295+
}
296+
297+
.ide-btn {
298+
padding: 4px 12px;
299+
border: 1px solid #dee2e6;
300+
border-radius: 4px;
301+
background: white;
302+
color: #495057;
303+
font-size: 0.8em;
304+
font-weight: 500;
305+
cursor: pointer;
306+
transition: all 0.2s ease;
307+
display: flex;
308+
align-items: center;
309+
gap: 4px;
310+
}
311+
312+
.ide-btn:hover {
313+
border-color: #667eea;
314+
background: #f0f4ff;
315+
}
316+
317+
.ide-btn.active {
318+
border-color: #667eea;
319+
background: #667eea;
320+
color: white;
321+
}
322+
323+
.ide-btn .ide-icon {
324+
font-size: 1.1em;
325+
}
326+
276327
.search-input-wrapper {
277328
position: relative;
278329
width: 100%;
@@ -564,6 +615,16 @@ <h2>🤖 Phase 2 (TL;DR) - AI Triage Summary</h2>
564615
<!-- Findings Section -->
565616
<div class="section">
566617
<h2>📋 Findings ({{FINDINGS_COUNT}})</h2>
618+
<!-- IDE Selector -->
619+
<div class="ide-selector">
620+
<span class="ide-selector-label">Open in:</span>
621+
<div class="ide-buttons">
622+
<button class="ide-btn" data-ide="vscode" title="Open in VS Code">💻 VS Code</button>
623+
<button class="ide-btn" data-ide="cursor" title="Open in Cursor">⚡ Cursor</button>
624+
<button class="ide-btn" data-ide="augment" title="Open in Augment">🔮 Augment</button>
625+
<button class="ide-btn" data-ide="file" title="Use file:// protocol">📁 File</button>
626+
</div>
627+
</div>
567628
{{FINDINGS_HTML}}
568629
</div>
569630

@@ -630,8 +691,60 @@ <h2>✓ Checks Summary</h2>
630691
});
631692
}
632693

694+
// IDE Protocol Configuration
695+
const ideProtocols = {
696+
vscode: { prefix: 'vscode://file', format: (file, line) => line ? `vscode://file${file}:${line}` : `vscode://file${file}` },
697+
cursor: { prefix: 'cursor://file', format: (file, line) => line ? `cursor://file${file}:${line}` : `cursor://file${file}` },
698+
augment: { prefix: 'augment://file', format: (file, line) => line ? `augment://file${file}:${line}` : `augment://file${file}` },
699+
file: { prefix: 'file://', format: (file, line) => `file://${file}` }
700+
};
701+
702+
// IDE Selector functionality
703+
function initIdeSelector() {
704+
const ideButtons = document.querySelectorAll('.ide-btn');
705+
const ideLinks = document.querySelectorAll('.ide-link');
706+
707+
// Load saved preference or default to 'file'
708+
const savedIde = localStorage.getItem('wp-code-check-ide') || 'file';
709+
710+
// Set initial active state and update links
711+
updateIdeSelection(savedIde, ideButtons, ideLinks);
712+
713+
// Add click handlers to IDE buttons
714+
ideButtons.forEach(btn => {
715+
btn.addEventListener('click', function() {
716+
const ide = this.dataset.ide;
717+
localStorage.setItem('wp-code-check-ide', ide);
718+
updateIdeSelection(ide, ideButtons, ideLinks);
719+
});
720+
});
721+
}
722+
723+
function updateIdeSelection(ide, buttons, links) {
724+
// Update button states
725+
buttons.forEach(btn => {
726+
if (btn.dataset.ide === ide) {
727+
btn.classList.add('active');
728+
} else {
729+
btn.classList.remove('active');
730+
}
731+
});
732+
733+
// Update all links
734+
const protocol = ideProtocols[ide] || ideProtocols.file;
735+
links.forEach(link => {
736+
const file = link.dataset.file;
737+
const line = link.dataset.line;
738+
if (file) {
739+
link.href = protocol.format(file, line);
740+
}
741+
});
742+
}
743+
633744
// Convert UTC timestamp to local time
634745
document.addEventListener('DOMContentLoaded', function() {
746+
// Initialize IDE selector
747+
initIdeSelector();
635748
// Get the UTC timestamp from the page
636749
const utcTimestamp = '{{TIMESTAMP}}';
637750

0 commit comments

Comments
 (0)