Compare commits

..

21 Commits

Author SHA1 Message Date
hikari b1a45ed00e feat: add high contrast mode for accessibility
- Add HighContrast variant to Theme enum in Rust backend
- Add high-contrast CSS theme with pure black/white for max contrast
- Use bright saturated colors for syntax highlighting
- Add High Contrast button to theme selector with accessibility tooltip
- Follows WCAG guidelines for contrast ratios

Closes #20
2026-01-25 13:44:52 -08:00
hikari 457722dc3a feat: add minimize to system tray option
Add ability to minimize Hikari to the system tray when closing the window
instead of fully exiting. When enabled, clicking the close button hides
the window and shows a tray icon with "Show Hikari" and "Quit" options.

- Add tray module with system tray setup and menu handling
- Add minimize_to_tray config option in settings
- Handle window close event to hide instead of close when enabled
- Add tray icon click handler to restore window
2026-01-25 13:38:30 -08:00
naomi 852a4d6661 feat: add native clipboard support for screenshot paste (#67)
CI / Lint & Test (push) Successful in 14m34s
CI / Build Linux (push) Successful in 18m19s
CI / Build Windows (cross-compile) (push) Successful in 27m57s
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 1m3s
## Summary
- Adds Tauri clipboard-manager plugin to read images from native clipboard
- Falls back to native clipboard when WebView clipboard API returns empty (fixes screenshot paste)
- Allows sending messages with just attachments (no text required)
- Logs attached files to output with 📎 emoji

## Test plan
- [ ] Build and run the app natively on Windows
- [ ] Copy a screenshot (Win+Shift+S) and paste in the chat input
- [ ] Verify the screenshot appears as an attachment preview
- [ ] Send the attachment and verify Claude receives the file path
- [ ] Test sending a message with only an attachment (no text)
- [ ] Verify the 📎 log line shows the attached filename

**Note:** Paste will not work in WSLg dev environment due to clipboard isolation - needs native Windows build to test.

 This PR was created with help from Hikari~ 🌸

Co-authored-by: Hikari <hikari@nhcarrigan.com>
Reviewed-on: #67
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2026-01-25 13:08:38 -08:00
naomi bbeff7ae2e release: v0.3.0
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 49s
CI / Lint & Test (push) Successful in 14m32s
CI / Build Linux (push) Successful in 15m53s
CI / Build Windows (cross-compile) (push) Successful in 25m32s
2026-01-23 19:08:50 -08:00
naomi 3f30997f0e feat: another wave of features (#61)
CI / Build Linux (push) Has been cancelled
CI / Build Windows (cross-compile) (push) Has been cancelled
Security Scan and Upload / Security & DefectDojo Upload (push) Has been cancelled
CI / Lint & Test (push) Has been cancelled
## Explanation

This PR bundles several user-facing improvements and feature additions for the v0.3.0 release, including quality-of-life improvements to the UI, new slash commands, better state persistence, and auto-update checking.

## Included Changes

- **Resizable chat input** with drag handle (#58 partial)
- **Arrow key navigation fix** - cursor keys now navigate text when user has typed input (#58)
- **Scroll position persistence** per conversation tab
- **/skill command** for invoking Claude Code skills (#57)
- **Stats persistence fix** - stats now persist across session changes, only reset on disconnect (#59)
- **Auto-update checker** on startup (#17)
- **Resizable character panel** with full-height sprites (#10)
- **Font size and zoom settings** with keyboard shortcuts (Ctrl++/Ctrl+-/Ctrl+0) (#19)

## Closes

Closes #10, #17, #19, #57, #58, #59

## Attestations

- [x] I have read and agree to the Code of Conduct
- [x] I have read and agree to the Community Guidelines
- [x] My contribution complies with the Contributor Covenant
- [x] I have run the linter and resolved any errors
- [x] My pull request uses an appropriate title, matching the conventional commit standards
- [x] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request
- [x] All new and existing tests pass locally with my changes
- [x] Code coverage remains at or above the configured threshold

## Documentation

N/A - Internal app features

## Versioning

Minor - My pull request introduces new non-breaking features.

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

Co-authored-by: Hikari <hikari@nhcarrigan.com>
Reviewed-on: #61
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2026-01-23 19:07:22 -08:00
naomi 06810537a9 feat: add AskUserQuestion tool support (#60)
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 53s
CI / Lint & Test (push) Successful in 14m12s
CI / Build Linux (push) Successful in 16m41s
CI / Build Windows (cross-compile) (push) Successful in 27m0s
## Summary

Implements support for Claude's `AskUserQuestion` tool, allowing Claude to ask the user questions with multiple choice options during a conversation.

## Changes

- Add `UserQuestionEvent` and `QuestionOption` types (Rust and TypeScript)
- Detect `AskUserQuestion` in permission denials and emit `claude:question` event
- Create `UserQuestionModal` component with option selection and custom answer input
- Use stop/reconnect approach (same as `PermissionModal`) since Claude API doesn't accept tool_result for permission-denied tools
- Add `pendingQuestion` to conversation store and `hasQuestionPending` derived store

## Technical Notes

We discovered that Claude Code's permission denial system doesn't allow sending tool results back directly - the API rejects them with "unexpected tool_use_id found in tool_result blocks". The solution was to use the same stop/reconnect pattern that permissions use: stop the session, reconnect with context, and include the user's answer in the context restoration message.

## Test Plan

- [x] Build compiles without errors (Rust + TypeScript)
- [x] Question modal appears when Claude uses `AskUserQuestion`
- [x] Can select options and submit answer
- [x] Answer is properly restored to Claude after reconnect

Closes #51

---

 This PR was created with help from Hikari~ 🌸

Co-authored-by: Hikari <hikari@nhcarrigan.com>
Reviewed-on: #60
2026-01-23 14:11:18 -08:00
hikari 94991796be feat: batch of fixes and features (#56)
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 57s
CI / Lint & Test (push) Successful in 14m14s
CI / Build Linux (push) Successful in 16m45s
CI / Build Windows (cross-compile) (push) Successful in 26m50s
## Summary

This PR includes a batch of bug fixes and new features:

### Bug Fixes
- **Links in chat history now open in default browser** instead of navigating within the app
  - Closes #54
- **Allow spaces in tab names** - space key no longer acts like enter when renaming tabs
  - Closes #52

### New Features
- **`/cd` command** - Change the working directory of an active tab with context preservation
  - Closes #55
- **`/search` command** - Search and highlight matches within the conversation
  - Closes #32

## Test Plan
- [ ] Click a link in chat history and verify it opens in the default browser
- [ ] Rename a tab and verify spaces can be typed
- [ ] Use `/cd <path>` and verify the directory changes while preserving conversation context
- [ ] Use `/search <query>` and verify matches are highlighted in yellow
- [ ] Use `/search` with no args to clear the search highlighting

 This PR was created with help from Hikari~ 🌸

Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Reviewed-on: #56
Co-authored-by: Hikari <hikari@nhcarrigan.com>
Co-committed-by: Hikari <hikari@nhcarrigan.com>
2026-01-23 11:59:21 -08:00
naomi 947e56ef41 feat: naomi did too much at once (#53)
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 53s
CI / Lint & Test (push) Successful in 14m10s
CI / Build Linux (push) Successful in 16m47s
CI / Build Windows (cross-compile) (push) Successful in 26m36s
- feat: add slash commands
- feat: toggle window always on top
- fix: save settings button closes settings panel
- feat: input history (both text and commands)
- feat: add keyboard shortcuts
- feat: add confirmation modal when closing connected tabs
- fix: better text colours in light mode
- fix: handle multiple tabs requesting permission

Closes #6
Closes #13
Closes #21
Closes #28

Reviewed-on: #53
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2026-01-21 17:38:36 -08:00
naomi 9fe4e8a48a feat: add markdown renderer and code block highlighting (#50)
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 56s
CI / Lint & Test (push) Successful in 14m14s
CI / Build Linux (push) Successful in 16m45s
CI / Build Windows (cross-compile) (push) Successful in 26m51s
### Explanation

_No response_

### Issue

Closes #33 Closes #31

### Attestations

- [ ] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/)
- [ ] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/).
- [ ] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/).

### Dependencies

- [ ] I have pinned the dependencies to a specific patch version.

### Style

- [ ] I have run the linter and resolved any errors.
- [ ] My pull request uses an appropriate title, matching the conventional commit standards.
- [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request.

### Tests

- [ ] My contribution adds new code, and I have added tests to cover it.
- [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes.
- [ ] All new and existing tests pass locally with my changes.
- [ ] Code coverage remains at or above the configured threshold.

### Documentation

_No response_

### Versioning

_No response_

Reviewed-on: #50
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2026-01-21 11:28:09 -08:00
naomi bc596867d4 release: v0.2.0
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 51s
CI / Lint & Test (push) Successful in 14m13s
CI / Build Linux (push) Successful in 16m38s
CI / Build Windows (cross-compile) (push) Successful in 26m43s
2026-01-20 20:37:36 -08:00
naomi e877f4aaf2 chore: clean up the sprites (#49)
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 1m1s
CI / Lint & Test (push) Successful in 14m51s
CI / Build Linux (push) Has been cancelled
CI / Build Windows (cross-compile) (push) Has been cancelled
### Explanation

_No response_

### Issue

Closes #9

### Attestations

- [ ] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/)
- [ ] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/).
- [ ] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/).

### Dependencies

- [ ] I have pinned the dependencies to a specific patch version.

### Style

- [ ] I have run the linter and resolved any errors.
- [ ] My pull request uses an appropriate title, matching the conventional commit standards.
- [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request.

### Tests

- [ ] My contribution adds new code, and I have added tests to cover it.
- [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes.
- [ ] All new and existing tests pass locally with my changes.
- [ ] Code coverage remains at or above the configured threshold.

### Documentation

_No response_

### Versioning

_No response_

Reviewed-on: #49
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2026-01-20 20:19:34 -08:00
naomi 377f81d978 feat: add about and help panels, donate button, and live setting update (#48)
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 52s
CI / Lint & Test (push) Successful in 14m11s
CI / Build Linux (push) Has been cancelled
CI / Build Windows (cross-compile) (push) Has been cancelled
### Explanation

_No response_

### Issue

Closes #26 Closes #27

### Attestations

- [ ] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/)
- [ ] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/).
- [ ] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/).

### Dependencies

- [ ] I have pinned the dependencies to a specific patch version.

### Style

- [ ] I have run the linter and resolved any errors.
- [ ] My pull request uses an appropriate title, matching the conventional commit standards.
- [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request.

### Tests

- [ ] My contribution adds new code, and I have added tests to cover it.
- [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes.
- [ ] All new and existing tests pass locally with my changes.
- [ ] Code coverage remains at or above the configured threshold.

### Documentation

_No response_

### Versioning

_No response_

Reviewed-on: #48
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2026-01-20 20:04:03 -08:00
naomi d83697e5cf feat: add ability to run multiple agents via tabbed views (#47)
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 54s
CI / Lint & Test (push) Successful in 14m18s
CI / Build Linux (push) Successful in 16m46s
CI / Build Windows (cross-compile) (push) Successful in 26m39s
### Explanation

_No response_

### Issue

Closes #30 Closes #41

### Attestations

- [ ] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/)
- [ ] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/).
- [ ] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/).

### Dependencies

- [ ] I have pinned the dependencies to a specific patch version.

### Style

- [ ] I have run the linter and resolved any errors.
- [ ] My pull request uses an appropriate title, matching the conventional commit standards.
- [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request.

### Tests

- [ ] My contribution adds new code, and I have added tests to cover it.
- [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes.
- [ ] All new and existing tests pass locally with my changes.
- [ ] Code coverage remains at or above the configured threshold.

### Documentation

_No response_

### Versioning

_No response_

Reviewed-on: #47
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2026-01-20 13:57:48 -08:00
naomi 2d3adcab1c feat: add chat modes and interrupt feature (#46)
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 52s
CI / Lint & Test (push) Successful in 14m15s
CI / Build Linux (push) Successful in 16m37s
CI / Build Windows (cross-compile) (push) Successful in 26m35s
### Explanation

_No response_

### Issue

Closes #40

### Attestations

- [ ] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/)
- [ ] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/).
- [ ] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/).

### Dependencies

- [ ] I have pinned the dependencies to a specific patch version.

### Style

- [ ] I have run the linter and resolved any errors.
- [ ] My pull request uses an appropriate title, matching the conventional commit standards.
- [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request.

### Tests

- [ ] My contribution adds new code, and I have added tests to cover it.
- [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes.
- [ ] All new and existing tests pass locally with my changes.
- [ ] Code coverage remains at or above the configured threshold.

### Documentation

_No response_

### Versioning

_No response_

Reviewed-on: #46
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2026-01-20 08:33:39 -08:00
naomi 70fcaa8650 feat: stats and achievements (#45)
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 53s
CI / Lint & Test (push) Successful in 14m11s
CI / Build Linux (push) Successful in 16m47s
CI / Build Windows (cross-compile) (push) Successful in 26m56s
### Explanation

_No response_

### Issue

Closes #39

### Attestations

- [ ] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/)
- [ ] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/).
- [ ] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/).

### Dependencies

- [ ] I have pinned the dependencies to a specific patch version.

### Style

- [ ] I have run the linter and resolved any errors.
- [ ] My pull request uses an appropriate title, matching the conventional commit standards.
- [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request.

### Tests

- [ ] My contribution adds new code, and I have added tests to cover it.
- [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes.
- [ ] All new and existing tests pass locally with my changes.
- [ ] Code coverage remains at or above the configured threshold.

### Documentation

_No response_

### Versioning

_No response_

Reviewed-on: #45
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2026-01-19 20:51:53 -08:00
naomi a8f98406e1 feat: add notification sounds (#44)
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 54s
CI / Lint & Test (push) Successful in 14m2s
CI / Build Linux (push) Successful in 16m38s
CI / Build Windows (cross-compile) (push) Successful in 26m27s
### Explanation

_No response_

### Issue

_No response_

### Attestations

- [ ] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/)
- [ ] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/).
- [ ] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/).

### Dependencies

- [ ] I have pinned the dependencies to a specific patch version.

### Style

- [ ] I have run the linter and resolved any errors.
- [ ] My pull request uses an appropriate title, matching the conventional commit standards.
- [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request.

### Tests

- [ ] My contribution adds new code, and I have added tests to cover it.
- [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes.
- [ ] All new and existing tests pass locally with my changes.
- [ ] Code coverage remains at or above the configured threshold.

### Documentation

_No response_

### Versioning

_No response_

Reviewed-on: #44
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2026-01-19 16:18:25 -08:00
naomi 0065bb4afc fix: reconnect bug, don't greet on reconnects (#43)
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 48s
CI / Lint & Test (push) Successful in 14m8s
CI / Build Linux (push) Successful in 16m25s
CI / Build Windows (cross-compile) (push) Successful in 26m35s
### Explanation

_No response_

### Issue

_No response_

### Attestations

- [ ] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/)
- [ ] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/).
- [ ] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/).

### Dependencies

- [ ] I have pinned the dependencies to a specific patch version.

### Style

- [ ] I have run the linter and resolved any errors.
- [ ] My pull request uses an appropriate title, matching the conventional commit standards.
- [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request.

### Tests

- [ ] My contribution adds new code, and I have added tests to cover it.
- [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes.
- [ ] All new and existing tests pass locally with my changes.
- [ ] Code coverage remains at or above the configured threshold.

### Documentation

_No response_

### Versioning

_No response_

Reviewed-on: #43
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2026-01-19 13:46:51 -08:00
naomi ac84366716 feat: add automatic greeting upon connection (#42)
CI / Lint & Test (push) Successful in 14m0s
CI / Build Linux (push) Successful in 16m33s
CI / Build Windows (cross-compile) (push) Successful in 26m23s
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 1m5s
### Explanation

_No response_

### Issue

Closes #23

### Attestations

- [ ] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/)
- [ ] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/).
- [ ] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/).

### Dependencies

- [ ] I have pinned the dependencies to a specific patch version.

### Style

- [ ] I have run the linter and resolved any errors.
- [ ] My pull request uses an appropriate title, matching the conventional commit standards.
- [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request.

### Tests

- [ ] My contribution adds new code, and I have added tests to cover it.
- [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes.
- [ ] All new and existing tests pass locally with my changes.
- [ ] Code coverage remains at or above the configured threshold.

### Documentation

_No response_

### Versioning

_No response_

Reviewed-on: #42
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2026-01-16 15:10:28 -08:00
naomi 2220c26c5e feat: add ability to configure the agent (also theme switcher) (#3)
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 57s
CI / Lint & Test (push) Successful in 13m59s
CI / Build Linux (push) Successful in 16m25s
CI / Build Windows (cross-compile) (push) Successful in 26m30s
### Explanation

_No response_

### Issue

_No response_

### Attestations

- [ ] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/)
- [ ] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/).
- [ ] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/).

### Dependencies

- [ ] I have pinned the dependencies to a specific patch version.

### Style

- [ ] I have run the linter and resolved any errors.
- [ ] My pull request uses an appropriate title, matching the conventional commit standards.
- [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request.

### Tests

- [ ] My contribution adds new code, and I have added tests to cover it.
- [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes.
- [ ] All new and existing tests pass locally with my changes.
- [ ] Code coverage remains at or above the configured threshold.

### Documentation

_No response_

### Versioning

_No response_

Reviewed-on: #3
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2026-01-16 11:56:17 -08:00
naomi c241544743 feat(tools): set up proper CI (#2)
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 57s
CI / Lint & Test (push) Successful in 14m1s
CI / Build Linux (push) Successful in 16m8s
CI / Build Windows (cross-compile) (push) Successful in 26m18s
### Explanation

_No response_

### Issue

_No response_

### Attestations

- [ ] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/)
- [ ] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/).
- [ ] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/).

### Dependencies

- [ ] I have pinned the dependencies to a specific patch version.

### Style

- [ ] I have run the linter and resolved any errors.
- [ ] My pull request uses an appropriate title, matching the conventional commit standards.
- [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request.

### Tests

- [ ] My contribution adds new code, and I have added tests to cover it.
- [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes.
- [ ] All new and existing tests pass locally with my changes.
- [ ] Code coverage remains at or above the configured threshold.

### Documentation

_No response_

### Versioning

_No response_

Reviewed-on: #2
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2026-01-15 20:06:47 -08:00
naomi bd04328e40 feat: add windows build woooooo (#1)
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 51s
### Explanation

_No response_

### Issue

_No response_

### Attestations

- [x] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/)
- [x] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/).
- [x] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/).

### Dependencies

- [ ] I have pinned the dependencies to a specific patch version.

### Style

- [ ] I have run the linter and resolved any errors.
- [ ] My pull request uses an appropriate title, matching the conventional commit standards.
- [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request.

### Tests

- [ ] My contribution adds new code, and I have added tests to cover it.
- [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes.
- [ ] All new and existing tests pass locally with my changes.
- [ ] Code coverage remains at or above the configured threshold.

### Documentation

_No response_

### Versioning

Minor - My pull request introduces a new non-breaking feature.

Reviewed-on: #1
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
2026-01-15 10:05:22 -08:00
156 changed files with 15298 additions and 605 deletions
+1
View File
@@ -8,3 +8,4 @@
*.jpg binary *.jpg binary
*.icons binary *.icons binary
*.ico binary *.ico binary
*.icns binary
+2 -3
View File
@@ -1,6 +1,6 @@
name: 🐛 Bug Report name: 🐛 Bug Report
description: Something isn't working as expected? Let us know! description: Something isn't working as expected? Let us know!
title: '[BUG] - ' title: "[BUG] - "
labels: labels:
- "status/awaiting triage" - "status/awaiting triage"
body: body:
@@ -50,7 +50,7 @@ body:
description: The operating system you are using, including the version/build number. description: The operating system you are using, including the version/build number.
validations: validations:
required: true required: true
# Remove this section for non-web apps. # Remove this section for non-web apps.
- type: input - type: input
id: browser id: browser
attributes: attributes:
@@ -66,4 +66,3 @@ body:
- No - No
validations: validations:
required: true required: true
+1 -1
View File
@@ -1,6 +1,6 @@
name: 💭 Feature Proposal name: 💭 Feature Proposal
description: Have an idea for how we can improve? Share it here! description: Have an idea for how we can improve? Share it here!
title: '[FEAT] - ' title: "[FEAT] - "
labels: labels:
- "status/awaiting triage" - "status/awaiting triage"
body: body:
+1 -1
View File
@@ -1,6 +1,6 @@
name: ❓ Other Issue name: ❓ Other Issue
description: I have something that is neither a bug nor a feature request. description: I have something that is neither a bug nor a feature request.
title: '[OTHER] - ' title: "[OTHER] - "
labels: labels:
- "status/awaiting triage" - "status/awaiting triage"
body: body:
+189
View File
@@ -0,0 +1,189 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
lint-and-test:
name: Lint & Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
librsvg2-dev \
patchelf \
libgtk-3-dev \
libayatana-appindicator3-dev
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Install frontend dependencies
run: pnpm install
- name: Run ESLint
run: pnpm lint
- name: Run Prettier check
run: pnpm format:check
- name: Run Svelte Check
run: pnpm check
- name: Run frontend tests
run: pnpm test
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
src-tauri/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run Clippy
working-directory: src-tauri
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run Rust tests
working-directory: src-tauri
run: cargo test
build-linux:
name: Build Linux
runs-on: ubuntu-latest
needs: lint-and-test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
librsvg2-dev \
patchelf \
libgtk-3-dev \
libayatana-appindicator3-dev \
xdg-utils
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Install frontend dependencies
run: pnpm install
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
src-tauri/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build Linux
run: pnpm build:linux
build-windows:
name: Build Windows (cross-compile)
runs-on: ubuntu-latest
needs: lint-and-test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Linux dependencies for cross-compilation
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
librsvg2-dev \
patchelf \
libgtk-3-dev \
libayatana-appindicator3-dev \
clang \
lld \
llvm \
nsis
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Install frontend dependencies
run: pnpm install
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc
- name: Install cargo-xwin
run: |
curl -fsSL https://github.com/rust-cross/cargo-xwin/releases/download/v0.20.2/cargo-xwin-v0.20.2.x86_64-unknown-linux-musl.tar.gz | tar xz
sudo mv cargo-xwin /usr/local/bin/
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
src-tauri/target/
key: ${{ runner.os }}-cargo-windows-${{ hashFiles('**/Cargo.lock') }}
- name: Build Windows
run: pnpm build:windows
+3 -3
View File
@@ -2,11 +2,11 @@ name: Security Scan and Upload
on: on:
push: push:
branches: [ main ] branches: [main]
pull_request: pull_request:
branches: [ main ] branches: [main]
schedule: schedule:
- cron: '0 0 * * 1' - cron: "0 0 * * 1"
workflow_dispatch: workflow_dispatch:
jobs: jobs:
+8
View File
@@ -0,0 +1,8 @@
build/
.svelte-kit/
dist/
src-tauri/target/
src-tauri/gen/
node_modules/
.pnpm-store/
pnpm-lock.yaml
+16
View File
@@ -0,0 +1,16 @@
{
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"overrides": [
{
"files": "*.svelte",
"options": {
"parser": "svelte"
}
}
]
}
+1 -5
View File
@@ -1,7 +1,3 @@
{ {
"recommendations": [ "recommendations": ["svelte.svelte-vscode", "tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"]
"svelte.svelte-vscode",
"tauri-apps.tauri-vscode",
"rust-lang.rust-analyzer"
]
} }
+1 -146
View File
@@ -1,146 +1 @@
# Hikari Desktop tem
A Linux desktop application that wraps Claude Code with an anime girl character that reacts to Claude's activities in real-time.
## Features
- Visual character that reflects Claude's current state (thinking, typing, searching, coding, etc.)
- Terminal-style output display
- Permission prompts with approve/deny interface
- Real-time state detection from Claude Code's NDJSON stream
## Installation
### 1. Install Claude Code
Hikari Desktop requires Claude Code to be installed and authenticated:
```bash
npm install -g @anthropic-ai/claude-code
claude # Follow the prompts to authenticate
```
### 2. Install Runtime Dependencies
**Debian/Ubuntu:**
```bash
sudo apt install libwebkit2gtk-4.1-0 libgtk-3-0 libayatana-appindicator3-1 xdg-utils
```
**Fedora:**
```bash
sudo dnf install webkit2gtk4.1 gtk3 libappindicator-gtk3 xdg-utils
```
**Arch Linux:**
```bash
sudo pacman -S webkit2gtk-4.1 gtk3 libappindicator-gtk3 xdg-utils
```
| Package | Purpose |
|---------|---------|
| webkit2gtk-4.1 | WebView rendering (app UI) |
| gtk3 | Window management and native widgets |
| libappindicator | System tray support |
| xdg-utils | Opening URLs/files with default applications |
### 3. Install Hikari Desktop
Download the latest release for your distribution:
**AppImage** (any distro):
```bash
chmod +x hikari-desktop_*.AppImage
./hikari-desktop_*.AppImage
```
**Debian/Ubuntu:**
```bash
sudo dpkg -i hikari-desktop_*.deb
```
**Fedora:**
```bash
sudo rpm -i hikari-desktop-*.rpm
```
## Character States
| State | Trigger |
|-------|---------|
| Idle | Waiting for user input |
| Thinking | Processing/API call in progress |
| Typing | Streaming text output |
| Searching | Using Read/Glob/Grep tools |
| Coding | Using Edit/Write tools |
| MCP | Running MCP tool calls |
| Permission | Permission prompt needed |
| Success | Task completed |
| Error | Error occurred |
## Building from Source
### Prerequisites
- Node.js and pnpm
- Rust toolchain
### Build
```bash
# Install dependencies
pnpm install
# Development mode
pnpm run dev
# Build for Linux
pnpm tauri build
```
## Architecture
```
Linux (Tauri App)
├── Svelte Frontend
│ ├── AnimeGirl (sprites + animations)
│ ├── Terminal (output display)
│ ├── InputBar (user input)
│ └── PermissionModal (approve/deny)
└── Rust Backend
├── Process Manager (spawn & communicate)
└── State Parser (NDJSON → character state)
│ stdin/stdout (NDJSON stream)
claude -p --output-format stream-json --input-format stream-json
```
## Tech Stack
- **Tauri 2.x** - Desktop framework with Rust backend
- **Svelte 5** - Reactive frontend with runes
- **Tailwind CSS** - Styling
- **Tokio** - Async runtime for process management
## Feedback and Bugs
If you have feedback or a bug report, please feel free to open a ticket request in our [Discord](https://chat.nhcarrigan.com)!
## Contributing
If you would like to contribute to the project, you may create a Pull Request containing your proposed changes and we will review it as soon as we are able! Please review our [contributing guidelines](CONTRIBUTING.md) first.
## Code of Conduct
Before interacting with our community, please read our [Code of Conduct](CODE_OF_CONDUCT.md).
## License
This software is licensed under our [global software license](https://docs.nhcarrigan.com/#/license).
Copyright held by Naomi Carrigan.
## Contact
We may be contacted through our [Chat Server](http://chat.nhcarrigan.com) or via email at `contact@nhcarrigan.com`.
+74
View File
@@ -0,0 +1,74 @@
# Hikari Desktop v0.3.0 Release Notes
## New Features
### AskUserQuestion Tool Support (#51)
- Claude can now ask you questions with multiple choice options during conversations
- A dedicated modal appears with answer choices and support for custom responses
- Answers are seamlessly integrated back into the conversation context
### Slash Commands
- `/cd <path>` - Change the working directory while preserving conversation context (#55)
- `/search <query>` - Search and highlight matches within the conversation (#32)
- `/skill <name> [data]` - Invoke Claude Code skills from `~/.claude/skills/` (#57)
- `/new`, `/clear`, `/rename`, `/help` commands for conversation management (#6)
### Auto-Update Checker (#17)
- Automatically checks for new releases on startup
- Notification appears when a newer version is available
- Can be disabled in settings
### Font Size & Zoom (#19)
- Adjust font size with keyboard shortcuts: `Ctrl++`, `Ctrl+-`, `Ctrl+0`
- Font size slider in settings (10-24px range)
- Preference persists between sessions
### Resizable Character Panel (#10)
- Drag the divider between the character panel and terminal to resize
- Panel width is saved and restored on app restart
- Sprite now uses full height for better proportions
### Input History Navigation (#13)
- Use up/down arrows to navigate through previous messages and commands
- Arrow keys only navigate history when input is empty - otherwise they move the cursor (#58)
### Keyboard Shortcuts (#21)
- `Ctrl+N` - New conversation
- `Ctrl+W` - Close current tab
- `Ctrl+Tab` / `Ctrl+Shift+Tab` - Switch between tabs
- `Ctrl+L` - Clear conversation
- `Ctrl+,` - Open settings
### Always On Top Toggle (#28)
- Pin the window to stay above other applications
- Toggle in settings
## Improvements
### UI/UX
- Resizable chat input with drag handle (expands upward)
- Send button properly aligned with input field
- Markdown rendering with syntax-highlighted code blocks (#31, #33)
- Light mode text colors improved for better readability
- Scroll position persists per conversation tab when switching
- Confirmation modal when closing connected tabs
- Links in chat now open in default browser (#54)
- Spaces allowed when renaming tabs (#52)
### State Management
- Stats (tokens, cost) persist across session changes and only reset on disconnect (#59)
- Multiple tabs can now request permissions simultaneously without conflicts
## Closed Issues
#6, #10, #13, #17, #19, #21, #28, #31, #32, #33, #51, #52, #54, #55, #57, #58, #59
Executable
+51
View File
@@ -0,0 +1,51 @@
#!/bin/bash
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to run a command and check its status
run_check() {
local desc=$1
local cmd=$2
echo -e "\n${YELLOW}Running: ${desc}${NC}"
echo -e "${YELLOW}Command: ${cmd}${NC}"
if eval "$cmd"; then
echo -e "${GREEN}${desc} passed${NC}"
return 0
else
echo -e "${RED}${desc} failed${NC}"
return 1
fi
}
# Track if any checks fail
failed=0
echo -e "${YELLOW}🔍 Running all checks for Hikari Desktop...${NC}"
# Frontend checks
run_check "Frontend lint" "pnpm lint" || failed=1
run_check "Frontend format check" "pnpm format:check" || failed=1
run_check "Frontend type check" "pnpm check" || failed=1
run_check "Frontend tests" "pnpm test" || failed=1
# Backend checks
run_check "Backend clippy (strict)" "cd src-tauri && cargo clippy --all-targets --all-features -- -D warnings" || failed=1
run_check "Backend tests" "cargo test" || failed=1
# Summary
echo -e "\n${YELLOW}========================================${NC}"
if [ $failed -eq 0 ]; then
echo -e "${GREEN}✨ All checks passed! The code is looking great!${NC}"
echo -e "${GREEN} Naomi would be so proud of us! 💖${NC}"
exit 0
else
echo -e "${RED}❌ Some checks failed. Let's fix them together!${NC}"
echo -e "${RED} Don't worry, we'll get through this! 💪${NC}"
exit 1
fi
+32
View File
@@ -0,0 +1,32 @@
import js from "@eslint/js";
import tseslint from "typescript-eslint";
import svelte from "eslint-plugin-svelte";
import prettier from "eslint-config-prettier";
import globals from "globals";
export default tseslint.config(
js.configs.recommended,
...tseslint.configs.recommended,
...svelte.configs["flat/recommended"],
prettier,
...svelte.configs["flat/prettier"],
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
},
},
{
files: ["**/*.svelte", "**/*.svelte.ts", "**/*.svelte.js"],
languageOptions: {
parserOptions: {
parser: tseslint.parser,
},
},
},
{
ignores: ["build/", ".svelte-kit/", "dist/", "src-tauri/target/", "node_modules/"],
}
);
+32 -4
View File
@@ -1,6 +1,6 @@
{ {
"name": "hikari-desktop", "name": "hikari-desktop",
"version": "0.1.0", "version": "0.3.0",
"description": "", "description": "",
"type": "module", "type": "module",
"scripts": { "scripts": {
@@ -9,25 +9,53 @@
"preview": "vite preview", "preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"tauri": "tauri" "tauri": "tauri",
"build:linux": "tauri build",
"build:windows": "tauri build --runner cargo-xwin --target x86_64-pc-windows-msvc",
"build:all": "pnpm build:linux && pnpm build:windows",
"test": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"format": "prettier --write .",
"format:check": "prettier --check ."
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@tauri-apps/api": "^2", "@tauri-apps/api": "^2",
"@tauri-apps/plugin-clipboard-manager": "^2.3.2",
"@tauri-apps/plugin-dialog": "^2", "@tauri-apps/plugin-dialog": "^2",
"@tauri-apps/plugin-notification": "^2",
"@tauri-apps/plugin-opener": "^2", "@tauri-apps/plugin-opener": "^2",
"@tauri-apps/plugin-shell": "^2.3.4" "@tauri-apps/plugin-os": "^2",
"@tauri-apps/plugin-shell": "^2.3.4",
"@tauri-apps/plugin-store": "^2",
"highlight.js": "^11.11.1",
"marked": "^17.0.1"
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "^9.39.2",
"@sveltejs/adapter-static": "^3.0.6", "@sveltejs/adapter-static": "^3.0.6",
"@sveltejs/kit": "^2.9.0", "@sveltejs/kit": "^2.9.0",
"@sveltejs/vite-plugin-svelte": "^5.0.0", "@sveltejs/vite-plugin-svelte": "^5.0.0",
"@tailwindcss/vite": "^4.1.18", "@tailwindcss/vite": "^4.1.18",
"@tauri-apps/cli": "^2", "@tauri-apps/cli": "^2",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/svelte": "^5.3.1",
"eslint": "^9.39.2",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-svelte": "^3.14.0",
"globals": "^17.0.0",
"jsdom": "^27.4.0",
"prettier": "^3.8.0",
"prettier-plugin-svelte": "^3.4.1",
"svelte": "^5.0.0", "svelte": "^5.0.0",
"svelte-check": "^4.0.0", "svelte-check": "^4.0.0",
"tailwindcss": "^4.1.18", "tailwindcss": "^4.1.18",
"typescript": "~5.6.2", "typescript": "~5.6.2",
"vite": "^6.0.3" "typescript-eslint": "^8.53.0",
"vite": "^6.0.3",
"vitest": "^4.0.17"
} }
} }
+1857
View File
File diff suppressed because it is too large Load Diff
+1020 -21
View File
File diff suppressed because it is too large Load Diff
+18 -2
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "hikari-desktop" name = "hikari-desktop"
version = "0.1.0" version = "0.3.0"
description = "Hikari - Claude Code Visual Assistant" description = "Hikari - Claude Code Visual Assistant"
authors = ["Naomi Carrigan"] authors = ["Naomi Carrigan"]
edition = "2021" edition = "2021"
@@ -13,7 +13,7 @@ crate-type = ["staticlib", "cdylib", "rlib"]
tauri-build = { version = "2", features = [] } tauri-build = { version = "2", features = [] }
[dependencies] [dependencies]
tauri = { version = "2", features = [] } tauri = { version = "2", features = ["tray-icon", "image-png"] }
tauri-plugin-dialog = "2" tauri-plugin-dialog = "2"
tauri-plugin-opener = "2" tauri-plugin-opener = "2"
tauri-plugin-shell = "2" tauri-plugin-shell = "2"
@@ -22,4 +22,20 @@ serde_json = "1"
tokio = { version = "1", features = ["full"] } tokio = { version = "1", features = ["full"] }
parking_lot = "0.12" parking_lot = "0.12"
uuid = { version = "1", features = ["v4"] } uuid = { version = "1", features = ["v4"] }
tauri-plugin-store = "2.4.2"
tauri-plugin-notification = "2"
tauri-plugin-os = "2"
tauri-plugin-http = "2"
tauri-plugin-clipboard-manager = "2"
tempfile = "3"
semver = "1"
chrono = { version = "0.4.43", features = ["serde"] }
[target.'cfg(windows)'.dependencies]
windows = { version = "0.62", features = [
"Data_Xml_Dom",
"UI_Notifications",
"Win32_System_Com",
"Win32_Foundation",
] }
+8 -1
View File
@@ -9,6 +9,13 @@
"opener:default", "opener:default",
"shell:allow-spawn", "shell:allow-spawn",
"shell:allow-stdin-write", "shell:allow-stdin-write",
"shell:allow-kill" "shell:allow-kill",
"notification:default",
"notification:allow-is-permission-granted",
"notification:allow-request-permission",
"notification:allow-notify",
"clipboard-manager:default",
"clipboard-manager:allow-read-image",
"core:tray:default"
] ]
} }
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 974 B

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 903 B

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<background android:drawable="@color/ic_launcher_background"/>
</adaptive-icon>
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#fff</color>
</resources>
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 878 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

+833
View File
@@ -0,0 +1,833 @@
use chrono::{DateTime, Datelike, Timelike, Utc};
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use tauri_plugin_store::StoreExt;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub enum AchievementId {
// Token Milestones
FirstSteps, // 1,000 tokens
GrowingStrong, // 10,000 tokens
BlossomingCoder, // 100,000 tokens
TokenMaster, // 1,000,000 tokens
// Code Generation
HelloWorld, // First code block
CodeWizard, // 100 code blocks
ThousandBlocks, // 1,000 code blocks
// File Operations
FileManipulator, // 10 files edited
FileArchitect, // 100 files edited
// Conversation milestones
ConversationStarter, // 10 messages
ChattyKathy, // 100 messages
Conversationalist, // 1,000 messages
// Tool usage
Toolsmith, // 5 different tools
ToolMaster, // 10 different tools
// Time-based achievements
EarlyBird, // Started session 5-7 AM
NightOwl, // Coding after midnight
AllNighter, // Worked 2-5 AM
WeekendWarrior, // Coding on weekend
DedicatedDeveloper, // 30 days in a row
// Search and exploration
Explorer, // 50 searches
MasterSearcher, // 500 searches
// Session achievements
QuickSession, // Productive session < 5 min
FocusedWork, // 30 min session
DeepDive, // 2 hour session
MarathonSession, // 5+ hour session
// Special achievements
FirstMessage, // First message sent
FirstTool, // First tool used
FirstCodeBlock, // First code generated
FirstFileEdit, // First file edit
Polyglot, // 5+ languages in one session
SpeedCoder, // 10 code blocks in 10 minutes
ClaudeConnoisseur, // Used all Claude models
MarathonCoder, // 10k tokens in one session
// Relationship & Greetings
GoodMorning, // Say "good morning"
GoodNight, // Say "good night" or "goodnight"
ThankYou, // Say "thank you" or "thanks"
LoveYou, // Say "love you" or "ily"
// Personality & Fun
EmojiUser, // Use an emoji in a message
QuestionMaster, // Use "?" in 20 messages
CapsLock, // Send a message in ALL CAPS
PleaseAndThankYou, // Use "please" in messages
// Git & Development
GitGuru, // Use git commands 10 times
TestWriter, // Create test files
Debugger, // Fix bugs (messages with "fix", "bug", "error")
// Tool Mastery
BashMaster, // Use Bash tool 50 times
FileExplorer, // Use Read tool 100 times
SearchExpert, // Use Grep tool 50 times
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Achievement {
pub id: AchievementId,
pub name: String,
pub description: String,
pub icon: String,
pub unlocked_at: Option<DateTime<Utc>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AchievementProgress {
pub unlocked: HashSet<AchievementId>,
pub newly_unlocked: Vec<AchievementId>, // Achievements unlocked but not yet notified
#[serde(skip)]
pub session_start: Option<DateTime<Utc>>,
}
impl AchievementProgress {
pub fn new() -> Self {
Self {
unlocked: HashSet::new(),
newly_unlocked: Vec::new(),
session_start: None,
}
}
pub fn unlock(&mut self, achievement: AchievementId) -> bool {
if self.unlocked.insert(achievement.clone()) {
self.newly_unlocked.push(achievement);
true
} else {
false
}
}
#[cfg(test)]
pub fn take_newly_unlocked(&mut self) -> Vec<AchievementId> {
std::mem::take(&mut self.newly_unlocked)
}
#[cfg(test)]
pub fn is_unlocked(&self, achievement: &AchievementId) -> bool {
self.unlocked.contains(achievement)
}
pub fn start_session(&mut self) {
self.session_start = Some(Utc::now());
}
}
impl Default for AchievementProgress {
fn default() -> Self {
Self::new()
}
}
pub fn get_achievement_info(id: &AchievementId) -> Achievement {
match id {
// Token Milestones
AchievementId::FirstSteps => Achievement {
id: id.clone(),
name: "First Steps!".to_string(),
description: "Used 1,000 tokens".to_string(),
icon: "🌱".to_string(),
unlocked_at: None,
},
AchievementId::GrowingStrong => Achievement {
id: id.clone(),
name: "Growing Strong!".to_string(),
description: "Used 10,000 tokens".to_string(),
icon: "🌸".to_string(),
unlocked_at: None,
},
AchievementId::BlossomingCoder => Achievement {
id: id.clone(),
name: "Blossoming Coder!".to_string(),
description: "Used 100,000 tokens".to_string(),
icon: "🌺".to_string(),
unlocked_at: None,
},
AchievementId::TokenMaster => Achievement {
id: id.clone(),
name: "Token Master!".to_string(),
description: "Used 1,000,000 tokens".to_string(),
icon: "🌟".to_string(),
unlocked_at: None,
},
// Code Generation
AchievementId::HelloWorld => Achievement {
id: id.clone(),
name: "Hello World!".to_string(),
description: "Generated your first code block".to_string(),
icon: "📝".to_string(),
unlocked_at: None,
},
AchievementId::CodeWizard => Achievement {
id: id.clone(),
name: "Code Wizard!".to_string(),
description: "Generated 100 code blocks".to_string(),
icon: "🎯".to_string(),
unlocked_at: None,
},
AchievementId::ThousandBlocks => Achievement {
id: id.clone(),
name: "Thousand Blocks".to_string(),
description: "1,000 code blocks! You're a code machine!".to_string(),
icon: "🏗️".to_string(),
unlocked_at: None,
},
// File Operations
AchievementId::FileManipulator => Achievement {
id: id.clone(),
name: "File Manipulator".to_string(),
description: "Edited 10 files".to_string(),
icon: "📝".to_string(),
unlocked_at: None,
},
AchievementId::FileArchitect => Achievement {
id: id.clone(),
name: "File Architect".to_string(),
description: "Created or edited 100 files".to_string(),
icon: "🏛️".to_string(),
unlocked_at: None,
},
// Conversation milestones
AchievementId::ConversationStarter => Achievement {
id: id.clone(),
name: "Conversation Starter".to_string(),
description: "Exchanged 10 messages".to_string(),
icon: "💬".to_string(),
unlocked_at: None,
},
AchievementId::ChattyKathy => Achievement {
id: id.clone(),
name: "Chatty Kathy".to_string(),
description: "100 messages exchanged".to_string(),
icon: "🗣️".to_string(),
unlocked_at: None,
},
AchievementId::Conversationalist => Achievement {
id: id.clone(),
name: "Master Conversationalist".to_string(),
description: "1,000 messages! We're really connecting!".to_string(),
icon: "💖".to_string(),
unlocked_at: None,
},
// Tool usage
AchievementId::Toolsmith => Achievement {
id: id.clone(),
name: "Toolsmith".to_string(),
description: "Used 5 different tools".to_string(),
icon: "🔨".to_string(),
unlocked_at: None,
},
AchievementId::ToolMaster => Achievement {
id: id.clone(),
name: "Tool Master".to_string(),
description: "Used 10 different tools efficiently".to_string(),
icon: "🛠️".to_string(),
unlocked_at: None,
},
// Time-based achievements
AchievementId::EarlyBird => Achievement {
id: id.clone(),
name: "Early Bird".to_string(),
description: "Started a session between 5 AM and 7 AM".to_string(),
icon: "🌅".to_string(),
unlocked_at: None,
},
AchievementId::NightOwl => Achievement {
id: id.clone(),
name: "Night Owl".to_string(),
description: "Coding after midnight".to_string(),
icon: "🦉".to_string(),
unlocked_at: None,
},
AchievementId::AllNighter => Achievement {
id: id.clone(),
name: "All Nighter".to_string(),
description: "Worked through the night (2 AM - 5 AM)".to_string(),
icon: "🌙".to_string(),
unlocked_at: None,
},
AchievementId::WeekendWarrior => Achievement {
id: id.clone(),
name: "Weekend Warrior".to_string(),
description: "Coding on a weekend".to_string(),
icon: "⚔️".to_string(),
unlocked_at: None,
},
AchievementId::DedicatedDeveloper => Achievement {
id: id.clone(),
name: "Dedicated Developer".to_string(),
description: "Coded for 30 days in a row".to_string(),
icon: "🏆".to_string(),
unlocked_at: None,
},
// Search and exploration
AchievementId::Explorer => Achievement {
id: id.clone(),
name: "Explorer".to_string(),
description: "Used search tools 50 times".to_string(),
icon: "🔍".to_string(),
unlocked_at: None,
},
AchievementId::MasterSearcher => Achievement {
id: id.clone(),
name: "Master Searcher".to_string(),
description: "Searched 500 times across files".to_string(),
icon: "🕵️‍♀️".to_string(),
unlocked_at: None,
},
// Session achievements
AchievementId::QuickSession => Achievement {
id: id.clone(),
name: "Quick Session".to_string(),
description: "Completed a productive session in under 5 minutes".to_string(),
icon: "".to_string(),
unlocked_at: None,
},
AchievementId::FocusedWork => Achievement {
id: id.clone(),
name: "Focused Work".to_string(),
description: "Worked for 30 minutes straight".to_string(),
icon: "🎯".to_string(),
unlocked_at: None,
},
AchievementId::DeepDive => Achievement {
id: id.clone(),
name: "Deep Dive".to_string(),
description: "Worked for 2 hours continuously".to_string(),
icon: "🏊‍♀️".to_string(),
unlocked_at: None,
},
AchievementId::MarathonSession => Achievement {
id: id.clone(),
name: "Marathon Session".to_string(),
description: "5+ hour coding session!".to_string(),
icon: "🏃‍♀️".to_string(),
unlocked_at: None,
},
// Special achievements
AchievementId::FirstMessage => Achievement {
id: id.clone(),
name: "First Message".to_string(),
description: "Sent your first message to Hikari".to_string(),
icon: "".to_string(),
unlocked_at: None,
},
AchievementId::FirstTool => Achievement {
id: id.clone(),
name: "First Tool".to_string(),
description: "Used your first tool".to_string(),
icon: "🔧".to_string(),
unlocked_at: None,
},
AchievementId::FirstCodeBlock => Achievement {
id: id.clone(),
name: "First Code".to_string(),
description: "Generated your first code block".to_string(),
icon: "📦".to_string(),
unlocked_at: None,
},
AchievementId::FirstFileEdit => Achievement {
id: id.clone(),
name: "First Edit".to_string(),
description: "Made your first file edit".to_string(),
icon: "✏️".to_string(),
unlocked_at: None,
},
AchievementId::Polyglot => Achievement {
id: id.clone(),
name: "Polyglot".to_string(),
description: "Generated code in 5+ languages in one session".to_string(),
icon: "🌍".to_string(),
unlocked_at: None,
},
AchievementId::SpeedCoder => Achievement {
id: id.clone(),
name: "Speed Coder".to_string(),
description: "Generated 10 code blocks in 10 minutes".to_string(),
icon: "🚀".to_string(),
unlocked_at: None,
},
AchievementId::ClaudeConnoisseur => Achievement {
id: id.clone(),
name: "Claude Connoisseur".to_string(),
description: "Used all available Claude models".to_string(),
icon: "🎨".to_string(),
unlocked_at: None,
},
AchievementId::MarathonCoder => Achievement {
id: id.clone(),
name: "Marathon Coder".to_string(),
description: "10,000 tokens in a single session".to_string(),
icon: "🏃‍♂️".to_string(),
unlocked_at: None,
},
// Relationship & Greetings
AchievementId::GoodMorning => Achievement {
id: id.clone(),
name: "Good Morning!".to_string(),
description: "Greeted Hikari with a good morning".to_string(),
icon: "🌅".to_string(),
unlocked_at: None,
},
AchievementId::GoodNight => Achievement {
id: id.clone(),
name: "Good Night".to_string(),
description: "Said good night to Hikari".to_string(),
icon: "🌙".to_string(),
unlocked_at: None,
},
AchievementId::ThankYou => Achievement {
id: id.clone(),
name: "Grateful Heart".to_string(),
description: "Thanked Hikari for her help".to_string(),
icon: "💝".to_string(),
unlocked_at: None,
},
AchievementId::LoveYou => Achievement {
id: id.clone(),
name: "Love Connection".to_string(),
description: "Expressed love to Hikari".to_string(),
icon: "💕".to_string(),
unlocked_at: None,
},
// Personality & Fun
AchievementId::EmojiUser => Achievement {
id: id.clone(),
name: "Emoji Enthusiast".to_string(),
description: "Used an emoji in your message".to_string(),
icon: "😊".to_string(),
unlocked_at: None,
},
AchievementId::QuestionMaster => Achievement {
id: id.clone(),
name: "Question Master".to_string(),
description: "Asked 20 questions".to_string(),
icon: "".to_string(),
unlocked_at: None,
},
AchievementId::CapsLock => Achievement {
id: id.clone(),
name: "CAPS LOCK ENGAGED".to_string(),
description: "SENT A MESSAGE IN ALL CAPS".to_string(),
icon: "📢".to_string(),
unlocked_at: None,
},
AchievementId::PleaseAndThankYou => Achievement {
id: id.clone(),
name: "Polite Programmer".to_string(),
description: "Said please in a request".to_string(),
icon: "🎩".to_string(),
unlocked_at: None,
},
// Git & Development
AchievementId::GitGuru => Achievement {
id: id.clone(),
name: "Git Guru".to_string(),
description: "Used git commands 10 times".to_string(),
icon: "🌿".to_string(),
unlocked_at: None,
},
AchievementId::TestWriter => Achievement {
id: id.clone(),
name: "Test Writer".to_string(),
description: "Created test files".to_string(),
icon: "🧪".to_string(),
unlocked_at: None,
},
AchievementId::Debugger => Achievement {
id: id.clone(),
name: "Bug Squasher".to_string(),
description: "Fixed bugs and errors".to_string(),
icon: "🐛".to_string(),
unlocked_at: None,
},
// Tool Mastery
AchievementId::BashMaster => Achievement {
id: id.clone(),
name: "Bash Master".to_string(),
description: "Used Bash tool 50 times".to_string(),
icon: "🐚".to_string(),
unlocked_at: None,
},
AchievementId::FileExplorer => Achievement {
id: id.clone(),
name: "File Explorer".to_string(),
description: "Read 100 files".to_string(),
icon: "📂".to_string(),
unlocked_at: None,
},
AchievementId::SearchExpert => Achievement {
id: id.clone(),
name: "Search Expert".to_string(),
description: "Used Grep tool 50 times".to_string(),
icon: "🔎".to_string(),
unlocked_at: None,
},
}
}
// Check achievements based on message content
pub fn check_message_achievements(
message: &str,
progress: &mut AchievementProgress,
) -> Vec<AchievementId> {
let mut newly_unlocked = Vec::new();
let message_lower = message.to_lowercase();
println!("Checking message achievements for: {}", message);
// Relationship & Greetings
if message_lower.contains("good morning") && progress.unlock(AchievementId::GoodMorning) {
newly_unlocked.push(AchievementId::GoodMorning);
}
if (message_lower.contains("good night") || message_lower.contains("goodnight"))
&& progress.unlock(AchievementId::GoodNight)
{
newly_unlocked.push(AchievementId::GoodNight);
}
if (message_lower.contains("thank you")
|| message_lower.contains("thanks")
|| message_lower.contains("thx"))
&& progress.unlock(AchievementId::ThankYou)
{
newly_unlocked.push(AchievementId::ThankYou);
}
if (message_lower.contains("love you") || message_lower.contains("ily"))
&& progress.unlock(AchievementId::LoveYou)
{
newly_unlocked.push(AchievementId::LoveYou);
}
// Personality & Fun
if message.chars().any(|c| c as u32 >= 0x1F300) && progress.unlock(AchievementId::EmojiUser) {
newly_unlocked.push(AchievementId::EmojiUser);
}
if message == message.to_uppercase()
&& message.len() > 5
&& message.chars().any(|c| c.is_alphabetic())
&& progress.unlock(AchievementId::CapsLock)
{
newly_unlocked.push(AchievementId::CapsLock);
}
if message_lower.contains("please") && progress.unlock(AchievementId::PleaseAndThankYou) {
newly_unlocked.push(AchievementId::PleaseAndThankYou);
}
// Git & Development patterns in messages
if (message_lower.contains("fix")
|| message_lower.contains("bug")
|| message_lower.contains("error"))
&& progress.unlock(AchievementId::Debugger)
{
newly_unlocked.push(AchievementId::Debugger);
}
newly_unlocked
}
// Check which achievements should be unlocked based on current stats
pub fn check_achievements(
stats: &crate::stats::UsageStats,
progress: &mut AchievementProgress,
) -> Vec<AchievementId> {
let mut newly_unlocked = Vec::new();
println!(
"Checking achievements with stats: messages={}, tokens={}, code_blocks={}",
stats.messages_exchanged,
stats.total_input_tokens + stats.total_output_tokens,
stats.code_blocks_generated
);
println!("Currently unlocked: {:?}", progress.unlocked);
// Token milestones
let total_tokens = stats.total_input_tokens + stats.total_output_tokens;
if total_tokens >= 1_000 && progress.unlock(AchievementId::FirstSteps) {
println!("Unlocked FirstSteps achievement!");
newly_unlocked.push(AchievementId::FirstSteps);
}
if total_tokens >= 10_000 && progress.unlock(AchievementId::GrowingStrong) {
newly_unlocked.push(AchievementId::GrowingStrong);
}
if total_tokens >= 100_000 && progress.unlock(AchievementId::BlossomingCoder) {
newly_unlocked.push(AchievementId::BlossomingCoder);
}
if total_tokens >= 1_000_000 && progress.unlock(AchievementId::TokenMaster) {
newly_unlocked.push(AchievementId::TokenMaster);
}
// Code generation
if stats.code_blocks_generated >= 1 && progress.unlock(AchievementId::HelloWorld) {
newly_unlocked.push(AchievementId::HelloWorld);
}
if stats.code_blocks_generated >= 100 && progress.unlock(AchievementId::CodeWizard) {
newly_unlocked.push(AchievementId::CodeWizard);
}
if stats.code_blocks_generated >= 1000 && progress.unlock(AchievementId::ThousandBlocks) {
newly_unlocked.push(AchievementId::ThousandBlocks);
}
// File operations
if stats.files_edited >= 10 && progress.unlock(AchievementId::FileManipulator) {
newly_unlocked.push(AchievementId::FileManipulator);
}
let total_files = stats.files_edited + stats.files_created;
if total_files >= 100 && progress.unlock(AchievementId::FileArchitect) {
newly_unlocked.push(AchievementId::FileArchitect);
}
// Conversation milestones
if stats.messages_exchanged >= 1 && progress.unlock(AchievementId::FirstMessage) {
newly_unlocked.push(AchievementId::FirstMessage);
}
if stats.messages_exchanged >= 10 && progress.unlock(AchievementId::ConversationStarter) {
newly_unlocked.push(AchievementId::ConversationStarter);
}
if stats.messages_exchanged >= 100 && progress.unlock(AchievementId::ChattyKathy) {
newly_unlocked.push(AchievementId::ChattyKathy);
}
if stats.messages_exchanged >= 1000 && progress.unlock(AchievementId::Conversationalist) {
newly_unlocked.push(AchievementId::Conversationalist);
}
// Tool usage
let unique_tools = stats.tools_usage.len();
if unique_tools >= 5 && progress.unlock(AchievementId::Toolsmith) {
newly_unlocked.push(AchievementId::Toolsmith);
}
if unique_tools >= 10 && progress.unlock(AchievementId::ToolMaster) {
newly_unlocked.push(AchievementId::ToolMaster);
}
// Search and exploration
let search_tools = ["Glob", "Grep", "search", "Task"];
let search_count: u64 = search_tools
.iter()
.filter_map(|tool| stats.tools_usage.get(*tool))
.sum();
if search_count >= 50 && progress.unlock(AchievementId::Explorer) {
newly_unlocked.push(AchievementId::Explorer);
}
if search_count >= 500 && progress.unlock(AchievementId::MasterSearcher) {
newly_unlocked.push(AchievementId::MasterSearcher);
}
// Session duration achievements
let session_secs = stats.session_duration_seconds;
if session_secs < 300
&& stats.session_messages_exchanged >= 5
&& progress.unlock(AchievementId::QuickSession)
{
newly_unlocked.push(AchievementId::QuickSession);
}
if session_secs >= 1800 && progress.unlock(AchievementId::FocusedWork) {
newly_unlocked.push(AchievementId::FocusedWork);
}
if session_secs >= 7200 && progress.unlock(AchievementId::DeepDive) {
newly_unlocked.push(AchievementId::DeepDive);
}
if session_secs >= 18000 && progress.unlock(AchievementId::MarathonSession) {
newly_unlocked.push(AchievementId::MarathonSession);
}
// Session token achievement
let session_tokens = stats.session_input_tokens + stats.session_output_tokens;
if session_tokens >= 10000 && progress.unlock(AchievementId::MarathonCoder) {
newly_unlocked.push(AchievementId::MarathonCoder);
}
// Special first-time achievements
if !stats.tools_usage.is_empty() && progress.unlock(AchievementId::FirstTool) {
newly_unlocked.push(AchievementId::FirstTool);
}
if stats.code_blocks_generated >= 1 && progress.unlock(AchievementId::FirstCodeBlock) {
newly_unlocked.push(AchievementId::FirstCodeBlock);
}
if stats.files_edited >= 1 && progress.unlock(AchievementId::FirstFileEdit) {
newly_unlocked.push(AchievementId::FirstFileEdit);
}
// Speed coder - need to track time for this
// TODO: Implement tracking for 10 code blocks in 10 minutes
// Polyglot - need to track languages
// TODO: Implement tracking for multiple programming languages
// Claude Connoisseur - check model usage
// TODO: Track different Claude models used
// Tool mastery achievements
if let Some(bash_count) = stats.tools_usage.get("Bash") {
if *bash_count >= 50 && progress.unlock(AchievementId::BashMaster) {
newly_unlocked.push(AchievementId::BashMaster);
}
}
if let Some(read_count) = stats.tools_usage.get("Read") {
if *read_count >= 100 && progress.unlock(AchievementId::FileExplorer) {
newly_unlocked.push(AchievementId::FileExplorer);
}
}
if let Some(grep_count) = stats.tools_usage.get("Grep") {
if *grep_count >= 50 && progress.unlock(AchievementId::SearchExpert) {
newly_unlocked.push(AchievementId::SearchExpert);
}
}
// Git Guru - check git command usage in Bash
if let Some(bash_count) = stats.tools_usage.get("Bash") {
if *bash_count >= 10 && progress.unlock(AchievementId::GitGuru) {
// TODO: More specific git command tracking
newly_unlocked.push(AchievementId::GitGuru);
}
}
// Time-based achievements
if let Some(session_start) = progress.session_start {
let hour = session_start.hour();
let weekday = session_start.weekday();
// Early bird - 5 AM to 7 AM
if (5..=7).contains(&hour) && progress.unlock(AchievementId::EarlyBird) {
newly_unlocked.push(AchievementId::EarlyBird);
}
// Night owl - after midnight
let current_hour = Utc::now().hour();
if current_hour < 6 && progress.unlock(AchievementId::NightOwl) {
newly_unlocked.push(AchievementId::NightOwl);
}
// All nighter - 2 AM to 5 AM
if (2..=5).contains(&current_hour) && progress.unlock(AchievementId::AllNighter) {
newly_unlocked.push(AchievementId::AllNighter);
}
// Weekend warrior
use chrono::Weekday;
if (weekday == Weekday::Sat || weekday == Weekday::Sun)
&& progress.unlock(AchievementId::WeekendWarrior)
{
newly_unlocked.push(AchievementId::WeekendWarrior);
}
}
// Dedicated Developer - need to track consecutive days
// TODO: Implement 30 days in a row tracking
newly_unlocked
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AchievementUnlockedEvent {
pub achievement: Achievement,
}
// Save achievements to persistent store
pub async fn save_achievements(
app: &tauri::AppHandle,
progress: &AchievementProgress,
) -> Result<(), String> {
let store = app.store("achievements.json").map_err(|e| e.to_string())?;
// Create a serializable version with just the unlocked achievement IDs
let unlocked_list: Vec<AchievementId> = progress.unlocked.iter().cloned().collect();
println!("Saving achievements: {:?}", unlocked_list);
store.set(
"unlocked",
serde_json::to_value(unlocked_list).map_err(|e| e.to_string())?,
);
store.save().map_err(|e| e.to_string())?;
println!("Achievements saved successfully");
Ok(())
}
// Load achievements from persistent store
pub async fn load_achievements(app: &tauri::AppHandle) -> AchievementProgress {
println!("Loading achievements from store...");
let store = match app.store("achievements.json") {
Ok(s) => s,
Err(e) => {
println!("Failed to open achievements store: {}", e);
return AchievementProgress::new();
}
};
let mut progress = AchievementProgress::new();
// Get unlocked achievements
if let Some(unlocked_value) = store.get("unlocked") {
println!("Found unlocked value in store: {:?}", unlocked_value);
if let Ok(unlocked_list) =
serde_json::from_value::<Vec<AchievementId>>(unlocked_value.clone())
{
println!("Loaded {} achievements", unlocked_list.len());
for achievement_id in unlocked_list {
progress.unlocked.insert(achievement_id);
}
} else {
println!("Failed to parse unlocked achievements");
}
} else {
println!("No unlocked achievements found in store");
}
progress
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_achievement_unlock() {
let mut progress = AchievementProgress::new();
// First unlock should return true
assert!(progress.unlock(AchievementId::FirstSteps));
assert!(progress.is_unlocked(&AchievementId::FirstSteps));
// Second unlock of same achievement should return false
assert!(!progress.unlock(AchievementId::FirstSteps));
// Newly unlocked should contain the achievement
let newly = progress.take_newly_unlocked();
assert_eq!(newly.len(), 1);
assert_eq!(newly[0], AchievementId::FirstSteps);
// After taking, newly unlocked should be empty
let newly = progress.take_newly_unlocked();
assert!(newly.is_empty());
}
}
+169
View File
@@ -0,0 +1,169 @@
use parking_lot::Mutex;
use std::collections::HashMap;
use std::sync::Arc;
use tauri::AppHandle;
use crate::config::ClaudeStartOptions;
use crate::stats::UsageStats;
use crate::wsl_bridge::WslBridge;
pub struct BridgeManager {
bridges: HashMap<String, WslBridge>,
app_handle: Option<AppHandle>,
}
impl BridgeManager {
pub fn new() -> Self {
BridgeManager {
bridges: HashMap::new(),
app_handle: None,
}
}
pub fn set_app_handle(&mut self, app: AppHandle) {
self.app_handle = Some(app);
}
pub fn start_claude(
&mut self,
conversation_id: &str,
options: ClaudeStartOptions,
) -> Result<(), String> {
// Check if a bridge already exists and is running for this conversation
if self
.bridges
.get(conversation_id)
.map(|b| b.is_running())
.unwrap_or(false)
{
return Err("Claude is already running for this conversation".to_string());
}
let app = self
.app_handle
.as_ref()
.ok_or_else(|| "App handle not set".to_string())?
.clone();
// Reuse existing bridge if it exists (preserves stats across reconnects)
// Only create a new bridge if one doesn't exist for this conversation
let bridge = self
.bridges
.entry(conversation_id.to_string())
.or_insert_with(|| WslBridge::new_with_conversation_id(conversation_id.to_string()));
// Start the Claude process
bridge.start(app, options)?;
Ok(())
}
pub fn stop_claude(&mut self, conversation_id: &str) -> Result<(), String> {
if let Some(bridge) = self.bridges.get_mut(conversation_id) {
let app = self
.app_handle
.as_ref()
.ok_or_else(|| "App handle not set".to_string())?;
bridge.stop(app);
Ok(())
} else {
Err("No Claude instance found for this conversation".to_string())
}
}
pub fn interrupt_claude(&mut self, conversation_id: &str) -> Result<(), String> {
if let Some(bridge) = self.bridges.get_mut(conversation_id) {
let app = self
.app_handle
.as_ref()
.ok_or_else(|| "App handle not set".to_string())?;
bridge.interrupt(app)
} else {
Err("No Claude instance found for this conversation".to_string())
}
}
pub fn send_prompt(&mut self, conversation_id: &str, message: String) -> Result<(), String> {
if let Some(bridge) = self.bridges.get_mut(conversation_id) {
bridge.send_message(&message)
} else {
Err("No Claude instance found for this conversation".to_string())
}
}
pub fn send_tool_result(
&mut self,
conversation_id: &str,
tool_use_id: &str,
result: serde_json::Value,
) -> Result<(), String> {
if let Some(bridge) = self.bridges.get_mut(conversation_id) {
bridge.send_tool_result(tool_use_id, result)
} else {
Err("No Claude instance found for this conversation".to_string())
}
}
pub fn is_claude_running(&self, conversation_id: &str) -> bool {
self.bridges
.get(conversation_id)
.map(|b| b.is_running())
.unwrap_or(false)
}
pub fn get_working_directory(&self, conversation_id: &str) -> Result<String, String> {
self.bridges
.get(conversation_id)
.map(|b| b.get_working_directory().to_string())
.ok_or_else(|| "No Claude instance found for this conversation".to_string())
}
pub fn get_usage_stats(&self, conversation_id: &str) -> Result<UsageStats, String> {
self.bridges
.get(conversation_id)
.map(|b| b.get_stats())
.ok_or_else(|| "No Claude instance found for this conversation".to_string())
}
#[allow(dead_code)]
pub fn cleanup_stopped_bridges(&mut self) {
// Remove bridges that are no longer running
self.bridges.retain(|_, bridge| bridge.is_running());
}
#[allow(dead_code)]
pub fn stop_all(&mut self) {
if let Some(app) = &self.app_handle {
for (_, bridge) in self.bridges.iter_mut() {
bridge.stop(app);
}
}
self.bridges.clear();
}
#[allow(dead_code)]
pub fn get_active_conversations(&self) -> Vec<String> {
self.bridges
.keys()
.filter(|id| {
self.bridges
.get(*id)
.map(|b| b.is_running())
.unwrap_or(false)
})
.cloned()
.collect()
}
}
impl Default for BridgeManager {
fn default() -> Self {
Self::new()
}
}
pub type SharedBridgeManager = Arc<Mutex<BridgeManager>>;
pub fn create_shared_bridge_manager() -> SharedBridgeManager {
Arc::new(Mutex::new(BridgeManager::new()))
}
+358 -20
View File
@@ -1,44 +1,382 @@
use std::path::PathBuf;
use tauri::{AppHandle, State}; use tauri::{AppHandle, State};
use tauri_plugin_http::reqwest;
use tauri_plugin_store::StoreExt;
use crate::wsl_bridge::SharedBridge; use crate::achievements::{get_achievement_info, load_achievements, AchievementUnlockedEvent};
use crate::bridge_manager::SharedBridgeManager;
use crate::config::{ClaudeStartOptions, HikariConfig};
use crate::stats::UsageStats;
use crate::temp_manager::SharedTempFileManager;
const CONFIG_STORE_KEY: &str = "config";
#[tauri::command] #[tauri::command]
pub async fn start_claude( pub async fn start_claude(
app: AppHandle, bridge_manager: State<'_, SharedBridgeManager>,
bridge: State<'_, SharedBridge>, conversation_id: String,
working_dir: String, options: ClaudeStartOptions,
allowed_tools: Option<Vec<String>>,
) -> Result<(), String> { ) -> Result<(), String> {
let mut bridge = bridge.lock(); let mut manager = bridge_manager.lock();
bridge.start(app, &working_dir, allowed_tools.unwrap_or_default()) manager.start_claude(&conversation_id, options)
} }
#[tauri::command] #[tauri::command]
pub async fn stop_claude(app: AppHandle, bridge: State<'_, SharedBridge>) -> Result<(), String> { pub async fn stop_claude(
let mut bridge = bridge.lock(); bridge_manager: State<'_, SharedBridgeManager>,
bridge.stop(&app); conversation_id: String,
Ok(()) ) -> Result<(), String> {
let mut manager = bridge_manager.lock();
manager.stop_claude(&conversation_id)
} }
#[tauri::command] #[tauri::command]
pub async fn send_prompt(bridge: State<'_, SharedBridge>, message: String) -> Result<(), String> { pub async fn interrupt_claude(
let mut bridge = bridge.lock(); bridge_manager: State<'_, SharedBridgeManager>,
bridge.send_message(&message) conversation_id: String,
) -> Result<(), String> {
let mut manager = bridge_manager.lock();
manager.interrupt_claude(&conversation_id)
} }
#[tauri::command] #[tauri::command]
pub async fn is_claude_running(bridge: State<'_, SharedBridge>) -> Result<bool, String> { pub async fn send_prompt(
let bridge = bridge.lock(); bridge_manager: State<'_, SharedBridgeManager>,
Ok(bridge.is_running()) conversation_id: String,
message: String,
) -> Result<(), String> {
let mut manager = bridge_manager.lock();
manager.send_prompt(&conversation_id, message)
} }
#[tauri::command] #[tauri::command]
pub async fn get_working_directory(bridge: State<'_, SharedBridge>) -> Result<String, String> { pub async fn is_claude_running(
let bridge = bridge.lock(); bridge_manager: State<'_, SharedBridgeManager>,
Ok(bridge.get_working_directory().to_string()) conversation_id: String,
) -> Result<bool, String> {
let manager = bridge_manager.lock();
Ok(manager.is_claude_running(&conversation_id))
}
#[tauri::command]
pub async fn get_working_directory(
bridge_manager: State<'_, SharedBridgeManager>,
conversation_id: String,
) -> Result<String, String> {
let manager = bridge_manager.lock();
manager.get_working_directory(&conversation_id)
} }
#[tauri::command] #[tauri::command]
pub async fn select_wsl_directory() -> Result<String, String> { pub async fn select_wsl_directory() -> Result<String, String> {
Ok("/home".to_string()) Ok("/home".to_string())
} }
#[tauri::command]
pub async fn get_config(app: AppHandle) -> Result<HikariConfig, String> {
let store = app.store("hikari-config.json").map_err(|e| e.to_string())?;
match store.get(CONFIG_STORE_KEY) {
Some(value) => serde_json::from_value(value.clone()).map_err(|e| e.to_string()),
None => Ok(HikariConfig::default()),
}
}
#[tauri::command]
pub async fn save_config(app: AppHandle, config: HikariConfig) -> Result<(), String> {
let store = app.store("hikari-config.json").map_err(|e| e.to_string())?;
let value = serde_json::to_value(&config).map_err(|e| e.to_string())?;
store.set(CONFIG_STORE_KEY, value);
store.save().map_err(|e| e.to_string())?;
Ok(())
}
#[tauri::command]
pub async fn get_usage_stats(
bridge_manager: State<'_, SharedBridgeManager>,
conversation_id: String,
) -> Result<UsageStats, String> {
let manager = bridge_manager.lock();
manager.get_usage_stats(&conversation_id)
}
#[tauri::command]
pub async fn validate_directory(
path: String,
current_dir: Option<String>,
) -> Result<String, String> {
use std::path::Path;
let path = Path::new(&path);
// Expand ~ to home directory
let expanded_path = if path.starts_with("~") {
if let Some(home) = std::env::var_os("HOME") {
let home_path = Path::new(&home);
if path == Path::new("~") {
home_path.to_path_buf()
} else {
home_path.join(path.strip_prefix("~").unwrap())
}
} else {
return Err("Could not determine home directory".to_string());
}
} else if path.is_relative() {
// Handle relative paths (., .., or any relative path) by resolving against current_dir
if let Some(ref cwd) = current_dir {
Path::new(cwd).join(path)
} else {
path.to_path_buf()
}
} else {
path.to_path_buf()
};
// Check if the path exists and is a directory
if !expanded_path.exists() {
return Err(format!(
"Directory does not exist: {}",
expanded_path.display()
));
}
if !expanded_path.is_dir() {
return Err(format!(
"Path is not a directory: {}",
expanded_path.display()
));
}
// Return the canonicalized (absolute) path
expanded_path
.canonicalize()
.map(|p| p.to_string_lossy().to_string())
.map_err(|e| format!("Failed to resolve path: {}", e))
}
#[tauri::command]
pub async fn load_saved_achievements(
app: AppHandle,
) -> Result<Vec<AchievementUnlockedEvent>, String> {
use chrono::Utc;
// Load achievements from persistent store
let progress = load_achievements(&app).await;
// Create events for all previously unlocked achievements
let mut events = Vec::new();
for achievement_id in &progress.unlocked {
let mut info = get_achievement_info(achievement_id);
info.unlocked_at = Some(Utc::now()); // We don't store timestamps, so just use now
events.push(AchievementUnlockedEvent { achievement: info });
}
Ok(events)
}
#[tauri::command]
pub async fn answer_question(
bridge_manager: State<'_, SharedBridgeManager>,
conversation_id: String,
tool_use_id: String,
answers: serde_json::Value,
) -> Result<(), String> {
let mut manager = bridge_manager.lock();
manager.send_tool_result(&conversation_id, &tool_use_id, answers)
}
#[tauri::command]
pub async fn list_skills() -> Result<Vec<String>, String> {
use std::fs;
use std::path::Path;
// Get the home directory
let home =
std::env::var_os("HOME").ok_or_else(|| "Could not determine home directory".to_string())?;
let skills_dir = Path::new(&home).join(".claude").join("skills");
// If the skills directory doesn't exist, return empty list
if !skills_dir.exists() {
return Ok(Vec::new());
}
// Read the directory and collect skill names
let mut skills = Vec::new();
let entries =
fs::read_dir(&skills_dir).map_err(|e| format!("Failed to read skills directory: {}", e))?;
for entry in entries {
let entry = entry.map_err(|e| format!("Failed to read directory entry: {}", e))?;
let path = entry.path();
// Only include directories that contain a SKILL.md file
if path.is_dir() {
let skill_file = path.join("SKILL.md");
if skill_file.exists() {
if let Some(name) = path.file_name() {
skills.push(name.to_string_lossy().to_string());
}
}
}
}
// Sort alphabetically
skills.sort();
Ok(skills)
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct UpdateInfo {
pub current_version: String,
pub latest_version: String,
pub has_update: bool,
pub release_url: String,
pub release_notes: Option<String>,
}
#[derive(Debug, serde::Deserialize)]
struct GiteaRelease {
tag_name: String,
html_url: String,
body: Option<String>,
prerelease: bool,
}
#[tauri::command]
pub async fn check_for_updates() -> Result<UpdateInfo, String> {
const CURRENT_VERSION: &str = env!("CARGO_PKG_VERSION");
const RELEASES_API: &str =
"https://git.nhcarrigan.com/api/v1/repos/nhcarrigan/hikari-desktop/releases";
// Fetch releases from Gitea API
let client = reqwest::Client::new();
let response = client
.get(RELEASES_API)
.header("Accept", "application/json")
.send()
.await
.map_err(|e| format!("Failed to fetch releases: {}", e))?;
if !response.status().is_success() {
return Err(format!("API returned status: {}", response.status()));
}
let text = response
.text()
.await
.map_err(|e| format!("Failed to read response: {}", e))?;
let releases: Vec<GiteaRelease> =
serde_json::from_str(&text).map_err(|e| format!("Failed to parse releases: {}", e))?;
// Find the latest non-prerelease, or fall back to latest prerelease
let latest = releases
.iter()
.find(|r| !r.prerelease)
.or_else(|| releases.first());
let latest = match latest {
Some(r) => r,
None => return Err("No releases found".to_string()),
};
// Parse version strings (remove 'v' prefix if present)
let current = semver::Version::parse(CURRENT_VERSION)
.map_err(|e| format!("Failed to parse current version: {}", e))?;
let latest_tag = latest.tag_name.trim_start_matches('v');
let latest_ver = semver::Version::parse(latest_tag)
.map_err(|e| format!("Failed to parse latest version: {}", e))?;
Ok(UpdateInfo {
current_version: CURRENT_VERSION.to_string(),
latest_version: latest.tag_name.clone(),
has_update: latest_ver > current,
release_url: latest.html_url.clone(),
release_notes: latest.body.clone(),
})
}
#[derive(Debug, Clone, serde::Serialize)]
pub struct SavedFileInfo {
pub path: String,
pub filename: String,
}
#[tauri::command]
pub async fn save_temp_file(
temp_manager: State<'_, SharedTempFileManager>,
conversation_id: String,
data: Vec<u8>,
filename: Option<String>,
) -> Result<SavedFileInfo, String> {
let mut manager = temp_manager.lock();
let path = manager.save_file(&conversation_id, &data, filename.as_deref())?;
let filename = path
.file_name()
.map(|n| n.to_string_lossy().to_string())
.unwrap_or_else(|| "unknown".to_string());
Ok(SavedFileInfo {
path: path.to_string_lossy().to_string(),
filename,
})
}
#[tauri::command]
pub async fn register_temp_file(
temp_manager: State<'_, SharedTempFileManager>,
conversation_id: String,
file_path: String,
) -> Result<(), String> {
let mut manager = temp_manager.lock();
manager.register_file(&conversation_id, PathBuf::from(file_path));
Ok(())
}
#[tauri::command]
pub async fn get_temp_files(
temp_manager: State<'_, SharedTempFileManager>,
conversation_id: String,
) -> Result<Vec<String>, String> {
let manager = temp_manager.lock();
let files = manager.get_files_for_conversation(&conversation_id);
Ok(files.iter().map(|p| p.to_string_lossy().to_string()).collect())
}
#[tauri::command]
pub async fn cleanup_temp_files(
temp_manager: State<'_, SharedTempFileManager>,
conversation_id: String,
) -> Result<(), String> {
let mut manager = temp_manager.lock();
manager.cleanup_conversation(&conversation_id)
}
#[tauri::command]
pub async fn cleanup_all_temp_files(
temp_manager: State<'_, SharedTempFileManager>,
) -> Result<(), String> {
let mut manager = temp_manager.lock();
manager.cleanup_all()
}
#[tauri::command]
pub async fn cleanup_orphaned_temp_files(
temp_manager: State<'_, SharedTempFileManager>,
) -> Result<usize, String> {
let mut manager = temp_manager.lock();
manager.cleanup_orphaned_files()
}
#[tauri::command]
pub async fn get_file_size(file_path: String) -> Result<u64, String> {
let metadata = std::fs::metadata(&file_path)
.map_err(|e| format!("Failed to get file metadata: {}", e))?;
Ok(metadata.len())
}
+199
View File
@@ -0,0 +1,199 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct ClaudeStartOptions {
#[serde(default)]
pub working_dir: String,
#[serde(default)]
pub model: Option<String>,
#[serde(default)]
pub api_key: Option<String>,
#[serde(default)]
pub custom_instructions: Option<String>,
#[serde(default)]
pub mcp_servers_json: Option<String>,
#[serde(default)]
pub allowed_tools: Vec<String>,
#[serde(default)]
pub skip_greeting: bool,
#[serde(default)]
pub resume_session_id: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HikariConfig {
#[serde(default)]
pub model: Option<String>,
#[serde(default)]
pub api_key: Option<String>,
#[serde(default)]
pub custom_instructions: Option<String>,
#[serde(default)]
pub mcp_servers_json: Option<String>,
#[serde(default)]
pub auto_granted_tools: Vec<String>,
#[serde(default)]
pub theme: Theme,
#[serde(default = "default_greeting_enabled")]
pub greeting_enabled: bool,
#[serde(default)]
pub greeting_custom_prompt: Option<String>,
#[serde(default = "default_notifications_enabled")]
pub notifications_enabled: bool,
#[serde(default = "default_notification_volume")]
pub notification_volume: f32,
#[serde(default)]
pub always_on_top: bool,
#[serde(default = "default_update_checks_enabled")]
pub update_checks_enabled: bool,
#[serde(default)]
pub character_panel_width: Option<u32>,
#[serde(default = "default_font_size")]
pub font_size: u32,
#[serde(default)]
pub minimize_to_tray: bool,
}
impl Default for HikariConfig {
fn default() -> Self {
Self {
model: None,
api_key: None,
custom_instructions: None,
mcp_servers_json: None,
auto_granted_tools: Vec::new(),
theme: Theme::default(),
greeting_enabled: true,
greeting_custom_prompt: None,
notifications_enabled: true,
notification_volume: 0.7,
always_on_top: false,
update_checks_enabled: true,
character_panel_width: None,
font_size: 14,
minimize_to_tray: false,
}
}
}
fn default_update_checks_enabled() -> bool {
true
}
fn default_greeting_enabled() -> bool {
true
}
fn default_notifications_enabled() -> bool {
true
}
fn default_notification_volume() -> f32 {
0.7
}
fn default_font_size() -> u32 {
14
}
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum Theme {
#[default]
Dark,
Light,
#[serde(rename = "high-contrast")]
HighContrast,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_default_config() {
let config = HikariConfig::default();
assert!(config.model.is_none());
assert!(config.api_key.is_none());
assert!(config.custom_instructions.is_none());
assert!(config.mcp_servers_json.is_none());
assert!(config.auto_granted_tools.is_empty());
assert_eq!(config.theme, Theme::Dark);
assert!(config.greeting_enabled);
assert!(config.greeting_custom_prompt.is_none());
assert!(!config.always_on_top);
assert!(config.update_checks_enabled);
assert!(config.character_panel_width.is_none());
assert_eq!(config.font_size, 14);
assert!(!config.minimize_to_tray);
}
#[test]
fn test_config_serialization() {
let config = HikariConfig {
model: Some("claude-sonnet-4-20250514".to_string()),
api_key: None,
custom_instructions: Some("Be helpful".to_string()),
mcp_servers_json: None,
auto_granted_tools: vec!["Read".to_string(), "Glob".to_string()],
theme: Theme::Light,
greeting_enabled: true,
greeting_custom_prompt: Some("Hello!".to_string()),
notifications_enabled: true,
notification_volume: 0.7,
always_on_top: true,
update_checks_enabled: true,
character_panel_width: Some(400),
font_size: 16,
minimize_to_tray: true,
};
let json = serde_json::to_string(&config).unwrap();
let deserialized: HikariConfig = serde_json::from_str(&json).unwrap();
assert_eq!(deserialized.model, config.model);
assert_eq!(deserialized.custom_instructions, config.custom_instructions);
assert_eq!(deserialized.auto_granted_tools, config.auto_granted_tools);
assert_eq!(deserialized.theme, Theme::Light);
assert!(deserialized.greeting_enabled);
assert_eq!(
deserialized.greeting_custom_prompt,
Some("Hello!".to_string())
);
}
#[test]
fn test_theme_serialization() {
let dark = Theme::Dark;
let light = Theme::Light;
let high_contrast = Theme::HighContrast;
assert_eq!(serde_json::to_string(&dark).unwrap(), "\"dark\"");
assert_eq!(serde_json::to_string(&light).unwrap(), "\"light\"");
assert_eq!(
serde_json::to_string(&high_contrast).unwrap(),
"\"high-contrast\""
);
}
}
+84 -3
View File
@@ -1,26 +1,107 @@
mod achievements;
mod bridge_manager;
mod commands; mod commands;
mod config;
mod notifications;
mod stats;
mod temp_manager;
mod tray;
mod types; mod types;
mod vbs_notification;
mod windows_toast;
mod wsl_bridge; mod wsl_bridge;
mod wsl_notifications;
use bridge_manager::create_shared_bridge_manager;
use commands::load_saved_achievements;
use commands::*; use commands::*;
use wsl_bridge::create_shared_bridge; use notifications::*;
use tauri::Manager;
use temp_manager::create_shared_temp_manager;
use tray::{setup_tray, should_minimize_to_tray};
use vbs_notification::*;
use windows_toast::*;
use wsl_notifications::*;
#[cfg_attr(mobile, tauri::mobile_entry_point)] #[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() { pub fn run() {
let bridge = create_shared_bridge(); let bridge_manager = create_shared_bridge_manager();
let temp_manager = create_shared_temp_manager().expect("Failed to create temp file manager");
tauri::Builder::default() tauri::Builder::default()
.plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_opener::init()) .plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_shell::init()) .plugin(tauri_plugin_shell::init())
.manage(bridge) .plugin(tauri_plugin_store::Builder::new().build())
.plugin(tauri_plugin_notification::init())
.plugin(tauri_plugin_os::init())
.plugin(tauri_plugin_http::init())
.plugin(tauri_plugin_clipboard_manager::init())
.manage(bridge_manager.clone())
.manage(temp_manager.clone())
.setup(move |app| {
// Initialize the app handle in the bridge manager
bridge_manager.lock().set_app_handle(app.handle().clone());
// Clean up any orphaned temp files from previous sessions
if let Ok(count) = temp_manager.lock().cleanup_orphaned_files() {
if count > 0 {
println!("Cleaned up {} orphaned temp files", count);
}
}
// Set up system tray
if let Err(e) = setup_tray(app.handle()) {
eprintln!("Failed to set up system tray: {}", e);
}
// Handle window close event for minimize to tray
let main_window = app.get_webview_window("main").unwrap();
main_window.on_window_event({
let app_handle = app.handle().clone();
move |event| {
if let tauri::WindowEvent::CloseRequested { api, .. } = event {
if should_minimize_to_tray(&app_handle) {
api.prevent_close();
if let Some(window) = app_handle.get_webview_window("main") {
let _ = window.hide();
}
}
}
}
});
Ok(())
})
.invoke_handler(tauri::generate_handler![ .invoke_handler(tauri::generate_handler![
start_claude, start_claude,
stop_claude, stop_claude,
interrupt_claude,
send_prompt, send_prompt,
is_claude_running, is_claude_running,
get_working_directory, get_working_directory,
select_wsl_directory, select_wsl_directory,
get_config,
save_config,
get_usage_stats,
load_saved_achievements,
answer_question,
send_windows_notification,
send_simple_notification,
send_windows_toast,
send_notify_send,
send_wsl_notification,
send_vbs_notification,
validate_directory,
list_skills,
check_for_updates,
save_temp_file,
register_temp_file,
get_temp_files,
cleanup_temp_files,
cleanup_all_temp_files,
cleanup_orphaned_temp_files,
get_file_size,
]) ])
.run(tauri::generate_context!()) .run(tauri::generate_context!())
.expect("error while running tauri application"); .expect("error while running tauri application");
+101
View File
@@ -0,0 +1,101 @@
use std::process::Command;
use tauri::command;
#[command]
pub async fn send_notify_send(title: String, body: String) -> Result<(), String> {
// Use notify-send for Linux/WSL
let output = Command::new("notify-send")
.arg(&title)
.arg(&body)
.arg("--urgency=normal")
.arg("--app-name=Hikari Desktop")
.output()
.map_err(|e| {
format!(
"Failed to execute notify-send: {}. Make sure libnotify-bin is installed.",
e
)
})?;
if !output.status.success() {
let error = String::from_utf8_lossy(&output.stderr);
return Err(format!("notify-send failed: {}", error));
}
Ok(())
}
#[command]
pub async fn send_windows_notification(title: String, body: String) -> Result<(), String> {
// Create PowerShell script for Windows Toast Notification
let ps_script = format!(
r#"
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] > $null
$APP_ID = 'Hikari Desktop'
$template = @"
<toast>
<visual>
<binding template="ToastText02">
<text id="1">{}</text>
<text id="2">{}</text>
</binding>
</visual>
<audio src="ms-winsoundevent:Notification.Default" />
</toast>
"@
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml($template)
$toast = New-Object Windows.UI.Notifications.ToastNotification $xml
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($APP_ID).Show($toast)
"#,
title.replace("\"", "`\""),
body.replace("\"", "`\"")
);
// Try PowerShell Core first (pwsh), then fall back to Windows PowerShell
let output = Command::new("pwsh.exe")
.arg("-NoProfile")
.arg("-WindowStyle")
.arg("Hidden")
.arg("-Command")
.arg(&ps_script)
.output()
.or_else(|_| {
Command::new("powershell.exe")
.arg("-NoProfile")
.arg("-WindowStyle")
.arg("Hidden")
.arg("-Command")
.arg(&ps_script)
.output()
})
.map_err(|e| format!("Failed to execute PowerShell: {}", e))?;
if !output.status.success() {
let error = String::from_utf8_lossy(&output.stderr);
return Err(format!("PowerShell script failed: {}", error));
}
Ok(())
}
// Alternative: Use Windows built-in MSG command for simple notifications
#[command]
pub async fn send_simple_notification(title: String, body: String) -> Result<(), String> {
let message = format!("{}\n\n{}", title, body);
Command::new("cmd.exe")
.arg("/c")
.arg("msg")
.arg("*")
.arg(&message)
.output()
.map_err(|e| format!("Failed to send message: {}", e))?;
Ok(())
}
+219
View File
@@ -0,0 +1,219 @@
use crate::achievements::{check_achievements, AchievementProgress};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::time::Instant;
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct UsageStats {
pub total_input_tokens: u64,
pub total_output_tokens: u64,
pub total_cost_usd: f64,
pub session_input_tokens: u64,
pub session_output_tokens: u64,
pub session_cost_usd: f64,
pub model: Option<String>,
// New fields
pub messages_exchanged: u64,
pub session_messages_exchanged: u64,
pub code_blocks_generated: u64,
pub session_code_blocks_generated: u64,
pub files_edited: u64,
pub session_files_edited: u64,
pub files_created: u64,
pub session_files_created: u64,
pub tools_usage: HashMap<String, u64>,
pub session_tools_usage: HashMap<String, u64>,
pub session_duration_seconds: u64,
#[serde(skip)]
pub session_start: Option<Instant>,
// Achievement tracking
#[serde(skip)]
pub achievements: AchievementProgress,
}
impl UsageStats {
pub fn new() -> Self {
let mut stats = Self::default();
stats.achievements.start_session();
stats
}
pub fn add_usage(&mut self, input_tokens: u64, output_tokens: u64, model: &str) {
self.total_input_tokens += input_tokens;
self.total_output_tokens += output_tokens;
self.session_input_tokens += input_tokens;
self.session_output_tokens += output_tokens;
let cost = calculate_cost(input_tokens, output_tokens, model);
self.total_cost_usd += cost;
self.session_cost_usd += cost;
self.model = Some(model.to_string());
}
pub fn reset_session(&mut self) {
self.session_input_tokens = 0;
self.session_output_tokens = 0;
self.session_cost_usd = 0.0;
self.session_messages_exchanged = 0;
self.session_code_blocks_generated = 0;
self.session_files_edited = 0;
self.session_files_created = 0;
self.session_tools_usage.clear();
self.session_duration_seconds = 0;
self.session_start = Some(Instant::now());
self.achievements.start_session();
}
pub fn increment_messages(&mut self) {
self.messages_exchanged += 1;
self.session_messages_exchanged += 1;
}
pub fn increment_code_blocks(&mut self) {
self.code_blocks_generated += 1;
self.session_code_blocks_generated += 1;
}
pub fn increment_files_edited(&mut self) {
self.files_edited += 1;
self.session_files_edited += 1;
}
pub fn increment_files_created(&mut self) {
self.files_created += 1;
self.session_files_created += 1;
}
pub fn increment_tool_usage(&mut self, tool_name: &str) {
*self.tools_usage.entry(tool_name.to_string()).or_insert(0) += 1;
*self
.session_tools_usage
.entry(tool_name.to_string())
.or_insert(0) += 1;
}
pub fn get_session_duration(&mut self) -> u64 {
// Only update if more than 1 second has passed to reduce calculations
if let Some(start) = self.session_start {
let elapsed = start.elapsed().as_secs();
if elapsed > self.session_duration_seconds {
self.session_duration_seconds = elapsed;
}
}
self.session_duration_seconds
}
pub fn check_achievements(&mut self) -> Vec<crate::achievements::AchievementId> {
let stats_copy = UsageStats {
total_input_tokens: self.total_input_tokens,
total_output_tokens: self.total_output_tokens,
total_cost_usd: self.total_cost_usd,
session_input_tokens: self.session_input_tokens,
session_output_tokens: self.session_output_tokens,
session_cost_usd: self.session_cost_usd,
model: self.model.clone(),
messages_exchanged: self.messages_exchanged,
session_messages_exchanged: self.session_messages_exchanged,
code_blocks_generated: self.code_blocks_generated,
session_code_blocks_generated: self.session_code_blocks_generated,
files_edited: self.files_edited,
session_files_edited: self.session_files_edited,
files_created: self.files_created,
session_files_created: self.session_files_created,
tools_usage: self.tools_usage.clone(),
session_tools_usage: self.session_tools_usage.clone(),
session_duration_seconds: self.session_duration_seconds,
session_start: self.session_start,
achievements: AchievementProgress::new(), // Dummy for copy
};
check_achievements(&stats_copy, &mut self.achievements)
}
}
// Pricing as of January 2025
// https://www.anthropic.com/pricing
fn calculate_cost(input_tokens: u64, output_tokens: u64, model: &str) -> f64 {
let (input_price_per_million, output_price_per_million) = match model {
// Opus 4.5
"claude-opus-4-5-20251101" => (15.0, 75.0),
// Opus 4
"claude-opus-4-20250514" => (15.0, 75.0),
// Sonnet 4
"claude-sonnet-4-20250514" => (3.0, 15.0),
// Previous generation models
"claude-3-5-sonnet-20241022" => (3.0, 15.0),
"claude-3-5-sonnet-20240620" => (3.0, 15.0),
"claude-3-5-haiku-20241022" => (1.0, 5.0),
"claude-3-opus-20240229" => (15.0, 75.0),
"claude-3-sonnet-20240229" => (3.0, 15.0),
"claude-3-haiku-20240307" => (0.25, 1.25),
// Default to Sonnet pricing if model unknown
_ => (3.0, 15.0),
};
let input_cost = (input_tokens as f64 / 1_000_000.0) * input_price_per_million;
let output_cost = (output_tokens as f64 / 1_000_000.0) * output_price_per_million;
input_cost + output_cost
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StatsUpdateEvent {
pub stats: UsageStats,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_cost_calculation_sonnet() {
let cost = calculate_cost(1000, 2000, "claude-sonnet-4-20250514");
// 1000 input * $3/M = $0.003
// 2000 output * $15/M = $0.030
// Total = $0.033
assert!((cost - 0.033).abs() < 0.0001);
}
#[test]
fn test_cost_calculation_opus() {
let cost = calculate_cost(1000, 2000, "claude-opus-4-20250514");
// 1000 input * $15/M = $0.015
// 2000 output * $75/M = $0.150
// Total = $0.165
assert!((cost - 0.165).abs() < 0.0001);
}
#[test]
fn test_usage_stats_accumulation() {
let mut stats = UsageStats::new();
stats.add_usage(1000, 2000, "claude-sonnet-4-20250514");
assert_eq!(stats.total_input_tokens, 1000);
assert_eq!(stats.total_output_tokens, 2000);
assert_eq!(stats.session_input_tokens, 1000);
assert_eq!(stats.session_output_tokens, 2000);
assert!((stats.total_cost_usd - 0.033).abs() < 0.0001);
}
#[test]
fn test_session_reset() {
let mut stats = UsageStats::new();
stats.add_usage(1000, 2000, "claude-sonnet-4-20250514");
stats.reset_session();
assert_eq!(stats.total_input_tokens, 1000);
assert_eq!(stats.total_output_tokens, 2000);
assert_eq!(stats.session_input_tokens, 0);
assert_eq!(stats.session_output_tokens, 0);
assert_eq!(stats.session_cost_usd, 0.0);
assert!(stats.total_cost_usd > 0.0);
}
}
+139
View File
@@ -0,0 +1,139 @@
use parking_lot::Mutex;
use std::collections::HashMap;
use std::fs;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use uuid::Uuid;
const TEMP_DIR_NAME: &str = "hikari-uploads";
pub struct TempFileManager {
base_dir: PathBuf,
files: HashMap<String, Vec<PathBuf>>,
}
impl TempFileManager {
pub fn new() -> Result<Self, String> {
let base_dir = std::env::temp_dir().join(TEMP_DIR_NAME);
if !base_dir.exists() {
fs::create_dir_all(&base_dir)
.map_err(|e| format!("Failed to create temp directory: {}", e))?;
}
Ok(TempFileManager {
base_dir,
files: HashMap::new(),
})
}
#[allow(dead_code)]
pub fn get_base_dir(&self) -> &Path {
&self.base_dir
}
pub fn save_file(
&mut self,
conversation_id: &str,
data: &[u8],
original_filename: Option<&str>,
) -> Result<PathBuf, String> {
let unique_id = Uuid::new_v4();
let extension = original_filename
.and_then(|name| Path::new(name).extension())
.and_then(|ext| ext.to_str())
.unwrap_or("bin");
let filename = format!("{}_{}.{}", conversation_id, unique_id, extension);
let file_path = self.base_dir.join(&filename);
fs::write(&file_path, data)
.map_err(|e| format!("Failed to write temp file: {}", e))?;
self.files
.entry(conversation_id.to_string())
.or_default()
.push(file_path.clone());
Ok(file_path)
}
pub fn register_file(&mut self, conversation_id: &str, file_path: PathBuf) {
self.files
.entry(conversation_id.to_string())
.or_default()
.push(file_path);
}
pub fn get_files_for_conversation(&self, conversation_id: &str) -> Vec<PathBuf> {
self.files
.get(conversation_id)
.cloned()
.unwrap_or_default()
}
pub fn cleanup_conversation(&mut self, conversation_id: &str) -> Result<(), String> {
if let Some(files) = self.files.remove(conversation_id) {
for file_path in files {
if file_path.exists() {
if let Err(e) = fs::remove_file(&file_path) {
eprintln!(
"Warning: Failed to remove temp file {:?}: {}",
file_path, e
);
}
}
}
}
Ok(())
}
pub fn cleanup_all(&mut self) -> Result<(), String> {
let conversation_ids: Vec<String> = self.files.keys().cloned().collect();
for conversation_id in conversation_ids {
self.cleanup_conversation(&conversation_id)?;
}
Ok(())
}
pub fn cleanup_orphaned_files(&mut self) -> Result<usize, String> {
let mut cleaned_count = 0;
if !self.base_dir.exists() {
return Ok(0);
}
let tracked_files: std::collections::HashSet<PathBuf> =
self.files.values().flatten().cloned().collect();
let entries = fs::read_dir(&self.base_dir)
.map_err(|e| format!("Failed to read temp directory: {}", e))?;
for entry in entries.flatten() {
let path = entry.path();
if path.is_file() && !tracked_files.contains(&path) {
if let Err(e) = fs::remove_file(&path) {
eprintln!("Warning: Failed to remove orphaned file {:?}: {}", path, e);
} else {
cleaned_count += 1;
}
}
}
Ok(cleaned_count)
}
}
impl Default for TempFileManager {
fn default() -> Self {
Self::new().expect("Failed to create TempFileManager")
}
}
pub type SharedTempFileManager = Arc<Mutex<TempFileManager>>;
pub fn create_shared_temp_manager() -> Result<SharedTempFileManager, String> {
Ok(Arc::new(Mutex::new(TempFileManager::new()?)))
}
+68
View File
@@ -0,0 +1,68 @@
use tauri::{
menu::{Menu, MenuItem},
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
AppHandle, Manager,
};
use crate::config::HikariConfig;
pub fn setup_tray(app: &AppHandle) -> tauri::Result<()> {
let show_item = MenuItem::with_id(app, "show", "Show Hikari", true, None::<&str>)?;
let quit_item = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>)?;
let menu = Menu::with_items(app, &[&show_item, &quit_item])?;
let _tray = TrayIconBuilder::with_id("main")
.icon(app.default_window_icon().unwrap().clone())
.menu(&menu)
.tooltip("Hikari - Claude Code Assistant")
.on_menu_event(|app, event| match event.id.as_ref() {
"show" => {
if let Some(window) = app.get_webview_window("main") {
let _ = window.show();
let _ = window.unminimize();
let _ = window.set_focus();
}
}
"quit" => {
app.exit(0);
}
_ => {}
})
.on_tray_icon_event(|tray, event| {
if let TrayIconEvent::Click {
button: MouseButton::Left,
button_state: MouseButtonState::Up,
..
} = event
{
let app = tray.app_handle();
if let Some(window) = app.get_webview_window("main") {
let _ = window.show();
let _ = window.unminimize();
let _ = window.set_focus();
}
}
})
.build(app)?;
Ok(())
}
pub fn should_minimize_to_tray(app: &AppHandle) -> bool {
let config_path = app
.path()
.app_config_dir()
.ok()
.map(|p| p.join("hikari-config.json"));
if let Some(path) = config_path {
if let Ok(content) = std::fs::read_to_string(&path) {
if let Ok(config) = serde_json::from_str::<HikariConfig>(&content) {
return config.minimize_to_tray;
}
}
}
false
}
+189 -14
View File
@@ -1,8 +1,15 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UsageInfo {
pub input_tokens: u64,
pub output_tokens: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum CharacterState { pub enum CharacterState {
#[default]
Idle, Idle,
Thinking, Thinking,
Typing, Typing,
@@ -14,27 +21,17 @@ pub enum CharacterState {
Error, Error,
} }
impl Default for CharacterState { #[derive(Debug, Clone, Serialize, Deserialize, Default)]
fn default() -> Self {
CharacterState::Idle
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum ConnectionStatus { pub enum ConnectionStatus {
#[default]
Disconnected, Disconnected,
Connecting, Connecting,
Connected, Connected,
Error, Error,
} }
impl Default for ConnectionStatus { #[allow(dead_code)]
fn default() -> Self {
ConnectionStatus::Disconnected
}
}
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TerminalLine { pub struct TerminalLine {
pub id: String, pub id: String,
@@ -46,6 +43,7 @@ pub struct TerminalLine {
pub tool_name: Option<String>, pub tool_name: Option<String>,
} }
#[allow(dead_code)]
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PermissionRequest { pub struct PermissionRequest {
pub id: String, pub id: String,
@@ -95,6 +93,8 @@ pub enum ClaudeMessage {
num_turns: Option<u32>, num_turns: Option<u32>,
#[serde(default)] #[serde(default)]
permission_denials: Option<Vec<PermissionDenial>>, permission_denials: Option<Vec<PermissionDenial>>,
#[serde(default)]
usage: Option<UsageInfo>,
}, },
} }
@@ -105,6 +105,8 @@ pub struct AssistantMessageContent {
pub model: Option<String>, pub model: Option<String>,
#[serde(default)] #[serde(default)]
pub stop_reason: Option<String>, pub stop_reason: Option<String>,
#[serde(default)]
pub usage: Option<UsageInfo>,
} }
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
@@ -170,6 +172,8 @@ pub struct DeltaContent {
pub struct StateChangeEvent { pub struct StateChangeEvent {
pub state: CharacterState, pub state: CharacterState,
pub tool_name: Option<String>, pub tool_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub conversation_id: Option<String>,
} }
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
@@ -177,6 +181,8 @@ pub struct OutputEvent {
pub line_type: String, pub line_type: String,
pub content: String, pub content: String,
pub tool_name: Option<String>, pub tool_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub conversation_id: Option<String>,
} }
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
@@ -185,4 +191,173 @@ pub struct PermissionPromptEvent {
pub tool_name: String, pub tool_name: String,
pub tool_input: serde_json::Value, pub tool_input: serde_json::Value,
pub description: String, pub description: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub conversation_id: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ConnectionEvent {
pub status: ConnectionStatus,
#[serde(skip_serializing_if = "Option::is_none")]
pub conversation_id: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SessionEvent {
pub session_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub conversation_id: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WorkingDirectoryEvent {
pub directory: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub conversation_id: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QuestionOption {
pub label: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserQuestionEvent {
pub id: String,
pub question: String,
pub header: Option<String>,
pub options: Vec<QuestionOption>,
pub multi_select: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub conversation_id: Option<String>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_character_state_default() {
let state = CharacterState::default();
assert_eq!(state, CharacterState::Idle);
}
#[test]
fn test_connection_status_default() {
let status = ConnectionStatus::default();
matches!(status, ConnectionStatus::Disconnected);
}
#[test]
fn test_character_state_serialization() {
let state = CharacterState::Thinking;
let serialized = serde_json::to_string(&state).unwrap();
assert_eq!(serialized, "\"thinking\"");
let deserialized: CharacterState = serde_json::from_str(&serialized).unwrap();
assert_eq!(deserialized, CharacterState::Thinking);
}
#[test]
fn test_all_character_states_serialize() {
let states = vec![
(CharacterState::Idle, "\"idle\""),
(CharacterState::Thinking, "\"thinking\""),
(CharacterState::Typing, "\"typing\""),
(CharacterState::Searching, "\"searching\""),
(CharacterState::Coding, "\"coding\""),
(CharacterState::Mcp, "\"mcp\""),
(CharacterState::Permission, "\"permission\""),
(CharacterState::Success, "\"success\""),
(CharacterState::Error, "\"error\""),
];
for (state, expected) in states {
let serialized = serde_json::to_string(&state).unwrap();
assert_eq!(serialized, expected, "Failed for state: {:?}", state);
}
}
#[test]
fn test_terminal_line_serialization() {
let line = TerminalLine {
id: "test-123".to_string(),
line_type: "assistant".to_string(),
content: "Hello, world!".to_string(),
timestamp: "2024-01-01T00:00:00Z".to_string(),
tool_name: None,
};
let serialized = serde_json::to_string(&line).unwrap();
assert!(serialized.contains("\"type\":\"assistant\""));
assert!(serialized.contains("\"content\":\"Hello, world!\""));
assert!(!serialized.contains("tool_name"));
}
#[test]
fn test_terminal_line_with_tool_name() {
let line = TerminalLine {
id: "test-456".to_string(),
line_type: "tool".to_string(),
content: "Reading file...".to_string(),
timestamp: "2024-01-01T00:00:00Z".to_string(),
tool_name: Some("Read".to_string()),
};
let serialized = serde_json::to_string(&line).unwrap();
assert!(serialized.contains("\"tool_name\":\"Read\""));
}
#[test]
fn test_content_block_text() {
let block = ContentBlock::Text {
text: "Hello!".to_string(),
};
let serialized = serde_json::to_string(&block).unwrap();
assert!(serialized.contains("\"type\":\"text\""));
assert!(serialized.contains("\"text\":\"Hello!\""));
}
#[test]
fn test_content_block_tool_use() {
let block = ContentBlock::ToolUse {
id: "tool-123".to_string(),
name: "Read".to_string(),
input: serde_json::json!({"file_path": "/test.txt"}),
};
let serialized = serde_json::to_string(&block).unwrap();
assert!(serialized.contains("\"type\":\"tool_use\""));
assert!(serialized.contains("\"name\":\"Read\""));
}
#[test]
fn test_state_change_event() {
let event = StateChangeEvent {
state: CharacterState::Coding,
tool_name: Some("Edit".to_string()),
conversation_id: None,
};
let serialized = serde_json::to_string(&event).unwrap();
assert!(serialized.contains("\"state\":\"coding\""));
assert!(serialized.contains("\"tool_name\":\"Edit\""));
}
#[test]
fn test_output_event() {
let event = OutputEvent {
line_type: "assistant".to_string(),
content: "Test output".to_string(),
tool_name: None,
conversation_id: None,
};
let serialized = serde_json::to_string(&event).unwrap();
assert!(serialized.contains("\"line_type\":\"assistant\""));
assert!(serialized.contains("\"content\":\"Test output\""));
}
} }
+71
View File
@@ -0,0 +1,71 @@
use std::io::Write;
use std::process::Command;
use tauri::command;
use tempfile::NamedTempFile;
#[command]
pub async fn send_vbs_notification(title: String, body: String) -> Result<(), String> {
// Create a VBScript that shows a Windows notification
let vbs_content = format!(
r#"
Set objShell = CreateObject("WScript.Shell")
objShell.Popup "{}" & vbCrLf & vbCrLf & "{}", 5, "{}", 64
"#,
body.replace("\"", "\"\"").replace("\n", "\" & vbCrLf & \""),
title.replace("\"", "\"\""),
title.replace("\"", "\"\"")
);
// Create a temporary VBS file
let mut temp_file =
NamedTempFile::new().map_err(|e| format!("Failed to create temp file: {}", e))?;
temp_file
.write_all(vbs_content.as_bytes())
.map_err(|e| format!("Failed to write VBS content: {}", e))?;
let temp_path = temp_file.path().to_string_lossy().to_string();
// Convert WSL path to Windows path
let windows_path = if temp_path.starts_with("/mnt/") {
// Convert /mnt/c/... to C:\...
let path_parts: Vec<&str> = temp_path.split('/').collect();
if path_parts.len() > 2 {
let drive_letter = path_parts[2].to_uppercase();
let rest_of_path = path_parts[3..].join("\\");
format!("{}:\\{}", drive_letter, rest_of_path)
} else {
temp_path.clone()
}
} else if temp_path.starts_with("/tmp/") {
// WSL temp files might be in a different location
// Try to use wslpath to convert
let output = Command::new("wslpath").arg("-w").arg(&temp_path).output();
if let Ok(result) = output {
if result.status.success() {
String::from_utf8_lossy(&result.stdout).trim().to_string()
} else {
temp_path.clone()
}
} else {
temp_path.clone()
}
} else {
temp_path.clone()
};
// Execute the VBScript using wscript.exe
let output = Command::new("/mnt/c/Windows/System32/wscript.exe")
.arg("//NoLogo")
.arg(&windows_path)
.output()
.map_err(|e| format!("Failed to execute VBScript: {}", e))?;
if !output.status.success() {
let error = String::from_utf8_lossy(&output.stderr);
return Err(format!("VBScript execution failed: {}", error));
}
Ok(())
}
+64
View File
@@ -0,0 +1,64 @@
use tauri::command;
#[cfg(target_os = "windows")]
use windows::{
core::{Result as WindowsResult, HSTRING},
Data::Xml::Dom::*,
UI::Notifications::*,
};
#[cfg(target_os = "windows")]
#[command]
pub async fn send_windows_toast(title: String, body: String) -> Result<(), String> {
show_toast_notification(&title, &body)
.map_err(|e| format!("Failed to show toast notification: {}", e))
}
#[cfg(target_os = "windows")]
fn show_toast_notification(title: &str, body: &str) -> WindowsResult<()> {
// Create the XML for the toast notification
let toast_xml = format!(
r#"<toast>
<visual>
<binding template="ToastGeneric">
<text>{}</text>
<text>{}</text>
</binding>
</visual>
<audio src="ms-winsoundevent:Notification.Default" />
</toast>"#,
escape_xml(title),
escape_xml(body)
);
let xml_doc = XmlDocument::new()?;
xml_doc.LoadXml(&HSTRING::from(toast_xml))?;
// Create the toast notification
let toast = ToastNotification::CreateToastNotification(&xml_doc)?;
// Create a toast notifier with an application ID
let notifier =
ToastNotificationManager::CreateToastNotifierWithId(&HSTRING::from("Hikari Desktop"))?;
// Show the notification
notifier.Show(&toast)?;
Ok(())
}
#[cfg(target_os = "windows")]
fn escape_xml(text: &str) -> String {
text.replace('&', "&amp;")
.replace('<', "&lt;")
.replace('>', "&gt;")
.replace('"', "&quot;")
.replace('\'', "&apos;")
}
// Stub for non-Windows platforms
#[cfg(not(target_os = "windows"))]
#[command]
pub async fn send_windows_toast(_title: String, _body: String) -> Result<(), String> {
Err("Windows toast notifications are only available on Windows".to_string())
}
File diff suppressed because it is too large Load Diff
+84
View File
@@ -0,0 +1,84 @@
use std::process::Command;
use tauri::command;
#[command]
pub async fn send_wsl_notification(title: String, body: String) -> Result<(), String> {
// Method 1: Try Windows 10/11 toast notification using PowerShell
let toast_command = format!(
r#"
Add-Type -AssemblyName System.Runtime.WindowsRuntime
$null = [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]
$null = [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime]
$APP_ID = 'Hikari Desktop'
$template = @"
<toast>
<visual>
<binding template="ToastGeneric">
<text>{0}</text>
<text>{1}</text>
</binding>
</visual>
</toast>
"@
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml($template -f ('{0}' -replace "'", "''"), ('{1}' -replace "'", "''"))
$toast = New-Object Windows.UI.Notifications.ToastNotification $xml
$notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($APP_ID)
$notifier.Show($toast)
"#,
title.replace("'", "''").replace("\"", "\\\""),
body.replace("'", "''").replace("\"", "\\\"")
);
// Try PowerShell.exe through WSL
let output = Command::new("/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe")
.arg("-NoProfile")
.arg("-ExecutionPolicy")
.arg("Bypass")
.arg("-WindowStyle")
.arg("Hidden")
.arg("-Command")
.arg(&toast_command)
.output();
match output {
Ok(result) => {
if result.status.success() {
println!("WSL notification sent successfully");
return Ok(());
} else {
let stderr = String::from_utf8_lossy(&result.stderr);
println!("PowerShell toast failed: {}", stderr);
}
}
Err(e) => {
println!("Failed to run PowerShell: {}", e);
}
}
// Skip msg.exe as it creates alert boxes
// Method 2 removed
// Method 3: Try wsl-notify-send if available
let notify_result = Command::new("wsl-notify-send")
.arg("--appId")
.arg("HikariDesktop")
.arg("--category")
.arg(&title)
.arg(&body)
.output();
if let Ok(result) = notify_result {
if result.status.success() {
println!("Notification sent via wsl-notify-send");
return Ok(());
}
}
// If all methods fail, return an error
Err("All WSL notification methods failed".to_string())
}
+7 -1
View File
@@ -1,7 +1,7 @@
{ {
"$schema": "https://schema.tauri.app/config/2", "$schema": "https://schema.tauri.app/config/2",
"productName": "hikari-desktop", "productName": "hikari-desktop",
"version": "0.1.0", "version": "0.3.0",
"identifier": "com.naomi.hikari-desktop", "identifier": "com.naomi.hikari-desktop",
"build": { "build": {
"beforeDevCommand": "pnpm dev", "beforeDevCommand": "pnpm dev",
@@ -22,6 +22,12 @@
], ],
"security": { "security": {
"csp": null "csp": null
},
"trayIcon": {
"id": "main",
"iconPath": "icons/32x32.png",
"iconAsTemplate": false,
"tooltip": "Hikari - Claude Code Assistant"
} }
}, },
"bundle": { "bundle": {
+81 -1
View File
@@ -1,14 +1,94 @@
@import "tailwindcss"; @import "tailwindcss";
:root { :root,
[data-theme="dark"] {
--bg-primary: #1a1a2e; --bg-primary: #1a1a2e;
--bg-secondary: #16213e; --bg-secondary: #16213e;
--bg-terminal: #0f0f1a; --bg-terminal: #0f0f1a;
--bg-hover: #2a2a4a;
--bg-code: #1e1e2e;
--accent-primary: #e94560; --accent-primary: #e94560;
--accent-secondary: #ff6b9d; --accent-secondary: #ff6b9d;
--text-primary: #ffffff; --text-primary: #ffffff;
--text-secondary: #a0a0a0; --text-secondary: #a0a0a0;
--text-tertiary: #6b7280;
--border-color: #2a2a4a; --border-color: #2a2a4a;
/* Terminal specific colors */
--terminal-user: #22d3ee;
--terminal-tool: #c084fc;
--terminal-tool-name: #ddd6fe;
--terminal-error: #f87171;
/* Syntax highlighting colors (dark) */
--hljs-keyword: #f472b6;
--hljs-string: #a3e635;
--hljs-number: #fbbf24;
--hljs-comment: #6b7280;
--hljs-function: #c084fc;
--hljs-type: #22d3ee;
--hljs-variable: #fb923c;
--hljs-meta: #94a3b8;
}
[data-theme="light"] {
--bg-primary: #f8f9fa;
--bg-secondary: #ffffff;
--bg-terminal: #f1f3f4;
--bg-hover: #e8e8e8;
--bg-code: #f5f5f5;
--accent-primary: #e94560;
--accent-secondary: #ff6b9d;
--text-primary: #1a1a2e;
--text-secondary: #5a5a7a;
--text-tertiary: #9ca3af;
--border-color: #d0d0e0;
/* Terminal specific colors */
--terminal-user: #0891b2;
--terminal-tool: #7c3aed;
--terminal-tool-name: #8b5cf6;
--terminal-error: #dc2626;
/* Syntax highlighting colors (light) */
--hljs-keyword: #d946ef;
--hljs-string: #16a34a;
--hljs-number: #d97706;
--hljs-comment: #9ca3af;
--hljs-function: #7c3aed;
--hljs-type: #0891b2;
--hljs-variable: #ea580c;
--hljs-meta: #64748b;
}
[data-theme="high-contrast"] {
--bg-primary: #000000;
--bg-secondary: #0a0a0a;
--bg-terminal: #000000;
--bg-hover: #1a1a1a;
--bg-code: #0a0a0a;
--accent-primary: #ff4d6d;
--accent-secondary: #ff85a1;
--text-primary: #ffffff;
--text-secondary: #e0e0e0;
--text-tertiary: #b0b0b0;
--border-color: #ffffff;
/* Terminal specific colors - bright and saturated */
--terminal-user: #00ffff;
--terminal-tool: #ff00ff;
--terminal-tool-name: #ffaaff;
--terminal-error: #ff5555;
/* Syntax highlighting colors (high contrast) */
--hljs-keyword: #ff66ff;
--hljs-string: #66ff66;
--hljs-number: #ffff00;
--hljs-comment: #aaaaaa;
--hljs-function: #ff99ff;
--hljs-type: #00ffff;
--hljs-variable: #ffaa00;
--hljs-meta: #cccccc;
} }
html, html,
+280
View File
@@ -0,0 +1,280 @@
import { get } from "svelte/store";
import { invoke } from "@tauri-apps/api/core";
import { claudeStore } from "$lib/stores/claude";
import { characterState } from "$lib/stores/character";
import { setSkipNextGreeting } from "$lib/tauri";
import { searchState } from "$lib/stores/search";
export interface SlashCommand {
name: string;
description: string;
usage: string;
execute: (args: string) => Promise<void> | void;
}
async function changeDirectory(path: string): Promise<void> {
const conversationId = get(claudeStore.activeConversationId);
if (!conversationId) {
claudeStore.addLine("error", "No active conversation");
return;
}
if (!path.trim()) {
const currentDir = get(claudeStore.currentWorkingDirectory);
claudeStore.addLine("system", `Current directory: ${currentDir}`);
return;
}
try {
characterState.setState("thinking");
claudeStore.addLine("system", `Changing directory to: ${path}`);
const currentDir = get(claudeStore.currentWorkingDirectory);
const validatedPath = await invoke<string>("validate_directory", { path, currentDir });
// Capture conversation history before disconnecting
const conversationHistory = claudeStore.getConversationHistory();
await invoke("stop_claude", { conversationId });
// Wait for clean shutdown
await new Promise((resolve) => setTimeout(resolve, 500));
claudeStore.setWorkingDirectory(validatedPath);
setSkipNextGreeting(true);
await invoke("start_claude", {
conversationId,
options: {
working_dir: validatedPath,
},
});
// Wait for connection to establish
await new Promise((resolve) => setTimeout(resolve, 1000));
// Restore context if there was conversation history
if (conversationHistory) {
const contextMessage = `[CONTEXT RESTORATION]
I just changed the working directory from ${currentDir} to ${validatedPath}. Here's our conversation so far:
${conversationHistory}
Please continue where we left off. You are now operating in the new directory.`;
await invoke("send_prompt", {
conversationId,
message: contextMessage,
});
}
claudeStore.addLine("system", `Changed directory to: ${validatedPath}`);
characterState.setState("idle");
} catch (error) {
claudeStore.addLine("error", `Failed to change directory: ${error}`);
characterState.setTemporaryState("error", 3000);
}
}
async function startNewConversation(): Promise<void> {
const conversationId = get(claudeStore.activeConversationId);
if (!conversationId) {
claudeStore.addLine("error", "No active conversation");
return;
}
try {
const workingDir = await invoke<string>("get_working_directory", {
conversationId,
});
claudeStore.addLine("system", "Starting new conversation...");
characterState.setState("thinking");
await invoke("interrupt_claude", { conversationId });
claudeStore.clearTerminal();
setSkipNextGreeting(true);
await invoke("start_claude", {
conversationId,
options: {
working_dir: workingDir,
},
});
claudeStore.addLine("system", "New conversation started!");
characterState.setState("idle");
} catch (error) {
claudeStore.addLine("error", `Failed to start new conversation: ${error}`);
characterState.setTemporaryState("error", 3000);
}
}
export const slashCommands: SlashCommand[] = [
{
name: "cd",
description: "Change the working directory",
usage: "/cd <path>",
execute: changeDirectory,
},
{
name: "clear",
description: "Clear the terminal display (keeps conversation context)",
usage: "/clear",
execute: () => {
claudeStore.clearTerminal();
claudeStore.addLine("system", "Terminal cleared");
},
},
{
name: "new",
description: "Start a fresh conversation (resets context)",
usage: "/new",
execute: startNewConversation,
},
{
name: "help",
description: "Show available slash commands",
usage: "/help",
execute: () => {
const helpText = slashCommands
.map((cmd) => ` ${cmd.usage.padEnd(12)} - ${cmd.description}`)
.join("\n");
claudeStore.addLine("system", `Available commands:\n${helpText}`);
},
},
{
name: "search",
description: "Search within the conversation (use /search to clear)",
usage: "/search [query]",
execute: (args: string) => {
if (!args.trim()) {
searchState.clear();
claudeStore.addLine("system", "Search cleared");
return;
}
searchState.setQuery(args.trim());
claudeStore.addLine("system", `Searching for: "${args.trim()}"`);
},
},
{
name: "summarise",
description: "Get a summary of the entire conversation",
usage: "/summarise",
execute: async () => {
const conversationId = get(claudeStore.activeConversationId);
if (!conversationId) {
claudeStore.addLine("error", "No active conversation");
return;
}
try {
claudeStore.addLine("system", "Requesting conversation summary...");
await invoke("send_prompt", {
conversationId,
message:
"Please provide a comprehensive summary of our entire conversation so far, including the key topics we've discussed, decisions made, and any important context.",
});
} catch (error) {
claudeStore.addLine("error", `Failed to request summary: ${error}`);
}
},
},
{
name: "skill",
description: "Invoke a Claude Code skill from ~/.claude/skills/",
usage: "/skill [name] [data]",
execute: async (args: string) => {
const conversationId = get(claudeStore.activeConversationId);
if (!conversationId) {
claudeStore.addLine("error", "No active conversation");
return;
}
const parts = args.trim().split(/\s+/);
const skillName = parts[0];
const skillData = parts.slice(1).join(" ");
// If no skill name provided, list available skills
if (!skillName) {
try {
const skills = await invoke<string[]>("list_skills");
if (skills.length === 0) {
claudeStore.addLine(
"system",
"No skills found in ~/.claude/skills/\nCreate a skill by adding a folder with a SKILL.md file."
);
} else {
const skillList = skills.map((s) => `${s}`).join("\n");
claudeStore.addLine(
"system",
`Available skills:\n${skillList}\n\nUsage: /skill <skill-name> [data]`
);
}
} catch (error) {
claudeStore.addLine("error", `Failed to list skills: ${error}`);
}
return;
}
try {
claudeStore.addLine("system", `Invoking skill: ${skillName}`);
characterState.setState("thinking");
const message = skillData
? `Please run the /${skillName} skill with the following data:\n\n${skillData}`
: `Please run the /${skillName} skill.`;
await invoke("send_prompt", {
conversationId,
message,
});
} catch (error) {
claudeStore.addLine("error", `Failed to invoke skill: ${error}`);
characterState.setTemporaryState("error", 3000);
}
},
},
];
export function parseSlashCommand(input: string): {
command: SlashCommand | null;
args: string;
} {
const trimmed = input.trim();
if (!trimmed.startsWith("/")) {
return { command: null, args: "" };
}
const parts = trimmed.slice(1).split(/\s+/);
const commandName = parts[0]?.toLowerCase();
const args = parts.slice(1).join(" ");
const command = slashCommands.find((cmd) => cmd.name.toLowerCase() === commandName);
return { command: command || null, args };
}
export function getMatchingCommands(input: string): SlashCommand[] {
const trimmed = input.trim();
if (!trimmed.startsWith("/")) {
return [];
}
const partial = trimmed.slice(1).toLowerCase();
if (partial === "") {
return slashCommands;
}
return slashCommands.filter((cmd) => cmd.name.toLowerCase().startsWith(partial));
}
export function isSlashCommand(input: string): boolean {
return input.trim().startsWith("/");
}
+153
View File
@@ -0,0 +1,153 @@
<script lang="ts">
import { openUrl } from "@tauri-apps/plugin-opener";
import { getVersion } from "@tauri-apps/api/app";
import { onMount } from "svelte";
interface Props {
onClose: () => void;
}
const { onClose }: Props = $props();
let appVersion = $state("");
onMount(async () => {
appVersion = await getVersion();
});
const links = {
source: "https://git.nhcarrigan.com/nhcarrigan/hikari-desktop",
discord: "https://chat.nhcarrigan.com",
website: "https://nhcarrigan.com",
license: "https://docs.nhcarrigan.com/legal/license/",
changelog: "https://git.nhcarrigan.com/nhcarrigan/hikari-desktop/releases",
};
</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-md w-full p-6"
onclick={(e) => e.stopPropagation()}
onkeydown={(e) => e.stopPropagation()}
role="dialog"
aria-labelledby="about-title"
tabindex="-1"
>
<div class="flex items-center justify-between mb-4">
<h2 id="about-title" class="text-xl font-semibold text-[var(--text-primary)]">
About Hikari Desktop
</h2>
<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="space-y-4 text-sm">
<div>
<h3 class="font-medium text-[var(--text-primary)] mb-2">What is Hikari Desktop?</h3>
<p class="text-[var(--text-secondary)]">
Hikari Desktop is an AI-powered desktop assistant that brings Claude directly to your
desktop. Built with love using Tauri, Svelte, and Rust for a fast, native experience.
</p>
</div>
<div>
<h3 class="font-medium text-[var(--text-primary)] mb-2">Version</h3>
<p class="text-[var(--text-secondary)] mb-1">
{appVersion || "Loading..."}
</p>
<button
onclick={() => openUrl(links.changelog)}
class="text-[var(--accent-primary)] hover:text-[var(--accent-primary-hover)] transition-colors underline"
>
View Changelog
</button>
</div>
<div>
<h3 class="font-medium text-[var(--text-primary)] mb-2">Source Code</h3>
<button
onclick={() => openUrl(links.source)}
class="text-[var(--accent-primary)] hover:text-[var(--accent-primary-hover)] transition-colors underline"
>
View on Git
</button>
</div>
<div>
<h3 class="font-medium text-[var(--text-primary)] mb-2">Support & Community</h3>
<p class="text-[var(--text-secondary)] mb-1">Found a bug or have a suggestion?</p>
<button
onclick={() => openUrl(links.discord)}
class="text-[var(--accent-primary)] hover:text-[var(--accent-primary-hover)] transition-colors underline"
>
Join our Discord
</button>
</div>
<div>
<h3 class="font-medium text-[var(--text-primary)] mb-2">Built with 💕 by</h3>
<button
onclick={() => openUrl(links.website)}
class="text-[var(--accent-primary)] hover:text-[var(--accent-primary-hover)] transition-colors underline"
>
Naomi Carrigan
</button>
</div>
<div>
<h3 class="font-medium text-[var(--text-primary)] mb-2">License</h3>
<p class="text-[var(--text-secondary)] mb-1">
This project is open source and available under our license terms.
</p>
<button
onclick={() => openUrl(links.license)}
class="text-[var(--accent-primary)] hover:text-[var(--accent-primary-hover)] transition-colors underline"
>
View License
</button>
</div>
<div class="pt-4 mt-4 border-t border-[var(--border-color)]">
<p class="text-xs text-[var(--text-tertiary)] text-center">
Copyright © {new Date().getFullYear()} Naomi Carrigan. All rights reserved.
</p>
</div>
</div>
</div>
</div>
<style>
/* Ensure the panel appears above other content */
[role="dialog"] {
animation: slideIn 0.2s ease-out;
}
@keyframes slideIn {
from {
opacity: 0;
transform: scale(0.95);
}
to {
opacity: 1;
transform: scale(1);
}
}
</style>
@@ -0,0 +1,202 @@
<script lang="ts">
import { onMount } from "svelte";
import { fade, fly } from "svelte/transition";
import { cubicOut } from "svelte/easing";
import { listen } from "@tauri-apps/api/event";
import type { AchievementUnlockedEvent } from "$lib/types/achievements";
let achievements = $state<AchievementUnlockedEvent[]>([]);
let currentAchievement = $state<AchievementUnlockedEvent | null>(null);
let showNotification = $state(false);
onMount(() => {
let unlisten: (() => void) | undefined;
const setupListener = async () => {
unlisten = await listen<AchievementUnlockedEvent>("achievement:unlocked", (event) => {
achievements.push(event.payload);
if (!showNotification) {
showNext();
}
});
};
setupListener();
return () => {
if (unlisten) {
unlisten();
}
};
});
function showNext() {
if (achievements.length > 0) {
currentAchievement = achievements.shift() || null;
showNotification = true;
// Auto-hide after 5 seconds
setTimeout(() => {
showNotification = false;
// Show next achievement after animation completes
setTimeout(() => showNext(), 300);
}, 5000);
}
}
function dismiss() {
showNotification = false;
// Show next achievement after animation completes
setTimeout(() => showNext(), 300);
}
function getRarityColor(rarity: string): string {
switch (rarity) {
case "legendary":
return "from-yellow-400 to-orange-500";
case "epic":
return "from-purple-400 to-pink-500";
case "rare":
return "from-blue-400 to-indigo-500";
default:
return "from-green-400 to-emerald-500";
}
}
function getAchievementRarity(id: string): string {
// Determine rarity based on achievement ID
if (id === "TokenMaster") return "legendary";
if (["CodeMachine", "Unstoppable"].includes(id)) return "epic";
if (
[
"BlossomingCoder",
"CodeWizard",
"MasterBuilder",
"EnduranceChamp",
"DeepDive",
"CreativeCoder",
].includes(id)
)
return "rare";
return "common";
}
</script>
{#if showNotification && currentAchievement}
<div
class="fixed top-20 right-4 z-50 max-w-sm"
in:fly={{ x: 300, duration: 500, easing: cubicOut }}
out:fade={{ duration: 300 }}
>
<!-- Backdrop with animated gradient border -->
<div class="relative p-[2px] rounded-lg overflow-hidden">
<!-- Animated gradient border -->
<div
class="absolute inset-0 bg-gradient-to-r {getRarityColor(
getAchievementRarity(currentAchievement.achievement.id)
)} animate-pulse"
></div>
<!-- Main notification content -->
<div class="relative bg-[var(--bg-primary)] rounded-lg p-4 shadow-2xl backdrop-blur-sm">
<button
onclick={dismiss}
onkeydown={(e) => e.key === "Enter" && dismiss()}
class="absolute top-2 right-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 transition-colors"
aria-label="Dismiss notification"
>
<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"
></path>
</svg>
</button>
<div class="flex items-start gap-4">
<!-- Icon with animated sparkles -->
<div class="relative flex-shrink-0">
<div class="text-5xl animate-bounce">{currentAchievement.achievement.icon}</div>
<!-- Sparkle animations -->
<div class="absolute -top-1 -right-1 text-yellow-400 animate-ping"></div>
<div
class="absolute -bottom-1 -left-1 text-yellow-400 animate-ping animation-delay-200"
>
</div>
<div class="absolute top-1/2 -right-2 text-yellow-400 animate-ping animation-delay-400">
</div>
</div>
<!-- Text content -->
<div class="flex-1 min-w-0 pt-1">
<h3
class="text-sm font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide"
>
Achievement Unlocked!
</h3>
<p class="text-lg font-bold text-[var(--text-primary)] mt-1">
{currentAchievement.achievement.name}
</p>
<p class="text-sm text-gray-600 dark:text-gray-400 mt-1">
{currentAchievement.achievement.description}
</p>
<!-- Rarity badge -->
<div class="mt-2 inline-flex items-center">
<span
class="px-2 py-1 text-xs font-medium rounded-full bg-gradient-to-r {getRarityColor(
getAchievementRarity(currentAchievement.achievement.id)
)} text-white capitalize"
>
{getAchievementRarity(currentAchievement.achievement.id)}
</span>
</div>
</div>
</div>
<!-- Celebration confetti effect (CSS only) -->
<div class="absolute inset-0 pointer-events-none overflow-hidden rounded-lg">
{#each Array(10) as _ (_)}
<div
class="absolute w-2 h-2 bg-gradient-to-br {getRarityColor(
getAchievementRarity(currentAchievement.achievement.id)
)} rounded-full animate-fall"
style="left: {Math.random() * 100}%; animation-delay: {Math.random() *
2}s; animation-duration: {2 + Math.random() * 2}s;"
></div>
{/each}
</div>
</div>
</div>
</div>
{/if}
<style>
@keyframes fall {
0% {
transform: translateY(-20px) rotate(0deg);
opacity: 1;
}
100% {
transform: translateY(400px) rotate(720deg);
opacity: 0;
}
}
.animate-fall {
animation: fall linear infinite;
}
.animation-delay-200 {
animation-delay: 200ms;
}
.animation-delay-400 {
animation-delay: 400ms;
}
</style>
+266
View File
@@ -0,0 +1,266 @@
<script lang="ts">
import { slide } from "svelte/transition";
import { quintOut } from "svelte/easing";
import {
achievementsStore,
achievementProgress,
achievementCategories,
} from "$lib/stores/achievements";
import type { Achievement } from "$lib/types/achievements";
interface Props {
isOpen: boolean;
onClose?: () => void;
}
const { isOpen = $bindable(false), onClose }: Props = $props();
let selectedCategory = $state<string | null>(null);
const achievementsState = $derived($achievementsStore);
const progress = $derived($achievementProgress);
function getRarityColor(rarity: string): string {
switch (rarity) {
case "legendary":
return "text-yellow-500 dark:text-yellow-400";
case "epic":
return "text-purple-500 dark:text-purple-400";
case "rare":
return "text-blue-500 dark:text-blue-400";
default:
return "text-green-500 dark:text-green-400";
}
}
function getRarityBg(rarity: string): string {
switch (rarity) {
case "legendary":
return "bg-yellow-500/10";
case "epic":
return "bg-purple-500/10";
case "rare":
return "bg-blue-500/10";
default:
return "bg-green-500/10";
}
}
function formatDate(date: Date | undefined): string {
if (!date) return "";
return new Date(date).toLocaleDateString("en-US", {
month: "short",
day: "numeric",
year: "numeric",
});
}
function getAchievementsForCategory(categoryIds: string[]): Achievement[] {
return categoryIds
.map(
(id) => achievementsState.achievements[id as keyof typeof achievementsState.achievements]
)
.filter(Boolean);
}
</script>
<!-- Achievements panel -->
{#if isOpen}
<div
class="fixed inset-0 bg-black/50 z-40"
onclick={onClose}
onkeydown={(e) => e.key === "Escape" && onClose?.()}
role="button"
tabindex="-1"
aria-label="Close achievements panel"
transition:slide={{ duration: 300, easing: quintOut }}
></div>
<div
class="fixed left-0 top-0 h-full w-96 bg-[var(--bg-primary)] border-r border-[var(--border-color)]
shadow-2xl z-50 flex flex-col"
transition:slide={{ duration: 300, easing: quintOut, axis: "x" }}
>
<!-- Header -->
<div class="p-6 border-b border-[var(--border-color)]">
<div class="flex items-center justify-between">
<h2 class="text-2xl font-bold text-[var(--text-primary)]">Achievements</h2>
<button
onclick={onClose}
onkeydown={(e) => e.key === "Enter" && onClose?.()}
class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"
aria-label="Close achievements panel"
>
<svg class="w-6 h-6" 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"
></path>
</svg>
</button>
</div>
<!-- Overall progress -->
<div class="mt-4">
<div
class="flex items-center justify-between text-sm text-gray-600 dark:text-gray-400 mb-2"
>
<span>{progress.unlocked} / {progress.total} Unlocked</span>
<span>{progress.percentage}%</span>
</div>
<div class="w-full bg-gray-200 dark:bg-gray-700 rounded-full h-2">
<div
class="bg-gradient-to-r from-[var(--accent-primary)] to-[var(--accent-secondary)] h-2 rounded-full transition-all duration-500"
style="width: {progress.percentage}%"
></div>
</div>
</div>
</div>
<!-- Categories -->
<div class="flex-1 overflow-y-auto">
{#each achievementCategories as category (category.name)}
{@const achievements = getAchievementsForCategory(category.ids)}
{@const unlockedCount = achievements.filter((a) => a.unlocked).length}
<div class="border-b border-[var(--border-color)]">
<button
onclick={() =>
(selectedCategory = selectedCategory === category.name ? null : category.name)}
onkeydown={(e) =>
e.key === "Enter" &&
(selectedCategory = selectedCategory === category.name ? null : category.name)}
class="w-full p-4 text-left hover:bg-[var(--bg-secondary)] transition-colors"
>
<div class="flex items-center justify-between">
<div>
<h3 class="font-semibold text-[var(--text-primary)]">{category.name}</h3>
<p class="text-sm text-gray-600 dark:text-gray-400">{category.description}</p>
</div>
<div class="flex items-center gap-2">
<span class="text-sm text-gray-600 dark:text-gray-400">
{unlockedCount} / {achievements.length}
</span>
<svg
class="w-5 h-5 transition-transform {selectedCategory === category.name
? 'rotate-180'
: ''}"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M19 9l-7 7-7-7"
></path>
</svg>
</div>
</div>
</button>
{#if selectedCategory === category.name}
<div class="p-4 space-y-3" transition:slide={{ duration: 200, easing: quintOut }}>
{#each achievements as achievement (achievement.id)}
<div
class="p-3 rounded-lg border {achievement.unlocked
? 'border-[var(--border-color)] bg-[var(--bg-secondary)]'
: 'border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-800 opacity-50'}"
>
<div class="flex items-start gap-3">
<!-- Icon -->
<div class="text-3xl flex-shrink-0 {achievement.unlocked ? '' : 'grayscale'}">
{achievement.icon}
</div>
<!-- Details -->
<div class="flex-1 min-w-0">
<div class="flex items-center gap-2">
<h4 class="font-semibold text-[var(--text-primary)]">
{achievement.name}
</h4>
<span
class="text-xs px-2 py-0.5 rounded-full {getRarityBg(
achievement.rarity
)} {getRarityColor(achievement.rarity)} capitalize"
>
{achievement.rarity}
</span>
</div>
<p class="text-sm text-gray-600 dark:text-gray-400 mt-1">
{achievement.description}
</p>
{#if achievement.unlocked && achievement.unlockedAt}
<p class="text-xs text-gray-500 dark:text-gray-500 mt-2">
Unlocked {formatDate(achievement.unlockedAt)}
</p>
{:else if achievement.maxProgress && achievement.progress !== undefined}
<!-- Progress bar for locked achievements -->
<div class="mt-2">
<div class="flex items-center justify-between text-xs text-gray-500 mb-1">
<span>Progress</span>
<span>{achievement.progress} / {achievement.maxProgress}</span>
</div>
<div class="w-full bg-gray-300 dark:bg-gray-700 rounded-full h-1.5">
<div
class="bg-gray-500 h-1.5 rounded-full transition-all duration-300"
style="width: {Math.min(
(achievement.progress / achievement.maxProgress) * 100,
100
)}%"
></div>
</div>
</div>
{/if}
</div>
</div>
</div>
{/each}
</div>
{/if}
</div>
{/each}
</div>
<!-- Footer with last unlocked -->
{#if achievementsState.lastUnlocked}
<div class="p-4 border-t border-[var(--border-color)] bg-[var(--bg-secondary)]">
<p class="text-sm text-gray-600 dark:text-gray-400 mb-1">Last Unlocked:</p>
<div class="flex items-center gap-2">
<span class="text-xl">{achievementsState.lastUnlocked.icon}</span>
<div>
<p class="font-semibold text-[var(--text-primary)]">
{achievementsState.lastUnlocked.name}
</p>
<p class="text-xs text-gray-500">
{formatDate(achievementsState.lastUnlocked.unlockedAt)}
</p>
</div>
</div>
</div>
{/if}
</div>
{/if}
<style>
/* Custom scrollbar for achievement list */
:global(.overflow-y-auto::-webkit-scrollbar) {
width: 8px;
}
:global(.overflow-y-auto::-webkit-scrollbar-track) {
background: var(--bg-secondary);
}
:global(.overflow-y-auto::-webkit-scrollbar-thumb) {
background: var(--border-color);
border-radius: 4px;
}
:global(.overflow-y-auto::-webkit-scrollbar-thumb:hover) {
background: var(--accent-primary);
}
</style>
+38 -17
View File
@@ -57,32 +57,40 @@
} }
</script> </script>
<div class="anime-girl-container flex flex-col items-center justify-end h-full p-4"> <div
<div class="character-frame relative {getBackgroundGlow()} w-full max-w-md"> class="anime-girl-container flex flex-col items-center justify-between h-full p-4 overflow-hidden"
<div class="sprite-container {getAnimationClass()}"> >
<div
class="character-frame relative {getBackgroundGlow()} flex-1 flex items-center justify-center min-h-0"
>
<div class="sprite-container {getAnimationClass()} h-full flex items-center justify-center">
<img <img
src="/sprites/{info.spriteFile}" src="/sprites/{info.spriteFile}"
alt="Hikari - {info.label}" alt="Hikari - {info.label}"
class="character-sprite w-full h-auto object-contain" class="character-sprite h-full w-auto max-w-full object-contain"
onerror={(e) => { onerror={(e) => {
const target = e.currentTarget as HTMLImageElement; const target = e.currentTarget as HTMLImageElement;
target.src = "/sprites/placeholder.svg"; target.src = "/sprites/placeholder.svg";
}} }}
/> />
</div> </div>
</div>
<div class="state-indicator absolute -bottom-2 left-1/2 transform -translate-x-1/2"> <div class="state-indicator mt-2">
<div <div
class="px-3 py-1 rounded-full text-xs font-medium bg-[var(--bg-secondary)] border border-[var(--border-color)] text-[var(--accent-primary)]" class="px-3 py-1 rounded-full text-xs font-medium bg-[var(--bg-secondary)] border border-[var(--border-color)] text-[var(--accent-primary)]"
> >
{info.label} {info.label}
</div> </div>
</div> </div>
</div>
<div class="speech-bubble mt-4 max-w-xs"> <div class="speech-bubble mt-2 max-w-xs flex-shrink-0">
<div class="relative bg-[var(--bg-secondary)] rounded-lg px-4 py-2 border border-[var(--border-color)]"> <div
<div class="absolute -top-2 left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-8 border-r-8 border-b-8 border-transparent border-b-[var(--bg-secondary)]"></div> class="relative bg-[var(--bg-secondary)] rounded-lg px-4 py-2 border border-[var(--border-color)]"
>
<div
class="absolute -top-2 left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-8 border-r-8 border-b-8 border-transparent border-b-[var(--bg-secondary)]"
></div>
<p class="text-sm text-gray-300 text-center italic">{info.description}</p> <p class="text-sm text-gray-300 text-center italic">{info.description}</p>
</div> </div>
</div> </div>
@@ -123,7 +131,8 @@
} }
@keyframes idle-bob { @keyframes idle-bob {
0%, 100% { 0%,
100% {
transform: translateY(0); transform: translateY(0);
} }
50% { 50% {
@@ -132,7 +141,8 @@
} }
@keyframes thinking-sway { @keyframes thinking-sway {
0%, 100% { 0%,
100% {
transform: rotate(-2deg); transform: rotate(-2deg);
} }
50% { 50% {
@@ -141,7 +151,8 @@
} }
@keyframes typing-bounce { @keyframes typing-bounce {
0%, 100% { 0%,
100% {
transform: translateY(0) scale(1); transform: translateY(0) scale(1);
} }
50% { 50% {
@@ -150,7 +161,8 @@
} }
@keyframes searching-look { @keyframes searching-look {
0%, 100% { 0%,
100% {
transform: translateX(0); transform: translateX(0);
} }
25% { 25% {
@@ -162,7 +174,8 @@
} }
@keyframes celebrate { @keyframes celebrate {
0%, 100% { 0%,
100% {
transform: scale(1) rotate(0deg); transform: scale(1) rotate(0deg);
} }
25% { 25% {
@@ -177,13 +190,21 @@
} }
@keyframes shake { @keyframes shake {
0%, 100% { 0%,
100% {
transform: translateX(0); transform: translateX(0);
} }
10%, 30%, 50%, 70%, 90% { 10%,
30%,
50%,
70%,
90% {
transform: translateX(-5px); transform: translateX(-5px);
} }
20%, 40%, 60%, 80% { 20%,
40%,
60%,
80% {
transform: translateX(5px); transform: translateX(5px);
} }
} }
+209
View File
@@ -0,0 +1,209 @@
<script lang="ts">
import type { Attachment } from "$lib/types/messages";
interface Props {
attachments: Attachment[];
onRemove: (id: string) => void;
}
let { attachments, onRemove }: Props = $props();
function formatFileSize(bytes: number): string {
if (bytes < 1024) return `${bytes} B`;
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
}
function getFileIcon(type: Attachment["type"]): string {
switch (type) {
case "image":
return "🖼️";
case "document":
return "📄";
default:
return "📎";
}
}
</script>
{#if attachments.length > 0}
<div class="attachment-preview-container">
<div class="attachment-header">
<span class="attachment-count"
>{attachments.length} attachment{attachments.length !== 1 ? "s" : ""}</span
>
</div>
<div class="attachment-list">
{#each attachments as attachment (attachment.id)}
<div class="attachment-item" class:is-image={attachment.type === "image"}>
{#if attachment.type === "image" && attachment.previewUrl}
<div class="image-preview">
<img src={attachment.previewUrl} alt={attachment.filename} />
</div>
{:else}
<div class="file-icon">
{getFileIcon(attachment.type)}
</div>
{/if}
<div class="attachment-info">
<span class="attachment-filename" title={attachment.filename}>
{attachment.filename}
</span>
<span class="attachment-size">
{formatFileSize(attachment.size)}
</span>
</div>
<button
type="button"
class="remove-button"
onclick={() => onRemove(attachment.id)}
title="Remove attachment"
>
<svg
width="14"
height="14"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>
</button>
</div>
{/each}
</div>
</div>
{/if}
<style>
.attachment-preview-container {
display: flex;
flex-direction: column;
gap: 8px;
padding: 8px;
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: 8px;
margin-bottom: 8px;
}
.attachment-header {
display: flex;
align-items: center;
gap: 8px;
}
.attachment-count {
font-size: 12px;
color: var(--text-secondary);
}
.attachment-list {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.attachment-item {
display: flex;
align-items: center;
gap: 8px;
padding: 6px 8px;
background: var(--bg-tertiary);
border: 1px solid var(--border-color);
border-radius: 6px;
max-width: 200px;
position: relative;
}
.attachment-item.is-image {
flex-direction: column;
padding: 4px;
max-width: 120px;
}
.image-preview {
width: 100%;
max-width: 110px;
max-height: 80px;
border-radius: 4px;
overflow: hidden;
background: var(--bg-primary);
display: flex;
align-items: center;
justify-content: center;
}
.image-preview img {
max-width: 100%;
max-height: 80px;
object-fit: contain;
}
.file-icon {
font-size: 24px;
flex-shrink: 0;
}
.attachment-info {
display: flex;
flex-direction: column;
gap: 2px;
overflow: hidden;
flex: 1;
}
.is-image .attachment-info {
width: 100%;
padding: 0 4px;
}
.attachment-filename {
font-size: 12px;
color: var(--text-primary);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.attachment-size {
font-size: 10px;
color: var(--text-secondary);
}
.remove-button {
position: absolute;
top: -6px;
right: -6px;
width: 20px;
height: 20px;
padding: 0;
background: var(--bg-primary);
border: 1px solid var(--border-color);
border-radius: 50%;
color: var(--text-secondary);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
opacity: 0;
transition:
opacity 0.2s,
background 0.2s,
color 0.2s;
}
.attachment-item:hover .remove-button {
opacity: 1;
}
.remove-button:hover {
background: var(--error-color, #ef4444);
border-color: var(--error-color, #ef4444);
color: white;
}
</style>
@@ -0,0 +1,107 @@
<script lang="ts">
interface Props {
isOpen: boolean;
tabName: string;
onConfirm: () => void;
onCancel: () => void;
}
const { isOpen, tabName, onConfirm, onCancel }: Props = $props();
function handleKeydown(event: KeyboardEvent) {
if (!isOpen) return;
if (event.key === "Enter") {
event.preventDefault();
onConfirm();
} else if (event.key === "Escape") {
event.preventDefault();
onCancel();
}
}
</script>
<svelte:window onkeydown={handleKeydown} />
{#if isOpen}
<div
class="fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4"
onclick={onCancel}
role="button"
tabindex="0"
onkeydown={(e) => e.key === " " && onCancel()}
>
<div
class="bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg shadow-xl max-w-md w-full"
onclick={(e) => e.stopPropagation()}
onkeydown={(e) => e.stopPropagation()}
role="dialog"
aria-labelledby="confirm-title"
aria-describedby="confirm-message"
tabindex="-1"
>
<div class="p-6">
<div class="flex items-start gap-4">
<div
class="w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center flex-shrink-0"
>
<svg
class="w-6 h-6 text-yellow-500"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
/>
</svg>
</div>
<div class="flex-1">
<h3 id="confirm-title" class="text-lg font-semibold text-[var(--text-primary)] mb-1">
Close Connected Tab?
</h3>
<p id="confirm-message" class="text-sm text-[var(--text-secondary)]">
The tab "{tabName}" is currently connected to Claude. Are you sure you want to close
it? This will disconnect the session.
</p>
</div>
</div>
<div class="flex gap-3 mt-6 justify-end">
<button
onclick={onCancel}
class="px-4 py-2 text-sm font-medium text-gray-300 bg-[var(--bg-secondary)] hover:bg-[var(--bg-tertiary)] border border-[var(--border-color)] rounded-lg transition-colors"
>
Cancel
</button>
<button
onclick={onConfirm}
class="px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 rounded-lg transition-colors"
>
Close Tab
</button>
</div>
</div>
</div>
</div>
{/if}
<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);
}
}
</style>
+609
View File
@@ -0,0 +1,609 @@
<script lang="ts">
import {
configStore,
type HikariConfig,
type Theme,
applyFontSize,
MIN_FONT_SIZE,
MAX_FONT_SIZE,
DEFAULT_FONT_SIZE,
} from "$lib/stores/config";
import { claudeStore } from "$lib/stores/claude";
import { getCurrentWindow } from "@tauri-apps/api/window";
let config: HikariConfig = $state({
model: null,
api_key: null,
custom_instructions: null,
mcp_servers_json: null,
auto_granted_tools: [],
theme: "dark",
greeting_enabled: true,
greeting_custom_prompt: null,
notifications_enabled: true,
notification_volume: 0.7,
always_on_top: false,
minimize_to_tray: false,
update_checks_enabled: true,
character_panel_width: null,
font_size: 14,
});
let isOpen = $state(false);
let isSaving = $state(false);
let saveError: string | null = $state(null);
let newToolName = $state("");
let showApiKey = $state(false);
let grantedTools: string[] = $state([]);
configStore.config.subscribe((c) => {
config = { ...c };
});
configStore.isSidebarOpen.subscribe((open) => {
isOpen = open;
});
configStore.saveError.subscribe((error) => {
saveError = error;
});
claudeStore.grantedTools.subscribe((tools) => {
grantedTools = Array.from(tools);
});
const availableModels = [
{ value: "", label: "Default (from ~/.claude)" },
{ value: "claude-sonnet-4-20250514", label: "Claude Sonnet 4" },
{ value: "claude-opus-4-20250514", label: "Claude Opus 4" },
];
const commonTools = [
"Read",
"Write",
"Edit",
"Bash",
"Glob",
"Grep",
"WebFetch",
"WebSearch",
"Task",
];
async function handleSave() {
isSaving = true;
saveError = null;
try {
await configStore.saveConfig(config);
configStore.closeSidebar();
} catch {
// Error is handled by the store
} finally {
isSaving = false;
}
}
async function handleThemeChange(theme: Theme) {
config.theme = theme;
await configStore.setTheme(theme);
}
function toggleTool(tool: string) {
if (config.auto_granted_tools.includes(tool)) {
config.auto_granted_tools = config.auto_granted_tools.filter((t) => t !== tool);
} else {
config.auto_granted_tools = [...config.auto_granted_tools, tool];
}
}
function addCustomTool() {
if (newToolName.trim() && !config.auto_granted_tools.includes(newToolName.trim())) {
config.auto_granted_tools = [...config.auto_granted_tools, newToolName.trim()];
newToolName = "";
}
}
function removeTool(tool: string) {
config.auto_granted_tools = config.auto_granted_tools.filter((t) => t !== tool);
}
function importFromSession() {
config.auto_granted_tools = [...new Set([...config.auto_granted_tools, ...grantedTools])];
}
async function handleAlwaysOnTopChange(enabled: boolean) {
config.always_on_top = enabled;
const window = getCurrentWindow();
await window.setAlwaysOnTop(enabled);
await configStore.updateConfig({ always_on_top: enabled });
}
</script>
<!-- Backdrop -->
{#if isOpen}
<div
class="fixed inset-0 bg-black/50 z-40 transition-opacity"
onclick={configStore.closeSidebar}
onkeydown={(e) => e.key === "Escape" && configStore.closeSidebar()}
role="button"
tabindex="-1"
aria-label="Close sidebar"
></div>
{/if}
<!-- Sidebar -->
<aside
class="fixed right-0 top-0 h-full w-96 bg-[var(--bg-secondary)] border-l border-[var(--border-color)] z-50 transform transition-transform duration-300 ease-in-out overflow-y-auto {isOpen
? 'translate-x-0'
: 'translate-x-full'}"
>
<div class="p-4">
<!-- Header -->
<div class="flex items-center justify-between mb-6">
<h2 class="text-lg font-semibold text-[var(--text-primary)]">Settings</h2>
<button
onclick={configStore.closeSidebar}
class="p-1 text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors"
aria-label="Close settings"
>
<svg class="w-6 h-6" 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>
{#if saveError}
<div class="mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-red-400 text-sm">
{saveError}
</div>
{/if}
<!-- Agent Settings Section -->
<section class="mb-6">
<h3 class="text-sm font-medium text-[var(--accent-primary)] uppercase tracking-wider mb-3">
Agent Settings
</h3>
<!-- Model Selection -->
<div class="mb-4">
<label for="model" class="block text-sm text-[var(--text-secondary)] mb-1">Model</label>
<select
id="model"
bind:value={config.model}
class="w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-primary)]"
>
{#each availableModels as model (model.value)}
<option value={model.value}>{model.label}</option>
{/each}
</select>
</div>
<!-- API Key -->
<div class="mb-4">
<label for="api-key" class="block text-sm text-[var(--text-secondary)] mb-1">
API Key <span class="text-[var(--text-tertiary)]">(optional override)</span>
</label>
<div class="relative">
<input
id="api-key"
type={showApiKey ? "text" : "password"}
bind:value={config.api_key}
placeholder="Falls back to ~/.claude settings"
class="w-full px-3 py-2 pr-10 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-primary)]"
/>
<button
type="button"
onclick={() => (showApiKey = !showApiKey)}
class="absolute right-2 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)] hover:text-[var(--text-primary)]"
aria-label={showApiKey ? "Hide API key" : "Show API key"}
>
{#if showApiKey}
<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="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"
/>
</svg>
{:else}
<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="M15 12a3 3 0 11-6 0 3 3 0 016 0z"
/>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"
/>
</svg>
{/if}
</button>
</div>
</div>
<!-- Custom Instructions -->
<div class="mb-4">
<label for="instructions" class="block text-sm text-[var(--text-secondary)] mb-1"
>Custom Instructions</label
>
<textarea
id="instructions"
bind:value={config.custom_instructions}
rows="4"
placeholder="Additional instructions for the agent..."
class="w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-primary)] resize-none"
></textarea>
</div>
</section>
<!-- Greeting Section -->
<section class="mb-6">
<h3 class="text-sm font-medium text-[var(--accent-primary)] uppercase tracking-wider mb-3">
Greeting
</h3>
<!-- Enable/Disable Toggle -->
<div class="mb-4">
<label class="flex items-center gap-3 cursor-pointer">
<input
type="checkbox"
bind:checked={config.greeting_enabled}
class="w-4 h-4 rounded border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--accent-primary)] focus:ring-[var(--accent-primary)]"
/>
<span class="text-sm text-[var(--text-primary)]">Send greeting on connect</span>
</label>
<p class="text-xs text-[var(--text-tertiary)] mt-1 ml-7">
Automatically greet you when a session starts with time-based messages
</p>
</div>
<!-- Custom Greeting Prompt -->
{#if config.greeting_enabled}
<div class="mb-4">
<label for="greeting-prompt" class="block text-sm text-[var(--text-secondary)] mb-1">
Custom Greeting Prompt <span class="text-[var(--text-tertiary)]">(optional)</span>
</label>
<textarea
id="greeting-prompt"
bind:value={config.greeting_custom_prompt}
rows="3"
placeholder="Leave empty for time-based greetings, or customize how you'd like to be greeted..."
class="w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-primary)] resize-none"
></textarea>
</div>
{/if}
</section>
<!-- MCP Servers Section -->
<section class="mb-6">
<h3 class="text-sm font-medium text-[var(--accent-primary)] uppercase tracking-wider mb-3">
MCP Servers
</h3>
<div class="mb-2">
<label for="mcp-config" class="block text-sm text-[var(--text-secondary)] mb-1">
Server Configuration <span class="text-[var(--text-tertiary)]">(JSON)</span>
</label>
<textarea
id="mcp-config"
bind:value={config.mcp_servers_json}
rows="6"
placeholder={`{\n "servers": {\n "example": {\n "command": "npx",\n "args": ["-y", "@example/mcp-server"]\n }\n }\n}`}
class="w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg text-[var(--text-primary)] font-mono text-sm focus:outline-none focus:border-[var(--accent-primary)] resize-none"
></textarea>
</div>
</section>
<!-- Auto-Granted Tools Section -->
<section class="mb-6">
<h3 class="text-sm font-medium text-[var(--accent-primary)] uppercase tracking-wider mb-3">
Auto-Granted Tools
</h3>
<p class="text-xs text-[var(--text-tertiary)] mb-3">
These tools will be pre-approved for every session (no permission prompts).
</p>
<!-- Common tools checkboxes -->
<div class="grid grid-cols-2 gap-2 mb-3">
{#each commonTools as tool (tool)}
<label class="flex items-center gap-2 text-sm text-[var(--text-primary)] cursor-pointer">
<input
type="checkbox"
checked={config.auto_granted_tools.includes(tool)}
onchange={() => toggleTool(tool)}
class="w-4 h-4 rounded border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--accent-primary)] focus:ring-[var(--accent-primary)]"
/>
{tool}
</label>
{/each}
</div>
<!-- Currently granted tools (with import) -->
{#if grantedTools.length > 0}
<div class="mb-3">
<div class="flex items-center justify-between mb-2">
<span class="text-xs text-[var(--text-tertiary)]">Session-granted tools:</span>
<button
onclick={importFromSession}
class="text-xs text-[var(--accent-primary)] hover:text-[var(--accent-secondary)] transition-colors"
>
Import all
</button>
</div>
<div class="flex flex-wrap gap-1">
{#each grantedTools as tool (tool)}
<span
class="px-2 py-0.5 text-xs bg-[var(--accent-primary)]/20 text-[var(--accent-primary)] rounded"
>
{tool}
</span>
{/each}
</div>
</div>
{/if}
<!-- Custom tools list -->
{#if config.auto_granted_tools.filter((t) => !commonTools.includes(t)).length > 0}
<div class="mb-3">
<span class="text-xs text-[var(--text-tertiary)] block mb-2">Custom tools:</span>
<div class="flex flex-wrap gap-1">
{#each config.auto_granted_tools.filter((t) => !commonTools.includes(t)) as tool (tool)}
<span
class="px-2 py-0.5 text-xs bg-[var(--bg-primary)] border border-[var(--border-color)] rounded flex items-center gap-1"
>
{tool}
<button
onclick={() => removeTool(tool)}
class="text-[var(--text-tertiary)] hover:text-red-400"
aria-label="Remove {tool}"
>
×
</button>
</span>
{/each}
</div>
</div>
{/if}
<!-- Add custom tool -->
<div class="flex gap-2">
<input
type="text"
bind:value={newToolName}
placeholder="Add custom tool..."
onkeydown={(e) => e.key === "Enter" && addCustomTool()}
class="flex-1 px-3 py-1.5 text-sm bg-[var(--bg-primary)] border border-[var(--border-color)] rounded-lg text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent-primary)]"
/>
<button
onclick={addCustomTool}
disabled={!newToolName.trim()}
class="px-3 py-1.5 text-sm bg-[var(--accent-primary)] hover:bg-[var(--accent-secondary)] text-white rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
>
Add
</button>
</div>
</section>
<!-- Appearance Section -->
<section class="mb-6">
<h3 class="text-sm font-medium text-[var(--accent-primary)] uppercase tracking-wider mb-3">
Appearance
</h3>
<!-- Theme Selection -->
<div class="mb-4">
<label class="block text-sm text-[var(--text-secondary)] mb-2">Theme</label>
<div class="flex gap-2">
<button
onclick={() => handleThemeChange("dark")}
class="flex-1 px-3 py-2 rounded-lg border transition-colors {config.theme === 'dark'
? 'bg-[var(--accent-primary)] border-[var(--accent-primary)] text-white'
: 'bg-[var(--bg-primary)] border-[var(--border-color)] text-[var(--text-secondary)] hover:border-[var(--accent-primary)]'}"
>
Dark
</button>
<button
onclick={() => handleThemeChange("light")}
class="flex-1 px-3 py-2 rounded-lg border transition-colors {config.theme === 'light'
? 'bg-[var(--accent-primary)] border-[var(--accent-primary)] text-white'
: 'bg-[var(--bg-primary)] border-[var(--border-color)] text-[var(--text-secondary)] hover:border-[var(--accent-primary)]'}"
>
Light
</button>
<button
onclick={() => handleThemeChange("high-contrast")}
class="flex-1 px-3 py-2 rounded-lg border transition-colors {config.theme ===
'high-contrast'
? 'bg-[var(--accent-primary)] border-[var(--accent-primary)] text-white'
: 'bg-[var(--bg-primary)] border-[var(--border-color)] text-[var(--text-secondary)] hover:border-[var(--accent-primary)]'}"
title="High contrast mode for improved accessibility"
>
High Contrast
</button>
</div>
</div>
<!-- Font Size -->
<div class="mb-4">
<label for="font-size" class="block text-sm text-[var(--text-secondary)] mb-2">
Terminal Font Size
</label>
<div class="flex items-center gap-3">
<input
id="font-size"
type="range"
bind:value={config.font_size}
oninput={() => applyFontSize(config.font_size)}
min={MIN_FONT_SIZE}
max={MAX_FONT_SIZE}
step="1"
class="flex-1 h-2 bg-[var(--bg-primary)] rounded-lg appearance-none cursor-pointer"
/>
<span class="text-sm text-gray-300 w-12 text-right">{config.font_size}px</span>
<button
onclick={() => {
config.font_size = DEFAULT_FONT_SIZE;
applyFontSize(DEFAULT_FONT_SIZE);
}}
class="px-2 py-1 text-xs bg-[var(--bg-primary)] border border-[var(--border-color)] rounded hover:border-[var(--accent-primary)] text-[var(--text-secondary)] transition-colors"
title="Reset to default (14px)"
>
Reset
</button>
</div>
<p class="text-xs text-[var(--text-tertiary)] mt-1">
Use Ctrl++ / Ctrl+- to quickly adjust, Ctrl+0 to reset
</p>
</div>
</section>
<!-- Window Section -->
<section class="mb-6">
<h3 class="text-sm font-medium text-[var(--accent-primary)] uppercase tracking-wider mb-3">
Window
</h3>
<!-- Always on Top Toggle -->
<div class="mb-4">
<label class="flex items-center gap-3 cursor-pointer">
<input
type="checkbox"
checked={config.always_on_top}
onchange={(e) => handleAlwaysOnTopChange(e.currentTarget.checked)}
class="w-4 h-4 text-[var(--accent-primary)] bg-[var(--bg-primary)] border-[var(--border-color)] rounded focus:ring-[var(--accent-primary)] focus:ring-2"
/>
<span class="text-sm text-[var(--text-primary)]">Always on top</span>
</label>
<p class="text-xs text-[var(--text-tertiary)] mt-1 ml-7">
Keep the window above other windows
</p>
</div>
<!-- Minimize to Tray Toggle -->
<div class="mb-4">
<label class="flex items-center gap-3 cursor-pointer">
<input
type="checkbox"
bind:checked={config.minimize_to_tray}
class="w-4 h-4 text-[var(--accent-primary)] bg-[var(--bg-primary)] border-[var(--border-color)] rounded focus:ring-[var(--accent-primary)] focus:ring-2"
/>
<span class="text-sm text-[var(--text-primary)]">Minimize to system tray</span>
</label>
<p class="text-xs text-[var(--text-tertiary)] mt-1 ml-7">
Hide to tray instead of closing when you click the X button
</p>
</div>
<!-- Update Checks Toggle -->
<div class="mb-4">
<label class="flex items-center gap-3 cursor-pointer">
<input
type="checkbox"
bind:checked={config.update_checks_enabled}
class="w-4 h-4 text-[var(--accent-primary)] bg-[var(--bg-primary)] border-[var(--border-color)] rounded focus:ring-[var(--accent-primary)] focus:ring-2"
/>
<span class="text-sm text-[var(--text-primary)]">Check for updates on startup</span>
</label>
<p class="text-xs text-[var(--text-tertiary)] mt-1 ml-7">
Notify when a new version is available
</p>
</div>
</section>
<!-- Notifications Section -->
<section class="mb-6">
<h3 class="text-sm font-medium text-[var(--accent-primary)] uppercase tracking-wider mb-3">
Notifications
</h3>
<!-- Enable/Disable Notifications -->
<div class="mb-4">
<label class="flex items-center gap-3 cursor-pointer">
<input
type="checkbox"
bind:checked={config.notifications_enabled}
class="w-4 h-4 text-[var(--accent-primary)] bg-[var(--bg-primary)] border-[var(--border-color)] rounded focus:ring-[var(--accent-primary)] focus:ring-2"
/>
<span class="text-sm text-[var(--text-primary)]">Enable sound notifications</span>
</label>
</div>
<!-- Volume Control -->
<div class="mb-4">
<label for="notification-volume" class="block text-sm text-[var(--text-secondary)] mb-2">
Notification Volume
</label>
<div class="flex items-center gap-3">
<input
id="notification-volume"
type="range"
bind:value={config.notification_volume}
min="0"
max="1"
step="0.1"
disabled={!config.notifications_enabled}
class="flex-1 h-2 bg-[var(--bg-primary)] rounded-lg appearance-none cursor-pointer disabled:opacity-50"
/>
<span class="text-sm text-gray-300 w-12 text-right">
{Math.round(config.notification_volume * 100)}%
</span>
</div>
</div>
<div class="text-xs text-[var(--text-tertiary)]">
Sound notifications will play when I complete tasks, encounter errors, or need permissions.
</div>
</section>
<!-- Save Button -->
<div class="sticky bottom-0 pt-4 pb-2 bg-[var(--bg-secondary)]">
<button
onclick={handleSave}
disabled={isSaving}
class="w-full py-3 bg-[var(--accent-primary)] hover:bg-[var(--accent-secondary)] text-white font-medium rounded-lg transition-colors disabled:opacity-50"
>
{isSaving ? "Saving..." : "Save Settings"}
</button>
</div>
</div>
</aside>
<style>
/* Custom range input styling */
input[type="range"]::-webkit-slider-thumb {
appearance: none;
width: 16px;
height: 16px;
background: var(--accent-primary);
border-radius: 50%;
cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
width: 16px;
height: 16px;
background: var(--accent-primary);
border-radius: 50%;
cursor: pointer;
border: none;
}
input[type="range"]:disabled::-webkit-slider-thumb {
background: var(--text-tertiary);
cursor: not-allowed;
}
input[type="range"]:disabled::-moz-range-thumb {
background: var(--text-tertiary);
cursor: not-allowed;
}
</style>
+296
View File
@@ -0,0 +1,296 @@
<script lang="ts">
import { claudeStore } from "$lib/stores/claude";
import { onMount } from "svelte";
import type { Conversation } from "$lib/stores/conversations";
import { SvelteMap } from "svelte/reactivity";
import CloseTabConfirmModal from "./CloseTabConfirmModal.svelte";
// Use store subscriptions with $ syntax
const conversations = $derived(claudeStore.conversations);
const activeConversationId = $derived(claudeStore.activeConversationId);
let editingTabId = $state<string | null>(null);
let editingName = $state("");
// Track last seen message count for each conversation
let lastSeenMessageCount = new SvelteMap<string, number>();
// Confirmation modal state
let showConfirmModal = $state(false);
let tabToClose = $state<string | null>(null);
let tabToCloseName = $state("");
// Update last seen count when active conversation changes
$effect(() => {
if ($activeConversationId) {
const activeConv = $conversations.get($activeConversationId);
if (activeConv) {
lastSeenMessageCount.set($activeConversationId, activeConv.terminalLines.length);
// Trigger reactivity
lastSeenMessageCount = lastSeenMessageCount;
}
}
});
function createNewTab() {
claudeStore.createConversation();
}
async function switchTab(id: string) {
if (editingTabId) {
saveTabName();
}
await claudeStore.switchConversation(id);
// Mark messages as seen when switching to this tab
const conv = $conversations.get(id);
if (conv) {
lastSeenMessageCount.set(id, conv.terminalLines.length);
// Trigger reactivity
lastSeenMessageCount = lastSeenMessageCount;
}
}
function deleteTab(id: string, event: MouseEvent) {
event.stopPropagation();
if ($conversations.size > 1) {
const conversation = $conversations.get(id);
if (conversation && conversation.connectionStatus === "connected") {
// Show confirmation modal for connected tabs
tabToClose = id;
tabToCloseName = conversation.name;
showConfirmModal = true;
} else {
// Close disconnected tabs immediately
claudeStore.deleteConversation(id);
}
}
}
function confirmCloseTab() {
if (tabToClose) {
claudeStore.deleteConversation(tabToClose);
}
showConfirmModal = false;
tabToClose = null;
tabToCloseName = "";
}
function cancelCloseTab() {
showConfirmModal = false;
tabToClose = null;
tabToCloseName = "";
}
function startEditing(id: string, name: string, event: MouseEvent) {
event.stopPropagation();
editingTabId = id;
editingName = name;
// Focus input after DOM update
setTimeout(() => {
const input = document.querySelector('.tab-item input[type="text"]') as HTMLInputElement;
if (input) input.focus();
}, 0);
}
function saveTabName() {
if (editingTabId && editingName.trim()) {
claudeStore.renameConversation(editingTabId, editingName.trim());
}
editingTabId = null;
editingName = "";
}
function getConnectionStatusColor(status: Conversation["connectionStatus"]): string {
switch (status) {
case "connected":
return "bg-green-500";
case "connecting":
return "bg-yellow-500";
case "disconnected":
return "bg-red-500";
default:
return "bg-gray-500";
}
}
function hasUnreadMessages(id: string, conversation: Conversation): boolean {
if (id === $activeConversationId) return false; // Active tab never has unread
const lastSeen = lastSeenMessageCount.get(id) || 0;
return conversation.terminalLines.length > lastSeen;
}
function handleKeydown(event: KeyboardEvent) {
if (event.key === "Enter") {
saveTabName();
} else if (event.key === "Escape") {
editingTabId = null;
editingName = "";
} else if (event.key === " ") {
event.stopPropagation();
}
}
function handleTabKeydown(id: string, event: KeyboardEvent) {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
switchTab(id);
}
}
// Keyboard shortcuts
onMount(() => {
function handleGlobalKeydown(event: KeyboardEvent) {
// Ctrl/Cmd + T: New tab
if ((event.ctrlKey || event.metaKey) && event.key === "t") {
event.preventDefault();
createNewTab();
}
// Ctrl/Cmd + W: Close current tab
else if ((event.ctrlKey || event.metaKey) && event.key === "w") {
event.preventDefault();
if ($activeConversationId && $conversations.size > 1) {
const conversation = $conversations.get($activeConversationId);
if (conversation && conversation.connectionStatus === "connected") {
// Show confirmation modal for connected tabs
tabToClose = $activeConversationId;
tabToCloseName = conversation.name;
showConfirmModal = true;
} else {
// Close disconnected tabs immediately
claudeStore.deleteConversation($activeConversationId);
}
}
}
// Ctrl/Cmd + Tab: Next tab
else if ((event.ctrlKey || event.metaKey) && event.key === "Tab" && !event.shiftKey) {
event.preventDefault();
const tabs = Array.from($conversations.keys());
const currentIndex = tabs.findIndex((id) => id === $activeConversationId);
if (currentIndex !== -1) {
const nextIndex = (currentIndex + 1) % tabs.length;
claudeStore.switchConversation(tabs[nextIndex]);
}
}
// Ctrl/Cmd + Shift + Tab: Previous tab
else if ((event.ctrlKey || event.metaKey) && event.key === "Tab" && event.shiftKey) {
event.preventDefault();
const tabs = Array.from($conversations.keys());
const currentIndex = tabs.findIndex((id) => id === $activeConversationId);
if (currentIndex !== -1) {
const prevIndex = (currentIndex - 1 + tabs.length) % tabs.length;
claudeStore.switchConversation(tabs[prevIndex]);
}
}
}
window.addEventListener("keydown", handleGlobalKeydown);
return () => window.removeEventListener("keydown", handleGlobalKeydown);
});
</script>
<div
class="terminal-tabs flex items-center gap-1 px-2 py-1 bg-[var(--bg-secondary)] border-b border-[var(--border-color)]"
>
{#each Array.from($conversations.entries()) as [id, conversation] (id)}
<div
class="tab-item group relative flex items-center px-3 py-1.5 rounded-t cursor-pointer transition-all
{id === $activeConversationId
? 'bg-[var(--bg-terminal)] text-[var(--text-primary)] border-t border-l border-r border-[var(--border-color)]'
: 'bg-[var(--bg-tertiary)] text-[var(--text-secondary)] hover:bg-[var(--bg-terminal)]/50'}"
onclick={() => switchTab(id)}
onkeydown={(e) => handleTabKeydown(id, e)}
role="tab"
tabindex={0}
aria-selected={id === $activeConversationId}
>
{#if editingTabId === id}
<input
type="text"
bind:value={editingName}
onblur={saveTabName}
onkeydown={handleKeydown}
onclick={(e) => e.stopPropagation()}
class="bg-transparent border-b border-[var(--border-color)] outline-none px-0 py-0 text-sm w-32"
/>
{:else}
<div class="flex items-center gap-2">
<div
class="w-2 h-2 rounded-full {getConnectionStatusColor(conversation.connectionStatus)}"
title="Connection: {conversation.connectionStatus}"
></div>
<span
class="text-sm pr-2 max-w-[150px] truncate"
ondblclick={(e) => startEditing(id, conversation.name, e)}
role="button"
tabindex={-1}
>
{conversation.name}
</span>
{#if hasUnreadMessages(id, conversation)}
<div
class="absolute -top-1 -right-1 w-2 h-2 rounded-full bg-blue-500 animate-pulse pointer-events-none"
title="New messages"
></div>
{/if}
</div>
{/if}
{#if $conversations.size > 1}
<button
onclick={(e) => deleteTab(id, e)}
class="absolute right-1 top-1/2 -translate-y-1/2 w-4 h-4 flex items-center justify-center rounded hover:bg-[var(--bg-secondary)] opacity-0 group-hover:opacity-100 transition-opacity"
title="Close tab"
>
<svg
class="w-3 h-3"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M6 18L18 6M6 6l12 12"
/>
</svg>
</button>
{/if}
</div>
{/each}
<button
onclick={createNewTab}
class="new-tab-btn flex items-center justify-center w-7 h-7 rounded hover:bg-[var(--bg-tertiary)] text-[var(--text-secondary)] transition-colors"
title="New conversation (Ctrl+T)"
>
<svg
class="w-4 h-4"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
</svg>
</button>
</div>
<CloseTabConfirmModal
isOpen={showConfirmModal}
tabName={tabToCloseName}
onConfirm={confirmCloseTab}
onCancel={cancelCloseTab}
/>
<style>
.terminal-tabs {
min-height: 36px;
}
.tab-item {
min-width: 100px;
}
</style>
@@ -0,0 +1,7 @@
<script lang="ts">
console.log("ConversationTabs component loading...");
</script>
<div class="terminal-tabs" style="background: red; height: 36px; color: white;">
Debug: Tabs Component Loaded
</div>
+150
View File
@@ -0,0 +1,150 @@
<script lang="ts">
interface Props {
onClose: () => void;
}
const { onClose }: Props = $props();
const sections = [
{
title: "Getting Started",
items: [
"Enter your Claude API key in Settings (gear icon)",
"Set your working directory and click Connect",
"Start chatting with Hikari - your AI assistant!",
],
},
{
title: "Key Features",
items: [
"🗂️ File Management: Hikari can read, write, and edit files in your project",
"💻 Terminal Access: Execute commands and run scripts",
"🔍 Code Search: Find files and search through code",
"🌐 Web Access: Fetch information from the web",
"📊 MCP Servers: Connect to external tools via Model Context Protocol",
"📁 Multi-tab Support: Work on multiple conversations simultaneously",
],
},
{
title: "Available Commands",
items: [
"Type naturally - Hikari understands context!",
"Ask to read, create, or modify files",
"Request code explanations or debugging help",
"Have Hikari run tests or build commands",
"Search for specific functions or patterns",
],
},
{
title: "Tips & Tricks",
items: [
"💡 Use the stats panel to track your usage",
"🎯 Be specific about file paths and requirements",
"🔒 Grant tool permissions as needed for security",
"📌 Pin important conversations for quick access",
"🎨 Customize your theme and preferences in Settings",
"⌨️ Check the keyboard icon for available shortcuts",
],
},
];
</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-2xl w-full max-h-[80vh] overflow-hidden flex flex-col"
onclick={(e) => e.stopPropagation()}
onkeydown={(e) => e.stopPropagation()}
role="dialog"
aria-labelledby="help-title"
tabindex="-1"
>
<div class="flex items-center justify-between p-6 pb-4 border-b border-[var(--border-color)]">
<h2 id="help-title" class="text-xl font-semibold text-[var(--text-primary)]">
How to Use Hikari Desktop
</h2>
<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 sections as section (section.title)}
<div>
<h3 class="font-medium text-[var(--text-primary)] mb-3">{section.title}</h3>
<ul class="space-y-2 text-sm text-[var(--text-secondary)]">
{#each section.items as item (item)}
<li class="flex items-start">
<span class="text-[var(--accent-primary)] mr-2 mt-0.5"></span>
<span>{item}</span>
</li>
{/each}
</ul>
</div>
{/each}
<div class="pt-4 border-t border-[var(--border-color)]">
<p class="text-sm text-[var(--text-tertiary)]">
<strong>Need more help?</strong> Join our Discord community for support and updates!
</p>
</div>
</div>
</div>
</div>
<style>
/* Ensure the panel appears above other content */
[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);
}
}
/* Custom scrollbar styling */
.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>
+61
View File
@@ -0,0 +1,61 @@
<script lang="ts">
export let content: string;
export let searchQuery: string;
interface TextPart {
text: string;
isMatch: boolean;
}
function getHighlightedParts(text: string, query: string): TextPart[] {
if (!query) {
return [{ text, isMatch: false }];
}
const escapedQuery = query.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const regex = new RegExp(`(${escapedQuery})`, "gi");
const parts: TextPart[] = [];
let lastIndex = 0;
let match: RegExpExecArray | null;
while ((match = regex.exec(text)) !== null) {
// Add non-matching text before the match
if (match.index > lastIndex) {
parts.push({
text: text.slice(lastIndex, match.index),
isMatch: false,
});
}
// Add the matching text
parts.push({
text: match[1],
isMatch: true,
});
lastIndex = regex.lastIndex;
}
// Add any remaining text after the last match
if (lastIndex < text.length) {
parts.push({
text: text.slice(lastIndex),
isMatch: false,
});
}
return parts;
}
$: parts = getHighlightedParts(content, searchQuery);
</script>
<span class="whitespace-pre-wrap">
{#each parts as part, index (index)}
{#if part.isMatch}
<mark class="search-highlight">{part.text}</mark>
{:else}
{part.text}
{/if}
{/each}
</span>
+844 -16
View File
@@ -1,30 +1,265 @@
<script lang="ts"> <script lang="ts">
import { invoke } from "@tauri-apps/api/core"; import { invoke } from "@tauri-apps/api/core";
import { claudeStore } from "$lib/stores/claude"; import { open } from "@tauri-apps/plugin-dialog";
import { readImage } from "@tauri-apps/plugin-clipboard-manager";
import { get } from "svelte/store";
import { claudeStore, isClaudeProcessing } from "$lib/stores/claude";
import { characterState } from "$lib/stores/character"; import { characterState } from "$lib/stores/character";
import { handleNewUserMessage } from "$lib/notifications/rules";
import { setSkipNextGreeting } from "$lib/tauri";
import {
setShouldRestoreHistory,
setSavedHistory,
getShouldRestoreHistory,
getSavedHistory,
clearHistoryRestore,
} from "$lib/stores/historyRestore";
import MessageModeSelector from "$lib/components/MessageModeSelector.svelte";
import SlashCommandMenu from "$lib/components/SlashCommandMenu.svelte";
import { getCurrentMode } from "$lib/stores/messageMode";
import { formatMessageWithMode } from "$lib/types/messageMode";
import {
parseSlashCommand,
getMatchingCommands,
isSlashCommand,
type SlashCommand,
} from "$lib/commands/slashCommands";
import AttachmentPreview from "$lib/components/AttachmentPreview.svelte";
import type { Attachment } from "$lib/types/messages";
const INPUT_HISTORY_KEY = "hikari-input-history";
const MAX_HISTORY_SIZE = 100;
let inputValue = $state(""); let inputValue = $state("");
let isSubmitting = $state(false); let isSubmitting = $state(false);
let isConnected = $state(false); let isConnected = $state(false);
let isProcessing = $state(false);
let showCommandMenu = $state(false);
let matchingCommands = $state<SlashCommand[]>([]);
let selectedCommandIndex = $state(0);
let attachments = $state<Attachment[]>([]);
let isDragging = $state(false);
// Input history state
let inputHistory = $state<string[]>([]);
let historyIndex = $state(-1);
let tempInput = $state("");
let userHasTyped = $state(false); // Track if user manually typed (vs history navigation)
// Textarea resize state
let textareaHeight = $state(48);
const MIN_HEIGHT = 48;
const MAX_HEIGHT = 200;
let isResizing = $state(false);
let startY = 0;
let startHeight = 0;
function handleResizeStart(event: MouseEvent) {
isResizing = true;
startY = event.clientY;
startHeight = textareaHeight;
document.addEventListener("mousemove", handleResizeMove);
document.addEventListener("mouseup", handleResizeEnd);
event.preventDefault();
}
function handleResizeMove(event: MouseEvent) {
if (!isResizing) return;
// Dragging up (negative deltaY) should increase height
const deltaY = startY - event.clientY;
const newHeight = Math.min(MAX_HEIGHT, Math.max(MIN_HEIGHT, startHeight + deltaY));
textareaHeight = newHeight;
}
function handleResizeEnd() {
isResizing = false;
document.removeEventListener("mousemove", handleResizeMove);
document.removeEventListener("mouseup", handleResizeEnd);
}
// Load history from localStorage on init
function loadHistory(): string[] {
try {
const stored = localStorage.getItem(INPUT_HISTORY_KEY);
return stored ? JSON.parse(stored) : [];
} catch {
return [];
}
}
function saveHistory(history: string[]) {
try {
localStorage.setItem(INPUT_HISTORY_KEY, JSON.stringify(history));
} catch {
// Ignore storage errors
}
}
function addToHistory(input: string) {
const trimmed = input.trim();
if (!trimmed) return;
// Don't add duplicates of the most recent entry
if (inputHistory.length > 0 && inputHistory[0] === trimmed) return;
// Add to front of history
inputHistory = [trimmed, ...inputHistory.slice(0, MAX_HISTORY_SIZE - 1)];
saveHistory(inputHistory);
}
// Initialize history on mount
inputHistory = loadHistory();
claudeStore.connectionStatus.subscribe((status) => { claudeStore.connectionStatus.subscribe((status) => {
isConnected = status === "connected"; isConnected = status === "connected";
}); });
isClaudeProcessing.subscribe((processing) => {
isProcessing = processing;
});
claudeStore.attachments.subscribe((storedAttachments) => {
attachments = storedAttachments;
});
function handleInputChange() {
// If input is empty, allow history navigation again
// Otherwise, mark that user has manually typed
if (inputValue === "") {
userHasTyped = false;
} else {
userHasTyped = true;
}
// Reset history navigation when user types
historyIndex = -1;
tempInput = "";
if (isSlashCommand(inputValue)) {
matchingCommands = getMatchingCommands(inputValue);
showCommandMenu = matchingCommands.length > 0;
selectedCommandIndex = 0;
} else {
showCommandMenu = false;
matchingCommands = [];
}
}
function selectCommand(command: SlashCommand) {
inputValue = `/${command.name} `;
showCommandMenu = false;
matchingCommands = [];
}
async function executeSlashCommand(): Promise<boolean> {
const { command, args } = parseSlashCommand(inputValue);
if (command) {
inputValue = "";
showCommandMenu = false;
matchingCommands = [];
await command.execute(args);
return true;
}
return false;
}
async function handleSubmit(event: Event) { async function handleSubmit(event: Event) {
event.preventDefault(); event.preventDefault();
const message = inputValue.trim(); const message = inputValue.trim();
if (!message || isSubmitting || !isConnected) return; const hasAttachments = attachments.length > 0;
// Need either a message or attachments to submit
if ((!message && !hasAttachments) || isSubmitting) return;
// Check for slash commands first (these work even when disconnected)
if (message && isSlashCommand(message)) {
// Add slash commands to history too
addToHistory(message);
historyIndex = -1;
tempInput = "";
userHasTyped = false;
const wasCommand = await executeSlashCommand();
if (wasCommand) return;
// If it started with / but wasn't a valid command, show error
claudeStore.addLine(
"error",
`Unknown command: ${message.split(" ")[0]}. Type /help for available commands.`
);
inputValue = "";
return;
}
// Regular messages require connection
if (!isConnected) return;
// Add to history before clearing (only if there's text)
if (message) {
addToHistory(message);
}
historyIndex = -1;
tempInput = "";
userHasTyped = false;
isSubmitting = true; isSubmitting = true;
inputValue = ""; inputValue = "";
claudeStore.addLine("user", message); // Capture attachments before clearing
const currentAttachments = [...attachments];
// Apply mode prefix if needed (only if there's a message)
const currentMode = getCurrentMode();
const formattedMessage = message ? formatMessageWithMode(message, currentMode) : "";
// Build message with attachments
let messageWithAttachments = formattedMessage;
if (currentAttachments.length > 0) {
const attachmentPaths = currentAttachments.map((a) => a.path).join("\n");
const attachmentPrefix = formattedMessage ? `${formattedMessage}\n\n` : "";
messageWithAttachments = `${attachmentPrefix}[Attached files - please read these files to see their contents:]\n${attachmentPaths}`;
// Log attached files to the output
for (const attachment of currentAttachments) {
claudeStore.addLine("system", `📎 Attached: ${attachment.filename} (${attachment.path})`);
}
}
// Clear attachments after capturing them
claudeStore.clearAttachments();
// Check if we need to restore conversation history
let messageToSend = messageWithAttachments;
if (getShouldRestoreHistory()) {
const savedHistory = getSavedHistory();
if (savedHistory) {
// Prepend the conversation history with a context message
messageToSend = `[Previous conversation context:]
${savedHistory}
[Continuing conversation after reconnection:]
User: ${formattedMessage}`;
// Clear the restoration flags
clearHistoryRestore();
}
}
// Reset notification state for new user message
handleNewUserMessage();
claudeStore.addLine("user", formattedMessage);
characterState.setState("thinking"); characterState.setState("thinking");
try { try {
await invoke("send_prompt", { message }); const conversationId = get(claudeStore.activeConversationId);
if (!conversationId) {
throw new Error("No active conversation");
}
await invoke("send_prompt", {
conversationId,
message: messageToSend,
});
} catch (error) { } catch (error) {
console.error("Failed to send prompt:", error); console.error("Failed to send prompt:", error);
claudeStore.addLine("error", `Failed to send: ${error}`); claudeStore.addLine("error", `Failed to send: ${error}`);
@@ -34,36 +269,494 @@
} }
} }
async function handleInterrupt() {
// Save the conversation history FIRST before anything else
const history = claudeStore.getConversationHistory();
if (history) {
setSavedHistory(history);
setShouldRestoreHistory(true);
}
try {
const conversationId = get(claudeStore.activeConversationId);
if (!conversationId) {
throw new Error("No active conversation");
}
await invoke("interrupt_claude", { conversationId });
claudeStore.addLine("system", "Process interrupted - reconnecting...");
characterState.setState("idle");
// Show connecting status while we reconnect
claudeStore.setConnectionStatus("connecting");
// Auto-reconnect after a brief delay
setTimeout(async () => {
try {
const conversationId = get(claudeStore.activeConversationId);
if (!conversationId) {
throw new Error("No active conversation");
}
// Get current working directory before reconnecting
const workingDir = await invoke<string>("get_working_directory", { conversationId });
// Set the flag to skip greeting on next connection
setSkipNextGreeting(true);
// Reconnect to Claude
await invoke("start_claude", {
conversationId,
options: {
working_dir: workingDir,
},
});
} catch (reconnectError) {
console.error("Failed to auto-reconnect:", reconnectError);
claudeStore.addLine("error", `Failed to reconnect: ${reconnectError}`);
claudeStore.addLine("system", "Please manually reconnect to continue");
}
}, 500); // Brief delay to ensure process is fully terminated
} catch (error) {
console.error("Failed to interrupt:", error);
claudeStore.addLine("error", `Failed to interrupt: ${error}`);
}
}
function handleRemoveAttachment(id: string) {
claudeStore.removeAttachment(id);
}
function getFileTypeFromExtension(extension: string): "image" | "document" | "other" {
const imageExtensions = ["png", "jpg", "jpeg", "gif", "webp", "svg", "bmp"];
const documentExtensions = ["pdf", "txt", "md", "doc", "docx", "csv", "json", "xml"];
if (imageExtensions.includes(extension)) {
return "image";
} else if (documentExtensions.includes(extension)) {
return "document";
}
return "other";
}
function handleDragEnter(event: DragEvent) {
event.preventDefault();
event.stopPropagation();
if (event.dataTransfer?.types.includes("Files")) {
isDragging = true;
}
}
function handleDragOver(event: DragEvent) {
event.preventDefault();
event.stopPropagation();
if (event.dataTransfer) {
event.dataTransfer.dropEffect = "copy";
}
}
function handleDragLeave(event: DragEvent) {
event.preventDefault();
event.stopPropagation();
// Only set isDragging to false if we're leaving the form element entirely
const relatedTarget = event.relatedTarget as Node | null;
const currentTarget = event.currentTarget as HTMLElement;
if (!relatedTarget || !currentTarget.contains(relatedTarget)) {
isDragging = false;
}
}
async function handleDrop(event: DragEvent) {
event.preventDefault();
event.stopPropagation();
isDragging = false;
const files = event.dataTransfer?.files;
if (!files || files.length === 0) return;
const conversationId = get(claudeStore.activeConversationId);
for (const file of files) {
const filename = file.name;
const extension = filename.split(".").pop()?.toLowerCase() || "";
const fileType = getFileTypeFromExtension(extension);
// Create attachment from dropped file
// Note: For dropped files, we create a preview URL for images
let previewUrl: string | undefined;
if (fileType === "image") {
previewUrl = URL.createObjectURL(file);
}
// Check if the file has a native path (from Tauri's file drop)
// If not, we need to save it to a temp file
let savedPath = (file as File & { path?: string }).path;
if (!savedPath && conversationId) {
try {
const arrayBuffer = await file.arrayBuffer();
const bytes = Array.from(new Uint8Array(arrayBuffer));
savedPath = await invoke<string>("save_temp_file", {
conversationId,
filename,
data: bytes,
});
} catch (error) {
console.error("Failed to save dropped file to temp:", error);
savedPath = file.name;
}
}
const attachment: Attachment = {
id: `attachment-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
filename,
path: savedPath || file.name,
size: file.size,
type: fileType,
mimeType: file.type,
previewUrl,
};
claudeStore.addAttachment(attachment);
}
}
async function handleFilePicker() {
try {
const selected = await open({
multiple: true,
filters: [
{
name: "All Files",
extensions: ["*"],
},
{
name: "Images",
extensions: ["png", "jpg", "jpeg", "gif", "webp", "svg", "bmp"],
},
{
name: "Documents",
extensions: ["pdf", "txt", "md", "doc", "docx", "csv", "json", "xml"],
},
{
name: "Code",
extensions: [
"js",
"ts",
"jsx",
"tsx",
"py",
"rs",
"go",
"java",
"c",
"cpp",
"h",
"hpp",
"css",
"html",
"svelte",
"vue",
],
},
],
});
if (!selected) return;
// Handle both single and multiple file selection
const files = Array.isArray(selected) ? selected : [selected];
for (const filePath of files) {
const filename = filePath.split(/[/\\]/).pop() || "unknown";
const extension = filename.split(".").pop()?.toLowerCase() || "";
const fileType = getFileTypeFromExtension(extension);
// Get file size from Tauri
let fileSize = 0;
try {
fileSize = await invoke<number>("get_file_size", { filePath });
} catch (e) {
console.warn("Could not get file size:", e);
}
const attachment: Attachment = {
id: `attachment-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
filename,
path: filePath,
size: fileSize,
type: fileType,
};
claudeStore.addAttachment(attachment);
}
} catch (error) {
console.error("Failed to open file picker:", error);
}
}
async function handlePaste(event: ClipboardEvent) {
// First, try the web clipboard API for files
const items = event.clipboardData?.items;
let handledFile = false;
if (items && items.length > 0) {
for (const item of items) {
if (item.kind === "file") {
const file = item.getAsFile();
if (!file) continue;
event.preventDefault();
handledFile = true;
const filename = file.name || `pasted-${Date.now()}.${file.type.split("/")[1] || "png"}`;
const extension = filename.split(".").pop()?.toLowerCase() || "";
const fileType = getFileTypeFromExtension(extension);
let previewUrl: string | undefined;
if (fileType === "image" || file.type.startsWith("image/")) {
previewUrl = URL.createObjectURL(file);
}
const conversationId = get(claudeStore.activeConversationId);
let savedPath = filename;
if (conversationId) {
try {
const arrayBuffer = await file.arrayBuffer();
const bytes = Array.from(new Uint8Array(arrayBuffer));
savedPath = await invoke<string>("save_temp_file", {
conversationId,
filename,
data: bytes,
});
} catch (error) {
console.error("Failed to save pasted file to temp:", error);
}
}
const attachment: Attachment = {
id: `attachment-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
filename,
path: savedPath,
size: file.size,
type: file.type.startsWith("image/") ? "image" : fileType,
mimeType: file.type,
previewUrl,
};
claudeStore.addAttachment(attachment);
}
}
}
// If web clipboard didn't have files, try Tauri's native clipboard for images
if (!handledFile) {
try {
const image = await readImage();
const rgba = await image.rgba();
const size = await image.size();
if (rgba && rgba.length > 0) {
event.preventDefault();
const conversationId = get(claudeStore.activeConversationId);
const filename = `screenshot-${Date.now()}.png`;
// Convert RGBA to PNG using canvas
const canvas = document.createElement("canvas");
canvas.width = size.width;
canvas.height = size.height;
const ctx = canvas.getContext("2d");
if (ctx) {
const imgData = ctx.createImageData(size.width, size.height);
imgData.data.set(new Uint8ClampedArray(rgba));
ctx.putImageData(imgData, 0, 0);
// Create preview URL from canvas
const previewUrl = canvas.toDataURL("image/png");
// Convert to blob for saving
const blob = await new Promise<Blob | null>((resolve) =>
canvas.toBlob(resolve, "image/png")
);
let savedPath = filename;
if (blob && conversationId) {
try {
const arrayBuffer = await blob.arrayBuffer();
const bytes = Array.from(new Uint8Array(arrayBuffer));
savedPath = await invoke<string>("save_temp_file", {
conversationId,
filename,
data: bytes,
});
} catch (error) {
console.error("Failed to save clipboard image to temp:", error);
}
}
const attachment: Attachment = {
id: `attachment-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
filename,
path: savedPath,
size: blob?.size || 0,
type: "image",
mimeType: "image/png",
previewUrl,
};
claudeStore.addAttachment(attachment);
}
}
} catch (error) {
// No image in clipboard or clipboard read failed - that's fine, just ignore
console.log("No image in native clipboard:", error);
}
}
}
function handleKeyDown(event: KeyboardEvent) { function handleKeyDown(event: KeyboardEvent) {
// Handle command menu navigation
if (showCommandMenu && matchingCommands.length > 0) {
if (event.key === "ArrowDown") {
event.preventDefault();
selectedCommandIndex = (selectedCommandIndex + 1) % matchingCommands.length;
return;
}
if (event.key === "ArrowUp") {
event.preventDefault();
selectedCommandIndex =
(selectedCommandIndex - 1 + matchingCommands.length) % matchingCommands.length;
return;
}
if (event.key === "Tab") {
event.preventDefault();
const selected = matchingCommands[selectedCommandIndex];
if (selected) {
selectCommand(selected);
}
return;
}
if (event.key === "Escape") {
event.preventDefault();
showCommandMenu = false;
return;
}
}
// Handle input history navigation (when command menu is closed AND user hasn't typed)
// If user has typed something, let arrow keys navigate the cursor instead
if (event.key === "ArrowUp" && inputHistory.length > 0 && !userHasTyped) {
event.preventDefault();
if (historyIndex === -1) {
// Save current input before navigating history
tempInput = inputValue;
}
if (historyIndex < inputHistory.length - 1) {
historyIndex++;
inputValue = inputHistory[historyIndex];
}
return;
}
if (event.key === "ArrowDown" && historyIndex >= 0 && !userHasTyped) {
event.preventDefault();
historyIndex--;
if (historyIndex === -1) {
// Restore the temp input when going back to current
inputValue = tempInput;
userHasTyped = false; // Reset since we're back to empty/temp state
} else {
inputValue = inputHistory[historyIndex];
}
return;
}
if (event.key === "Enter" && !event.shiftKey) { if (event.key === "Enter" && !event.shiftKey) {
handleSubmit(event); handleSubmit(event);
} }
} }
</script> </script>
<form onsubmit={handleSubmit} class="input-bar flex gap-3 items-end"> <form
<div class="flex-1 relative"> onsubmit={handleSubmit}
ondragenter={handleDragEnter}
ondragover={handleDragOver}
ondragleave={handleDragLeave}
ondrop={handleDrop}
class="input-bar"
class:is-dragging={isDragging}
>
<AttachmentPreview {attachments} onRemove={handleRemoveAttachment} />
<div class="input-controls flex gap-2 mb-2">
<MessageModeSelector />
</div>
<div class="input-row">
<div class="textarea-wrapper">
<SlashCommandMenu
commands={matchingCommands}
selectedIndex={selectedCommandIndex}
onSelect={selectCommand}
/>
<!-- svelte-ignore a11y_no_static_element_interactions -->
<div class="resize-handle" onmousedown={handleResizeStart} title="Drag to resize"></div>
<textarea <textarea
bind:value={inputValue} bind:value={inputValue}
onkeydown={handleKeyDown} onkeydown={handleKeyDown}
placeholder={isConnected ? "Ask Hikari anything..." : "Connect to Claude first..."} oninput={handleInputChange}
disabled={!isConnected || isSubmitting} onpaste={handlePaste}
placeholder={isConnected
? "Ask Hikari anything... (type / for commands)"
: "Connect to Claude first..."}
disabled={isSubmitting}
rows={1} rows={1}
style="height: {textareaHeight}px; font-size: var(--terminal-font-size, 14px);"
class="w-full px-4 py-3 bg-[var(--bg-secondary)] border border-[var(--border-color)] class="w-full px-4 py-3 bg-[var(--bg-secondary)] border border-[var(--border-color)]
rounded-lg text-white placeholder-gray-500 resize-none rounded-lg text-[var(--text-primary)] placeholder-gray-500 resize-none
focus:outline-none focus:border-[var(--accent-primary)] focus:ring-1 focus:ring-[var(--accent-primary)] focus:outline-none focus:border-[var(--accent-primary)] focus:ring-1 focus:ring-[var(--accent-primary)]
disabled:opacity-50 disabled:cursor-not-allowed disabled:opacity-50 disabled:cursor-not-allowed"
transition-all duration-200"
></textarea> ></textarea>
</div> </div>
<div class="button-wrapper">
<button type="button" onclick={handleFilePicker} class="attach-button" title="Attach files">
<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="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"
/>
</svg>
</button>
{#if isProcessing}
<button
type="button"
onclick={handleInterrupt}
class="send-button bg-red-600 hover:bg-red-700"
title="Interrupt the current response (Ctrl+C)"
>
<span class="font-bold"></span> Stop
</button>
{:else}
<button <button
type="submit" type="submit"
disabled={!isConnected || isSubmitting || !inputValue.trim()} disabled={!isConnected ||
class="px-6 py-3 bg-[var(--accent-primary)] hover:bg-[var(--accent-secondary)] isSubmitting ||
text-white font-medium rounded-lg (!inputValue.trim() && attachments.length === 0)}
disabled:opacity-50 disabled:cursor-not-allowed class="send-button bg-[var(--accent-primary)] hover:bg-[var(--accent-secondary)]
transition-all duration-200 transform hover:scale-105 active:scale-95" disabled:opacity-50 disabled:cursor-not-allowed"
> >
{#if isSubmitting} {#if isSubmitting}
<span class="inline-block animate-spin"></span> <span class="inline-block animate-spin"></span>
@@ -71,4 +764,139 @@
Send Send
{/if} {/if}
</button> </button>
{/if}
</div>
</div>
</form> </form>
<style>
.input-bar {
display: flex;
flex-direction: column;
gap: 8px;
position: relative;
transition:
border-color 0.2s,
background 0.2s;
}
.input-bar.is-dragging {
background: var(--bg-secondary);
border: 2px dashed var(--accent-primary);
border-radius: 12px;
padding: 8px;
}
.input-bar.is-dragging::before {
content: "Drop files here";
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 18px;
font-weight: 500;
color: var(--accent-primary);
pointer-events: none;
z-index: 10;
}
.input-bar.is-dragging > * {
opacity: 0.3;
pointer-events: none;
}
.input-controls {
display: flex;
align-items: center;
gap: 8px;
}
.input-row {
display: flex;
gap: 12px;
align-items: flex-end;
}
.textarea-wrapper {
flex: 1;
position: relative;
display: flex;
flex-direction: column;
}
.resize-handle {
height: 6px;
cursor: ns-resize;
background: transparent;
border-radius: 3px;
margin-bottom: 2px;
display: flex;
justify-content: center;
align-items: center;
}
.resize-handle::before {
content: "";
width: 40px;
height: 3px;
background: var(--border-color);
border-radius: 2px;
opacity: 0.5;
transition: opacity 0.2s;
}
.resize-handle:hover::before {
opacity: 1;
background: var(--accent-primary);
}
.button-wrapper {
display: flex;
align-items: flex-end;
height: 100%;
}
.attach-button {
display: flex;
align-items: center;
justify-content: center;
width: 48px;
height: 48px;
padding: 0;
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: 8px;
color: var(--text-secondary);
cursor: pointer;
transition: all 0.2s;
}
.attach-button:hover {
background: var(--bg-tertiary);
border-color: var(--accent-primary);
color: var(--accent-primary);
transform: scale(1.05);
}
.attach-button:active {
transform: scale(0.95);
}
.send-button {
padding: 0 24px;
height: 48px;
color: white;
font-weight: 500;
border-radius: 8px;
transition: all 0.2s;
white-space: nowrap;
}
.send-button:hover:not(:disabled) {
transform: scale(1.05);
}
.send-button:active:not(:disabled) {
transform: scale(0.95);
}
</style>
@@ -0,0 +1,177 @@
<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" },
],
},
{
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: "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>

Some files were not shown because too many files have changed in this diff Show More