generated from nhcarrigan/template
665f74e3bf
Adds /simplify, /loop, and /batch as CLI-sourced slash commands so they appear in the autocomplete menu with a 'CLI' badge and forward correctly to Claude Code instead of triggering 'Unknown command' errors. Introduces source?: 'cli' field to the SlashCommand interface to distinguish app-level commands from CLI pass-through entries. Resolves #208.
104 lines
2.4 KiB
Svelte
104 lines
2.4 KiB
Svelte
<script lang="ts">
|
|
import type { SlashCommand } from "$lib/commands/slashCommands";
|
|
|
|
interface Props {
|
|
commands: SlashCommand[];
|
|
selectedIndex: number;
|
|
onSelect: (command: SlashCommand) => void;
|
|
}
|
|
|
|
let { commands, selectedIndex, onSelect }: Props = $props();
|
|
</script>
|
|
|
|
{#if commands.length > 0}
|
|
<div class="slash-command-menu">
|
|
<div class="menu-header">Commands</div>
|
|
{#each commands as command, index (command.name)}
|
|
<button
|
|
type="button"
|
|
class="menu-item"
|
|
class:selected={index === selectedIndex}
|
|
onclick={() => onSelect(command)}
|
|
onmouseenter={() => (selectedIndex = index)}
|
|
>
|
|
<span class="command-name">/{command.name}</span>
|
|
<span class="command-description">{command.description}</span>
|
|
{#if command.source === "cli"}
|
|
<span class="cli-badge">CLI</span>
|
|
{/if}
|
|
</button>
|
|
{/each}
|
|
</div>
|
|
{/if}
|
|
|
|
<style>
|
|
.slash-command-menu {
|
|
position: absolute;
|
|
bottom: 100%;
|
|
left: 0;
|
|
right: 0;
|
|
margin-bottom: 8px;
|
|
background: var(--bg-secondary);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: 8px;
|
|
overflow: hidden;
|
|
box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.2);
|
|
z-index: 100;
|
|
}
|
|
|
|
.menu-header {
|
|
padding: 8px 12px;
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
color: var(--text-tertiary);
|
|
background: var(--bg-tertiary);
|
|
border-bottom: 1px solid var(--border-color);
|
|
}
|
|
|
|
.menu-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
width: 100%;
|
|
padding: 10px 12px;
|
|
text-align: left;
|
|
background: transparent;
|
|
border: none;
|
|
cursor: pointer;
|
|
transition: background-color 0.15s ease;
|
|
}
|
|
|
|
.menu-item:hover,
|
|
.menu-item.selected {
|
|
background: var(--bg-tertiary);
|
|
}
|
|
|
|
.command-name {
|
|
font-family: monospace;
|
|
font-weight: 600;
|
|
color: var(--accent-primary);
|
|
min-width: 80px;
|
|
}
|
|
|
|
.command-description {
|
|
color: var(--text-secondary);
|
|
font-size: 13px;
|
|
flex: 1;
|
|
}
|
|
|
|
.cli-badge {
|
|
font-size: 10px;
|
|
font-weight: 600;
|
|
padding: 1px 5px;
|
|
border-radius: 4px;
|
|
background: color-mix(in srgb, var(--accent-primary) 15%, transparent);
|
|
color: var(--accent-primary);
|
|
border: 1px solid color-mix(in srgb, var(--accent-primary) 30%, transparent);
|
|
letter-spacing: 0.5px;
|
|
text-transform: uppercase;
|
|
flex-shrink: 0;
|
|
}
|
|
</style>
|