1135 Commits

Author SHA1 Message Date
dexhorthy
c0b0335da2 feat(mcp): Connect MCP server to approval manager with tool_use_id (Phase 4)
- Add CreateApprovalWithToolUseID method to approval manager
- Extract session ID from X-Session-ID header in MCP requests
- Handle auto-approval for dangerously_skip_permissions flag
- Fix approval creation to include comment field in SQLite store
- Wire up MCP server with approval manager in daemon HTTP server
2025-08-13 19:51:55 -07:00
samdickson22
69e00845e1 fix: uncomment debug function and logger import per review feedback
- Kept debugLogSnapshotFailure function and logger import uncommented
- Function invocation remains commented in catch block
- Added proper ESLint and TypeScript ignore comments for unused function
- Cleaner approach that keeps debug code readily available
2025-08-13 19:51:34 -07:00
samdickson22
7b276d050e fix: handle permission_denials as objects instead of strings in claudecode-go
The Claude API returns permission_denials as an array of objects with
tool_name, tool_use_id, and tool_input fields, but the SDK expected
a simple string array. This type mismatch caused JSON unmarshaling
failures that incorrectly marked successful sessions as FAILED.

- Add PermissionDenial struct and PermissionDenials wrapper type
- Implement custom UnmarshalJSON to handle both object and string formats
- Update StreamEvent and Result structs to use the new type
- Add missing PermissionDenials field copy in Result builder
- Add comprehensive tests for all permission denial formats

Fixes sessions being incorrectly marked as FAILED when they contain
permission denials but complete successfully (e.g., session C5E8CF80
which created PR #430 successfully but showed as failed).
2025-08-13 19:28:57 -07:00
samdickson22
55a20dd783 fix: comment out debug function to pass linting and type checks
- Commented out entire debug function as block comment
- Logger import also commented to avoid unused import
- Clean approach that preserves debug code for future use
- All checks now pass (lint, typecheck, format)
2025-08-13 19:28:25 -07:00
samdickson22
d53a31ad61 style: apply prettier formatting to CustomDiffViewer 2025-08-13 19:24:42 -07:00
samdickson22
98c8ea8137 refactor: extract debug logging to separate function for cleaner code
- Created debugLogSnapshotFailure helper function with original logging logic
- Commented out just the function invocation instead of entire code block
- Kept logger import active for potential future use
- Cleaner approach that preserves debug capability without code clutter
2025-08-13 19:24:09 -07:00
Sam Dickson
465c6b40a6 Merge pull request #434 from samdickson22/sam/eng-1942-notification-say-dangerous-skip-permissions-expired-not
sam/eng-1942 - fix: update bypass permissions expiry notification text to use 'bypass permissions' terminology
2025-08-13 18:51:14 -07:00
samdickson22
cf0615151d fix: update expiry notification text to use "bypass permissions" terminology
Changed notification messages from "Dangerous skip permissions expired" to
"Bypass permissions expired" for consistency with user-facing terminology
2025-08-13 18:44:27 -07:00
samdickson22
3334281ab6 fix: remove unused catch parameter to pass linting 2025-08-13 18:44:19 -07:00
samdickson22
d4f8d73d16 fix: remove unused logger import and error variable to pass linting 2025-08-13 18:43:40 -07:00
samdickson22
13d4fb4e7f fix: suppress noisy snapshot-based diff rendering console warning 2025-08-13 18:40:36 -07:00
dexhorthy
22ca015d2a feat(ui): enhance command palette with conditional display logic
- Hide 'Brainrot Mode' until user types 'brain' in search
- Show context-aware 'Archive'/'Unarchive' label based on session state
- Improves UI clarity and reduces clutter in command palette
2025-08-13 18:33:19 -07:00
dexhorthy
6fd1f14c08 feat(mcp): Implement full MCP server with mark3labs library (Phase 3)
Replace stub MCP handler with full implementation using mark3labs/mcp-go v0.37.0
library. The new server provides complete MCP protocol support with proper
JSON-RPC handling, tool schema generation with annotations, and session ID
extraction from headers.

Key changes:
- Add mark3labs/mcp-go dependency for MCP protocol implementation
- Create MCPServer with request_approval tool and auto-deny mode
- Update daemon to use new MCP server instead of stub
- Add proper context key type to satisfy linter requirements
- Extract session IDs from X-Session-ID and Mcp-Session-Id headers
- Add comprehensive integration tests for schema validation and edge cases

The server is configured as stateless for Phase 3, with approval manager
integration coming in Phase 4. Auto-deny mode (MCP_AUTO_DENY_ALL=true)
enables predictable testing without requiring approval infrastructure.

Tested with curl commands and integration test suite (40 tests passing).
2025-08-13 18:32:20 -07:00
dexhorthy
b90b65c7a6 fix(store): Update migration test name and defer pattern
- Rename TestMigration12_ToolUseID to TestMigration14_ToolUseID to match actual migration number
- Fix defer Close() to ignore error per linter recommendation
2025-08-13 18:28:21 -07:00
dexhorthy
a59fc3a28a Merge branch 'main' of github.com:humanlayer/humanlayer into brainrot-mode 2025-08-13 17:40:46 -07:00
dexhorthy
421540a7eb improvements 2025-08-13 17:40:40 -07:00
dexhorthy
4cb993758b update generated models...? 2025-08-13 17:39:04 -07:00
dexhorthy
38f240c369 merge from upstream 2025-08-13 17:21:24 -07:00
dexhorthy
e55b06fb37 wip 2025-08-13 17:14:52 -07:00
dexhorthy
10b5966eee feat(store): Add tool_use_id column to approvals table (Phase 2)
Extend the approvals table to store tool_use_id for direct correlation between
tool calls and approvals. This eliminates the race condition issue when matching
approvals to tool executions.

Changes:
- Add tool_use_id column to approvals table schema
- Add migration 12 to update existing databases
- Create index for efficient tool_use_id lookups
- Update CreateApproval and GetApproval methods to handle tool_use_id
- Populate tool_use_id for existing approvals from conversation_events

The tool_use_id provides a direct 1:1 mapping between Claude's tool calls
and approval requests, removing the need for indirect correlation via
session_id + tool_name matching.
2025-08-13 17:13:24 -07:00
dexhorthy
6e06d53eab feat(mcp): Mount MCP HTTP endpoint with minimal stub (Phase 1)
Add a minimal HTTP endpoint at /api/v1/mcp that implements basic MCP protocol support.
This phase creates the foundation for migrating from stdio-based MCP to HTTP-based
communication directly with the daemon.

Changes:
- Create minimal MCP stub handler that responds to initialize and tools/list
- Mount endpoint at /api/v1/mcp in daemon HTTP server
- Add integration tests to verify endpoint functionality
- Support auto-deny mode via MCP_AUTO_DENY_ALL env var for testing

The stub handler provides a working MCP endpoint that can be verified with
MCP Inspector while we build out the full implementation in subsequent phases.
2025-08-13 16:57:17 -07:00
samdickson22
550938beb9 fix: formatting in generated SDK file 2025-08-13 16:56:38 -07:00
samdickson22
e156de19a7 feat: add optional title field for sessions
- Add title field to CreateSession API endpoint
- Update SDK and client libraries to support title parameter
- Add title input to UI session launcher
- Add --title flag to CLI launch command
- Store and display custom titles instead of using query as title
2025-08-13 16:50:31 -07:00
samdickson22
933743f063 fix: enable resuming failed sessions with proper message delivery
- Fix claudecode-go to pass query as positional argument with --print flag
- Allow failed sessions with claude_session_id to be resumed in backend
- Add debug logging for failed session resumption attempts
- Update integration tests to match new behavior allowing failed sessions
- Remove unnecessary session status restrictions in frontend components
2025-08-13 16:49:06 -07:00
Dex
8896053971 Merge pull request #429 from samdickson22/sam/eng-1936-sometimes-the-context-used-shows-as-like-10x-the-actual
Fix token counting for Claude sessions
2025-08-13 17:55:29 -05:00
Dex
ebbe0def6a Merge pull request #430 from samdickson22/sam/eng-1905-active-sessions-show-in-archive-view
sam/ENG-1905 Fix archive view showing active sessions
2025-08-13 17:54:57 -05:00
Dex
ff98bf788c Merge pull request #426 from samdickson22/sam/eng-1745-escape-key-feels-unreliable
sam/ENG-1745- fix: improve escape key handling and prevent modal stacking
2025-08-13 17:34:03 -05:00
samdickson22
90307e05df Merge upstream/main and resolve conflicts
- Keep Shift+R rename session hotkey from upstream
- Remove useStealHotkeyScope call (SessionDetail is base layer)
- Preserve all escape key handling improvements
2025-08-13 15:27:01 -07:00
samdickson22
8f28580c8d fix: forward archivedOnly parameter to SDK in getSessionLeaves
The archivedOnly parameter was not being passed from the HTTP client
adapter to the underlying SDK, causing archive view to show all sessions
instead of just archived ones. This regression was introduced in 436e4a1
when the previous fix from PR #394 was inadvertently reverted.
2025-08-13 15:12:20 -07:00
samdickson22
6e5b82f361 fix: correct token counting for Claude sessions
- Fix session ID extraction from assistant/user messages
- Process token updates even without Claude session ID
- Skip incorrect cumulative token counts from result events
- Update UI to reflect real-time token changes in active session
- Publish token update events to keep UI in sync

The API sends result events with cumulative cache read tokens that incorrectly accumulate across the entire session. This fix only trusts token counts from individual assistant messages which are accurate.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-13 13:55:58 -07:00
Dex
28008b9c79 Merge pull request #424 from samdickson22/sam/eng-1657-show-context-remaining-tokens-used-in-current-context-window
sam/ENG-1657- feat: add token usage tracking and display
20250813-nightly
2025-08-12 18:06:38 -05:00
samdickson22
521bd6a635 fix: add missing ansi-regex dependency for ansiParser 2025-08-12 15:31:32 -07:00
samdickson22
347c1e1162 Merge upstream/main and resolve conflicts
- Kept upstream's migration 12 for model_id column
- Moved token tracking fields to migration 13
- Regenerated server.gen.go from OpenAPI spec
- All GetSession queries already include model_id field
2025-08-12 15:20:21 -07:00
Dex
b529a51e66 Merge pull request #427 from samdickson22/sam/eng-1930-remove-misleading-verbs-like-connecting
sam/eng-1930: removed connecting from list of robot words
2025-08-12 17:11:23 -05:00
Sundeep Malladi
99a8d9f503 Approval Exploration Grabbag (#428)
* Add model_id to stored session fields

* feat(wui): add stacked cards component and demo

Create a reusable StackedCards component inspired by Sonner's toast stacking,
with smooth animations for card dismissal and stack reorganization.

- Add StackedCards component with configurable gap and visible card count
- Implement smooth scale and translate animations for stacking effect
- Create demo page at /demo/stacked_cards with interactive controls
- Cards stack with negative Y offset to show peeking effect

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

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

* feat: Add database info to debug panel with improved layout

- Add REST API endpoint /api/v1/database-info to expose SQLite stats
- Implement GetDatabaseInfo handler with file size, counts, and metadata
- Add helper methods to SQLiteStore for session/approval/event counts
- Update debug panel with wider grid layout (max-w-3xl)
- Display database path, size, table counts, and statistics in organized grid
- Add copy button for database path
- Remove unused RPC implementation in favor of REST endpoint

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

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

* post cherry-pick regen

* Couple additional goodies from 166411c4a6

* mct; includes fix for permission_denials

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-12 15:53:24 -05:00
Dex
91547b597a Merge pull request #425 from dexhorthy/dexter/eng-1897-fix-install-instructions-on-nightly-build-release-notes
Fix nightly release version format
2025-08-12 13:33:54 -07:00
dexhorthy
3bf03df118 update local review to launch 2025-08-12 13:19:08 -05:00
samdickson22
6c0030f3ea removed connecting from list of robot words 2025-08-12 11:07:27 -07:00
samdickson22
5265202787 format 2025-08-12 11:02:31 -07:00
samdickson22
5a628e33f2 fix: improve escape key handling and prevent modal stacking
- Add proper escape key handling to back out of modals and session detail view
- Fix ESC key in bypass permissions dialog to blur input instead of closing modal
- Implement hotkey scope stealing for modals to prevent background hotkey conflicts
- Add SessionDetailHotkeysScope to all session detail hooks for proper scope management
- Prevent modal stacking by checking active scopes before opening modals (alt+y, cmd+y)
- Fix tool result modal scope cleanup to prevent stuck states blocking global hotkeys
- Improve escape key cascade: blur inputs → clear confirmations → unfocus → close view
- Handle escape key properly when fork view and other modals are open
- Clean up debug logging from development
2025-08-12 10:35:29 -07:00
samdickson22
8b34f775f1 fix: correct expected token count in TestResumedSessionTokenCounting
The test was expecting 150500 but the calculation is:
- Input tokens: 500
- Output tokens: 300
- Cache read tokens: 150000
- Total: 150800

This test was not caught earlier because it only runs with -tags=integration
2025-08-11 17:42:45 -07:00
samdickson22
15c191745e format 2025-08-11 17:30:01 -07:00
samdickson22
9e24a633e7 feat: add token usage tracking and display
- Track input, output, cache creation, and cache read tokens in sessions
- Calculate and store effective context tokens (sum of all token types)
- Add context limit management with default of 168k tokens
- Display token usage badge in UI with visual warnings at 60% and 90%
- Update OpenAPI spec and regenerate TypeScript SDK types
- Add database migrations for new token tracking columns
2025-08-11 17:20:49 -07:00
Dex
add13105b1 Merge pull request #423 from samdickson22/sam/eng-1763-render-bash-color-codes
Add ANSI color code rendering for Bash tool outputs
20250812-nightly-test
2025-08-11 15:52:47 -07:00
dexhorthy
44487997b9 Fix nightly release version format
Remove "-test" suffix from nightly version to ensure release notes
correctly show "codelayer-nightly" in installation instructions.

The conditional expression in release notes was already correct,
but the version format included an extra "-test" suffix causing
the condition to match incorrectly.
2025-08-11 17:44:45 -05:00
Dex
306ae3be8e Merge pull request #421 from samdickson22/sam/eng-1913-add-keyboard-shortcut-guidance-below-text-input
fix: use Option symbol (⌥) for consistency with other shortcuts
2025-08-11 15:42:45 -07:00
Dex
d71951c67a Merge pull request #420 from dexhorthy/dexter/eng-1917-change-rename-session-hotkey-from-commandr-to-shiftr
feat: change rename session hotkey from Command+R to Shift+R
2025-08-11 15:39:45 -07:00
samdickson22
f48df11cb8 Add ANSI color code rendering for Bash tool outputs
- Add terminal color palettes for all 14 themes (colors 0-15)
- Create ANSI parser utility to convert escape sequences to styled React components
- Integrate selective ANSI rendering for Bash tool outputs only
- Preserve colors in inline previews using CSS truncation
- Add comprehensive unit tests for ANSI parsing
- Other tools preserve raw ANSI codes for debugging purposes
2025-08-11 15:17:02 -07:00
dexhorthy
b2f137a7e3 feat: add color cycling and per-session persistence to brainrot mode
- Remove glow effect, add color cycling on bounce instead
- Cycles through theme colors: accent, accent-alt, success, error, warning
- Add per-session localStorage persistence (each session remembers its state)
- Ensure proper contrast with background color on all themes
2025-08-10 22:56:04 -04:00
dexhorthy
8b94c73c13 feat: add Brainrot Mode with DVD screensaver animation
Implements a DVD screensaver-style bouncing box that displays the current
tool name from the active Claude session. The feature is accessible via
the command palette (Cmd+K) when viewing a session detail.

- Add DvdScreensaver component with physics-based bouncing animation
- Integrate with command palette, showing option only on session detail
- Add fuzzy search support for command palette options
- Auto-close command palette after selecting brainrot mode
- Ensure DVD box only appears when viewing session details
- Display tool names like "Assistant", "Bash", "Edit", "Thinking"
2025-08-10 22:36:26 -04:00