75 Commits

Author SHA1 Message Date
Sundeep Malladi
fd6739dffe Suppress approval notifications for already-approved messages (and some other stuff) (#391)
* Fix auto-accept edits toggle to update store directly

- Update SessionDetail shift+tab handler to directly update store
- Ensures immediate UI feedback when toggling auto-accept mode
- Add debug logging to track toggle behavior

* Add SessionSettingsChanged event for real-time settings updates

Implements a new event type to propagate session settings changes (like auto-accept edits)
from backend to frontend via SSE. This ensures the UI stays in sync when settings are
modified through any interface (REST API or RPC).

Key changes:
- Add EventSessionSettingsChanged constant to event bus types
- Add UpdateSessionSettings method to SessionManager interface to centralize event publishing
- Update REST API handler to use session manager instead of direct store updates
- Fix SSE handler to recognize and forward session_settings_changed events
- Add TypeScript types and event handling in frontend
- Wire up event handler in Layout.tsx to update local state
- Add make task for regenerating SDKs from OpenAPI specs

The implementation follows the existing architectural pattern where managers (not handlers
or stores) are responsible for publishing events to maintain consistency.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add approval notifications to Layout component

Implements proper notification handling for approval events in the main Layout component.
This ensures users are notified when AI agents request approval for tool usage.

Key changes:
- Add notification tracking with isItemNotified/addNotifiedItem to prevent duplicate notifications
- Implement onNewApproval handler to show notifications when approvals are requested
- Move session fetching outside completion block for better code reuse
- Add proper TypeScript types for event data
- Show tool-specific approval messages with fallback for error cases

The implementation follows the event-based notification pattern, as the investigation
showed that status-based notifications (waiting_input transitions) never occur in practice.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add delay to prevent notifications for auto-approved items

Implements a 100ms delay in the onNewApproval handler to check if an approval
was auto-resolved before showing a notification. This prevents the brief flash
of approval notifications for edit operations when auto-accept mode is enabled.

The solution works by:
- Waiting 100ms after receiving a new_approval event
- Checking if the session is still in waiting_input status
- Skipping the notification if the status has already changed (indicating auto-approval)

This handles the race condition where the backend sends both new_approval and
approval_resolved events in quick succession for auto-approved items.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix auto-approval notification logic with approval cache

Replaces the flawed session status check with a proper approval resolution cache.
The previous approach incorrectly skipped notifications for manual approvals (like Bash)
because it checked session status before updating it to waiting_input.

The new implementation:
- Tracks resolved approvals in a cache when onApprovalResolved fires
- Checks this cache after 100ms delay to determine if an approval was auto-resolved
- Works correctly for both auto-approved (Edit tools) and manual approval cases

Also adds timestamps to console logs for better debugging of event timing.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat(wui): rework shift+tab to toggle auto-accept edits for selected sessions

- Add bulkSetAutoAcceptEdits method to store for bulk updating auto-accept settings
- Replace shift+tab view mode toggle with auto-accept toggle functionality
- Similar behavior to 'e' archive hotkey: works on selected sessions or focused session
- Shows success/error toast notifications for user feedback
- Intelligently toggles status: if all selected sessions have auto-accept enabled, disables it; otherwise enables it

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat(wui): improve archive hotkey behavior and add auto-accept indicator

- Fix archive hotkey ('e') to properly handle mixed selection states
- Show warning when trying to bulk archive sessions with different archived states
- Add visual indicator (⏵⏵) for running sessions with auto-accept edits enabled
- Improve error handling and logging for archive operations

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* MCT

* test tweaks

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-31 15:51:52 -05:00
Allison Durham
877ec27b0a Allison/eng 1784 bundle daemon and cli with wui for single installation (#385)
* feat(daemon): add dynamic port allocation support

- Always create HTTP server regardless of port configuration
- Support port 0 for dynamic allocation
- Output actual port to stdout when using dynamic allocation
- Enable WUI to start daemon on any available port

* feat(wui): add daemon process management infrastructure

- Add Tauri shell and store plugins for process and state management
- Implement Rust daemon manager with automatic startup on app launch
- Add branch-based daemon isolation for development environments
- Create TypeScript services and hooks for daemon lifecycle management
- Add debug panel UI for manual daemon control in dev mode
- Support automatic daemon connection with managed port discovery
- Handle graceful daemon shutdown on app close
- Implement retry logic for daemon connection during startup

* feat(wui): add daemon process management infrastructure

* chore(wui): update gitignore for daemon artifacts

* build(wui): update Tauri bundle configuration

* build: add homebrew formula and update CI for daemon bundling

* formatting

* makefile to build daemon too (when run wui on dev)

* refactor: improve daemon management in WUI with async/await and better error handling

- Convert daemon start/stop operations to async/await pattern
- Switch HTTP host from 127.0.0.1 to localhost for better compatibility
- Add debug URL override support for development
- Improve error handling and startup behavior
- Fix path resolution for development mode when running from src-tauri

* daemon no longer randomly crashes
Needed to do weird stdout things

* Parse daemon log levels to improve dev logging output

Previously all daemon stderr output was logged as ERROR level, causing confusion
and double timestamps. Now we parse slog format to extract actual log levels
(INFO, WARN, ERROR, etc.) and route them to appropriate tracing levels.

* Integrate debug panel into status bar with theme-aware colors

- Move debug panel button from floating bottom-left to status bar bottom-right
- Replace Settings icon with Bug icon and match styling of other status controls
- Update connection status colors to use CSS variables for theme consistency
- Refactor DebugPanel to accept open/onOpenChange props for controlled state

* Remove local homebrew tap files - moved to separate repository

The homebrew tap is now properly maintained in its own repository
at humanlayer/homebrew-humanlayer for public distribution.

* Migrate WUI backend from tracing to log crate with tauri-plugin-log

- Replace tracing with log crate for consistency
- Add tauri-plugin-log with file rotation (50MB) and proper formatting
- Configure LogDir, Stdout (dev), and Webview targets
- Add proper prefixes: [Tauri] for WUI logs, [Daemon] for daemon logs
- Add log:default permission to capabilities

* Add frontend logging infrastructure for WUI

- Install @tauri-apps/plugin-log and @tauri-apps/api dependencies
- Create logging service with JSON serialization for objects
- Add log location notification for production builds
- Initialize attachConsole to display Rust logs in browser console
- All frontend logs will use [Console] prefix

* Migrate all console calls to use logger throughout WUI

- Replace 94 console.* calls with logger.* across 24 files
- Ensures all frontend logs are captured in production log file
- Maintains browser console output in development mode
- High-traffic files: NotificationService (22), AppStore (21), useSubscriptions (10)

* git ignore of compiled things

* fix it to not be annoyed

* Implement branch-based logging for WUI

- Extract branch detection logic (get_git_branch, extract_ticket_id, get_branch_id)
  into shared functions in lib.rs
- Configure tauri-plugin-log to use branch-based folders in development:
  ~/.humanlayer/logs/wui-{branch-id}/codelayer.log
- Update daemon.rs to use shared branch detection functions
- Add get_log_directory Tauri command to expose log paths to frontend
- Update log notification service to handle branch-based directories
- All log sources (WUI backend, daemon stderr, frontend console) now write
  to a single rotated log file per branch with clear source prefixes

* Update documentation and simplify Makefile for new logging structure

- Remove tee command from wui-dev target in Makefile since logging is now
  handled by tauri-plugin-log
- Update DEVELOPMENT.md to show new WUI log paths in environment overview
- Update CLAUDE.md files to document branch-based log locations:
  - Dev: ~/.humanlayer/logs/wui-{branch}/codelayer.log
  - Prod: Platform-specific directories
- Document that logs include all sources with prefixes: [Tauri], [Daemon], [Console]

* formatting

* add touch to bins

* ci: align GitHub Actions workflows with local development setup

- Simplify main.yml workflow to use unified setup process
- Add CI detection to setup_repo.sh for conditional tool installation
- Install CI-specific tools (Claude Code CLI, UV, golangci-lint) only in CI
- Add setup-ci and ci-tools targets to Makefile for explicit CI setup
- Parallelize npm and bun dependency installations for faster setup
- Add Go and Rust tool caching to improve CI performance
- Create platform-specific dependency script for future expansion

This change reduces workflow complexity from 75+ to ~50 lines per job while
maintaining all functionality. CI and local development now share the same
setup process, improving maintainability and consistency.

* sdk needs to build in order for wui to check
2025-07-31 12:10:26 -07:00
dexhorthy
6df13fe3d6 fix(hld): add signal propagation script for graceful shutdown (ENG-1826)
Phase 3 completion - fixes signal handling when running daemon with logging.

The run-with-logging.sh script properly captures the daemon PID and forwards
signals (SIGTERM/SIGINT) to enable graceful shutdown. Without this, the
daemon gets force-killed by the shell/make process chain, preventing proper
session cleanup.

Key improvements:
- Captures actual daemon PID (not tee process)
- Sets up signal traps to forward TERM and INT signals
- Preserves daemon exit code
- Ensures graceful shutdown works in logged environments

This was the missing piece for making graceful shutdown work properly.
All tests passing (278 unit tests, 40 integration tests).
2025-07-30 11:36:50 -07:00
dexhorthy
31f59f632c remove tui refs 2025-07-30 11:27:09 -07:00
dexhorthy
5a09507f5d daemon: phase 2 shutdown - persistent dev database and interrupted states
- Add clone-nightly-db-to-dev-db make target to clone nightly db with backup
- Update daemon-dev to use persistent ~/.humanlayer/daemon-dev.db instead of creating copies
- Clarify markOrphanedSessionsAsFailed behavior for interrupting/interrupted states
- Add test coverage for new interrupting and interrupted session statuses
- Update CLAUDE.md to document nightly vs dev database usage

This prepares the daemon for handling interrupted session states while making
development easier with a persistent dev database.
2025-07-28 14:27:32 -07:00
Allison Durham
b2ef3da640 Add end-to-end tests for HLD REST API (#351)
* Add end-to-end tests for HLD REST API

- Implement comprehensive e2e test suite covering all 16 REST endpoints
- Add GitHub Actions job for running e2e tests in CI
- Support multiple test modes: standard, verbose, and manual approval
- Test approval workflows (deny → retry → approve), SSE events, and session lifecycle
- Document known upstream issues discovered during testing
- Add proper .gitignore to exclude node_modules and test artifacts

* formatting

* comment out
2025-07-28 10:51:45 -07:00
dexhorthy
169d4bf4ba Update Makefile to use CodeLayer.app instead of humanlayer-wui.app 2025-07-26 18:41:28 -07:00
Dex
713893cdc9 command tweaks for style (#333)
* command tweaks for style

* one more command fix and hld/ claude fix

* research spec metadata in allowlisted script now :)

* remove triangle spinner

* proposal: web research prompt

* grab more dev intel
2025-07-21 09:51:32 -07:00
Sundeep Malladi
320ec41617 Ignore tauri releases from eslint 2025-07-18 14:47:14 -05:00
Dex
bbec78b42a Merge pull request #328 from balanceiskey/dexter/eng-1666-two-lingering-thoughts-on-the-things-on-the-hey-we-need-to
Fixes related to launching the right humanlayer
2025-07-18 11:36:42 -07:00
Dex
544dd16ae2 Merge pull request #326 from dexhorthy/dexter/eng-1666-two-lingering-thoughts-on-the-things-on-the-hey-we-need-to
enable parallel dev and prod wui development
2025-07-18 08:54:13 -07:00
Sundeep Malladi
9f8ffeb46e Fixes related to launching the right humanlayer 2025-07-18 10:11:12 -05:00
dexhorthy
0076de5b5e only build the app 2025-07-18 07:43:32 -07:00
dexhorthy
ab81cc7095 Improve daemon socket handling and development workflow
- Add development workflow aliases (make daemon, make wui)
- Document MCP server daemon socket inheritance behavior
- Add clean-wui-release target to fix check-wui reliability
- Update tests to pass socket path to NewManager
- Ensure MCP servers launched by Claude Code sessions connect to the correct daemon instance
2025-07-17 21:25:17 -07:00
dexhorthy
e136b875e7 Fix MCP server socket path for parallel dev environments
Pass HUMANLAYER_DAEMON_SOCKET environment variable to MCP servers launched
by the daemon. This ensures MCP servers connect back to the correct daemon
instance (dev vs nightly) instead of always using the default socket path.

- Update session Manager to accept and store socket path
- Add HUMANLAYER_DAEMON_SOCKET to MCP server environment variables
- Update MCP server to read socket path from environment
- Update all tests to pass socket path parameter
2025-07-17 20:35:18 -07:00
dexhorthy
7ad6dbd672 thoughts 2025-07-17 14:43:17 -07:00
Sundeep Malladi
84a2479d94 [ENG-1612] Improve bulk action handling; add unit tests; adjust checkbox handling (#296)
* feat: add conditional visibility and animations to session table checkboxes

- Checkboxes now only visible when row is focused or in bulk selection mode
- Added smooth fade and scale animations (200ms) for checkbox appearance/disappearance
- Improves UI cleanliness by reducing visual clutter when checkboxes aren't needed

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat(wui): implement proper range selection for shift+j/k keyboard shortcuts

- Add range selection state management to AppStore with anchor tracking
- Fix shift+j/k to select contiguous ranges instead of toggling individual items
- Clear selection anchor on regular navigation (j/k) and individual toggles (x/click)
- Add ViewMode enum to replace string literals for view mode management
- Remove archived icon from session table (redundant with view mode)
- Auto-switch to normal view when resuming archived sessions
- Set up Bun test runner infrastructure for WUI project
- Add comprehensive unit tests for range selection behavior
- Create test utilities for mock session generation

The shift+j/k shortcuts now work as expected:
- First shift+j sets anchor and selects current + next
- Subsequent shift+j extends selection downward
- shift+k after shift+j shrinks selection upward
- Regular navigation clears the range selection

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(wui): preserve multiple selection ranges with shift+j/k

Fixed an issue where continuing shift+j/k after navigating with j/k would
replace existing selections instead of adding to them. The problem was
caused by React's state update batching making the isAddingToSelection
flag stale when checked immediately after setting it.

The fix pre-calculates whether to add to selection before any state
updates, then combines this with the stored isAddingToSelection flag
to ensure the entire shift+j/k sequence maintains the correct behavior.

Now the keyboard shortcuts work correctly:
- Select sessions 1-3 with shift+j
- Navigate down with j
- Press shift+j to ADD sessions 5-6 to the selection
- All 5 sessions remain selected (1, 2, 3, 5, 6)

Added debug logging to help diagnose selection behavior issues.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Adding this, don't know if I like it

* mct

* fix(wui): implement stateless anchor management for shift+j/k keyboard shortcuts

Previously, shift+k wasn't properly deselecting items when navigating back
to an initially created selection range. The issue was that anchor positions
were determined solely by movement direction, not by the current position
within the range.

Changes:
- Remove anchor state management (selectionAnchor, isAddingToSelection)
- Add bulkSelect method to AppStore with intelligent anchor positioning
- Update SessionTable to use store's bulkSelect instead of local logic
- Fix pivot behavior: anchor is now set at opposite end of current position
- Add comprehensive tests for shift+j/k scenarios including pivot cases

The new logic correctly handles:
- Creating new selections from no selection
- Pivoting within existing selections (shrinking/expanding)
- Multiple sequential operations maintaining proper anchor position

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor(wui): clean up SessionTable after bulkSelect refactor

- Remove unused imports (selectRange, addRangeToSelection, updateCurrentRange)
- Remove all commented-out code from shift+j/k handlers
- Remove debug console.log statements from tests
- Simplify dependency arrays for keyboard shortcuts

The first section of tests in AppStore.test.ts remains relevant as they
test the underlying methods that bulkSelect depends on (selectRange,
addRangeToSelection, updateCurrentRange).

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add bun install to CI

* docs(wui): update CLAUDE.md with testing and keyboard shortcut documentation

Add documentation for:
- Unit testing with Bun's built-in test runner
- Test-driven development approach for store changes
- Keyboard shortcuts and selection management details
- Stateless anchor management architecture

This captures the patterns established while fixing the shift+j/k selection bug
and introduces testing as a first-class practice for WUI development.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-14 15:41:38 -05:00
Dex
793c07feab daemon things (#295)
* daemon things

* no more pork-barrel prompting
2025-07-11 10:58:40 -07:00
Dex
15b3af7460 Update Makefile 2025-07-03 18:34:45 -05:00
dexhorthy
baabb50a21 make wui 2025-07-03 16:16:56 -07:00
Allison Durham
37d13c4727 fix resumed sessions to inherit all configuration from parent (#253)
* Add missing configuration fields to sessions table

- Add permission_prompt_tool, append_system_prompt, allowed_tools,
  and disallowed_tools fields to Session struct
- Create database migration to add new columns to sessions table
- Update CreateSession, GetSession, GetSessionByRunID, and ListSessions
  to handle new fields
- Serialize tool arrays as JSON for database storage

* Implement full configuration inheritance for resumed sessions

- Inherit all configuration fields from parent session in ContinueSession
  (except MaxTurns which is intentionally not inherited)
- Retrieve and inherit MCP server configurations from parent
- Add comprehensive tests for field inheritance, MCP inheritance, and
  override behavior
- Update existing tests to handle new mock expectations

* Remove manual inheritance workaround from TUI

Now that the backend properly inherits all configuration from parent
sessions, remove the manual workaround that was storing and applying
parentModel and parentWorkingDir fields.

* Fix database migration ordering and versioning

Move migration application after schema initialization to ensure proper
execution order for both new and existing databases. Update migration
version to 3 and ensure new databases start with the latest schema
version to avoid unnecessary migrations.

* Fix MCP server retrieval ordering for consistent test results

Add ORDER BY clause to GetMCPServers query to ensure deterministic
ordering when retrieving MCP servers from the database. This fixes
the InheritsMCPServers test failure in CI where servers were being
returned in non-deterministic order.

* Fix MCP server ordering for consistent test results

Ensure deterministic ordering when converting MCP servers from map to slice
by sorting server names before iteration. This prevents test flakiness
caused by map iteration order variations.

* Fix integration test failures and improve test infrastructure

- Enable integration tests in standard test suite by default
- Add quiet mode support for integration tests to match unit test output
- Fix scanner usage and connection handling in session tests
- Add config override to prevent loading user configuration in tests
- Filter approval poller events in subscription tests to reduce noise
- Use in-memory database for test isolation

* Fix race conditions and improve error handling

- Fix approval status race condition: only update from pending to resolved,
  never overwrite approved/denied status
- Return error for non-existent sessions instead of empty result
- Fix listener double-close issue by tracking close state
- Handle context cancellation properly in monitorSession to prevent
  'database is closed' errors during shutdown
- Update test expectations to match new error handling behavior

* Fix CI test failure in TestSessionStateTransitionsIntegration

Use temporary database file instead of :memory: to ensure all connections
access the same database. SQLite in-memory databases are unique per connection,
which was causing 'no such table' errors when different components tried to
access the database.

* formatting
2025-06-27 15:26:50 -07:00
Allison Durham
da079ca3b2 Complete InterruptSession implementation and enable resume during running status (#230)
* Complete InterruptSession implementation

- Fix syscall import compilation error in claudecode-go
- Add proper race condition handling in session manager
- Move InterruptSessionRequest to types.go for consistency
- Add InterruptSessionResponse with success/status fields
- Add 'completing' status for graceful shutdown semantics
- Update event publishing to use completing status
- Add TypeScript types for interrupt operations
- Update Rust client with proper response handling
- Fix unit tests for new completing status
- All 109 tests passing with full type safety

* git ignore test-results.json

* Enable resume during running status

- Allow continueSession to accept running sessions in addition to completed
- Interrupt running sessions before resuming to ensure clean state transitions
- Reorder validation to check claude_session_id before attempting interrupt
- Provide clear error messages for orphaned sessions (running but no claude_session_id)
- Add comprehensive unit and integration tests for new resume-during-running functionality
- Maintain backward compatibility for existing completed session resume workflow

* fix: force bash shell in CI to prevent shell compatibility errors

The CI was using /bin/sh which doesn't support bash-specific syntax
like [[ ]] used in hack/run_silent.sh lines 73 and 88. This caused
'/bin/sh: [[: not found' errors that made tests appear to pass when
they may not have actually run properly.

* add fail-fast shell syntax validation to prevent silent CI failures

- Added 'set -e' to hack/run_silent.sh to exit on any command failure
- Added 'bash -n' syntax validation before sourcing shell scripts in Makefile
- This ensures CI will fail immediately if shell scripts have syntax errors
- Prevents scenarios where malformed scripts cause tests to appear to pass
  when they may not have actually executed properly

* fix: resolve Claude Code streaming JSON schema compatibility issues

- Fix pointer-to-loop-variable bug in streaming test event collection
- Add missing system event fields (CWD, Model, PermissionMode, APIKeySource)
- Update Usage struct to match current Claude Code schema (ServerToolUse, ServiceTier)
- Fix cost field mapping from TotalCost to CostUSD throughout codebase
- Improve message event validation to handle user vs assistant differences
- All schema compatibility tests now pass

* fix: complete TotalCost to CostUSD field migration across codebase

- Remove deprecated TotalCost field assignments in session manager
- Update TUI to display CostUSD instead of TotalCost
- Remove TotalCost test assertions in result population tests
- Completes schema consistency with Claude Code SDK changes

* fix: make shell scripts POSIX-compliant to prevent CI failures

- Replace bash-specific [[ with POSIX [ syntax in run_silent.sh
- Replace == with = for POSIX compatibility
- Simplify test-ts to use run_silent instead of complex JSON parsing
- Remove SHELL := /bin/bash from all Makefiles (no longer needed)
- Remove shell: bash from GitHub Actions (no longer needed)
- Keep set -e for fail-fast behavior and syntax validation
- Scripts now work consistently in both bash and sh environments

* fix: use sh -n instead of bash -n for syntax validation

Since scripts are now POSIX-compliant, use sh for syntax validation
to match the target shell environment and ensure consistency.
2025-06-23 08:47:55 -07:00
Dex
9ff57a773e Merge branch 'main' into release-0.7.9 2025-06-17 08:12:26 -07:00
Allison Durham
e599fa4773 Cleanup for make commands and ci (#213)
* Refactor humanlayer-wui build system and fix TypeScript issues

- Remove Docker dependency from wui Makefile, use bun directly
- Update setup_repo.sh to include wui bun install step
- Fix TypeScript errors in App.tsx and daemon-client.ts
  - Add proper useEffect cleanup for event subscriptions
  - Add GetSessionStateResponse type interface
  - Remove unused 'connected' variable
- Add Button component usage from shadcn/ui
- Fix root .gitignore to only ignore Python lib/ at root level
- Initialize shadcn/ui properly with utils.ts file
- Remove unnecessary Dockerfile from wui

* formatting

* Fix CI: Add bun installation and remove obsolete poetry configuration

- Install bun in CI for humanlayer-wui build support
- Add humanlayer-wui dependency installation step
- Remove obsolete poetry CI action (migrated to uv)

* Reduce make check/test output verbosity from 500+ to ~50 lines

- Add hack/run_silent.sh with helper functions for quiet command execution
- Update all Makefiles to support quiet mode by default with VERBOSE=1 override
- Show only pass/fail indicators with test counts where available
- Preserve full error output when commands fail for easy debugging
- Add make check-verbose and test-verbose convenience targets
- Document the new quiet build system in CLAUDE.md

The new system provides clean, scannable output while maintaining full
visibility into failures, making CI logs and local development much
more pleasant.

* formatting
2025-06-16 10:00:31 -07:00
Sundeep Malladi
d506260e23 Add base eslint/prettier setup 2025-06-13 14:28:55 -05:00
Allison Durham
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>
2025-06-13 10:39:33 -07:00
Allison Durham
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
2025-06-06 17:26:13 -07:00
dexhorthy
8ef6c30786 bump to next alpha 2025-06-03 13:37:26 -07:00
dexhorthy
619ea0f41b update changelog 2025-06-03 13:35:44 -07:00
dexhorthy
e4fd91e504 release: v0.7.8 2025-05-29 08:54:45 -07:00
Allison Durham
6ed9301b5a approvals mcp 2025-05-27 10:57:10 -07:00
dexhorthy
9efdf97e51 Add login command and Go binary integration to hlyr CLI
- Bump version to 0.4.0 to reflect new major features
- Add login command with browser integration and token management
- Integrate Go TUI binary into npm build process and distribution
- Add TUI command that spawns the packaged Go binary
- Enhance config system to store API tokens and base URLs
- Create basic Go TUI application structure
2025-05-24 13:05:13 -07:00
dexhorthy
7e8164cfc4 Implement contact human functionality in hlyr CLI
- Add humanlayer dependency and integrate contact human logic from humanlayer-mcp
- Support multiple contact channels (Slack and Email) with comprehensive configuration
- Add CLI flags for all contact channel options (--slack-channel, --email-address, etc.)
- Support HUMANLAYER_* environment variables for configuration
- Add config file support (humanlayer.json in current dir, home dir, or /etc)
- Configuration priority: CLI flags > env vars > config file
- Support stdin input with '-' message flag for piping workflows
- Separate configuration logic into dedicated config.ts module
- Output human responses to stdout, status messages to stderr for pipe compatibility

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-23 13:35:07 -07:00
dexhorthy
8ca3b13e48 wip 2025-05-22 13:12:15 -07:00
dexhorthy
7a7866a674 makefile 2025-04-14 16:16:36 -07:00
dexhorthy
3252dc0830 release: bump to next alpha 2025-04-14 16:15:26 -07:00
dexhorthy
7190c7b1c7 release: v0.7.7 2025-04-14 16:13:37 -07:00
dexhorthy
b35b7ab4dd release: bump to next alpha 2025-03-23 11:27:28 -07:00
dexhorthy
3e04f40b1d release: v0.7.6 2025-03-23 11:27:05 -07:00
dexhorthy
6c890d716c add thread ts and models to ts 2025-03-21 12:19:00 -07:00
Timothy102
4f019fb2a7 Bringing Makefile back after accidental deletion 2025-03-21 13:26:22 +01:00
Timothy102
5659383a6f dropping makefile 2025-03-20 18:17:28 +01:00
Timothy102
914cddf2f3 example does not exist -> start 2025-03-20 10:04:21 +01:00
Timothy102
28236239ce Adding basic research langgraph example - equivalent to examples/langgraph python 2025-03-19 17:56:47 +01:00
dexhorthy
f39bc68962 remove comments 2025-02-24 09:27:26 -08:00
dexhorthy
2e3abd9caa release: v0.7.5 2025-02-24 09:26:22 -08:00
dexhorthy
2a8c84dae3 rc testing done 2025-01-21 19:39:19 -08:00
dexhorthy
c5bf664103 changes locked 2025-01-21 16:04:11 -08:00
Dex
9ea4c5588e Merge branch 'main' into langchain-updates 2025-01-20 09:46:05 -08:00
dexhorthy
06486b1cdf thanks codebuff 2025-01-19 18:17:50 -08:00