feat: new drafts feature and sound spam fix (#174)
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 58s
CI / Build Linux (push) Has been cancelled
CI / Build Windows (cross-compile) (push) Has been cancelled
CI / Lint & Test (push) Has been cancelled

## Summary

- **Saved Drafts feature**: Users can now save input content as drafts for later use, and manage them from a new panel
- **Sound spam fix**: The "Working on it!" sound no longer plays repeatedly when Claude makes multiple tool calls in a row

## Details

### Drafts feature
- Rust backend (`drafts.rs`) with `list_drafts`, `save_draft`, `delete_draft`, and `delete_all_drafts` commands, persisted to `hikari-drafts.json` via the Tauri Store plugin
- `draftsStore` wrapping all four commands with timestamp formatting
- `DraftPanel` overlay with insert, per-item two-step delete confirmation, delete-all with confirmation, empty state, and slide-in animation
- **Drafts** button in the top control row (pencil icon)
- **Save as Draft** floppy-disk icon button in the button wrapper (disabled when input is empty)

### Sound spam fix
- Root cause: `resetSoundState` was called on **every** `thinking` state transition, including mid-task transitions (`coding → thinking → coding`)
- Fix: only reset sound state when entering `thinking` from a clean-slate state (`idle`, `success`, or `error`) — states that genuinely mark the end of one task and the start of a new one

## Test plan
- [ ] Save a draft and verify it persists across app restarts
- [ ] Insert a draft and verify it populates the input
- [ ] Delete individual drafts and verify delete-all works
- [ ] Verify "Working on it!" plays once per user message regardless of how many tools are called

 This PR was created with help from Hikari~ 🌸

Reviewed-on: #174
Co-authored-by: Hikari <hikari@nhcarrigan.com>
Co-committed-by: Hikari <hikari@nhcarrigan.com>
This commit was merged in pull request #174.
This commit is contained in:
2026-02-27 15:07:10 -08:00
committed by Naomi Carrigan
parent fe7027c585
commit 7ebd9dc97a
8 changed files with 807 additions and 4 deletions
+80 -3
View File
@@ -34,7 +34,9 @@
import SnippetLibraryPanel from "$lib/components/SnippetLibraryPanel.svelte";
import QuickActionsPanel from "$lib/components/QuickActionsPanel.svelte";
import ClipboardHistoryPanel from "$lib/components/ClipboardHistoryPanel.svelte";
import DraftPanel from "$lib/components/DraftPanel.svelte";
import TextInputContextMenu from "$lib/components/TextInputContextMenu.svelte";
import { draftsStore } from "$lib/stores/drafts";
import type { Attachment } from "$lib/types/messages";
const INPUT_HISTORY_KEY = "hikari-input-history";
@@ -52,6 +54,7 @@
let showSnippetLibrary = $state(false);
let showQuickActions = $state(false);
let showClipboardHistory = $state(false);
let showDraftPanel = $state(false);
let streamerModeActive = $state(false);
// Cost estimation for pre-submission display
@@ -175,6 +178,14 @@
}
});
function clearInput() {
inputValue = "";
const activeId = get(claudeStore.activeConversationId);
if (activeId) {
claudeStore.setDraftText(activeId, "");
}
}
function handleInputChange() {
// If input is empty, allow history navigation again
// Otherwise, mark that user has manually typed
@@ -212,7 +223,7 @@
async function executeSlashCommand(): Promise<boolean> {
const { command, args } = parseSlashCommand(inputValue);
if (command) {
inputValue = "";
clearInput();
showCommandMenu = false;
matchingCommands = [];
await command.execute(args);
@@ -245,7 +256,7 @@
"error",
`Unknown command: ${message.split(" ")[0]}. Type /help for available commands.`
);
inputValue = "";
clearInput();
return;
}
@@ -261,7 +272,7 @@
userHasTyped = false;
isSubmitting = true;
inputValue = "";
clearInput();
// Capture attachments before clearing
const currentAttachments = [...attachments];
@@ -720,6 +731,22 @@ User: ${formattedMessage}`;
userHasTyped = true;
}
function handleDraftInsert(content: string): void {
inputValue = content;
userHasTyped = true;
const activeId = get(claudeStore.activeConversationId);
if (activeId) {
claudeStore.setDraftText(activeId, content);
}
}
async function handleSaveAsDraft(): Promise<void> {
const content = inputValue.trim();
if (!content) return;
await draftsStore.saveDraft(content);
clearInput();
}
function handleClipboardInsert(content: string): void {
// Insert clipboard content at cursor position or append to input
if (inputValue.trim()) {
@@ -936,6 +963,29 @@ User: ${formattedMessage}`;
<span>Clipboard</span>
</button>
<button
type="button"
onclick={() => (showDraftPanel = true)}
class="control-button"
title="Saved Drafts"
>
<svg
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path
d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"
/>
</svg>
<span>Drafts</span>
</button>
<CliVersion />
<SystemClock />
</div>
@@ -976,6 +1026,29 @@ User: ${formattedMessage}`;
</div>
{/if}
<button
type="button"
onclick={handleSaveAsDraft}
disabled={!inputValue.trim()}
class="attach-button"
title="Save as Draft"
>
<svg
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z" />
<polyline points="17 21 17 13 7 13 7 21" />
<polyline points="7 3 7 8 15 8" />
</svg>
</button>
<button type="button" onclick={handleFilePicker} class="attach-button" title="Attach files">
<svg
width="20"
@@ -1041,6 +1114,10 @@ User: ${formattedMessage}`;
/>
{/if}
{#if showDraftPanel}
<DraftPanel onClose={() => (showDraftPanel = false)} onInsert={handleDraftInsert} />
{/if}
{#if contextMenuShow && textareaElement}
<TextInputContextMenu
x={contextMenuX}