Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
84b28f1
fix: tmux parsing/targeting + review feedback
leeroybrun Jan 12, 2026
f60c222
fix(daemon): do not apply CLI active profile to GUI-spawned sessions
leeroybrun Jan 13, 2026
2974e88
feat(session): persist profileId in session metadata via daemon spawn
leeroybrun Jan 13, 2026
674768e
fix(pr107): harden daemon spawn + align profile schema
leeroybrun Jan 13, 2026
fc13267
fix(security): redact spawn secrets from daemon logs
leeroybrun Jan 13, 2026
e25add6
fix(socket): restore offline buffering for sends
leeroybrun Jan 15, 2026
4bee9b4
fix(logging): gate debug output and redact templates
leeroybrun Jan 15, 2026
2aecbe2
fix(pr107): redact profile secrets in doctor + align tmux tmpDir
leeroybrun Jan 13, 2026
ab03468
refactor(profiles): remove unwired startup script and local env cache
leeroybrun Jan 13, 2026
bbb786b
refactor(profiles): drop provider config objects
leeroybrun Jan 15, 2026
b64a1b8
feat(runtime): support bun for daemon-spawned subprocesses
leeroybrun Jan 15, 2026
8ba83aa
refactor(rpc): accept arbitrary env var maps for spawn
leeroybrun Jan 15, 2026
6acd6a3
fix(env): implement default assignment semantics
leeroybrun Jan 17, 2026
8e3d564
feat(rpc): add preview-env handler
leeroybrun Jan 17, 2026
7d7b5de
fix(codex): harden MCP command detection
leeroybrun Jan 15, 2026
cf7f72f
refactor(offline): make offline session stub safer
leeroybrun Jan 15, 2026
e260466
feat(tmux): support per-instance socket path
leeroybrun Jan 15, 2026
1808c62
fix(tmux): correct env, tmpdir, and session selection
leeroybrun Jan 15, 2026
0ff0b37
test(claude): align sessionScanner path mapping
leeroybrun Jan 15, 2026
f4ab056
feat(rpc): add detect-cli handler
leeroybrun Jan 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions bin/happy-dev.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import { homedir } from 'os';
const hasNoWarnings = process.execArgv.includes('--no-warnings');
const hasNoDeprecation = process.execArgv.includes('--no-deprecation');

// Set development environment variables
process.env.HAPPY_HOME_DIR = join(homedir(), '.happy-dev');
process.env.HAPPY_VARIANT = 'dev';

if (!hasNoWarnings || !hasNoDeprecation) {
// Re-execute with the flags
const __filename = fileURLToPath(import.meta.url);
const scriptPath = join(dirname(__filename), '../dist/index.mjs');

// Set development environment variables
process.env.HAPPY_HOME_DIR = join(homedir(), '.happy-dev');
process.env.HAPPY_VARIANT = 'dev';

try {
execFileSync(
process.execPath,
Expand All @@ -33,9 +33,5 @@ if (!hasNoWarnings || !hasNoDeprecation) {
}
} else {
// Already have the flags, import normally
// Set development environment variables
process.env.HAPPY_HOME_DIR = join(homedir(), '.happy-dev');
process.env.HAPPY_VARIANT = 'dev';

await import('../dist/index.mjs');
}
1 change: 0 additions & 1 deletion docs/bug-fix-plan-2025-01-15-athundt.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ describe('claudeLocal --continue handling', () => {
addListener: vi.fn(),
removeListener: vi.fn(),
kill: vi.fn(),
on: vi.fn(),
stdout: { on: vi.fn() },
stderr: { on: vi.fn() },
stdin: { on: vi.fn(), end: vi.fn() }
Expand Down
42 changes: 23 additions & 19 deletions scripts/__tests__/ripgrep_launcher.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { describe, it, expect, vi, beforeEach } from 'vitest';

function readLauncherFile(): string {
return readFileSync(join(__dirname, '../ripgrep_launcher.cjs'), 'utf8');
}

describe('Ripgrep Launcher Runtime Compatibility', () => {
beforeEach(() => {
vi.clearAllMocks();
Expand All @@ -8,9 +14,7 @@ describe('Ripgrep Launcher Runtime Compatibility', () => {
it('has correct file structure', () => {
// Test that the launcher file has the correct structure
expect(() => {
const fs = require('fs');
const path = require('path');
const content = fs.readFileSync(path.join(__dirname, '../ripgrep_launcher.cjs'), 'utf8');
const content = readLauncherFile();

// Check for required elements
expect(content).toContain('#!/usr/bin/env node');
Expand All @@ -22,9 +26,7 @@ describe('Ripgrep Launcher Runtime Compatibility', () => {
it('handles --version argument gracefully', () => {
// Test that --version handling logic exists
expect(() => {
const fs = require('fs');
const path = require('path');
const content = fs.readFileSync(path.join(__dirname, '../ripgrep_launcher.cjs'), 'utf8');
const content = readLauncherFile();

// Check that --version handling is present
expect(content).toContain('--version');
Expand All @@ -35,9 +37,7 @@ describe('Ripgrep Launcher Runtime Compatibility', () => {
it('detects runtime correctly', () => {
// Test runtime detection function exists
expect(() => {
const fs = require('fs');
const path = require('path');
const content = fs.readFileSync(path.join(__dirname, '../ripgrep_launcher.cjs'), 'utf8');
const content = readLauncherFile();

// Check that runtime detection logic is present
expect(content).toContain('detectRuntime');
Expand All @@ -50,9 +50,7 @@ describe('Ripgrep Launcher Runtime Compatibility', () => {
it('contains fallback chain logic', () => {
// Test that fallback logic is present
expect(() => {
const fs = require('fs');
const path = require('path');
const content = fs.readFileSync(path.join(__dirname, '../ripgrep_launcher.cjs'), 'utf8');
const content = readLauncherFile();

// Check that fallback chain is present
expect(content).toContain('loadRipgrepNative');
Expand All @@ -65,9 +63,7 @@ describe('Ripgrep Launcher Runtime Compatibility', () => {
it('contains cross-platform logic', () => {
// Test that cross-platform logic is present
expect(() => {
const fs = require('fs');
const path = require('path');
const content = fs.readFileSync(path.join(__dirname, '../ripgrep_launcher.cjs'), 'utf8');
const content = readLauncherFile();

// Check for platform-specific logic
expect(content).toContain('process.platform');
Expand All @@ -81,14 +77,22 @@ describe('Ripgrep Launcher Runtime Compatibility', () => {
it('provides helpful error messages', () => {
// Test that helpful error messages are present
expect(() => {
const fs = require('fs');
const path = require('path');
const content = fs.readFileSync(path.join(__dirname, '../ripgrep_launcher.cjs'), 'utf8');
const content = readLauncherFile();

// Check for helpful messages
expect(content).toContain('brew install ripgrep');
expect(content).toContain('winget install BurntSushi.ripgrep');
expect(content).toContain('Search functionality unavailable');
expect(content).toContain('Missing arguments: expected JSON-encoded argv');
}).not.toThrow();
});

it('does not treat signal termination as success', () => {
expect(() => {
const content = readLauncherFile();

expect(content).not.toContain('result.status || 0');
expect(content).toContain('result.signal');
}).not.toThrow();
});
});
});
4 changes: 3 additions & 1 deletion scripts/claude_version_utils.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ function detectSourceFromPath(resolvedPath) {
// Windows-specific detection (detect by path patterns, not current platform)
if (normalizedPath.includes('appdata') || normalizedPath.includes('program files') || normalizedPath.endsWith('.exe')) {
// Windows npm
if (normalizedPath.includes('appdata') && normalizedPath.includes('npm') && normalizedPath.includes('node_modules')) {
if (normalizedPath.includes('appdata') && normalizedPath.includes('npm') && normalizedPath.includes('node_modules') &&
normalizedPath.includes('@anthropic-ai') && normalizedPath.includes('claude-code') &&
!normalizedPath.includes('.claude-code-')) {
return 'npm';
}

Expand Down
4 changes: 2 additions & 2 deletions scripts/claude_version_utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ describe('Claude Version Utils - Cross-Platform Detection', () => {
expect(result).toBe('npm');
});

it('should detect npm with different scoped packages', () => {
it('should not classify unrelated scoped npm packages as npm', () => {
const result = detectSourceFromPath('C:/Users/test/AppData/Roaming/npm/node_modules/@babel/core/cli.js');
expect(result).toBe('npm');
expect(result).toBe('PATH');
});

it('should detect npm through Homebrew', () => {
Expand Down
9 changes: 9 additions & 0 deletions scripts/env-wrapper.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ if (!variant || !VARIANTS[variant]) {
process.exit(1);
}

if (!command) {
console.error('Usage: node scripts/env-wrapper.js <stable|dev> <command> [...args]');
console.error('');
console.error('Examples:');
console.error(' node scripts/env-wrapper.js stable daemon start');
console.error(' node scripts/env-wrapper.js dev auth login');
process.exit(1);
}

const config = VARIANTS[variant];

// Create home directory if it doesn't exist
Expand Down
13 changes: 10 additions & 3 deletions scripts/ripgrep_launcher.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function findSystemRipgrep() {
try {
const result = execFileSync(cmd, args, {
encoding: 'utf8',
stdio: 'ignore'
stdio: ['ignore', 'pipe', 'ignore']
});

if (result) {
Expand Down Expand Up @@ -93,7 +93,9 @@ function createRipgrepWrapper(binaryPath) {
stdio: 'inherit',
cwd: process.cwd()
});
return result.status || 0;
if (typeof result.status === 'number') return result.status;
if (result.signal) return 1;
return 0;
}
};
}
Expand Down Expand Up @@ -170,6 +172,11 @@ const args = process.argv.slice(2);
// Parse the JSON-encoded arguments
let parsedArgs;
try {
if (!args[0]) {
console.error('Missing arguments: expected JSON-encoded argv as the first parameter.');
console.error('Example: node scripts/ripgrep_launcher.cjs \'["--version"]\'');
process.exit(1);
}
parsedArgs = JSON.parse(args[0]);
} catch (error) {
console.error('Failed to parse arguments:', error.message);
Expand All @@ -183,4 +190,4 @@ try {
} catch (error) {
console.error('Ripgrep error:', error.message);
process.exit(1);
}
}
7 changes: 6 additions & 1 deletion scripts/test-continue-fix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ echo
echo "2. Testing session finder with current directory..."
node -e "
const { resolve, join } = require('path');
const { readdirSync, statSync, readFileSync } = require('fs');
const { readdirSync, statSync, readFileSync, existsSync } = require('fs');
const { homedir } = require('os');

const workingDirectory = process.cwd();
const projectId = resolve(workingDirectory).replace(/[\\\\\\/\.:]/g, '-');
const claudeConfigDir = process.env.CLAUDE_CONFIG_DIR || join(homedir(), '.claude');
const projectDir = join(claudeConfigDir, 'projects', projectId);

if (!existsSync(projectDir)) {
console.log('ERROR: Project directory does not exist:', projectDir);
process.exit(1);
}

const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\$/i;

const files = readdirSync(projectDir)
Expand Down
108 changes: 59 additions & 49 deletions src/api/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,64 +176,74 @@ describe('Api server error handling', () => {
connectionState.reset();
const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});

// Mock axios to return 500 error
mockPost.mockRejectedValue({
response: { status: 500 },
isAxiosError: true
});

const result = await api.getOrCreateSession({
tag: 'test-tag',
metadata: testMetadata,
state: null
});

expect(result).toBeNull();
expect(consoleSpy).toHaveBeenCalledWith(
expect.stringContaining('⚠️ Happy server unreachable')
);
consoleSpy.mockRestore();
try {
// Mock axios to return 500 error
mockPost.mockRejectedValue({
response: { status: 500 },
isAxiosError: true
});

const result = await api.getOrCreateSession({
tag: 'test-tag',
metadata: testMetadata,
state: null
});

expect(result).toBeNull();
expect(consoleSpy).toHaveBeenCalledWith(
expect.stringContaining('⚠️ Happy server unreachable')
);
} finally {
consoleSpy.mockRestore();
}
});

it('should return null when server returns 503 Service Unavailable', async () => {
connectionState.reset();
const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});

// Mock axios to return 503 error
mockPost.mockRejectedValue({
response: { status: 503 },
isAxiosError: true
});

const result = await api.getOrCreateSession({
tag: 'test-tag',
metadata: testMetadata,
state: null
});

expect(result).toBeNull();
expect(consoleSpy).toHaveBeenCalledWith(
expect.stringContaining('⚠️ Happy server unreachable')
);
consoleSpy.mockRestore();
try {
// Mock axios to return 503 error
mockPost.mockRejectedValue({
response: { status: 503 },
isAxiosError: true
});

const result = await api.getOrCreateSession({
tag: 'test-tag',
metadata: testMetadata,
state: null
});

expect(result).toBeNull();
expect(consoleSpy).toHaveBeenCalledWith(
expect.stringContaining('⚠️ Happy server unreachable')
);
} finally {
consoleSpy.mockRestore();
}
});

it('should re-throw non-connection errors', async () => {
// Mock axios to throw a different type of error (e.g., authentication error)
const authError = new Error('Invalid API key');
(authError as any).code = 'UNAUTHORIZED';
mockPost.mockRejectedValue(authError);

await expect(
api.getOrCreateSession({ tag: 'test-tag', metadata: testMetadata, state: null })
).rejects.toThrow('Failed to get or create session: Invalid API key');

// Should not show the offline mode message
const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
expect(consoleSpy).not.toHaveBeenCalledWith(
expect.stringContaining('⚠️ Happy server unreachable')
);
consoleSpy.mockRestore();

try {
// Mock axios to throw a different type of error (e.g., authentication error)
const authError = new Error('Invalid API key');
(authError as any).code = 'UNAUTHORIZED';
mockPost.mockRejectedValue(authError);

await expect(
api.getOrCreateSession({ tag: 'test-tag', metadata: testMetadata, state: null })
).rejects.toThrow('Failed to get or create session: Invalid API key');

// Should not show the offline mode message
expect(consoleSpy).not.toHaveBeenCalledWith(
expect.stringContaining('⚠️ Happy server unreachable')
);
} finally {
consoleSpy.mockRestore();
}
});
});

Expand Down Expand Up @@ -310,4 +320,4 @@ describe('Api server error handling', () => {
consoleSpy.mockRestore();
});
});
});
});
Loading