generated from nhcarrigan/template
e45a1a1c98
## Summary - Add CodeMirror 6 editor with syntax highlighting for 40+ languages - Add file browser sidebar with collapsible directory tree navigation - Add multi-tab support with dirty state indicators and close buttons - Add keyboard shortcuts (Ctrl+E toggle, Ctrl+B file browser, Ctrl+S save, Ctrl+W close tab) - Add editor toggle button to status bar (disabled when not connected) - Editor automatically uses current session's working directory - Add Tauri backend commands for file operations (list_directory, read_file_content, write_file_content) ## Test Plan - [ ] Connect to a session and verify the editor toggle button becomes enabled - [ ] Press Ctrl+E to open the editor and verify file tree shows the session's CWD - [ ] Navigate directories and open files to verify syntax highlighting works - [ ] Edit a file and verify the dirty indicator (*) appears - [ ] Save with Ctrl+S and verify the dirty indicator disappears - [ ] Open multiple files and verify tab switching works - [ ] Close tabs with Ctrl+W or the X button - [ ] Disconnect and verify the editor automatically closes - [ ] Verify keyboard shortcuts are documented in the shortcuts modal Closes #72 ✨ This PR was created with help from Hikari~ 🌸 Reviewed-on: #79 Co-authored-by: Hikari <hikari@nhcarrigan.com> Co-committed-by: Hikari <hikari@nhcarrigan.com>
192 lines
6.1 KiB
Svelte
192 lines
6.1 KiB
Svelte
<script lang="ts">
|
|
interface Props {
|
|
onClose: () => void;
|
|
}
|
|
|
|
const { onClose }: Props = $props();
|
|
|
|
const shortcuts = [
|
|
{
|
|
category: "General",
|
|
items: [
|
|
{ keys: ["Escape"], description: "Close modals and panels" },
|
|
{ keys: ["Ctrl", "L"], description: "Clear the terminal" },
|
|
{ keys: ["Ctrl", ","], description: "Open settings" },
|
|
{ keys: ["Ctrl", "E"], description: "Toggle file editor" },
|
|
{ keys: ["Ctrl", "Shift", "M"], description: "Toggle compact mode" },
|
|
{ keys: ["Ctrl", "Shift", "S"], description: "Toggle streamer mode" },
|
|
],
|
|
},
|
|
{
|
|
category: "Chat",
|
|
items: [
|
|
{ keys: ["Enter"], description: "Send message" },
|
|
{ keys: ["Shift", "Enter"], description: "New line in message" },
|
|
{ keys: ["Ctrl", "C"], description: "Interrupt/stop response" },
|
|
{ keys: ["↑"], description: "Previous input from history" },
|
|
{ keys: ["↓"], description: "Next input from history" },
|
|
],
|
|
},
|
|
{
|
|
category: "File Editor",
|
|
items: [
|
|
{ keys: ["Ctrl", "E"], description: "Toggle editor view" },
|
|
{ keys: ["Ctrl", "B"], description: "Toggle file browser" },
|
|
{ keys: ["Ctrl", "S"], description: "Save current file" },
|
|
{ keys: ["Ctrl", "W"], description: "Close current tab" },
|
|
{ keys: ["Ctrl", "N"], description: "New file" },
|
|
{ keys: ["Right-click"], description: "Context menu (New/Delete)" },
|
|
],
|
|
},
|
|
{
|
|
category: "Slash Commands",
|
|
items: [
|
|
{ keys: ["↑", "↓"], description: "Navigate command menu" },
|
|
{ keys: ["Tab"], description: "Complete selected command" },
|
|
{ keys: ["Escape"], description: "Close command menu" },
|
|
],
|
|
},
|
|
{
|
|
category: "Permission Prompts",
|
|
items: [
|
|
{ keys: ["Enter"], description: "Allow & reconnect" },
|
|
{ keys: ["Escape"], description: "Dismiss" },
|
|
],
|
|
},
|
|
];
|
|
</script>
|
|
|
|
<div
|
|
class="fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4"
|
|
onclick={onClose}
|
|
role="button"
|
|
tabindex="0"
|
|
onkeydown={(e) => e.key === "Escape" && onClose()}
|
|
>
|
|
<div
|
|
class="bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] overflow-hidden flex flex-col"
|
|
onclick={(e) => e.stopPropagation()}
|
|
onkeydown={(e) => e.stopPropagation()}
|
|
role="dialog"
|
|
aria-labelledby="shortcuts-title"
|
|
tabindex="-1"
|
|
>
|
|
<div class="flex items-center justify-between p-6 pb-4 border-b border-[var(--border-color)]">
|
|
<div class="flex items-center gap-3">
|
|
<div
|
|
class="w-8 h-8 rounded-lg bg-[var(--accent-primary)]/20 flex items-center justify-center"
|
|
>
|
|
<svg
|
|
class="w-5 h-5 text-[var(--accent-primary)]"
|
|
fill="none"
|
|
stroke="currentColor"
|
|
viewBox="0 0 24 24"
|
|
>
|
|
<path
|
|
stroke-linecap="round"
|
|
stroke-linejoin="round"
|
|
stroke-width="2"
|
|
d="M12 3C10.22 3 8.47 3.23 6.86 3.68A2 2 0 005 5.57V18.43a2 2 0 001.86 1.89C8.47 20.77 10.22 21 12 21s3.53-.23 5.14-.68A2 2 0 0019 18.43V5.57a2 2 0 00-1.86-1.89C15.53 3.23 13.78 3 12 3z"
|
|
/>
|
|
<path
|
|
stroke-linecap="round"
|
|
stroke-linejoin="round"
|
|
stroke-width="2"
|
|
d="M8 7h.01M12 7h.01M16 7h.01M8 11h.01M12 11h.01M16 11h.01M8 15h8"
|
|
/>
|
|
</svg>
|
|
</div>
|
|
<h2 id="shortcuts-title" class="text-xl font-semibold text-[var(--text-primary)]">
|
|
Keyboard Shortcuts
|
|
</h2>
|
|
</div>
|
|
<button
|
|
onclick={onClose}
|
|
class="p-1 text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors"
|
|
aria-label="Close"
|
|
>
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path
|
|
stroke-linecap="round"
|
|
stroke-linejoin="round"
|
|
stroke-width="2"
|
|
d="M6 18L18 6M6 6l12 12"
|
|
/>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
|
|
<div class="overflow-y-auto flex-1 p-6 space-y-6">
|
|
{#each shortcuts as section (section.category)}
|
|
<div>
|
|
<h3
|
|
class="text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider mb-3"
|
|
>
|
|
{section.category}
|
|
</h3>
|
|
<div class="space-y-2">
|
|
{#each section.items as item (item.description)}
|
|
<div
|
|
class="flex items-center justify-between py-2 px-3 bg-[var(--bg-secondary)] rounded-lg"
|
|
>
|
|
<span class="text-sm text-[var(--text-primary)]">{item.description}</span>
|
|
<div class="flex items-center gap-1">
|
|
{#each item.keys as key, i (key)}
|
|
{#if i > 0}
|
|
<span class="text-[var(--text-secondary)] text-xs">+</span>
|
|
{/if}
|
|
<kbd
|
|
class="px-2 py-1 text-xs font-mono bg-[var(--bg-primary)] border border-[var(--border-color)] rounded text-[var(--text-primary)] shadow-sm min-w-[24px] text-center"
|
|
>
|
|
{key}
|
|
</kbd>
|
|
{/each}
|
|
</div>
|
|
</div>
|
|
{/each}
|
|
</div>
|
|
</div>
|
|
{/each}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
[role="dialog"] {
|
|
animation: slideIn 0.2s ease-out;
|
|
}
|
|
|
|
@keyframes slideIn {
|
|
from {
|
|
opacity: 0;
|
|
transform: scale(0.95) translateY(10px);
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
transform: scale(1) translateY(0);
|
|
}
|
|
}
|
|
|
|
.overflow-y-auto {
|
|
scrollbar-width: thin;
|
|
scrollbar-color: var(--border-color) transparent;
|
|
}
|
|
|
|
.overflow-y-auto::-webkit-scrollbar {
|
|
width: 8px;
|
|
}
|
|
|
|
.overflow-y-auto::-webkit-scrollbar-track {
|
|
background: transparent;
|
|
}
|
|
|
|
.overflow-y-auto::-webkit-scrollbar-thumb {
|
|
background-color: var(--border-color);
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.overflow-y-auto::-webkit-scrollbar-thumb:hover {
|
|
background-color: var(--accent-primary);
|
|
}
|
|
</style>
|