mirror of
https://github.com/humanlayer/humanlayer.git
synced 2025-08-20 19:01:22 +03:00
30adfed8cef1d6229f5323b62a5c7c83d61669cf
6 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
30adfed8ce | initial steps for interrupt | ||
|
|
e3aac8ca07 |
Pretty tui (#208)
* fix bug of incorrect responses and add type safety * Implement improved TUI session list with table layout and proper ordering - Fix last_activity_at auto-update bug in SQLite UpdateSession - Add LastActivityAt, ClaudeSessionID, and WorkingDir to session.Info - Change SQL ordering to last_activity_at DESC for better UX - Replace single-line session display with aligned table format - Add proper session ordering: Running → Completed → Failed - Show Claude Session ID for manual resume capability - Add relative time formatting and column alignment helpers * support working directory expansion (~/...) * linting for client test (ignoring error returned) * feat: add result storage fields to sessions schema - Add num_turns and result_content columns to sessions table - Update SessionUpdate struct to support new fields - Modify all queries to handle new columns * feat: populate session results from completed Claude sessions - Capture result data (content, turns, cost, duration) on session completion - Populate Result field in session info with comprehensive data - Handle both successful and failed session results * feat: enhance TUI with result display and modal editing support - Clean up newlines in query text display - Add vim-style navigation (j/k keys) - Add modal editing infrastructure for multi-line queries - Improve working directory field handling - Add comprehensive tests for result storage and population * add todos in respective directories * conversation view * feat: add conversation view and improve TUI architecture - Add conversation view support with conversation cache - Implement notification system for new approvals - Remove history tab and update to 2-tab layout (Approvals/Sessions) - Add conversation cache with LRU eviction for better performance - Improve tab switching and view state management - Add updateAllViewSizes for responsive terminal handling * feat: add viewport support and modal editor enhancements Sessions improvements: - Add viewport support for proper scrolling in sessions list - Implement clipboard paste support (Ctrl+V) in modal editors - Change Enter key behavior to open conversation view instead of detail view - Add updateSize method for responsive layout Approvals improvements: - Add viewport support for scrolling approval lists - Change Enter key to open conversation view for session-linked approvals - Add updateSize method for responsive terminal adaptation * fix: correct tool call approval matching for Claude Code batching Change ORDER BY from 'created_at DESC' to 'sequence ASC' in GetPendingToolCall to match approvals with the oldest pending tool call (currently executing) instead of the most recent. This fixes approval correlation issues when Claude Code queues multiple tool calls. * refactor: remove unused history.go file Removed history.go as part of TUI restructuring to focus on 2-tab layout (Approvals/Sessions) with integrated conversation view * formatting! * make tests work in more enviornments (ci) * put bug about working dir on resumumption in TODO * fix tui to correctly handle approvals with creation * worktree and setup helpers * making setup on fresh instances easier * formatting of bash scripts * Fix formatting of tool response denials * Add worktree command to make * setup repo silent `make check test` if succesful * nice and clean silent printing so output is small. * simplify test to make it consistently fast * add handling for early broken pipe (intermittent test failure) * remove duplicate checks * Remove redundant session headers from list and detail views The tab bar already provides context, so remove duplicate "Claude Sessions" and "Session Details" headers to save vertical space and reduce visual clutter. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Add message count display to sessions table - Add "Turns" column to sessions table header - Display turn count from existing sess.Result.NumTurns data - Show "-" for incomplete sessions (nil Result) - Use "k" abbreviation for counts >= 1000 (e.g., "1.2k") - Reduce query preview width from 45 to 39 chars to accommodate new column 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix tab switching navigation to exit conversation view When in conversation view, pressing '1' or '2' now properly exits the conversation and shows the selected tab's list view. Previously, the tab would switch but the conversation view remained open, creating a janky UX. Added conversation cleanup (stopPolling and clear sessionID) to both Tab1 and Tab2 key handlers, matching the ESC key behavior. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix session sorting priority to show waiting_input sessions first Sessions requiring user approval (waiting_input status) now appear at the top of the sessions list in the TUI, making it easier for users to find sessions that need their attention. Changes: - Updated statusPriority function to give waiting_input highest priority (0) - Adjusted other priorities: running/starting (1), completed (2), failed (3) - Added hourglass emoji (⏳) icon for waiting_input sessions This ensures users see sessions needing their approval before any other sessions, improving the user experience when multiple sessions are active. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(tui): Store parent session data for instant inheritance display When resuming a session, capture parent model and working directory for immediate display in child session. This provides instant visual feedback while waiting for daemon to persist the data. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Remove redundant approval headers from detail and feedback views Tab bar already provides "Approvals" context, so remove duplicate headers like "Approval Request" and "Approve with Comment" to reduce visual clutter. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix infinite scrolling issue in session detail view Users could previously scroll infinitely past the bottom of session detail content with the 'j' key, requiring excessive 'k' presses to return. This fix adds proper bounds checking to the Down key handler, preventing scrolling beyond the actual content length. The solution extracts content building into a reusable method and applies the same scrolling bounds calculation used by the render function to the input handler, ensuring consistent behavior. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(daemon): Persist inherited model and working directory in database When continuing a session, explicitly copy parent model and working directory to child session config and database record. This ensures the TUI displays correct inherited values instead of defaults. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Clean up whitespace after header removal * test: Fix working directory test failure in daemon continue session Use empty working directory instead of non-existent path to prevent chdir errors during test execution. Also handle both possible error messages (claude not found or chdir failure). 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(sessions): Complete working directory inheritance in sessions list Add ParentSessionID field to session.Info struct and implement inheritance logic in sessions list rendering. Child sessions now properly inherit and display parent working directory and model instead of showing defaults. Changes: - Add ParentSessionID to session.Info struct for consistency with RPC types - Update ListSessions conversion to include ParentSessionID from database - Implement inheritance logic in TUI sessions list for WorkingDir and Model - Child sessions now show inherited values instead of '~' and 'default' 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * updated todos * fix(tui): Remove artificial list view restriction from quit handler Allow Ctrl+C to quit from any view, not just list views. This prevents users from getting trapped in child views and aligns with standard terminal application behavior. * fix(tui): Process global quit key in modal views before delegation Ensure Ctrl+C is handled even in modal views by checking for quit key before delegating to sub-handlers. This prevents users from being trapped in modal input states. * fix(store): Improve approval correlation with temporal proximity matching - Update GetPendingToolCall to find most recent uncompleted tool call - Order by sequence DESC for temporal proximity instead of ASC - Exclude already correlated approvals (approval_status IS NULL) - Add GetPendingToolCalls method to retrieve all pending tool calls - Better handle multiple tool calls of the same type 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(tui): Implement dynamic viewport height calculation for conversation view - Add calculateBottomContentHeight() to measure actual bottom content size - Replace hardcoded height offset with dynamic calculation - Account for input prompts and status lines in viewport sizing - Ensure viewport doesn't extend below visible area 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat(approval): Add bidirectional state synchronization for approvals - Enhanced approval poller to reconcile cached states with backend - Added detection for externally resolved approvals (via web UI) - Implemented automatic cleanup of resolved approvals from cache - Added store methods for retrieving all cached approvals and removing resolved ones - Publishes events when external resolutions are detected This fixes the issue where approvals resolved through the web UI would not be reflected in the daemon/TUI, causing "call already has a response" errors. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat(tui): Implement two-step quit behavior for better UX Add graceful two-step quit: first Ctrl+C navigates back to list view, second Ctrl+C quits the application. This prevents accidental quits while still allowing users to exit from any view. Includes visual feedback with notification message and automatic timeout. * feat(approvals): Add real-time approval context updates via event bus - Publish EventApprovalResolved when approval is correlated with tool call - Add CorrelateApprovalByToolID method for direct tool_id correlation - Enable real-time UI updates when approvals arrive - Support correlation by tool_id for stronger matching 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(sessions): Update last_activity_at timestamp for conversation events Previously the modified date in the TUI sessions table showed the same timestamp as the created date. This was because session activity wasn't being tracked during conversation events. Added timestamp updates for: - Text messages from assistant/user - Tool calls - Tool results - Session completion The TUI now correctly shows different timestamps for Created and Modified columns, with Modified updating as conversation activity occurs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(tui): Complete viewport bounds management for conversation view - Handle window resize events to recalculate viewport dynamically - Improve bottom content height calculation with accurate line counts - Preserve scroll position during polling updates - Add proper bounds checking to prevent content overflow 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * style(tui): Fix trailing whitespace * feat(tui): Show multiple pending approvals with better context visibility - Track all pending approvals, not just the first one - Display pending approval count in conversation header - Show approval position (1 of N) for multiple pending approvals - Improve tool call status display with queue position - Better visual indicators for approval context 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat(approval): Add conflict resolution for 409 responses - Added APIError type in humanlayer-go client to identify 409 conflicts - Implemented handleConflictError method to gracefully handle already-responded approvals - Added ErrAlreadyResponded error for clear user feedback - Updated ApproveFunctionCall, DenyFunctionCall, and RespondToHumanContact to handle conflicts - Automatically removes resolved approvals from cache and updates database status This prevents "call already has a response" errors when approvals are resolved externally through the web UI while the daemon is trying to respond. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(tui): Add error message truncation and bounds checking Prevent long error messages from disrupting TUI layout by: - Truncating error messages to fit available terminal width - Adding intelligent word boundary breaking with ellipsis - Preprocessing common API errors into user-friendly messages - Calculating dynamic width based on status bar elements - Adding error detail view accessible via 'e' key for full messages Fixes layout corruption when "call already has a response" and other long API error messages overflow the status bar width. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat(approval): Implement approval state recovery for session restarts - Added ReconcileApprovalsForSession method to re-correlate approvals after session restart - Enhanced correlateApproval to check parent sessions for tool calls in continued sessions - Added ApprovalReconciler interface to decouple session manager from approval manager - Integrated reconciliation into LaunchSession and ContinueSession flows - Approvals are now automatically recovered when sessions restart or continue This fixes the issue where pending approvals become orphaned when sessions crash and restart, allowing users to continue the approval flow seamlessly. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(tests): Fix mock implementations and correlation logic - Add GetPendingToolCalls and CorrelateApprovalByToolID to MockConversationStore - Add GetUncorrelatedPendingToolCall method for finding tool calls without approvals - Fix variable redeclaration error in poller - Ensure tests pass with updated correlation logic 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(approval): Add missing ApprovalStatusResolved constant and regenerate mocks - Added ApprovalStatusResolved constant to store package for external resolutions - Regenerated mocks to include new Store interface methods - Fixed compilation errors in approval package 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(tui): Restore help footer with contextual keybinding hints Added context-sensitive help text to the status bar that shows relevant keybindings based on the current view: - List views show navigation and action keys - Modal views show submit/cancel options - Error detail view shows close options - Conversation view uses its own help line The help text appears on the right side of the status bar, with proper spacing that accounts for connection status and error messages. When space is limited, help text is hidden to prioritize error display. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(tui): Correct viewport height calculations and spacing - Remove extra newline between viewport and input prompts - Add leading newline to input prompts section for consistent spacing - Update bottom content height calculation to account for all spacing - Fix off-by-one errors in height calculations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(tui): Fix view state transition layout updates and viewport calculations - Add layout update calls on all view state transitions to prevent viewport mismatches - Standardize content height calculation across all views (terminal - tab bar - status bar) - Fix conversation view to properly use content area dimensions instead of full terminal - Add bounds checking to prevent negative dimensions in approvals and sessions views - Update modal rendering to account for UI chrome properly - Add layout constants for consistent dimension calculations across the codebase This ensures that inline operations (like denying approvals with 'n') properly recalculate layout dimensions, preventing viewport size mismatches and content positioning problems. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(tui): Simplify quit behavior to single Ctrl+C immediate exit Remove two-step quit logic and return to simple immediate quit on Ctrl+C from any view. This matches standard terminal application behavior and fixes the header disappearing bug when exiting from conversation view. * fix(tui): Fix conversation view denial input overlap - Add dynamic viewport resizing when input prompts are shown/hidden - Store content dimensions in conversationModel for dynamic adjustments - Reduce viewport height by 8 lines when denial/resume prompts are active - Call adjustViewportSize when toggling prompt visibility This prevents the denial reason input from overlapping with conversation content by properly reserving space for the input prompt. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Remove deleted hlyr-tui binary --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
b8ea3ee9a7 |
Add multi-turn conversation support with session continuation (#207)
* resuming session work * pull request template formatting * make claudecode-go happy with race conditions * tests for session continuation |
||
|
|
418fb93cae |
initial phase 1 of second round (#203)
* initial phase 1 of second round * prompt to query * mocks and gitignore * making sure `make check test` covers all the thing * fixing `make check test` now that vercel-ai-sdk is in it * another makefile addition * store and store tests * session integration tests passing with store * daemon changes for store * formatting * properly pass config into mcp servers * unused errors (linting) * get sessions from db when fetching * linting and approvals returning error * linting * better client handling of race conditions and linting * use proper config path (to have daemon match hlyr) * linting and exposing approvals even if no hl api key * linting * fix daemon client hang when running `hl launch` * fix: Pass context through updateSessionStatus for proper cancellation - Replace context.Background() with parent context in updateSessionStatus - Ensures database operations respect context cancellation and deadlines - Preserves context values like trace IDs through the call chain - Update all callers to pass context parameter * fix: Wrap conversation event insertion in transaction to prevent race conditions - Use transaction for atomic sequence number generation and insert - Prevents concurrent inserts from getting duplicate sequence numbers - Ensures sequence numbers remain unique per claude_session_id * refactor: migrate session storage from in-memory to SQLite-only - Replace m.sessions map with m.activeProcesses for Claude processes only - Remove in-memory GetSession() and old ListSessions() methods - Rename ListSessionInfo() to ListSessions() as primary database query method - Add GetSessionInfo() for single session database queries - Update Session struct to remove unused claude field - Ensure all session data queries use database as source of truth This completes the migration to SQLite storage, reducing memory usage and eliminating potential data synchronization issues between memory and database. * test: update tests for SQLite-backed session management - Remove tests for internal implementation details (in-memory maps) - Update unit tests to use mock store instead of in-memory session access - Fix integration tests to work with new activeProcesses architecture - Update test assertions to query database instead of in-memory state * install ai sdk as well now that it's in make check * generate mocks for ci to run checks/tests * add mocks to test step as well * ci fixes (hopefully) * claude code binary with tests in ci * correct path * change for ci to bypass auth-required claude code * correct thing |
||
|
|
794d4d70fa |
cleaning up/refactoring of tui (#202)
* cleaning up/refactoring * formatting cleanup * rebind c to l to avoid vim l binding conflict * change "prompt" to "query" * no more agent name! |
||
|
|
3705589a29 |
claude code go (#184)
* claude code go * formatting * Update README.md |