Commit Graph

894 Commits

Author SHA1 Message Date
Dave
2976c854d0 Fix model selection resetting issue
The useEffect was re-running every time model changed, causing
Claude model selection to reset back to Ollama models. Fixed by:
- Removing model from useEffect dependency array
- Only run model fetch on component mount
- Check if saved model exists before loading it
- Don't reset model if it's not in Ollama list (allows Claude)
2025-12-27 19:50:47 +00:00
Dave
e3f4f92c54 Frontend: Add Claude integration UI
- Add Claude models to dropdown with optgroup sections
- Update context window calculation for Claude (200k tokens)
- Add API key dialog modal for first-time Claude use
- Check for API key existence before sending Claude requests
- Auto-detect provider from model name (claude-*)
- Update sendMessage to handle Claude provider
- Store and retrieve API key via backend commands
- Add visual separation between Anthropic and Ollama models
2025-12-27 19:43:00 +00:00
Dave
1529ca77e7 Backend: Add Anthropic/Claude provider integration
- Add anthropic.rs module with streaming support
- Convert between internal and Anthropic tool/message formats
- Add keyring dependency for secure API key storage
- Add API key management commands (get_exists, set)
- Auto-detect provider from model name (claude-* prefix)
- Support SSE streaming from Anthropic API
- Handle tool calling with Anthropic's format
- Add cancellation support for Anthropic streams
2025-12-27 19:41:20 +00:00
Dave
e71dcd8226 Story 12: Update story and specs for Claude integration
Story Updates:
- Unified model dropdown with section headers (Anthropic, Ollama)
- Auto-detect provider from model name (claude-* prefix)
- API key prompt on first Claude model use
- Secure storage in OS keychain via keyring crate
- 200k token context window for Claude models

Spec Updates (AI_INTEGRATION.md):
- Document Anthropic provider implementation
- Anthropic API protocol (SSE streaming, tool format)
- Tool format conversion between internal and Anthropic formats
- API key storage in OS keychain
- Unified dropdown UI flow

Spec Updates (STACK.md):
- Add keyring crate for secure API key storage
- Add eventsource-stream for Anthropic SSE streaming
- Document automatic provider detection
- Update API key management approach
2025-12-27 19:37:01 +00:00
Dave
ca7efc2888 Archive Story 23 to stories/archive/ 2025-12-27 19:30:32 +00:00
Dave
bdb82bcf49 Story 23: Alphabetize LLM dropdown list
User Story:
As a user, I want the LLM model dropdown to be alphabetically sorted
so I can quickly find the model I'm looking for.

Implementation:
- Added alphabetical sorting with case-insensitive comparison
- Used localeCompare() for proper string comparison
- Sort happens immediately after fetching models from backend
- Currently selected model remains selected after sorting

Technical Details:
- Sort logic: models.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
- Frontend-only change, no backend modifications needed
- Sorting preserves model selection state

Acceptance Criteria Met:
 Models sorted alphabetically (case-insensitive)
 Selected model remains selected after sorting
 Works for all models from Ollama
 Updates correctly when models change

Files Changed:
- src/components/Chat.tsx: Added sorting logic to model fetch
- .living_spec/stories/23_alphabetize_llm_dropdown.md: Marked complete
2025-12-27 19:30:17 +00:00
Dave
f963c2e17e Archive Story 22 to stories/archive/ 2025-12-27 19:21:48 +00:00
Dave
57826dc5ee Story 22: Implement smart auto-scroll that respects user scrolling
User Story:
As a user, I want to be able to scroll up to review previous messages
while the AI is streaming or adding new content, without being
constantly dragged back to the bottom.

Implementation:
- Replaced position-based threshold detection with user-intent tracking
- Detects when user scrolls UP and disables auto-scroll completely
- Auto-scroll only re-enables when user manually returns to bottom (<5px)
- Uses refs to track scroll position and direction for smooth operation
- Works seamlessly during rapid token streaming and tool execution

Technical Details:
- lastScrollTopRef: Tracks previous scroll position to detect direction
- userScrolledUpRef: Flag set when upward scrolling is detected
- Direct scrollTop manipulation for instant, non-fighting scroll behavior
- Threshold of 5px from absolute bottom to re-enable auto-scroll

Spec Updates:
- Added comprehensive Smart Auto-Scroll section to UI_UX.md
- Documented the problem, solution, requirements, and implementation
- Includes code examples and edge case handling

Acceptance Criteria Met:
 Auto-scroll disabled when scrolling up
 Auto-scroll resumes when returning to bottom
 Works normally when already at bottom
 Smooth detection without flickering
 Works during streaming and tool execution

Files Changed:
- src/components/Chat.tsx: Implemented user-intent tracking
- .living_spec/specs/functional/UI_UX.md: Added Smart Auto-Scroll spec
- .living_spec/stories/22_smart_autoscroll.md: Marked complete
2025-12-27 19:21:34 +00:00
Dave
1baf3fa728 Clean up duplicate Story 18 files (already archived) 2025-12-27 18:51:11 +00:00
Dave
50e2c2cd70 Remove Story 16 placeholder (work completed in previous commit) 2025-12-27 18:50:05 +00:00
Dave
02d3c05f34 UI: Move submit/stop button outside input field
- Restructure input area to use flexbox layout
- Button now sits beside input instead of overlapping
- Prevents text from being obscured on longer prompts
- Input takes full available width with proper spacing
2025-12-27 18:47:48 +00:00
Dave
71ce87d836 Story 15: Implement New Session cancellation
- Call cancel_chat before clearing session state
- Prevents tools from executing silently in background
- Prevents streaming from leaking into new session
- Uses same cancellation infrastructure as Story 13
- Clean session start with no side effects

Closes Story 15
2025-12-27 18:39:28 +00:00
Dave
e1fb0e3d19 Story 13: Implement Stop button with backend cancellation
- Add tokio watch channel for cancellation signaling
- Implement cancel_chat command
- Add cancellation checks in streaming loop and before tool execution
- Stop button (■) replaces Send button (↑) during generation
- Preserve partial streaming content when cancelled
- Clean UX: no error messages on cancellation
- Backend properly stops streaming and prevents tool execution

Closes Story 13
2025-12-27 18:32:15 +00:00
Dave
846967ee99 Fix race condition: ignore streaming events from old sessions
- Added sessionIdRef to track current session
- When clearing session, generate new session ID
- Event listeners check if sessionId matches before updating state
- Prevents old streaming responses from appearing in new sessions
- All quality checks passing
2025-12-27 17:37:25 +00:00
Dave
68f35d4591 Fix New Session bug: use async Tauri dialog instead of window.confirm
- Tauri overrides window.confirm to return Promise, not boolean
- Changed clearSession to async function using Tauri's ask() dialog
- Now properly waits for user confirmation before clearing state
- Removed debug logging
- All quality checks passing
2025-12-27 17:33:03 +00:00
Dave
418fa86f7d Add debug logging to clearSession to diagnose Cancel button bug 2025-12-27 17:30:03 +00:00
Dave
bd8d838457 Story 17: Display Context Window Usage with emoji indicator
- Added real-time context window usage indicator in header
- Format: emoji + percentage (🟢 52%)
- Color-coded emoji: 🟢 <75%, 🟡 <90%, 🔴 >=90%
- Hover tooltip shows full details: 'Context: 4,300 / 8,192 tokens (52%)'
- Token estimation: 1 token ≈ 4 characters
- Model-aware context windows: llama3 (8K), qwen2.5 (32K), deepseek (16K)
- Includes system prompts, messages, tool calls, and streaming content
- Updates in real-time as conversation progresses
- All quality checks passing (TypeScript, Biome, Clippy, builds)

Tested and verified:
- Shows accurate percentage of context usage
- Emoji changes color at appropriate thresholds
- Different models show correct context window sizes
- Can exceed 100% when over limit (shows red)
- Tooltip provides exact token counts
2025-12-27 17:26:21 +00:00
Dave
9965c78221 Remove duplicate/empty Story 15 (New Session was completed as Story 20) 2025-12-27 17:10:25 +00:00
Dave
88e2a9c0bc Add Story 22: Smart auto-scroll that respects user scrolling 2025-12-27 17:09:32 +00:00
Dave
fdefdd7204 Add biome-ignore for intentional useEffect dependencies 2025-12-27 17:08:29 +00:00
Dave
9a61b03c09 Fix auto-scroll bug: add messages and streamingContent as dependencies to useEffect 2025-12-27 17:04:06 +00:00
Dave
b3dd5f5670 Story 20: New Session button to clear chat history
- Added 'New Session' button in header with confirmation dialog
- Clears frontend messages, streaming content, and loading state
- Button has subtle styling with hover effects
- Preserves project path, model selection, and tool settings
- Backend context automatically cleared (no server-side history)
- Fixed build errors by removing unused tokio watch channel
- All quality checks passing (TypeScript, Biome, Clippy, builds)

Tested and verified:
- Button appears in header near model controls
- Confirmation dialog prevents accidental clearing
- Messages clear immediately after confirmation
- Input remains ready for new conversation
- Settings preserved across session clears
2025-12-27 17:01:55 +00:00
Dave
64d1b788be Story 18: Token-by-token streaming responses
- Backend: Added OllamaProvider::chat_stream() with newline-delimited JSON parsing
- Backend: Emit chat:token events for each token received from Ollama
- Backend: Added futures dependency and stream feature for reqwest
- Frontend: Added streamingContent state and chat:token event listener
- Frontend: Real-time token display with auto-scroll
- Frontend: Markdown and syntax highlighting support for streaming content
- Fixed all TypeScript errors (tsc --noEmit)
- Fixed all Biome warnings and errors
- Fixed all Clippy warnings
- Added comprehensive code quality documentation
- Added tsc --noEmit to verification checklist

Tested and verified:
- Tokens stream in real-time
- Auto-scroll works during streaming
- Tool calls interrupt streaming correctly
- Multi-turn conversations work
- Smooth performance with no lag
2025-12-27 16:50:18 +00:00
Dave
bb700ce870 feat: Backend cancellation support for interrupting model responses
Merged from feature/interrupt-on-type branch.

Backend cancellation infrastructure:
- Added tokio watch channel to SessionState for cancellation signaling
- Implemented cancel_chat command
- Modified chat command to use tokio::select! for racing requests vs cancellation
- When cancelled, HTTP request to Ollama is dropped and returns early
- Added tokio dependency with sync feature

Story updates:
- Story 13: Updated to use Stop button pattern (industry standard)
- Story 18: Created placeholder for streaming responses
- Stories 15-17: Placeholders for future features

Frontend changes:
- Removed auto-interrupt on typing behavior (too confusing)
- Backend infrastructure ready for Stop button implementation

Note: Story 13 UI (Stop button) not yet implemented - backend ready
2025-12-27 15:36:58 +00:00
Dave
909e8f1a2a feat: Story 14 - Auto-focus chat input on startup
Implemented Story 14: Auto-focus Chat Input
- Added inputRef using useRef<HTMLInputElement>
- Added useEffect to focus input on component mount
- Input now automatically receives focus when chat loads
- Cursor is visible and blinking immediately
- Users can start typing without clicking into the field

Updated Specs
- Added Input Focus Management section to UI_UX.md
- Specified auto-focus behavior and requirements
- Provided implementation example
2025-12-25 15:43:29 +00:00
Dave
0ff1a4b167 feat: Story 11 - Left-align text and add syntax highlighting
Implemented Story 11: Text Alignment and Syntax Highlighting
- Removed center-alignment from chat container (text-align: center)
- Added left-alignment to markdown body and code blocks
- Integrated react-syntax-highlighter with react-markdown
- Added syntax highlighting for code blocks using oneDark theme
- Supports JavaScript, TypeScript, Rust, Python, JSON, Markdown, Shell, and more
- Inline code maintains simple styling without full highlighting
- All code blocks are now left-aligned for better readability

Fixed: Agent over-aggressive file writing behavior
- Refined system prompt to distinguish between:
  * 'show/example/how does' → respond with code in chat
  * 'create/add/implement/fix' → use write_file tool
- Removed aggressive AGENT DIRECTIVE prefix from user messages
- Softened reminder message to reflect nuanced behavior
- Agent can now both teach (show examples) and implement (write files)

Updated Specs
- Added Text Alignment and Readability section to UI_UX.md
- Added Syntax Highlighting section with implementation details
- Updated SDSW workflow: acceptance criteria marked complete only after user acceptance

Dependencies
- Added react-syntax-highlighter and @types/react-syntax-highlighter
2025-12-25 15:39:22 +00:00
Dave
ed15279dae feat: Story 9 - Remove scroll bars for cleaner UI
Implemented Story 9: Hidden Scroll Bars
- Added CSS to hide scroll bars globally while maintaining functionality
- Used scrollbar-width: none for Firefox
- Used ::-webkit-scrollbar { display: none; } for Chrome/Safari/Edge
- Set overflow-x: hidden to prevent unwanted horizontal scrolling
- Maintained full scroll functionality (mouse wheel, trackpad, keyboard)

Updated Specs
- Added Scroll Bar Styling section to UI_UX.md
- Documented cross-browser compatibility requirements
- Specified areas affected and implementation approach

Bug Fixes
- Fixed biome linting issues in App.tsx (import organization, button type)
- Applied biome formatter for consistent code style
2025-12-25 15:23:49 +00:00
Dave
990441dfc1 feat: Story 8 - Collapsible tool outputs + autonomous coding improvements
Implemented Story 8: Collapsible Tool Outputs
- Tool outputs now render in <details>/<summary> elements, collapsed by default
- Summary shows tool name with key argument (e.g., ▶ read_file(src/main.rs))
- Added arrow rotation animation and scrollable content (max 300px)
- Enhanced tool_calls display to show arguments inline
- Added CSS styling for dark theme consistency

Fixed: LLM autonomous coding behavior
- Strengthened system prompt with explicit examples and directives
- Implemented triple-reinforcement system (primary prompt + reminder + message prefixes)
- Improved tool descriptions to be more explicit and action-oriented
- Increased MAX_TURNS from 10 to 30 for complex agentic workflows
- Added debug logging for Ollama requests/responses
- Result: GPT-OSS (gpt-oss:20b) now successfully uses write_file autonomously

Documentation improvements
- Created MODEL_SELECTION.md guide with recommendations
- Updated PERSONA.md spec to emphasize autonomous agent behavior
- Updated UI_UX.md spec with collapsible tool output requirements
- Updated SDSW workflow: LLM archives stories and performs squash merge

Cleanup
- Removed unused ToolTester.tsx component
2025-12-25 15:18:12 +00:00
Dave
c493da2f2a chore: archive story 10 2025-12-25 13:22:08 +00:00
Dave
d3fa8d940b feat: persist model selection 2025-12-25 13:21:55 +00:00
Dave
a924de8b36 chore: archive story 09 2025-12-25 13:10:12 +00:00
Dave
f1d4efb266 feat: system prompt and persona 2025-12-25 13:10:03 +00:00
Dave
9aa52a4b6c chore: archive story 07 2025-12-25 12:58:47 +00:00
Dave
c3ff2bdebd feat: ui polish (sticky header, dark mode, flat inputs) 2025-12-25 12:58:37 +00:00
Dave
dfefa3a8bd chore: archive story 06 2025-12-25 12:40:38 +00:00
Dave
e560bd1323 feat: event-driven ui updates 2025-12-25 12:39:20 +00:00
Dave
a97a83ef53 chore: archive story 04 2025-12-25 12:26:39 +00:00
Dave
6572f45422 feat: auto-detect ollama models 2025-12-25 12:21:58 +00:00
Dave
e229f2efa8 feat: persist project selection 2025-12-24 17:46:27 +00:00
Dave
4e2d7416e8 Added some more stories for later 2025-12-24 17:34:22 +00:00
Dave
b241c47fd9 fix: make llm provider async and add tool toggle 2025-12-24 17:32:46 +00:00
Dave
d9cd16601b feat: agent brain (ollama) and chat ui 2025-12-24 17:17:35 +00:00
Dave
76e03bc1a2 feat: core agent tools (fs, search, shell) 2025-12-24 16:59:14 +00:00
Dave
54810631be Initial commit 2025-12-24 16:29:33 +00:00