Files
hikari-desktop/src/lib/stores/quickActions.ts
T
hikari 4c46d4c8fd
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 54s
CI / Lint & Test (push) Successful in 14m42s
CI / Build Linux (push) Successful in 19m4s
CI / Build Windows (cross-compile) (push) Successful in 28m37s
feat: add multiple productivity features and UI enhancements (#68)
## Summary

This PR adds a collection of productivity features and UI enhancements to improve the Hikari Desktop experience:

### New Features
- **Clipboard History** (#25) - Track and manage copied code snippets with language detection, search, filtering, and pinning
- **Quick Actions Panel** (#15) - Buttons for common quick actions like "Review PR", "Run tests", "Explain file", with customizable actions
- **Git Integration Panel** (#24) - View current branch, changed/staged files, quick git actions (commit, push, pull), and branch management
- **Session Import/Export** (#8) - Export conversations to JSON and import previously saved sessions
- **Snippet Library** (#22) - Save and reuse common prompts with categories and quick insert
- **Session History** (#14) - Auto-save conversations with browsable history and search
- **High Contrast Mode** (#20) - Accessibility theme with improved visibility
- **Minimize to System Tray** (#11) - System tray support with right-click menu

### UI Enhancements
- Trans-pride gradient theme applied across UI elements
- Copy button added to code blocks
- Linter formatting and eslint-disable comments for cleaner code

## Closes

Closes #8
Closes #11
Closes #14
Closes #15
Closes #20
Closes #22
Closes #24
Closes #25
Closes #34
Closes #35
Closes #36
Closes #37
Closes #69
Closes #70

## Test Plan

- [ ] Verify clipboard history captures code from code block copy buttons
- [ ] Verify clipboard history captures manually selected text from terminal
- [ ] Test snippet library CRUD operations and insertion
- [ ] Test quick actions panel with default and custom actions
- [ ] Test git panel shows correct status, branch, and performs git operations
- [ ] Test session history auto-save and restore
- [ ] Test session import/export roundtrip
- [ ] Verify high contrast mode provides adequate contrast
- [ ] Test minimize to tray functionality and tray menu
- [ ] Verify trans-pride gradient theme displays correctly in all themes

---
* This PR was created with help from Hikari~ 🌸*

Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Reviewed-on: #68
Co-authored-by: Hikari <hikari@nhcarrigan.com>
Co-committed-by: Hikari <hikari@nhcarrigan.com>
2026-01-25 22:19:00 -08:00

115 lines
2.8 KiB
TypeScript

import { writable } from "svelte/store";
import { invoke } from "@tauri-apps/api/core";
export interface QuickAction {
id: string;
name: string;
prompt: string;
icon: string;
is_default: boolean;
created_at: string;
updated_at: string;
}
function createQuickActionsStore() {
const actions = writable<QuickAction[]>([]);
const isLoading = writable(false);
async function loadQuickActions(): Promise<void> {
isLoading.set(true);
try {
const actionList = await invoke<QuickAction[]>("list_quick_actions");
actions.set(actionList);
} catch (error) {
console.error("Failed to load quick actions:", error);
} finally {
isLoading.set(false);
}
}
async function saveQuickAction(action: QuickAction): Promise<boolean> {
try {
await invoke("save_quick_action", { action });
await loadQuickActions();
return true;
} catch (error) {
console.error("Failed to save quick action:", error);
return false;
}
}
async function createQuickAction(name: string, prompt: string, icon: string): Promise<boolean> {
const now = new Date().toISOString();
const action: QuickAction = {
id: `custom-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`,
name,
prompt,
icon,
is_default: false,
created_at: now,
updated_at: now,
};
return saveQuickAction(action);
}
async function updateQuickAction(
id: string,
name: string,
prompt: string,
icon: string
): Promise<boolean> {
const currentActions = await invoke<QuickAction[]>("list_quick_actions");
const existing = currentActions.find((a) => a.id === id);
if (!existing) {
console.error("Quick action not found for update");
return false;
}
const updated: QuickAction = {
...existing,
name,
prompt,
icon,
updated_at: new Date().toISOString(),
};
return saveQuickAction(updated);
}
async function deleteQuickAction(actionId: string): Promise<boolean> {
try {
await invoke("delete_quick_action", { actionId });
await loadQuickActions();
return true;
} catch (error) {
console.error("Failed to delete quick action:", error);
return false;
}
}
async function resetDefaults(): Promise<boolean> {
try {
await invoke("reset_default_quick_actions");
await loadQuickActions();
return true;
} catch (error) {
console.error("Failed to reset default quick actions:", error);
return false;
}
}
return {
actions: { subscribe: actions.subscribe },
isLoading: { subscribe: isLoading.subscribe },
loadQuickActions,
saveQuickAction,
createQuickAction,
updateQuickAction,
deleteQuickAction,
resetDefaults,
};
}
export const quickActionsStore = createQuickActionsStore();