Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

This file provides guidance to Claude Code when working with this repository.

Auto Claude is an autonomous multi-agent coding framework that plans, builds, and validates software for you. It's a monorepo with a Python backend (CLI + agent logic) and an Electron/React frontend (desktop UI).
Aperant (formerly Auto Claude) is an autonomous multi-agent coding framework that plans, builds, and validates software for you. It's a monorepo with a Python backend (CLI + agent logic) and an Electron/React frontend (desktop UI).

> **Deep-dive reference:** [ARCHITECTURE.md](shared_docs/ARCHITECTURE.md) | **Frontend contributing:** [apps/frontend/CONTRIBUTING.md](apps/frontend/CONTRIBUTING.md)

## Product Overview

Auto Claude is a desktop application (+ CLI) where users describe a goal and AI agents autonomously handle planning, implementation, and QA validation. All work happens in isolated git worktrees so the main branch stays safe.
Aperant is a desktop application (+ CLI) where users describe a goal and AI agents autonomously handle planning, implementation, and QA validation. All work happens in isolated git worktrees so the main branch stays safe.

**Core workflow:** User creates a task → Spec creation pipeline assesses complexity and writes a specification → Planner agent breaks it into subtasks → Coder agent implements (can spawn parallel subagents) → QA reviewer validates → QA fixer resolves issues → User reviews and merges.

Expand All @@ -25,7 +25,7 @@ Auto Claude is a desktop application (+ CLI) where users describe a goal and AI
- **Memory System** — Graphiti-based knowledge graph retains insights across sessions
- **Isolated Workspaces** — Git worktree isolation for every build; AI-powered semantic merge
- **Flexible Authentication** — Use a Claude Code subscription (OAuth) or API profiles with any Anthropic-compatible endpoint (e.g., Anthropic API, z.ai for GLM models)
- **Multi-Account Swapping** — Register multiple Claude accounts; when one hits a rate limit, Auto Claude automatically switches to an available account
- **Multi-Account Swapping** — Register multiple Claude accounts; when one hits a rate limit, Aperant automatically switches to an available account
- **Cross-Platform** — Native desktop app for Windows, macOS, and Linux with auto-updates

## Critical Rules
Expand Down
18 changes: 6 additions & 12 deletions apps/frontend/src/main/terminal/claude-integration-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,17 +540,16 @@ export function handleOAuthToken(

console.warn('[ClaudeIntegration] Profile credentials verified via Keychain (not caching token):', profileId);

// Set flag to watch for Claude's ready state (onboarding complete)
terminal.awaitingOnboardingComplete = true;

// needsOnboarding: true tells the UI to show "complete setup" message
// instead of "success" - user should finish Claude's onboarding before closing
// Credentials verified - close the auth terminal immediately.
// claude /login exits after OAuth completes and does not continue as an interactive
// session, so the welcome screen never appears and waiting for it would leave the
// window open forever.
safeSendToRenderer(getWindow, IPC_CHANNELS.TERMINAL_OAUTH_TOKEN, {
terminalId: terminal.id,
profileId,
email: emailFromOutput || keychainCreds.email || profile?.email,
success: true,
needsOnboarding: true,
needsOnboarding: false,
detectedAt: new Date().toISOString()
} as OAuthTokenEvent);
Comment on lines +543 to 554
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for where awaitingOnboardingComplete is set to true
echo "=== Searching for awaitingOnboardingComplete assignments ==="
rg -n 'awaitingOnboardingComplete\s*=' --type=ts

echo ""
echo "=== Searching for references to handleOnboardingComplete ==="
rg -n 'handleOnboardingComplete|onOnboardingComplete' --type=ts -C2

Repository: AndyMik90/Aperant

Length of output: 2515


🏁 Script executed:

#!/bin/bash
# Read the handleOnboardingComplete function to see what's at line 704
echo "=== Reading handleOnboardingComplete function (lines 698-750) ==="
sed -n '698,750p' apps/frontend/src/main/terminal/claude-integration-handler.ts

echo ""
echo "=== Searching for where onOnboardingComplete is triggered ==="
rg -n 'onOnboardingComplete|ONBOARDING_COMPLETE' --type=ts --type=tsx -C3

echo ""
echo "=== Checking if needsOnboarding affects event triggering ==="
rg -n 'needsOnboarding' --type=ts --type=tsx -C2

Repository: AndyMik90/Aperant

Length of output: 2534


🏁 Script executed:

#!/bin/bash
# Search for awaitingOnboardingComplete initialization or being set to true
echo "=== Searching for awaitingOnboardingComplete initialization ==="
rg -n 'awaitingOnboardingComplete' apps/frontend/src/main/terminal/ -A1 -B1

echo ""
echo "=== Checking terminal type definition ==="
rg -n 'awaitingOnboardingComplete' apps/frontend/src/main/terminal/types.ts -A2 -B2

echo ""
echo "=== Searching for where it should be set to true ==="
rg -n 'needsOnboarding.*true' apps/frontend/src/main/terminal/ -B3 -A3

Repository: AndyMik90/Aperant

Length of output: 1431


🏁 Script executed:

#!/bin/bash
# Search handleOAuthToken to see what it does
echo "=== Reading handleOAuthToken function ==="
rg -n 'export function handleOAuthToken' apps/frontend/src/main/terminal/claude-integration-handler.ts -A50 | head -70

echo ""
echo "=== Look for any assignment of awaitingOnboardingComplete to true ==="
rg -n 'awaitingOnboardingComplete\s*=\s*true' apps/frontend/src/

echo ""
echo "=== Check what happens with needsOnboarding in the original logic ==="
rg -n 'needsOnboarding' apps/frontend/src/main/terminal/claude-integration-handler.ts -B3 -A3

Repository: AndyMik90/Aperant

Length of output: 3318


🏁 Script executed:

#!/bin/bash
# Search for where terminals are created and how they might set flags
echo "=== Search for terminal creation and initialization ==="
rg -n 'createTerminal|new TerminalProcess' apps/frontend/src/main/terminal/ -B2 -A5

echo ""
echo "=== Check if there are regular Claude terminals (non-auth) ==="
rg -n 'claude-session|createClaudeTerminal' apps/frontend/src/main/terminal/ -B3 -A3

echo ""
echo "=== Search for where handleOnboardingComplete might be triggered for non-auth terminals ==="
rg -n 'isOnboardingCompleteOutput|ONBOARDING_COMPLETE' apps/frontend/src/main/

Repository: AndyMik90/Aperant

Length of output: 3685


🏁 Script executed:

#!/bin/bash
# Understand the broader context - what terminal types exist?
echo "=== Search for terminal type constants/enums ==="
rg -n 'TerminalType|AUTH|CLAUDE' apps/frontend/src/main/terminal/types.ts -B2 -A2

echo ""
echo "=== Check terminal-event-handler to see all terminal event paths ==="
sed -n '1,60p' apps/frontend/src/main/terminal/terminal-event-handler.ts

echo ""
echo "=== Look at the full flow - when is onOnboardingComplete callback invoked? ==="
sed -n '40,60p' apps/frontend/src/main/terminal/terminal-event-handler.ts

Repository: AndyMik90/Aperant

Length of output: 2887


Add a comment to handleOnboardingComplete clarifying its scope for auth terminals.

The guard at line 704 (if (!terminal.awaitingOnboardingComplete) { return; }) means handleOnboardingComplete is effectively dead code for OAuth login terminals since awaitingOnboardingComplete is never set to true for them. This is intentional—as the comment at lines 543-546 explains, claude /login exits immediately after OAuth completes without showing an onboarding screen, so skipping the onboarding handler is correct.

For future maintainers, consider adding a comment in handleOnboardingComplete (around the guard) noting that it only activates when awaitingOnboardingComplete is true, which currently applies only to non-auth terminal flows, to clarify the scope and prevent confusion about why the function appears unreachable for auth terminals.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/frontend/src/main/terminal/claude-integration-handler.ts` around lines
543 - 554, Add a clarifying comment inside handleOnboardingComplete immediately
above the guard that checks terminal.awaitingOnboardingComplete explaining that
this handler is only used for terminals that explicitly set
awaitingOnboardingComplete (i.e., non-auth flows) and will never run for
OAuth/login terminals because those close immediately after OAuth completes;
reference the guard (terminal.awaitingOnboardingComplete) and the OAuth flow
behavior described in the earlier safeSendToRenderer block to make the intent
clear for future maintainers.

} else {
Expand All @@ -561,17 +560,12 @@ export function handleOAuthToken(
if (hasCredentials) {
console.warn('[ClaudeIntegration] Profile credentials verified (no Keychain token):', profileId);

// Set flag to watch for Claude's ready state (onboarding complete)
terminal.awaitingOnboardingComplete = true;

// needsOnboarding: true tells the UI to show "complete setup" message
// instead of "success" - user should finish Claude's onboarding before closing
safeSendToRenderer(getWindow, IPC_CHANNELS.TERMINAL_OAUTH_TOKEN, {
terminalId: terminal.id,
profileId,
email: emailFromOutput || profile?.email,
success: true,
needsOnboarding: true,
needsOnboarding: false,
detectedAt: new Date().toISOString()
} as OAuthTokenEvent);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ export function AuthTerminal({
debugLog('Setting status to success (no onboarding needed)', { terminalId });
setStatus('success');
onAuthSuccess?.(info.email);
// Auto-close after a brief delay to show success UI
successTimeoutRef.current = setTimeout(() => {
if (isCreatedRef.current) {
window.electronAPI.destroyTerminal(terminalId).catch(console.error);
isCreatedRef.current = false;
}
onClose();
}, 1500);
Comment on lines +255 to +262
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This auto-close logic is duplicated. A similar block exists in the onTerminalOnboardingComplete handler (lines 325-331). To avoid duplication and improve maintainability, you could extract this logic into a helper function. Also, the timeout duration 1500 is a magic number and could be defined as a constant.

For example, you could define these within the component:

const SUCCESS_CLOSE_DELAY_MS = 1500;

const scheduleCloseOnSuccess = useCallback(() => {
  // Auto-close after a brief delay to show success UI
  successTimeoutRef.current = setTimeout(() => {
    if (isCreatedRef.current) {
      window.electronAPI.destroyTerminal(terminalId).catch(console.error);
      isCreatedRef.current = false;
    }
    onClose();
  }, SUCCESS_CLOSE_DELAY_MS);
}, [terminalId, onClose]);

Then, you can call scheduleCloseOnSuccess() here and in the other location.

Suggested change
// Auto-close after a brief delay to show success UI
successTimeoutRef.current = setTimeout(() => {
if (isCreatedRef.current) {
window.electronAPI.destroyTerminal(terminalId).catch(console.error);
isCreatedRef.current = false;
}
onClose();
}, 1500);
scheduleCloseOnSuccess();

}
} else {
debugLog('OAuth failed', { terminalId, message: info.message });
Expand Down
Loading