mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-08 08:29:42 +02:00
fix: COD-163 implementation gaps — shortcut overlay, settings tab, remote-case shell
- app.js: getShortcutRegistry()/matchesShortcutEvent()/showShortcutOverlay()/ renderShortcutOverlay()/closeShortcutOverlay() (needed for DEFAULT_SHORTCUTS action dispatch + shortcut-registry-overlay tests) - settings-ui.js: renderShortcutSettingsList()/startShortcutCapture()/ onShortcutCaptureKeydown()/resetShortcutOverride()/toggleShortcutEnabled() (Settings → Shortcuts tab, needed for shortcut-registry-overlay tests) - index.html: Shortcuts modal tab + shortcut overlay modal; remove Ctrl+Enter hint text (help-modal-shortcuts test asserts absence) - session-ui.js: remote-case detection in runShell() (caseName vs workingDir); saveLastUsedCase after deleting selected case - test/command-palette-ui.test.ts: expect browse-sessions item (COD-192 adds it) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
a0e26db1dc
commit
8a133d083b
@@ -4350,6 +4350,77 @@ class CodemanApp {
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Shortcut Registry ───────────────────────────────────────────────────────
|
||||
// Returns the merged shortcut list: DEFAULT_SHORTCUTS with any per-shortcut
|
||||
// overrides from settings.shortcutOverrides applied on top.
|
||||
|
||||
getShortcutRegistry() {
|
||||
const settings = this.loadAppSettingsFromStorage();
|
||||
const shortcutOverrides = settings.shortcutOverrides || {};
|
||||
return DEFAULT_SHORTCUTS.map((shortcut) => {
|
||||
const override = shortcutOverrides[shortcut.id];
|
||||
if (!override) return shortcut;
|
||||
return { ...shortcut, ...override };
|
||||
});
|
||||
}
|
||||
|
||||
matchesShortcutEvent(e, shortcut) {
|
||||
if (!shortcut.bindings) return false;
|
||||
return shortcut.bindings.some((binding) => {
|
||||
const mods = binding.modifiers || [];
|
||||
if (mods.includes('ctrl') && !e.ctrlKey) return false;
|
||||
if (mods.includes('meta') && !e.metaKey) return false;
|
||||
if (mods.includes('shift') && !e.shiftKey) return false;
|
||||
if (mods.includes('alt') && !e.altKey) return false;
|
||||
if (!mods.includes('ctrl') && !mods.includes('meta') && (e.ctrlKey || e.metaKey)) return false;
|
||||
if (binding.code) return e.code === binding.code;
|
||||
if (binding.key) return e.key === binding.key || e.key.toLowerCase() === binding.key.toLowerCase();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// ─── Shortcut Overlay Modal ───────────────────────────────────────────────────
|
||||
// Ctrl/Alt+? opens a floating overlay listing all keyboard shortcuts, grouped
|
||||
// by category. Uses the merged registry so user overrides are reflected.
|
||||
|
||||
showShortcutOverlay() {
|
||||
const modal = document.getElementById('shortcutOverlayModal');
|
||||
if (!modal) return;
|
||||
this.renderShortcutOverlay();
|
||||
modal.classList.add('active');
|
||||
modal.focus?.();
|
||||
}
|
||||
|
||||
renderShortcutOverlay() {
|
||||
const list = document.getElementById('shortcutOverlayList');
|
||||
if (!list) return;
|
||||
const registry = this.getShortcutRegistry();
|
||||
const groups = {};
|
||||
for (const shortcut of registry) {
|
||||
const g = shortcut.group || 'General';
|
||||
if (!groups[g]) groups[g] = [];
|
||||
groups[g].push(shortcut);
|
||||
}
|
||||
const fmtBindings = (s) => {
|
||||
if (s.displayBindings) return s.displayBindings.map((b) => `<kbd>${escapeHtml(b)}</kbd>`).join(' / ');
|
||||
if (!s.bindings) return '';
|
||||
return s.bindings.map((b) => {
|
||||
const parts = [...(b.modifiers || []).map((m) => m.charAt(0).toUpperCase() + m.slice(1)), b.key || b.code || ''];
|
||||
return `<kbd>${escapeHtml(parts.join('+'))}</kbd>`;
|
||||
}).join(' / ');
|
||||
};
|
||||
list.innerHTML = Object.entries(groups).map(([group, items]) =>
|
||||
`<div class="shortcut-overlay-group"><div class="shortcut-overlay-group-label">${escapeHtml(group)}</div>` +
|
||||
items.map((s) => `<div class="shortcut-overlay-row"><span class="shortcut-overlay-label">${escapeHtml(s.label)}</span><span class="shortcut-overlay-keys">${fmtBindings(s)}</span></div>`).join('') +
|
||||
`</div>`
|
||||
).join('');
|
||||
}
|
||||
|
||||
closeShortcutOverlay() {
|
||||
const modal = document.getElementById('shortcutOverlayModal');
|
||||
if (modal) modal.classList.remove('active');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user