Skip to content

fix(frontend): support Windows shell commands in Claude CLI invocation (ACS-261)#3

Closed
StillKnotKnown wants to merge 1 commit intodevelopfrom
stillknotknown/acs-261-frontend-or-terminal-claude-cli-invocation-hangs-after-environment-override-check-log-on-windows
Closed

fix(frontend): support Windows shell commands in Claude CLI invocation (ACS-261)#3
StillKnotKnown wants to merge 1 commit intodevelopfrom
stillknotknown/acs-261-frontend-or-terminal-claude-cli-invocation-hangs-after-environment-override-check-log-on-windows

Conversation

@StillKnotKnown
Copy link
Owner

Summary

Fixes hang on Windows after "Environment override check" log by replacing hardcoded bash commands with platform-aware shell syntax.

Problem

On Windows, the terminal would hang indefinitely after logging "Environment override check" because buildClaudeShellCommand() was hardcoded to use bash -c commands that don't exist on Windows.

Solution

  • Windows: Uses cmd.exe/PowerShell compatible syntax:

    • cls instead of clear
    • call to execute .bat temp files
    • set for environment variables
    • del for file cleanup
    • .bat extension for temp files with \r\n line endings
  • Unix/macOS: Preserves existing bash syntax (unchanged):

    • clear, source, export, rm -f
    • Shell temp files with \n line endings

Changes

  • Modified buildClaudeShellCommand() to detect platform and generate appropriate commands
  • Added generateTokenTempFileContent() helper for DRY
  • Added getTempFileExtension() helper for DRY
  • Added error handling with 10s timeout protection in invokeClaudeAsync()
  • Added 7 Windows-specific tests (30 total tests passing)

Test Plan

  • All 30 tests in claude-integration-handler.test.ts passing
  • TypeScript compilation succeeds (0 errors)
  • Production build succeeds
  • ESLint passes (0 errors)
  • Cross-platform paths validated (uses path.join(), os.tmpdir())

Linear Ticket

Resolves ACS-261

…n (ACS-261)

Fixes hang on Windows after "Environment override check" log by replacing
hardcoded bash commands with platform-aware shell syntax.

- Windows: Uses cmd.exe syntax (cls, call, set, del) with .bat temp files
- Unix/macOS: Preserves existing bash syntax (clear, source, export, rm)
- Adds error handling and 10s timeout protection in async invocation
- Extracts helper functions for DRY: generateTokenTempFileContent(),
  getTempFileExtension()
- Adds 7 Windows-specific tests (30 total tests passing)
@StillKnotKnown
Copy link
Owner Author

Superseded by upstream PR: AndyMik90#1152

StillKnotKnown pushed a commit that referenced this pull request Jan 18, 2026
…ik90#1259)

* fix(windows): prevent zombie process accumulation on app close

- Use taskkill /f /t on Windows to properly kill process trees
  (SIGTERM/SIGKILL are ignored on Windows)
- Make killAllProcesses() wait for process exit events with timeout
- Kill PTY daemon process on shutdown
- Clear periodic update check interval on app quit

Fixes process accumulation in Task Manager after closing Auto-Claude.

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

* fix(windows): extract killProcessGracefully utility with timer cleanup

- Extract shared killProcessGracefully() to platform module
- Fix Issue #1: Move taskkill outside try-catch scope
- Fix Issue #2: Track exit state to skip unnecessary taskkill
- Fix Issue #3: Add GRACEFUL_KILL_TIMEOUT_MS constant
- Fix Issue #4: Use consistent 5000ms timeout everywhere
- Fix Issue #5: Add debug logging for catch blocks
- Fix Issue AndyMik90#6: Log warning when process.once unavailable
- Fix Issue AndyMik90#7: Eliminate code duplication across 3 files
- Fix timer leak: Clear timeout on process exit/error, unref timer

Add comprehensive tests (19 test cases) covering:
- Windows taskkill fallback behavior
- Unix SIGTERM/SIGKILL sequence
- Timer cleanup and memory leak prevention
- Edge cases and error handling

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

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Andy <119136210+AndyMik90@users.noreply.github.com>
StillKnotKnown pushed a commit that referenced this pull request Jan 26, 2026
…ndyMik90#1456)

* auto-claude: subtask-1-1 - Add GITHUB_AUTH_CHANGED IPC channel constant

* auto-claude: subtask-1-2 - Add async getGitHubTokenForSubprocess() helper to utils.ts

Add a new exported async function getGitHubTokenForSubprocess() that calls
getTokenFromGhCli() to retrieve fresh GitHub tokens for subprocess use.
This provides a clean interface for runner-env.ts to get tokens without
caching, ensuring account changes are reflected immediately.

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

* auto-claude: subtask-1-3 - Update getRunnerEnv() to include GITHUB_TOKEN

* auto-claude: subtask-2-1 - Add auth change detection and event emission to oauth-handlers.ts

- Add GitHubAuthChangedPayload interface for auth change events
- Add sendAuthChangedToRenderer() to broadcast auth changes to all windows
- Add getCurrentGitHubUsername() helper to get current GitHub user
- Modify registerStartGhAuth() to:
  - Capture username before auth starts
  - Get username after successful auth
  - Emit GITHUB_AUTH_CHANGED event if account changed

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

* auto-claude: subtask-3-1 - Add onGitHubAuthChanged listener to GitHubAPI interface

- Add onGitHubAuthChanged to GitHubAPI interface in github-api.ts
- Add implementation using createIpcListener with IPC_CHANNELS.GITHUB_AUTH_CHANGED
- Add mock implementation in browser-mock.ts for testing

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

* auto-claude: subtask-4-1 - Add GitHub auth change listener to pr-review-store

* fix: Address PR review findings for GitHub auth handlers

- Convert getCurrentGitHubUsername() to async using promisified execFile
  to avoid blocking Electron main thread during auth flow (finding #1)
- Make getGitHubTokenForSubprocess() truly async by introducing async
  getTokenFromGhCliAsync() - the sync version is preserved for
  getGitHubConfig (finding #2)
- Add warning log when username fetch fails after successful auth,
  handling the edge case where auth succeeds but account change
  detection fails (finding #3)
- Remove unused timestamp field from GitHubAuthChangedPayload interface
  since the renderer callback only uses oldUsername/newUsername (finding #4)
- Document the intentional extraEnv override behavior in getRunnerEnv()
  JSDoc comment (finding #5)

All 5 findings from PR review were real issues. These fixes improve code
quality by avoiding main thread blocking and clarifying edge cases.

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

* test: Fix oauth-handlers tests for async getCurrentGitHubUsername

Update test mocks and add waitForAsyncSetup helper to handle the async
changes in getCurrentGitHubUsername(). The function now uses promisified
execFile instead of execFileSync to avoid blocking the main thread.

Key changes:
- Add mockExecFile mock for the promisified execFile function
- Add waitForAsyncSetup helper to wait for async setup before emitting
  process events
- Update all affected tests to use waitForAsyncSetup before emitting
  mock process events

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

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
StillKnotKnown added a commit that referenced this pull request Jan 30, 2026
* Fix GitLab Merged MRs Not Displaying

Fixes AndyMik90#1521

- Added UseGitLabMRsOptions interface with stateFilter parameter
- Updated hook signature to accept optional options parameter
- Removed hardcoded useState for stateFilter
- Defaults to 'opened' for backward compatibility
- Pass stateFilter state to useGitLabMRs hook via options parameter
- Enables proper filtering of MRs by state (opened/merged/closed/all)
- Completes frontend implementation for GitLab MR state filtering

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>

* GitLab Support for Create PR Button (#2)

Title:
  feat: add GitLab support for Create PR button (#2)
  Fixes: AndyMik90#1519

  Body:
  Add automatic git remote detection to route GitLab repositories to the
  `glab` CLI for creating merge requests, while preserving existing GitHub
  functionality.

  ## Changes

  - Add `git_provider.py` for detecting GitHub vs GitLab from remote URLs
    - Supports SSH and HTTPS formats
    - Supports self-hosted GitLab instances (detects "gitlab" in hostname)
  - Add `glab_executable.py` for finding GitLab CLI with platform-specific fallbacks
  - Update `WorktreeManager.push_and_create_pr()` to detect provider and route
    to either `create_pull_request()` (GitHub) or `create_merge_request()` (GitLab)
  - Add `create_merge_request()` method for GitLab MR creation via glab CLI
  - Update error messages to include provider-specific installation instructions

  ## Testing

  - Unit tests for `git_provider.py` detection logic
  - Integration tests for WorktreeManager PR/MR creation
  - Manual E2E tests for GitLab remote repositories
  - Regression tests to ensure GitHub PR creation still works

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

* Add GitLab CLI (glab) Path Configuration to Settings (#3)

feat(frontend): add GitLab CLI (glab) path configuration to Settings

  Add support for configuring the GitLab CLI (glab) path in the Settings
  page, consistent with existing GitHub CLI (gh) path configuration.

  Changes:
  - Add 'glab' to CLITool type union and gitlabCLIPath to ToolConfig
  - Implement detectGitLabCLI() and validateGitLabCLI() with multi-level
    detection (user config, Homebrew, system PATH, Windows Program Files)
  - Implement async variants for non-blocking detection
  - Add gitlabCLIPath to AppSettings interface and DEFAULT_APP_SETTINGS
  - Add glab to getCliToolsInfo IPC handler return type
  - Add gitlabCLIPath to pathFields array and configureTools calls
  - Add English and French translation keys for GitLab CLI path
  - Add GitLab CLI path input field to GeneralSettings component
  - Fix glab version regex to match actual output format ("glab X.Y.Z"
    instead of "glab version X.Y.Z")
  - Add augmented env to all sync CLI validators (Python, Git, gh, glab)
    for consistency with validateClaude and async validators

  Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* Fix GitLab bugs from CodeRabbitAI review comments

Address actionable comments reported by CodeRabbitAI:

- Fix SSH URL parsing in git_provider.py to support ssh:// URLs and
  arbitrary usernames (not just git@)
- Fix Windows glab paths to use correct installation directory
  (glab\glab.exe instead of GitLab CLI\glab.exe)
- Fix regex for GitLab MR URLs to correctly match both /merge_requests/
  and /-/merge_requests/ patterns
- Move inline json import to top-level in worktree.py
- Fix incorrect mock paths in test_worktree_gitlab.py
- Remove unused imports and f-strings without placeholders
- Add WINDOWS_GLAB_PATHS constant to frontend for centralized path management
- Replace fragile monkeypatch with unittest.mock.patch in manual tests

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

* Consolidate GitLab test files and move tests to tests/ directory

- Remove duplicate test_gitlab_pr_manual.py, consolidate into test_gitlab_e2e.py
- Expand provider detection to test 8 URL patterns (GitHub/GitLab variants)
- Add WorktreeManager method signature verification test
- Improve error message test to use unittest.mock.patch
- Move all GitLab test files from apps/backend/core/ to tests/

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

* Convert GitLab E2E tests to pytest-style assertions

Rename test functions to _check_* helpers and create proper test_*
pytest functions with assertions. This fixes PytestReturnNotNoneWarning
warnings and ensures tests actually fail when checks return False.

Fixes: AndyMik90#1544 (comment)

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

* Fix GitHub Enterprise detection in git_provider

Broaden the hostname check in _classify_hostname to also detect
GitHub Enterprise hostnames (e.g., github.company.com) by checking
for "github" substring, matching the pattern already used for GitLab.

Addresses CodeRabbitAI review comment on PR AndyMik90#1544.

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

* Fix CI failures: Ruff formatting and test isolation issues

- Split long regex line in worktree.py for Ruff compliance
- Fix test isolation issue caused by worktree.py importlib shim
- Convert patch() calls to patch.object() pattern in test files
- Add fixtures to test_github_pr_regression.py for consistency

The importlib shim in apps/backend/worktree.py causes module-level
patches to fail when tests run after test_agent_flow.py. Using
patch.object() on the imported module directly resolves this.

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

* Skip glab detection test when glab CLI is not installed

Address CodeRabbit recommendation: add pytest import and guard
test_glab_detection with get_glab_executable() check, using
pytest.skip() when glab is not available on the system.

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

* Disable GPG signing in test git repos to prevent CI hangs

Tests may hang if the runner has global GPG signing enabled.
Explicitly disable commit.gpgsign in create_test_git_repo.

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

* Fix glab CLI path not passed to backend subprocess

The frontend detected glab but never set GITLAB_CLI_PATH env var.
Added 'glab' to CliTool type and CLI_TOOL_ENV_MAP, and call
detectAndSetCliPath('glab') in setupProcessEnvironment.

This ensures GitLab MR creation works when the app is launched
from Finder/Dock and glab is in a non-standard PATH location.

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

* Fix glab CLI flags and JSON field name in _get_existing_mr_url

glab uses --output json (not --json fieldName like gh CLI) and
returns snake_case field names (web_url instead of webUrl).

Verified with actual glab mr view command on lcoffice repo.

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

* Extract shared test fixtures to conftest.py

Move temp_project_dir and worktree_manager fixtures from
test_gitlab_worktree.py and test_github_pr_regression.py
to a shared conftest.py file.

Also adds GPG signing disable to the shared fixture for CI.

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

* Use throwaway variable for unused WorktreeManager instance

Replace `manager` with `_` to indicate the variable is intentionally
unused - the test only verifies the constructor doesn't raise.

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

* Remove unused imports in test_gitlab_worktree.py

Remove pytest and WorktreeManager imports that are not used in the file.
Fixtures are provided by conftest.py which handles the imports.

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

* Address PR review findings: cleanup and improve hostname matching

- Remove unused MergeRequestResult TypedDict (dead code)
- Rename GH_CLI_TIMEOUT/GH_QUERY_TIMEOUT to provider-neutral CLI_TIMEOUT/CLI_QUERY_TIMEOUT
- Improve hostname classification to use precise domain segment matching
  (rejects edge cases like attacker-github.com while still matching github-enterprise.local)
- Add test coverage for GitHub/GitLab hostname detection edge cases

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

* Revert "Extract shared test fixtures to conftest.py"

This reverts commit 22ab666.

* Extract shared test fixtures to conftest.py

- Move temp_project_dir and worktree_manager fixtures to conftest.py
  (shared across GitLab and GitHub test suites)
- Remove duplicate fixtures from test_github_pr_regression.py and
  test_gitlab_worktree.py
- Remove unused subprocess import from test_gitlab_worktree.py

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

* Use consistent shim imports in GitLab/GitHub tests

Switch to shim imports (worktree instead of core.worktree) to match
other test files and avoid module aliasing issues caused by Python's
module caching when tests use different import paths for the same module.

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

* Isolate git environment in temp_project_dir fixture

Pass sanitized environment to subprocess.run calls to prevent git
operations from leaking into parent repos when tests run inside
git worktrees (e.g., during pre-commit hooks).

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

* Fix CodeQL findings in test files

- Remove URL substring check that triggered py/incomplete-url-substring-sanitization
  (redundant - error message check is sufficient)
- Remove unused pytest import in test_gitlab_worktree.py

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

* fix: use pushed remote for provider detection in multi-remote repos

detect_git_provider() now accepts an optional remote_name parameter
so push_and_create_pr() can pass the actual pushed remote instead of
always checking 'origin'. This fixes incorrect PR/MR creation when
repos have multiple remotes pointing to different providers.

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

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: StillKnotKnown <192589389+StillKnotKnown@users.noreply.github.com>
StillKnotKnown pushed a commit that referenced this pull request Feb 6, 2026
…ndyMik90#1724)

* auto-claude: subtask-1-1 - Add ErrorBoundary wrapper around Context component

* auto-claude: subtask-1-2 - Wrap statSync() calls in try-catch in memory-statu

* auto-claude: subtask-1-3 - Wrap statSync() calls in try-catch in memory-data-handlers.ts

* auto-claude: subtask-1-4 - Add safe property access with optional chaining in MemoryCard.tsx

- Add optional chaining to pattern.pattern with fallback to pattern.applies_to
- Add optional chaining to gotcha.gotcha with JSON.stringify fallback
- Prevents crashes when memory data has malformed discoveries structures
- Fixes Root Cause #3: Unsafe Property Access

* auto-claude: subtask-1-5 - Add Promise guard flags in memory-service.ts executeQuery()

* auto-claude: subtask-1-5 - Add Promise guard flags in memory-service.ts executeQuery()

- Store timeoutId to enable cleanup
- Add clearTimeout() in close and error handlers
- Prevents race condition where timeout fires after Promise resolved
- Follows pattern from memory-handlers.ts:262-312

* auto-claude: subtask-1-5 - Add Promise guard flags in memory-service.ts executeQuery()

Fix Promise race condition by reordering timeout setup before event handlers.
Follows pattern from memory-handlers.ts:262-312 with resolved guard flag,
timeout cleanup in close/error handlers, preventing double-resolution crashes.

* fix: apply timeout cleanup pattern to executeSemanticQuery matching executeQuery

Store the setTimeout ID and clear it in both close and error handlers to
prevent timeout resource leaks. Also move resolved flag immediately after
the guard check for consistency with executeQuery.

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

---------

Co-authored-by: Test User <test@example.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
StillKnotKnown pushed a commit that referenced this pull request Feb 6, 2026
…ndyMik90#1747)

* auto-claude: subtask-1-1 - Add errorCode propagation in reactiveTokenRefresh()

* auto-claude: subtask-1-2 - Return null instead of revoked token for permanent errors in ensureValidToken()

* auto-claude: subtask-1-3 - Clear credential cache on invalid_grant error in refreshOAuthToken()

* auto-claude: subtask-1-4 - Clear revoked credentials on persistence failure (Bug #5)

When token refresh succeeds but persistence to keychain fails, the old
credentials in the keychain are now revoked server-side. This commit adds
defensive cache clearing in both ensureValidToken() and reactiveTokenRefresh()
to prevent serving revoked tokens from cache.

On app restart, Bugs #3 and #4 fixes will handle the revoked credentials
properly by returning null and clearing the cache, forcing re-authentication.

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

* auto-claude: subtask-2-1 - Move authFailedProfiles marking before early return

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
StillKnotKnown pushed a commit that referenced this pull request Feb 9, 2026
…ndyMik90#1456)

* auto-claude: subtask-1-1 - Add GITHUB_AUTH_CHANGED IPC channel constant

* auto-claude: subtask-1-2 - Add async getGitHubTokenForSubprocess() helper to utils.ts

Add a new exported async function getGitHubTokenForSubprocess() that calls
getTokenFromGhCli() to retrieve fresh GitHub tokens for subprocess use.
This provides a clean interface for runner-env.ts to get tokens without
caching, ensuring account changes are reflected immediately.

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

* auto-claude: subtask-1-3 - Update getRunnerEnv() to include GITHUB_TOKEN

* auto-claude: subtask-2-1 - Add auth change detection and event emission to oauth-handlers.ts

- Add GitHubAuthChangedPayload interface for auth change events
- Add sendAuthChangedToRenderer() to broadcast auth changes to all windows
- Add getCurrentGitHubUsername() helper to get current GitHub user
- Modify registerStartGhAuth() to:
  - Capture username before auth starts
  - Get username after successful auth
  - Emit GITHUB_AUTH_CHANGED event if account changed

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

* auto-claude: subtask-3-1 - Add onGitHubAuthChanged listener to GitHubAPI interface

- Add onGitHubAuthChanged to GitHubAPI interface in github-api.ts
- Add implementation using createIpcListener with IPC_CHANNELS.GITHUB_AUTH_CHANGED
- Add mock implementation in browser-mock.ts for testing

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

* auto-claude: subtask-4-1 - Add GitHub auth change listener to pr-review-store

* fix: Address PR review findings for GitHub auth handlers

- Convert getCurrentGitHubUsername() to async using promisified execFile
  to avoid blocking Electron main thread during auth flow (finding #1)
- Make getGitHubTokenForSubprocess() truly async by introducing async
  getTokenFromGhCliAsync() - the sync version is preserved for
  getGitHubConfig (finding #2)
- Add warning log when username fetch fails after successful auth,
  handling the edge case where auth succeeds but account change
  detection fails (finding #3)
- Remove unused timestamp field from GitHubAuthChangedPayload interface
  since the renderer callback only uses oldUsername/newUsername (finding #4)
- Document the intentional extraEnv override behavior in getRunnerEnv()
  JSDoc comment (finding #5)

All 5 findings from PR review were real issues. These fixes improve code
quality by avoiding main thread blocking and clarifying edge cases.

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

* test: Fix oauth-handlers tests for async getCurrentGitHubUsername

Update test mocks and add waitForAsyncSetup helper to handle the async
changes in getCurrentGitHubUsername(). The function now uses promisified
execFile instead of execFileSync to avoid blocking the main thread.

Key changes:
- Add mockExecFile mock for the promisified execFile function
- Add waitForAsyncSetup helper to wait for async setup before emitting
  process events
- Update all affected tests to use waitForAsyncSetup before emitting
  mock process events

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

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
StillKnotKnown added a commit that referenced this pull request Feb 9, 2026
* Fix GitLab Merged MRs Not Displaying

Fixes AndyMik90#1521

- Added UseGitLabMRsOptions interface with stateFilter parameter
- Updated hook signature to accept optional options parameter
- Removed hardcoded useState for stateFilter
- Defaults to 'opened' for backward compatibility
- Pass stateFilter state to useGitLabMRs hook via options parameter
- Enables proper filtering of MRs by state (opened/merged/closed/all)
- Completes frontend implementation for GitLab MR state filtering

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>

* GitLab Support for Create PR Button (#2)

Title:
  feat: add GitLab support for Create PR button (#2)
  Fixes: AndyMik90#1519

  Body:
  Add automatic git remote detection to route GitLab repositories to the
  `glab` CLI for creating merge requests, while preserving existing GitHub
  functionality.

  ## Changes

  - Add `git_provider.py` for detecting GitHub vs GitLab from remote URLs
    - Supports SSH and HTTPS formats
    - Supports self-hosted GitLab instances (detects "gitlab" in hostname)
  - Add `glab_executable.py` for finding GitLab CLI with platform-specific fallbacks
  - Update `WorktreeManager.push_and_create_pr()` to detect provider and route
    to either `create_pull_request()` (GitHub) or `create_merge_request()` (GitLab)
  - Add `create_merge_request()` method for GitLab MR creation via glab CLI
  - Update error messages to include provider-specific installation instructions

  ## Testing

  - Unit tests for `git_provider.py` detection logic
  - Integration tests for WorktreeManager PR/MR creation
  - Manual E2E tests for GitLab remote repositories
  - Regression tests to ensure GitHub PR creation still works

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

* Add GitLab CLI (glab) Path Configuration to Settings (#3)

feat(frontend): add GitLab CLI (glab) path configuration to Settings

  Add support for configuring the GitLab CLI (glab) path in the Settings
  page, consistent with existing GitHub CLI (gh) path configuration.

  Changes:
  - Add 'glab' to CLITool type union and gitlabCLIPath to ToolConfig
  - Implement detectGitLabCLI() and validateGitLabCLI() with multi-level
    detection (user config, Homebrew, system PATH, Windows Program Files)
  - Implement async variants for non-blocking detection
  - Add gitlabCLIPath to AppSettings interface and DEFAULT_APP_SETTINGS
  - Add glab to getCliToolsInfo IPC handler return type
  - Add gitlabCLIPath to pathFields array and configureTools calls
  - Add English and French translation keys for GitLab CLI path
  - Add GitLab CLI path input field to GeneralSettings component
  - Fix glab version regex to match actual output format ("glab X.Y.Z"
    instead of "glab version X.Y.Z")
  - Add augmented env to all sync CLI validators (Python, Git, gh, glab)
    for consistency with validateClaude and async validators

  Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* Fix GitLab bugs from CodeRabbitAI review comments

Address actionable comments reported by CodeRabbitAI:

- Fix SSH URL parsing in git_provider.py to support ssh:// URLs and
  arbitrary usernames (not just git@)
- Fix Windows glab paths to use correct installation directory
  (glab\glab.exe instead of GitLab CLI\glab.exe)
- Fix regex for GitLab MR URLs to correctly match both /merge_requests/
  and /-/merge_requests/ patterns
- Move inline json import to top-level in worktree.py
- Fix incorrect mock paths in test_worktree_gitlab.py
- Remove unused imports and f-strings without placeholders
- Add WINDOWS_GLAB_PATHS constant to frontend for centralized path management
- Replace fragile monkeypatch with unittest.mock.patch in manual tests

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

* Consolidate GitLab test files and move tests to tests/ directory

- Remove duplicate test_gitlab_pr_manual.py, consolidate into test_gitlab_e2e.py
- Expand provider detection to test 8 URL patterns (GitHub/GitLab variants)
- Add WorktreeManager method signature verification test
- Improve error message test to use unittest.mock.patch
- Move all GitLab test files from apps/backend/core/ to tests/

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

* Convert GitLab E2E tests to pytest-style assertions

Rename test functions to _check_* helpers and create proper test_*
pytest functions with assertions. This fixes PytestReturnNotNoneWarning
warnings and ensures tests actually fail when checks return False.

Fixes: AndyMik90#1544 (comment)

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

* Fix GitHub Enterprise detection in git_provider

Broaden the hostname check in _classify_hostname to also detect
GitHub Enterprise hostnames (e.g., github.company.com) by checking
for "github" substring, matching the pattern already used for GitLab.

Addresses CodeRabbitAI review comment on PR AndyMik90#1544.

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

* Fix CI failures: Ruff formatting and test isolation issues

- Split long regex line in worktree.py for Ruff compliance
- Fix test isolation issue caused by worktree.py importlib shim
- Convert patch() calls to patch.object() pattern in test files
- Add fixtures to test_github_pr_regression.py for consistency

The importlib shim in apps/backend/worktree.py causes module-level
patches to fail when tests run after test_agent_flow.py. Using
patch.object() on the imported module directly resolves this.

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

* Skip glab detection test when glab CLI is not installed

Address CodeRabbit recommendation: add pytest import and guard
test_glab_detection with get_glab_executable() check, using
pytest.skip() when glab is not available on the system.

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

* Disable GPG signing in test git repos to prevent CI hangs

Tests may hang if the runner has global GPG signing enabled.
Explicitly disable commit.gpgsign in create_test_git_repo.

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

* Fix glab CLI path not passed to backend subprocess

The frontend detected glab but never set GITLAB_CLI_PATH env var.
Added 'glab' to CliTool type and CLI_TOOL_ENV_MAP, and call
detectAndSetCliPath('glab') in setupProcessEnvironment.

This ensures GitLab MR creation works when the app is launched
from Finder/Dock and glab is in a non-standard PATH location.

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

* Fix glab CLI flags and JSON field name in _get_existing_mr_url

glab uses --output json (not --json fieldName like gh CLI) and
returns snake_case field names (web_url instead of webUrl).

Verified with actual glab mr view command on lcoffice repo.

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

* Extract shared test fixtures to conftest.py

Move temp_project_dir and worktree_manager fixtures from
test_gitlab_worktree.py and test_github_pr_regression.py
to a shared conftest.py file.

Also adds GPG signing disable to the shared fixture for CI.

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

* Use throwaway variable for unused WorktreeManager instance

Replace `manager` with `_` to indicate the variable is intentionally
unused - the test only verifies the constructor doesn't raise.

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

* Remove unused imports in test_gitlab_worktree.py

Remove pytest and WorktreeManager imports that are not used in the file.
Fixtures are provided by conftest.py which handles the imports.

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

* Address PR review findings: cleanup and improve hostname matching

- Remove unused MergeRequestResult TypedDict (dead code)
- Rename GH_CLI_TIMEOUT/GH_QUERY_TIMEOUT to provider-neutral CLI_TIMEOUT/CLI_QUERY_TIMEOUT
- Improve hostname classification to use precise domain segment matching
  (rejects edge cases like attacker-github.com while still matching github-enterprise.local)
- Add test coverage for GitHub/GitLab hostname detection edge cases

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

* Revert "Extract shared test fixtures to conftest.py"

This reverts commit 22ab666.

* Extract shared test fixtures to conftest.py

- Move temp_project_dir and worktree_manager fixtures to conftest.py
  (shared across GitLab and GitHub test suites)
- Remove duplicate fixtures from test_github_pr_regression.py and
  test_gitlab_worktree.py
- Remove unused subprocess import from test_gitlab_worktree.py

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

* Use consistent shim imports in GitLab/GitHub tests

Switch to shim imports (worktree instead of core.worktree) to match
other test files and avoid module aliasing issues caused by Python's
module caching when tests use different import paths for the same module.

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

* Isolate git environment in temp_project_dir fixture

Pass sanitized environment to subprocess.run calls to prevent git
operations from leaking into parent repos when tests run inside
git worktrees (e.g., during pre-commit hooks).

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

* Fix CodeQL findings in test files

- Remove URL substring check that triggered py/incomplete-url-substring-sanitization
  (redundant - error message check is sufficient)
- Remove unused pytest import in test_gitlab_worktree.py

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

* fix: use pushed remote for provider detection in multi-remote repos

detect_git_provider() now accepts an optional remote_name parameter
so push_and_create_pr() can pass the actual pushed remote instead of
always checking 'origin'. This fixes incorrect PR/MR creation when
repos have multiple remotes pointing to different providers.

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

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: StillKnotKnown <192589389+StillKnotKnown@users.noreply.github.com>
StillKnotKnown pushed a commit that referenced this pull request Feb 9, 2026
…ndyMik90#1724)

* auto-claude: subtask-1-1 - Add ErrorBoundary wrapper around Context component

* auto-claude: subtask-1-2 - Wrap statSync() calls in try-catch in memory-statu

* auto-claude: subtask-1-3 - Wrap statSync() calls in try-catch in memory-data-handlers.ts

* auto-claude: subtask-1-4 - Add safe property access with optional chaining in MemoryCard.tsx

- Add optional chaining to pattern.pattern with fallback to pattern.applies_to
- Add optional chaining to gotcha.gotcha with JSON.stringify fallback
- Prevents crashes when memory data has malformed discoveries structures
- Fixes Root Cause #3: Unsafe Property Access

* auto-claude: subtask-1-5 - Add Promise guard flags in memory-service.ts executeQuery()

* auto-claude: subtask-1-5 - Add Promise guard flags in memory-service.ts executeQuery()

- Store timeoutId to enable cleanup
- Add clearTimeout() in close and error handlers
- Prevents race condition where timeout fires after Promise resolved
- Follows pattern from memory-handlers.ts:262-312

* auto-claude: subtask-1-5 - Add Promise guard flags in memory-service.ts executeQuery()

Fix Promise race condition by reordering timeout setup before event handlers.
Follows pattern from memory-handlers.ts:262-312 with resolved guard flag,
timeout cleanup in close/error handlers, preventing double-resolution crashes.

* fix: apply timeout cleanup pattern to executeSemanticQuery matching executeQuery

Store the setTimeout ID and clear it in both close and error handlers to
prevent timeout resource leaks. Also move resolved flag immediately after
the guard check for consistency with executeQuery.

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

---------

Co-authored-by: Test User <test@example.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
StillKnotKnown pushed a commit that referenced this pull request Feb 9, 2026
…ndyMik90#1747)

* auto-claude: subtask-1-1 - Add errorCode propagation in reactiveTokenRefresh()

* auto-claude: subtask-1-2 - Return null instead of revoked token for permanent errors in ensureValidToken()

* auto-claude: subtask-1-3 - Clear credential cache on invalid_grant error in refreshOAuthToken()

* auto-claude: subtask-1-4 - Clear revoked credentials on persistence failure (Bug #5)

When token refresh succeeds but persistence to keychain fails, the old
credentials in the keychain are now revoked server-side. This commit adds
defensive cache clearing in both ensureValidToken() and reactiveTokenRefresh()
to prevent serving revoked tokens from cache.

On app restart, Bugs #3 and #4 fixes will handle the revoked credentials
properly by returning null and clearing the cache, forcing re-authentication.

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

* auto-claude: subtask-2-1 - Move authFailedProfiles marking before early return

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
StillKnotKnown pushed a commit that referenced this pull request Feb 9, 2026
…ndyMik90#1456)

* auto-claude: subtask-1-1 - Add GITHUB_AUTH_CHANGED IPC channel constant

* auto-claude: subtask-1-2 - Add async getGitHubTokenForSubprocess() helper to utils.ts

Add a new exported async function getGitHubTokenForSubprocess() that calls
getTokenFromGhCli() to retrieve fresh GitHub tokens for subprocess use.
This provides a clean interface for runner-env.ts to get tokens without
caching, ensuring account changes are reflected immediately.

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

* auto-claude: subtask-1-3 - Update getRunnerEnv() to include GITHUB_TOKEN

* auto-claude: subtask-2-1 - Add auth change detection and event emission to oauth-handlers.ts

- Add GitHubAuthChangedPayload interface for auth change events
- Add sendAuthChangedToRenderer() to broadcast auth changes to all windows
- Add getCurrentGitHubUsername() helper to get current GitHub user
- Modify registerStartGhAuth() to:
  - Capture username before auth starts
  - Get username after successful auth
  - Emit GITHUB_AUTH_CHANGED event if account changed

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

* auto-claude: subtask-3-1 - Add onGitHubAuthChanged listener to GitHubAPI interface

- Add onGitHubAuthChanged to GitHubAPI interface in github-api.ts
- Add implementation using createIpcListener with IPC_CHANNELS.GITHUB_AUTH_CHANGED
- Add mock implementation in browser-mock.ts for testing

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

* auto-claude: subtask-4-1 - Add GitHub auth change listener to pr-review-store

* fix: Address PR review findings for GitHub auth handlers

- Convert getCurrentGitHubUsername() to async using promisified execFile
  to avoid blocking Electron main thread during auth flow (finding #1)
- Make getGitHubTokenForSubprocess() truly async by introducing async
  getTokenFromGhCliAsync() - the sync version is preserved for
  getGitHubConfig (finding #2)
- Add warning log when username fetch fails after successful auth,
  handling the edge case where auth succeeds but account change
  detection fails (finding #3)
- Remove unused timestamp field from GitHubAuthChangedPayload interface
  since the renderer callback only uses oldUsername/newUsername (finding #4)
- Document the intentional extraEnv override behavior in getRunnerEnv()
  JSDoc comment (finding #5)

All 5 findings from PR review were real issues. These fixes improve code
quality by avoiding main thread blocking and clarifying edge cases.

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

* test: Fix oauth-handlers tests for async getCurrentGitHubUsername

Update test mocks and add waitForAsyncSetup helper to handle the async
changes in getCurrentGitHubUsername(). The function now uses promisified
execFile instead of execFileSync to avoid blocking the main thread.

Key changes:
- Add mockExecFile mock for the promisified execFile function
- Add waitForAsyncSetup helper to wait for async setup before emitting
  process events
- Update all affected tests to use waitForAsyncSetup before emitting
  mock process events

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

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
StillKnotKnown added a commit that referenced this pull request Feb 9, 2026
* Fix GitLab Merged MRs Not Displaying

Fixes AndyMik90#1521

- Added UseGitLabMRsOptions interface with stateFilter parameter
- Updated hook signature to accept optional options parameter
- Removed hardcoded useState for stateFilter
- Defaults to 'opened' for backward compatibility
- Pass stateFilter state to useGitLabMRs hook via options parameter
- Enables proper filtering of MRs by state (opened/merged/closed/all)
- Completes frontend implementation for GitLab MR state filtering

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>

* GitLab Support for Create PR Button (#2)

Title:
  feat: add GitLab support for Create PR button (#2)
  Fixes: AndyMik90#1519

  Body:
  Add automatic git remote detection to route GitLab repositories to the
  `glab` CLI for creating merge requests, while preserving existing GitHub
  functionality.

  ## Changes

  - Add `git_provider.py` for detecting GitHub vs GitLab from remote URLs
    - Supports SSH and HTTPS formats
    - Supports self-hosted GitLab instances (detects "gitlab" in hostname)
  - Add `glab_executable.py` for finding GitLab CLI with platform-specific fallbacks
  - Update `WorktreeManager.push_and_create_pr()` to detect provider and route
    to either `create_pull_request()` (GitHub) or `create_merge_request()` (GitLab)
  - Add `create_merge_request()` method for GitLab MR creation via glab CLI
  - Update error messages to include provider-specific installation instructions

  ## Testing

  - Unit tests for `git_provider.py` detection logic
  - Integration tests for WorktreeManager PR/MR creation
  - Manual E2E tests for GitLab remote repositories
  - Regression tests to ensure GitHub PR creation still works

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

* Add GitLab CLI (glab) Path Configuration to Settings (#3)

feat(frontend): add GitLab CLI (glab) path configuration to Settings

  Add support for configuring the GitLab CLI (glab) path in the Settings
  page, consistent with existing GitHub CLI (gh) path configuration.

  Changes:
  - Add 'glab' to CLITool type union and gitlabCLIPath to ToolConfig
  - Implement detectGitLabCLI() and validateGitLabCLI() with multi-level
    detection (user config, Homebrew, system PATH, Windows Program Files)
  - Implement async variants for non-blocking detection
  - Add gitlabCLIPath to AppSettings interface and DEFAULT_APP_SETTINGS
  - Add glab to getCliToolsInfo IPC handler return type
  - Add gitlabCLIPath to pathFields array and configureTools calls
  - Add English and French translation keys for GitLab CLI path
  - Add GitLab CLI path input field to GeneralSettings component
  - Fix glab version regex to match actual output format ("glab X.Y.Z"
    instead of "glab version X.Y.Z")
  - Add augmented env to all sync CLI validators (Python, Git, gh, glab)
    for consistency with validateClaude and async validators

  Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* Fix GitLab bugs from CodeRabbitAI review comments

Address actionable comments reported by CodeRabbitAI:

- Fix SSH URL parsing in git_provider.py to support ssh:// URLs and
  arbitrary usernames (not just git@)
- Fix Windows glab paths to use correct installation directory
  (glab\glab.exe instead of GitLab CLI\glab.exe)
- Fix regex for GitLab MR URLs to correctly match both /merge_requests/
  and /-/merge_requests/ patterns
- Move inline json import to top-level in worktree.py
- Fix incorrect mock paths in test_worktree_gitlab.py
- Remove unused imports and f-strings without placeholders
- Add WINDOWS_GLAB_PATHS constant to frontend for centralized path management
- Replace fragile monkeypatch with unittest.mock.patch in manual tests

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

* Consolidate GitLab test files and move tests to tests/ directory

- Remove duplicate test_gitlab_pr_manual.py, consolidate into test_gitlab_e2e.py
- Expand provider detection to test 8 URL patterns (GitHub/GitLab variants)
- Add WorktreeManager method signature verification test
- Improve error message test to use unittest.mock.patch
- Move all GitLab test files from apps/backend/core/ to tests/

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

* Convert GitLab E2E tests to pytest-style assertions

Rename test functions to _check_* helpers and create proper test_*
pytest functions with assertions. This fixes PytestReturnNotNoneWarning
warnings and ensures tests actually fail when checks return False.

Fixes: AndyMik90#1544 (comment)

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

* Fix GitHub Enterprise detection in git_provider

Broaden the hostname check in _classify_hostname to also detect
GitHub Enterprise hostnames (e.g., github.company.com) by checking
for "github" substring, matching the pattern already used for GitLab.

Addresses CodeRabbitAI review comment on PR AndyMik90#1544.

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

* Fix CI failures: Ruff formatting and test isolation issues

- Split long regex line in worktree.py for Ruff compliance
- Fix test isolation issue caused by worktree.py importlib shim
- Convert patch() calls to patch.object() pattern in test files
- Add fixtures to test_github_pr_regression.py for consistency

The importlib shim in apps/backend/worktree.py causes module-level
patches to fail when tests run after test_agent_flow.py. Using
patch.object() on the imported module directly resolves this.

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

* Skip glab detection test when glab CLI is not installed

Address CodeRabbit recommendation: add pytest import and guard
test_glab_detection with get_glab_executable() check, using
pytest.skip() when glab is not available on the system.

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

* Disable GPG signing in test git repos to prevent CI hangs

Tests may hang if the runner has global GPG signing enabled.
Explicitly disable commit.gpgsign in create_test_git_repo.

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

* Fix glab CLI path not passed to backend subprocess

The frontend detected glab but never set GITLAB_CLI_PATH env var.
Added 'glab' to CliTool type and CLI_TOOL_ENV_MAP, and call
detectAndSetCliPath('glab') in setupProcessEnvironment.

This ensures GitLab MR creation works when the app is launched
from Finder/Dock and glab is in a non-standard PATH location.

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

* Fix glab CLI flags and JSON field name in _get_existing_mr_url

glab uses --output json (not --json fieldName like gh CLI) and
returns snake_case field names (web_url instead of webUrl).

Verified with actual glab mr view command on lcoffice repo.

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

* Extract shared test fixtures to conftest.py

Move temp_project_dir and worktree_manager fixtures from
test_gitlab_worktree.py and test_github_pr_regression.py
to a shared conftest.py file.

Also adds GPG signing disable to the shared fixture for CI.

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

* Use throwaway variable for unused WorktreeManager instance

Replace `manager` with `_` to indicate the variable is intentionally
unused - the test only verifies the constructor doesn't raise.

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

* Remove unused imports in test_gitlab_worktree.py

Remove pytest and WorktreeManager imports that are not used in the file.
Fixtures are provided by conftest.py which handles the imports.

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

* Address PR review findings: cleanup and improve hostname matching

- Remove unused MergeRequestResult TypedDict (dead code)
- Rename GH_CLI_TIMEOUT/GH_QUERY_TIMEOUT to provider-neutral CLI_TIMEOUT/CLI_QUERY_TIMEOUT
- Improve hostname classification to use precise domain segment matching
  (rejects edge cases like attacker-github.com while still matching github-enterprise.local)
- Add test coverage for GitHub/GitLab hostname detection edge cases

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

* Revert "Extract shared test fixtures to conftest.py"

This reverts commit 22ab666.

* Extract shared test fixtures to conftest.py

- Move temp_project_dir and worktree_manager fixtures to conftest.py
  (shared across GitLab and GitHub test suites)
- Remove duplicate fixtures from test_github_pr_regression.py and
  test_gitlab_worktree.py
- Remove unused subprocess import from test_gitlab_worktree.py

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

* Use consistent shim imports in GitLab/GitHub tests

Switch to shim imports (worktree instead of core.worktree) to match
other test files and avoid module aliasing issues caused by Python's
module caching when tests use different import paths for the same module.

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

* Isolate git environment in temp_project_dir fixture

Pass sanitized environment to subprocess.run calls to prevent git
operations from leaking into parent repos when tests run inside
git worktrees (e.g., during pre-commit hooks).

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

* Fix CodeQL findings in test files

- Remove URL substring check that triggered py/incomplete-url-substring-sanitization
  (redundant - error message check is sufficient)
- Remove unused pytest import in test_gitlab_worktree.py

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

* fix: use pushed remote for provider detection in multi-remote repos

detect_git_provider() now accepts an optional remote_name parameter
so push_and_create_pr() can pass the actual pushed remote instead of
always checking 'origin'. This fixes incorrect PR/MR creation when
repos have multiple remotes pointing to different providers.

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

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: StillKnotKnown <192589389+StillKnotKnown@users.noreply.github.com>
StillKnotKnown pushed a commit that referenced this pull request Feb 9, 2026
…ndyMik90#1747)

* auto-claude: subtask-1-1 - Add errorCode propagation in reactiveTokenRefresh()

* auto-claude: subtask-1-2 - Return null instead of revoked token for permanent errors in ensureValidToken()

* auto-claude: subtask-1-3 - Clear credential cache on invalid_grant error in refreshOAuthToken()

* auto-claude: subtask-1-4 - Clear revoked credentials on persistence failure (Bug #5)

When token refresh succeeds but persistence to keychain fails, the old
credentials in the keychain are now revoked server-side. This commit adds
defensive cache clearing in both ensureValidToken() and reactiveTokenRefresh()
to prevent serving revoked tokens from cache.

On app restart, Bugs #3 and #4 fixes will handle the revoked credentials
properly by returning null and clearing the cache, forcing re-authentication.

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

* auto-claude: subtask-2-1 - Move authFailedProfiles marking before early return

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
StillKnotKnown pushed a commit that referenced this pull request Feb 9, 2026
…ndyMik90#1456)

* auto-claude: subtask-1-1 - Add GITHUB_AUTH_CHANGED IPC channel constant

* auto-claude: subtask-1-2 - Add async getGitHubTokenForSubprocess() helper to utils.ts

Add a new exported async function getGitHubTokenForSubprocess() that calls
getTokenFromGhCli() to retrieve fresh GitHub tokens for subprocess use.
This provides a clean interface for runner-env.ts to get tokens without
caching, ensuring account changes are reflected immediately.

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

* auto-claude: subtask-1-3 - Update getRunnerEnv() to include GITHUB_TOKEN

* auto-claude: subtask-2-1 - Add auth change detection and event emission to oauth-handlers.ts

- Add GitHubAuthChangedPayload interface for auth change events
- Add sendAuthChangedToRenderer() to broadcast auth changes to all windows
- Add getCurrentGitHubUsername() helper to get current GitHub user
- Modify registerStartGhAuth() to:
  - Capture username before auth starts
  - Get username after successful auth
  - Emit GITHUB_AUTH_CHANGED event if account changed

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

* auto-claude: subtask-3-1 - Add onGitHubAuthChanged listener to GitHubAPI interface

- Add onGitHubAuthChanged to GitHubAPI interface in github-api.ts
- Add implementation using createIpcListener with IPC_CHANNELS.GITHUB_AUTH_CHANGED
- Add mock implementation in browser-mock.ts for testing

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

* auto-claude: subtask-4-1 - Add GitHub auth change listener to pr-review-store

* fix: Address PR review findings for GitHub auth handlers

- Convert getCurrentGitHubUsername() to async using promisified execFile
  to avoid blocking Electron main thread during auth flow (finding #1)
- Make getGitHubTokenForSubprocess() truly async by introducing async
  getTokenFromGhCliAsync() - the sync version is preserved for
  getGitHubConfig (finding #2)
- Add warning log when username fetch fails after successful auth,
  handling the edge case where auth succeeds but account change
  detection fails (finding #3)
- Remove unused timestamp field from GitHubAuthChangedPayload interface
  since the renderer callback only uses oldUsername/newUsername (finding #4)
- Document the intentional extraEnv override behavior in getRunnerEnv()
  JSDoc comment (finding #5)

All 5 findings from PR review were real issues. These fixes improve code
quality by avoiding main thread blocking and clarifying edge cases.

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

* test: Fix oauth-handlers tests for async getCurrentGitHubUsername

Update test mocks and add waitForAsyncSetup helper to handle the async
changes in getCurrentGitHubUsername(). The function now uses promisified
execFile instead of execFileSync to avoid blocking the main thread.

Key changes:
- Add mockExecFile mock for the promisified execFile function
- Add waitForAsyncSetup helper to wait for async setup before emitting
  process events
- Update all affected tests to use waitForAsyncSetup before emitting
  mock process events

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

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
StillKnotKnown added a commit that referenced this pull request Feb 9, 2026
* Fix GitLab Merged MRs Not Displaying

Fixes AndyMik90#1521

- Added UseGitLabMRsOptions interface with stateFilter parameter
- Updated hook signature to accept optional options parameter
- Removed hardcoded useState for stateFilter
- Defaults to 'opened' for backward compatibility
- Pass stateFilter state to useGitLabMRs hook via options parameter
- Enables proper filtering of MRs by state (opened/merged/closed/all)
- Completes frontend implementation for GitLab MR state filtering

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>

* GitLab Support for Create PR Button (#2)

Title:
  feat: add GitLab support for Create PR button (#2)
  Fixes: AndyMik90#1519

  Body:
  Add automatic git remote detection to route GitLab repositories to the
  `glab` CLI for creating merge requests, while preserving existing GitHub
  functionality.

  ## Changes

  - Add `git_provider.py` for detecting GitHub vs GitLab from remote URLs
    - Supports SSH and HTTPS formats
    - Supports self-hosted GitLab instances (detects "gitlab" in hostname)
  - Add `glab_executable.py` for finding GitLab CLI with platform-specific fallbacks
  - Update `WorktreeManager.push_and_create_pr()` to detect provider and route
    to either `create_pull_request()` (GitHub) or `create_merge_request()` (GitLab)
  - Add `create_merge_request()` method for GitLab MR creation via glab CLI
  - Update error messages to include provider-specific installation instructions

  ## Testing

  - Unit tests for `git_provider.py` detection logic
  - Integration tests for WorktreeManager PR/MR creation
  - Manual E2E tests for GitLab remote repositories
  - Regression tests to ensure GitHub PR creation still works

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

* Add GitLab CLI (glab) Path Configuration to Settings (#3)

feat(frontend): add GitLab CLI (glab) path configuration to Settings

  Add support for configuring the GitLab CLI (glab) path in the Settings
  page, consistent with existing GitHub CLI (gh) path configuration.

  Changes:
  - Add 'glab' to CLITool type union and gitlabCLIPath to ToolConfig
  - Implement detectGitLabCLI() and validateGitLabCLI() with multi-level
    detection (user config, Homebrew, system PATH, Windows Program Files)
  - Implement async variants for non-blocking detection
  - Add gitlabCLIPath to AppSettings interface and DEFAULT_APP_SETTINGS
  - Add glab to getCliToolsInfo IPC handler return type
  - Add gitlabCLIPath to pathFields array and configureTools calls
  - Add English and French translation keys for GitLab CLI path
  - Add GitLab CLI path input field to GeneralSettings component
  - Fix glab version regex to match actual output format ("glab X.Y.Z"
    instead of "glab version X.Y.Z")
  - Add augmented env to all sync CLI validators (Python, Git, gh, glab)
    for consistency with validateClaude and async validators

  Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* Fix GitLab bugs from CodeRabbitAI review comments

Address actionable comments reported by CodeRabbitAI:

- Fix SSH URL parsing in git_provider.py to support ssh:// URLs and
  arbitrary usernames (not just git@)
- Fix Windows glab paths to use correct installation directory
  (glab\glab.exe instead of GitLab CLI\glab.exe)
- Fix regex for GitLab MR URLs to correctly match both /merge_requests/
  and /-/merge_requests/ patterns
- Move inline json import to top-level in worktree.py
- Fix incorrect mock paths in test_worktree_gitlab.py
- Remove unused imports and f-strings without placeholders
- Add WINDOWS_GLAB_PATHS constant to frontend for centralized path management
- Replace fragile monkeypatch with unittest.mock.patch in manual tests

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

* Consolidate GitLab test files and move tests to tests/ directory

- Remove duplicate test_gitlab_pr_manual.py, consolidate into test_gitlab_e2e.py
- Expand provider detection to test 8 URL patterns (GitHub/GitLab variants)
- Add WorktreeManager method signature verification test
- Improve error message test to use unittest.mock.patch
- Move all GitLab test files from apps/backend/core/ to tests/

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

* Convert GitLab E2E tests to pytest-style assertions

Rename test functions to _check_* helpers and create proper test_*
pytest functions with assertions. This fixes PytestReturnNotNoneWarning
warnings and ensures tests actually fail when checks return False.

Fixes: AndyMik90#1544 (comment)

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

* Fix GitHub Enterprise detection in git_provider

Broaden the hostname check in _classify_hostname to also detect
GitHub Enterprise hostnames (e.g., github.company.com) by checking
for "github" substring, matching the pattern already used for GitLab.

Addresses CodeRabbitAI review comment on PR AndyMik90#1544.

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

* Fix CI failures: Ruff formatting and test isolation issues

- Split long regex line in worktree.py for Ruff compliance
- Fix test isolation issue caused by worktree.py importlib shim
- Convert patch() calls to patch.object() pattern in test files
- Add fixtures to test_github_pr_regression.py for consistency

The importlib shim in apps/backend/worktree.py causes module-level
patches to fail when tests run after test_agent_flow.py. Using
patch.object() on the imported module directly resolves this.

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

* Skip glab detection test when glab CLI is not installed

Address CodeRabbit recommendation: add pytest import and guard
test_glab_detection with get_glab_executable() check, using
pytest.skip() when glab is not available on the system.

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

* Disable GPG signing in test git repos to prevent CI hangs

Tests may hang if the runner has global GPG signing enabled.
Explicitly disable commit.gpgsign in create_test_git_repo.

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

* Fix glab CLI path not passed to backend subprocess

The frontend detected glab but never set GITLAB_CLI_PATH env var.
Added 'glab' to CliTool type and CLI_TOOL_ENV_MAP, and call
detectAndSetCliPath('glab') in setupProcessEnvironment.

This ensures GitLab MR creation works when the app is launched
from Finder/Dock and glab is in a non-standard PATH location.

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

* Fix glab CLI flags and JSON field name in _get_existing_mr_url

glab uses --output json (not --json fieldName like gh CLI) and
returns snake_case field names (web_url instead of webUrl).

Verified with actual glab mr view command on lcoffice repo.

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

* Extract shared test fixtures to conftest.py

Move temp_project_dir and worktree_manager fixtures from
test_gitlab_worktree.py and test_github_pr_regression.py
to a shared conftest.py file.

Also adds GPG signing disable to the shared fixture for CI.

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

* Use throwaway variable for unused WorktreeManager instance

Replace `manager` with `_` to indicate the variable is intentionally
unused - the test only verifies the constructor doesn't raise.

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

* Remove unused imports in test_gitlab_worktree.py

Remove pytest and WorktreeManager imports that are not used in the file.
Fixtures are provided by conftest.py which handles the imports.

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

* Address PR review findings: cleanup and improve hostname matching

- Remove unused MergeRequestResult TypedDict (dead code)
- Rename GH_CLI_TIMEOUT/GH_QUERY_TIMEOUT to provider-neutral CLI_TIMEOUT/CLI_QUERY_TIMEOUT
- Improve hostname classification to use precise domain segment matching
  (rejects edge cases like attacker-github.com while still matching github-enterprise.local)
- Add test coverage for GitHub/GitLab hostname detection edge cases

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

* Revert "Extract shared test fixtures to conftest.py"

This reverts commit 22ab666.

* Extract shared test fixtures to conftest.py

- Move temp_project_dir and worktree_manager fixtures to conftest.py
  (shared across GitLab and GitHub test suites)
- Remove duplicate fixtures from test_github_pr_regression.py and
  test_gitlab_worktree.py
- Remove unused subprocess import from test_gitlab_worktree.py

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

* Use consistent shim imports in GitLab/GitHub tests

Switch to shim imports (worktree instead of core.worktree) to match
other test files and avoid module aliasing issues caused by Python's
module caching when tests use different import paths for the same module.

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

* Isolate git environment in temp_project_dir fixture

Pass sanitized environment to subprocess.run calls to prevent git
operations from leaking into parent repos when tests run inside
git worktrees (e.g., during pre-commit hooks).

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

* Fix CodeQL findings in test files

- Remove URL substring check that triggered py/incomplete-url-substring-sanitization
  (redundant - error message check is sufficient)
- Remove unused pytest import in test_gitlab_worktree.py

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

* fix: use pushed remote for provider detection in multi-remote repos

detect_git_provider() now accepts an optional remote_name parameter
so push_and_create_pr() can pass the actual pushed remote instead of
always checking 'origin'. This fixes incorrect PR/MR creation when
repos have multiple remotes pointing to different providers.

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

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: StillKnotKnown <192589389+StillKnotKnown@users.noreply.github.com>
StillKnotKnown pushed a commit that referenced this pull request Feb 9, 2026
…ndyMik90#1747)

* auto-claude: subtask-1-1 - Add errorCode propagation in reactiveTokenRefresh()

* auto-claude: subtask-1-2 - Return null instead of revoked token for permanent errors in ensureValidToken()

* auto-claude: subtask-1-3 - Clear credential cache on invalid_grant error in refreshOAuthToken()

* auto-claude: subtask-1-4 - Clear revoked credentials on persistence failure (Bug #5)

When token refresh succeeds but persistence to keychain fails, the old
credentials in the keychain are now revoked server-side. This commit adds
defensive cache clearing in both ensureValidToken() and reactiveTokenRefresh()
to prevent serving revoked tokens from cache.

On app restart, Bugs #3 and #4 fixes will handle the revoked credentials
properly by returning null and clearing the cache, forcing re-authentication.

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

* auto-claude: subtask-2-1 - Move authFailedProfiles marking before early return

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
StillKnotKnown pushed a commit that referenced this pull request Feb 10, 2026
…ndyMik90#1456)

* auto-claude: subtask-1-1 - Add GITHUB_AUTH_CHANGED IPC channel constant

* auto-claude: subtask-1-2 - Add async getGitHubTokenForSubprocess() helper to utils.ts

Add a new exported async function getGitHubTokenForSubprocess() that calls
getTokenFromGhCli() to retrieve fresh GitHub tokens for subprocess use.
This provides a clean interface for runner-env.ts to get tokens without
caching, ensuring account changes are reflected immediately.

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

* auto-claude: subtask-1-3 - Update getRunnerEnv() to include GITHUB_TOKEN

* auto-claude: subtask-2-1 - Add auth change detection and event emission to oauth-handlers.ts

- Add GitHubAuthChangedPayload interface for auth change events
- Add sendAuthChangedToRenderer() to broadcast auth changes to all windows
- Add getCurrentGitHubUsername() helper to get current GitHub user
- Modify registerStartGhAuth() to:
  - Capture username before auth starts
  - Get username after successful auth
  - Emit GITHUB_AUTH_CHANGED event if account changed

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

* auto-claude: subtask-3-1 - Add onGitHubAuthChanged listener to GitHubAPI interface

- Add onGitHubAuthChanged to GitHubAPI interface in github-api.ts
- Add implementation using createIpcListener with IPC_CHANNELS.GITHUB_AUTH_CHANGED
- Add mock implementation in browser-mock.ts for testing

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

* auto-claude: subtask-4-1 - Add GitHub auth change listener to pr-review-store

* fix: Address PR review findings for GitHub auth handlers

- Convert getCurrentGitHubUsername() to async using promisified execFile
  to avoid blocking Electron main thread during auth flow (finding #1)
- Make getGitHubTokenForSubprocess() truly async by introducing async
  getTokenFromGhCliAsync() - the sync version is preserved for
  getGitHubConfig (finding #2)
- Add warning log when username fetch fails after successful auth,
  handling the edge case where auth succeeds but account change
  detection fails (finding #3)
- Remove unused timestamp field from GitHubAuthChangedPayload interface
  since the renderer callback only uses oldUsername/newUsername (finding #4)
- Document the intentional extraEnv override behavior in getRunnerEnv()
  JSDoc comment (finding #5)

All 5 findings from PR review were real issues. These fixes improve code
quality by avoiding main thread blocking and clarifying edge cases.

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

* test: Fix oauth-handlers tests for async getCurrentGitHubUsername

Update test mocks and add waitForAsyncSetup helper to handle the async
changes in getCurrentGitHubUsername(). The function now uses promisified
execFile instead of execFileSync to avoid blocking the main thread.

Key changes:
- Add mockExecFile mock for the promisified execFile function
- Add waitForAsyncSetup helper to wait for async setup before emitting
  process events
- Update all affected tests to use waitForAsyncSetup before emitting
  mock process events

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

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
StillKnotKnown added a commit that referenced this pull request Feb 10, 2026
* Fix GitLab Merged MRs Not Displaying

Fixes AndyMik90#1521

- Added UseGitLabMRsOptions interface with stateFilter parameter
- Updated hook signature to accept optional options parameter
- Removed hardcoded useState for stateFilter
- Defaults to 'opened' for backward compatibility
- Pass stateFilter state to useGitLabMRs hook via options parameter
- Enables proper filtering of MRs by state (opened/merged/closed/all)
- Completes frontend implementation for GitLab MR state filtering

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>

* GitLab Support for Create PR Button (#2)

Title:
  feat: add GitLab support for Create PR button (#2)
  Fixes: AndyMik90#1519

  Body:
  Add automatic git remote detection to route GitLab repositories to the
  `glab` CLI for creating merge requests, while preserving existing GitHub
  functionality.

  ## Changes

  - Add `git_provider.py` for detecting GitHub vs GitLab from remote URLs
    - Supports SSH and HTTPS formats
    - Supports self-hosted GitLab instances (detects "gitlab" in hostname)
  - Add `glab_executable.py` for finding GitLab CLI with platform-specific fallbacks
  - Update `WorktreeManager.push_and_create_pr()` to detect provider and route
    to either `create_pull_request()` (GitHub) or `create_merge_request()` (GitLab)
  - Add `create_merge_request()` method for GitLab MR creation via glab CLI
  - Update error messages to include provider-specific installation instructions

  ## Testing

  - Unit tests for `git_provider.py` detection logic
  - Integration tests for WorktreeManager PR/MR creation
  - Manual E2E tests for GitLab remote repositories
  - Regression tests to ensure GitHub PR creation still works

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

* Add GitLab CLI (glab) Path Configuration to Settings (#3)

feat(frontend): add GitLab CLI (glab) path configuration to Settings

  Add support for configuring the GitLab CLI (glab) path in the Settings
  page, consistent with existing GitHub CLI (gh) path configuration.

  Changes:
  - Add 'glab' to CLITool type union and gitlabCLIPath to ToolConfig
  - Implement detectGitLabCLI() and validateGitLabCLI() with multi-level
    detection (user config, Homebrew, system PATH, Windows Program Files)
  - Implement async variants for non-blocking detection
  - Add gitlabCLIPath to AppSettings interface and DEFAULT_APP_SETTINGS
  - Add glab to getCliToolsInfo IPC handler return type
  - Add gitlabCLIPath to pathFields array and configureTools calls
  - Add English and French translation keys for GitLab CLI path
  - Add GitLab CLI path input field to GeneralSettings component
  - Fix glab version regex to match actual output format ("glab X.Y.Z"
    instead of "glab version X.Y.Z")
  - Add augmented env to all sync CLI validators (Python, Git, gh, glab)
    for consistency with validateClaude and async validators

  Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* Fix GitLab bugs from CodeRabbitAI review comments

Address actionable comments reported by CodeRabbitAI:

- Fix SSH URL parsing in git_provider.py to support ssh:// URLs and
  arbitrary usernames (not just git@)
- Fix Windows glab paths to use correct installation directory
  (glab\glab.exe instead of GitLab CLI\glab.exe)
- Fix regex for GitLab MR URLs to correctly match both /merge_requests/
  and /-/merge_requests/ patterns
- Move inline json import to top-level in worktree.py
- Fix incorrect mock paths in test_worktree_gitlab.py
- Remove unused imports and f-strings without placeholders
- Add WINDOWS_GLAB_PATHS constant to frontend for centralized path management
- Replace fragile monkeypatch with unittest.mock.patch in manual tests

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

* Consolidate GitLab test files and move tests to tests/ directory

- Remove duplicate test_gitlab_pr_manual.py, consolidate into test_gitlab_e2e.py
- Expand provider detection to test 8 URL patterns (GitHub/GitLab variants)
- Add WorktreeManager method signature verification test
- Improve error message test to use unittest.mock.patch
- Move all GitLab test files from apps/backend/core/ to tests/

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

* Convert GitLab E2E tests to pytest-style assertions

Rename test functions to _check_* helpers and create proper test_*
pytest functions with assertions. This fixes PytestReturnNotNoneWarning
warnings and ensures tests actually fail when checks return False.

Fixes: AndyMik90#1544 (comment)

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

* Fix GitHub Enterprise detection in git_provider

Broaden the hostname check in _classify_hostname to also detect
GitHub Enterprise hostnames (e.g., github.company.com) by checking
for "github" substring, matching the pattern already used for GitLab.

Addresses CodeRabbitAI review comment on PR AndyMik90#1544.

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

* Fix CI failures: Ruff formatting and test isolation issues

- Split long regex line in worktree.py for Ruff compliance
- Fix test isolation issue caused by worktree.py importlib shim
- Convert patch() calls to patch.object() pattern in test files
- Add fixtures to test_github_pr_regression.py for consistency

The importlib shim in apps/backend/worktree.py causes module-level
patches to fail when tests run after test_agent_flow.py. Using
patch.object() on the imported module directly resolves this.

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

* Skip glab detection test when glab CLI is not installed

Address CodeRabbit recommendation: add pytest import and guard
test_glab_detection with get_glab_executable() check, using
pytest.skip() when glab is not available on the system.

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

* Disable GPG signing in test git repos to prevent CI hangs

Tests may hang if the runner has global GPG signing enabled.
Explicitly disable commit.gpgsign in create_test_git_repo.

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

* Fix glab CLI path not passed to backend subprocess

The frontend detected glab but never set GITLAB_CLI_PATH env var.
Added 'glab' to CliTool type and CLI_TOOL_ENV_MAP, and call
detectAndSetCliPath('glab') in setupProcessEnvironment.

This ensures GitLab MR creation works when the app is launched
from Finder/Dock and glab is in a non-standard PATH location.

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

* Fix glab CLI flags and JSON field name in _get_existing_mr_url

glab uses --output json (not --json fieldName like gh CLI) and
returns snake_case field names (web_url instead of webUrl).

Verified with actual glab mr view command on lcoffice repo.

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

* Extract shared test fixtures to conftest.py

Move temp_project_dir and worktree_manager fixtures from
test_gitlab_worktree.py and test_github_pr_regression.py
to a shared conftest.py file.

Also adds GPG signing disable to the shared fixture for CI.

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

* Use throwaway variable for unused WorktreeManager instance

Replace `manager` with `_` to indicate the variable is intentionally
unused - the test only verifies the constructor doesn't raise.

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

* Remove unused imports in test_gitlab_worktree.py

Remove pytest and WorktreeManager imports that are not used in the file.
Fixtures are provided by conftest.py which handles the imports.

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

* Address PR review findings: cleanup and improve hostname matching

- Remove unused MergeRequestResult TypedDict (dead code)
- Rename GH_CLI_TIMEOUT/GH_QUERY_TIMEOUT to provider-neutral CLI_TIMEOUT/CLI_QUERY_TIMEOUT
- Improve hostname classification to use precise domain segment matching
  (rejects edge cases like attacker-github.com while still matching github-enterprise.local)
- Add test coverage for GitHub/GitLab hostname detection edge cases

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

* Revert "Extract shared test fixtures to conftest.py"

This reverts commit 22ab666.

* Extract shared test fixtures to conftest.py

- Move temp_project_dir and worktree_manager fixtures to conftest.py
  (shared across GitLab and GitHub test suites)
- Remove duplicate fixtures from test_github_pr_regression.py and
  test_gitlab_worktree.py
- Remove unused subprocess import from test_gitlab_worktree.py

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

* Use consistent shim imports in GitLab/GitHub tests

Switch to shim imports (worktree instead of core.worktree) to match
other test files and avoid module aliasing issues caused by Python's
module caching when tests use different import paths for the same module.

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

* Isolate git environment in temp_project_dir fixture

Pass sanitized environment to subprocess.run calls to prevent git
operations from leaking into parent repos when tests run inside
git worktrees (e.g., during pre-commit hooks).

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

* Fix CodeQL findings in test files

- Remove URL substring check that triggered py/incomplete-url-substring-sanitization
  (redundant - error message check is sufficient)
- Remove unused pytest import in test_gitlab_worktree.py

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

* fix: use pushed remote for provider detection in multi-remote repos

detect_git_provider() now accepts an optional remote_name parameter
so push_and_create_pr() can pass the actual pushed remote instead of
always checking 'origin'. This fixes incorrect PR/MR creation when
repos have multiple remotes pointing to different providers.

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

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: StillKnotKnown <192589389+StillKnotKnown@users.noreply.github.com>
StillKnotKnown pushed a commit that referenced this pull request Feb 10, 2026
…ndyMik90#1724)

* auto-claude: subtask-1-1 - Add ErrorBoundary wrapper around Context component

* auto-claude: subtask-1-2 - Wrap statSync() calls in try-catch in memory-statu

* auto-claude: subtask-1-3 - Wrap statSync() calls in try-catch in memory-data-handlers.ts

* auto-claude: subtask-1-4 - Add safe property access with optional chaining in MemoryCard.tsx

- Add optional chaining to pattern.pattern with fallback to pattern.applies_to
- Add optional chaining to gotcha.gotcha with JSON.stringify fallback
- Prevents crashes when memory data has malformed discoveries structures
- Fixes Root Cause #3: Unsafe Property Access

* auto-claude: subtask-1-5 - Add Promise guard flags in memory-service.ts executeQuery()

* auto-claude: subtask-1-5 - Add Promise guard flags in memory-service.ts executeQuery()

- Store timeoutId to enable cleanup
- Add clearTimeout() in close and error handlers
- Prevents race condition where timeout fires after Promise resolved
- Follows pattern from memory-handlers.ts:262-312

* auto-claude: subtask-1-5 - Add Promise guard flags in memory-service.ts executeQuery()

Fix Promise race condition by reordering timeout setup before event handlers.
Follows pattern from memory-handlers.ts:262-312 with resolved guard flag,
timeout cleanup in close/error handlers, preventing double-resolution crashes.

* fix: apply timeout cleanup pattern to executeSemanticQuery matching executeQuery

Store the setTimeout ID and clear it in both close and error handlers to
prevent timeout resource leaks. Also move resolved flag immediately after
the guard check for consistency with executeQuery.

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

---------

Co-authored-by: Test User <test@example.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
StillKnotKnown pushed a commit that referenced this pull request Feb 10, 2026
…ndyMik90#1747)

* auto-claude: subtask-1-1 - Add errorCode propagation in reactiveTokenRefresh()

* auto-claude: subtask-1-2 - Return null instead of revoked token for permanent errors in ensureValidToken()

* auto-claude: subtask-1-3 - Clear credential cache on invalid_grant error in refreshOAuthToken()

* auto-claude: subtask-1-4 - Clear revoked credentials on persistence failure (Bug #5)

When token refresh succeeds but persistence to keychain fails, the old
credentials in the keychain are now revoked server-side. This commit adds
defensive cache clearing in both ensureValidToken() and reactiveTokenRefresh()
to prevent serving revoked tokens from cache.

On app restart, Bugs #3 and #4 fixes will handle the revoked credentials
properly by returning null and clearing the cache, forcing re-authentication.

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

* auto-claude: subtask-2-1 - Move authFailedProfiles marking before early return

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant