Skip to content

feat(account): headless + agent-compatible ade login#822

Merged
arul28 merged 15 commits into
mainfrom
ade/accounts-headless-login-59857fcb
Jul 15, 2026
Merged

feat(account): headless + agent-compatible ade login#822
arul28 merged 15 commits into
mainfrom
ade/accounts-headless-login-59857fcb

Conversation

@arul28

@arul28 arul28 commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Headless / agent-compatible ade login

The merged ade login (#815) is browser + 127.0.0.1 loopback — it needs a local browser, so it breaks on a headless VPC and can't be driven by an agent. This adds two headless paths + auto-detection, all additive (loopback + local-first unchanged).

  • Device Authorization flow (interactive-headless / VPC): a D1-backed device-code bridge in the account-directory Worker — mint { device_code, user_code, verification_uri }; a rate-limited hosted approval page runs the Clerk PKCE sign-in (redirect → Worker); the daemon polls with a secret-bound, one-time, atomically-burned redemption. ade login --headless (or auto-detected: no DISPLAY / SSH / browser-open fails) prints the URL + user code and polls — the gh auth login pattern ("copy-paste link in any browser").
  • Non-interactive agent token: ADE_ACCOUNT_TOKEN (access or refresh token) is used directly with no flow / no disk writes and is never logged (asserted by test); ade account token create mints the durable credential once (CTO-only).
  • Auto-detection picks device-flow when headless, loopback otherwise; ADE_ACCOUNT_TOKEN short-circuits both. ade auth status reports the auth source.
  • Security: startDeviceLogin / pollDeviceLogin / createToken are CTO-role-only (a subagent can't drive login or extract the token); state/secret hashed; redemption secret-bound + one-time + atomic; approval page rate-limited; zero analytics on the credential path (deliberate).
  • No mobile / TUI / sync / ade code contract touched.

Tests: 17/17 account-directory (device bridge + PKCE + redemption + rate-limit) + 1,814 ADE CLI + 66/66 registry + docs validation, all green.

Deploy (pending): apply the new D1 migration, set CLERK_ISSUER + CLERK_OAUTH_CLIENT_ID, register https://<worker>/device/callback with Clerk, wrangler deploy, and set ADE_ACCOUNT_DIRECTORY_URL for ADE brains.

🤖 Generated with Claude Code

ADE   Open in ADE  ·  ade/accounts-headless-login-59857fcb branch  ·  PR #822

Summary by CodeRabbit

  • New Features
    • Added a headless device-code sign-in bridge with /device/* endpoints, including approval redirect handling and token polling.
    • Added ade login --headless with automatic fallback, plus ade account token create --text for durable tokens.
    • Extended available account.* actions for device login and token creation, with sign-in source reporting (loopback, device, env-token).
  • Security & Reliability
    • Enforced TTL, one-time redemption, polling backoff (slow_down), and per-client rate limits.
    • Added scheduled cleanup for expired authorizations and stale rate-limit windows.
    • Applied role-based redaction to account.status.
  • Documentation
    • Expanded Worker setup and OAuth redirect configuration for device login and durable tokens.

Greptile Summary

This PR adds headless and agent-compatible account login for ADE. The main changes are:

  • Device authorization endpoints in the account-directory Worker for code creation, approval, OAuth callback handling, polling, and cleanup.
  • CLI support for ade login --headless, automatic device-flow fallback, and ADE_ACCOUNT_TOKEN short-circuiting.
  • Durable account-token creation through ade account token create.
  • CTO-only gating for credential-bearing account actions, with redacted account status for non-CTO callers.
  • Tests and documentation for the new Worker, CLI, RPC, and agent authentication paths.

Confidence Score: 5/5

This PR appears safe to merge with low risk.

The Worker, CLI service, RPC gates, and role-scoping changes were reviewed, and no blocking correctness or security issues were identified.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • T-Rex ran a focused Vitest runtime to extract high-value proof.
  • T-Rex saved the full verbose Vitest output as a log file from the focused run.
  • T-Rex verified that no real secrets or external flows were used during the focused run, and that no broader ADE RPC spawn-agent suites or account-directory tests were executed.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
apps/account-directory/migrations/0002_device_authorization.sql Adds D1 tables and indexes for device authorization state and approval rate limits.
apps/account-directory/src/deviceAuthorization.ts Implements device-code creation, approval, OAuth callback exchange, polling redemption, and cleanup with one-time secret-bound token consumption.
apps/account-directory/src/directory.ts Routes device authorization endpoints before authenticated account machine endpoints while preserving existing machine API auth.
apps/ade-cli/src/cli.ts Adds ade login --headless, auto device-flow fallback, env-token short-circuiting, and account token creation command wiring.
apps/ade-cli/src/multiProjectRpcServer.ts Adds account-call handling to the multi-project runtime with CTO-only enforcement and prioritized account config roots.
apps/ade-cli/src/services/account/accountAuthService.ts Implements device login sessions, env-token authentication, durable token generation, status source reporting, and refresh handling.
apps/desktop/src/main/services/adeActions/registry.ts Registers new account actions, marks credential-bearing actions CTO-only, and redacts account identity for non-CTO roles.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant CLI as ade login --headless
participant Worker as account-directory Worker
participant Browser as User browser
participant Clerk as Clerk OAuth
participant D1 as D1 device_authorizations

CLI->>Worker: "POST /device/code {device_secret}"
Worker->>D1: Store device_code, user_code, secret hash, TTL
Worker-->>CLI: user_code + verification_uri
Browser->>Worker: "POST /device {user_code}"
Worker->>D1: Claim pending code, store PKCE verifier + state hash
Worker-->>Browser: Redirect to Clerk /oauth/authorize
Browser->>Clerk: Sign in with PKCE/state
Clerk-->>Worker: "GET /device/callback?code&state"
Worker->>D1: Atomic state claim
Worker->>Clerk: Exchange authorization code
Clerk-->>Worker: Token pair
Worker->>D1: Mark approved, store tokens temporarily
loop until approved or expired
    CLI->>Worker: "POST /device/token {device_code, device_secret}"
    Worker->>D1: Verify secret hash and status
    Worker-->>CLI: pending / slow_down / token response
end
Worker->>D1: Atomic consume, clear stored tokens
CLI->>CLI: Persist account session
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant CLI as ade login --headless
participant Worker as account-directory Worker
participant Browser as User browser
participant Clerk as Clerk OAuth
participant D1 as D1 device_authorizations

CLI->>Worker: "POST /device/code {device_secret}"
Worker->>D1: Store device_code, user_code, secret hash, TTL
Worker-->>CLI: user_code + verification_uri
Browser->>Worker: "POST /device {user_code}"
Worker->>D1: Claim pending code, store PKCE verifier + state hash
Worker-->>Browser: Redirect to Clerk /oauth/authorize
Browser->>Clerk: Sign in with PKCE/state
Clerk-->>Worker: "GET /device/callback?code&state"
Worker->>D1: Atomic state claim
Worker->>Clerk: Exchange authorization code
Clerk-->>Worker: Token pair
Worker->>D1: Mark approved, store tokens temporarily
loop until approved or expired
    CLI->>Worker: "POST /device/token {device_code, device_secret}"
    Worker->>D1: Verify secret hash and status
    Worker-->>CLI: pending / slow_down / token response
end
Worker->>D1: Atomic consume, clear stored tokens
CLI->>CLI: Persist account session
Loading

Comments Outside Diff (1)

  1. apps/ade-cli/src/cli.ts, line 17788-17790 (link)

    P1 Allow headless login startup
    ade login --headless still forces createConnection to attach to an existing machine brain with headless: false and machineRuntimeOnly: true, so on the headless VPC case this PR targets it throws before reaching detectAccountLoginMode or startDeviceLogin. The device flow only starts after this connection succeeds, making the new headless path unusable unless a brain is already running.

    Artifacts

    Repro: headless login no-brain harness

    • Contains supporting evidence from the run (text/x-shellscript; charset=utf-8).

    Repro: failing headless login command output

    • Keeps the command output available without making the summary code-heavy.

    View artifacts

    T-Rex Ran code and verified through T-Rex

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: apps/ade-cli/src/cli.ts
    Line: 17788-17790
    
    Comment:
    **Allow headless login startup**
    `ade login --headless` still forces `createConnection` to attach to an existing machine brain with `headless: false` and `machineRuntimeOnly: true`, so on the headless VPC case this PR targets it throws before reaching `detectAccountLoginMode` or `startDeviceLogin`. The device flow only starts after this connection succeeds, making the new headless path unusable unless a brain is already running.
    
    How can I resolve this? If you propose a fix, please make it concise.

    Fix in Claude Code

Reviews (16): Last reviewed commit: "ship: iteration 13 — claim device callba..." | Re-trigger Greptile

@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
ade Ignored Ignored Preview Jul 15, 2026 11:20am

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The account-directory Worker now provides a D1-backed device authorization bridge. ADE CLI authentication supports loopback, device, and durable environment-token flows, with new account actions, token creation, cleanup scheduling, authorization controls, tests, and documentation.

Changes

Device authorization bridge

Layer / File(s) Summary
Device authorization bridge
apps/account-directory/migrations/..., apps/account-directory/src/deviceAuthorization.ts, apps/account-directory/README.md, apps/account-directory/wrangler.jsonc
Adds D1 schema, rate limiting, OAuth approval, PKCE callback exchange, secret-bound token redemption, cleanup, cron configuration, and setup documentation.
Worker routing and scheduled cleanup
apps/account-directory/src/directory.ts, apps/account-directory/src/index.ts, apps/account-directory/test/directory.test.ts
Routes device endpoints, schedules cleanup, extends the D1 test double, and tests bridge lifecycle behavior.

ADE account authentication

Layer / File(s) Summary
Account authentication service
apps/ade-cli/src/services/account/*
Adds device-login and durable-token APIs, authentication-source tracking, bridge resolution, environment-token handling, OAuth context persistence, session lifecycle handling, and service tests.
CLI login orchestration
apps/ade-cli/src/cli.ts, apps/ade-cli/src/cli.test.ts, apps/ade-cli/README.md
Adds headless login detection, device fallback, environment-token paths, token creation output, command routing, project-root injection, help text, and integration coverage.

Account action exposure

Layer / File(s) Summary
Account action exposure and authorization
apps/ade-cli/src/multiProjectRpcServer.*, apps/ade-cli/src/adeRpcServer.*, apps/desktop/src/main/services/adeActions/registry.*
Exposes device-login and token-creation actions, applies role-based account-status scoping, updates CTO-only gating and input contracts, registers project roots, and extends action tests.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

  • arul28/ADE#814: Introduces the account-directory Worker structure extended here with device-authorization routing and persistence.

Suggested labels: desktop, docs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 1.72% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: headless and agent-compatible ADE login support.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ade/accounts-headless-login-59857fcb

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@arul28

arul28 commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@copilot review but do not make fixes

@arul28

arul28 commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@arul28
arul28 force-pushed the ade/accounts-headless-login-59857fcb branch from 2e674bc to e48e98f Compare July 15, 2026 05:47

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e48e98f219

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/account-directory/src/deviceAuthorization.ts
Comment thread apps/ade-cli/src/cli.ts Outdated
@arul28

arul28 commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 19924cfdeb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/ade-cli/src/cli.ts Outdated
Comment thread apps/ade-cli/src/services/account/accountAuthService.ts Outdated
@arul28

arul28 commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5bc9b24c19

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/ade-cli/src/services/account/accountAuthService.ts Outdated
Comment thread apps/account-directory/src/deviceAuthorization.ts
@arul28

arul28 commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ff0b394db

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/ade-cli/src/services/account/accountAuthService.ts Outdated
@arul28
arul28 force-pushed the ade/accounts-headless-login-59857fcb branch from 4ff0b39 to 016fe0d Compare July 15, 2026 07:32
@arul28

arul28 commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 016fe0d383

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/ade-cli/src/cli.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 9

🧹 Nitpick comments (1)
apps/ade-cli/src/multiProjectRpcServer.test.ts (1)

225-233: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Cover pollLogin in the CTO-only action matrix.

The matrix includes device polling but omits the equivalent loopback polling action. Add pollLogin so both credential-bearing polling paths remain protected against authorization regressions.

Proposed fix
         "createToken",
         "startLogin",
+        "pollLogin",
         "startDeviceLogin",
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/ade-cli/src/multiProjectRpcServer.test.ts` around lines 225 - 233,
Update the CTO-only action matrix loop in multiProjectRpcServer.test.ts to
include "pollLogin" alongside "pollDeviceLogin", ensuring the loopback polling
action receives the same authorization coverage as the other credential-bearing
actions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/account-directory/src/deviceAuthorization.ts`:
- Around line 226-253: Update checkDeviceRateLimit to replace the separate
select and subsequent insert/update operations with one conditional UPSERT that
resets expired windows, increments active-window attempts only below
maxAttempts, and leaves exhausted rows unchanged. Determine whether admission
succeeded from the UPSERT result’s meta.changes value, returning true only when
a row was inserted or updated.

In `@apps/account-directory/test/directory.test.ts`:
- Around line 129-133: Update the fake D1 query handling in the test database
class so machine deletion returns the number of rows actually removed, including
0 when no row matches both user_id and machine_key. In the generic expiration
branch, only mutate rows whose status is pending or approved, matching
production WHERE semantics; preserve unchanged rows and report the actual change
count.

In `@apps/ade-cli/src/cli.ts`:
- Around line 3455-3459: Update the account polling branch in the action
dispatch logic to accept the positional form only when argsList contains exactly
one string session ID. Ensure inputs with additional positional arguments fall
through to CliUsageError instead of silently discarding trailing values, while
preserving the empty-argument and valid single-session-ID behaviors.
- Around line 17753-17754: Update the authentication selection logic so
args.explicitHeadless is checked before env.ADE_ACCOUNT_TOKEN, ensuring ade
login --headless always selects the device flow even when a token is present or
expired. Preserve the existing env-token behavior for non-headless requests, and
add a regression test covering a token combined with explicit headless mode.
- Around line 17863-17867: Update the timedOut helper in the account sign-in
flow to inspect the result of runAccountAction("status") before returning
failure. If the status indicates the user is signed in, return the formatted
output with exitCode 0 and preserve the active session; otherwise retain the
timeout message, exitCode 1, and existing cancellation behavior.

In `@apps/ade-cli/src/services/account/accountAuthService.ts`:
- Around line 868-872: Update both bridge fetch calls in the account
authentication flow, including the device-code request near fetchImpl and the
polling request, to use a bounded AbortSignal timeout. Catch timeout failures
and convert them into actionable errors; when polling times out, preserve the
existing session so callers can retry. Verify the behavior through both headless
login and the desktop socket-backed ADE RPC path.
- Around line 942-970: Update the non-OK response handling in the device-session
polling flow to retain pendingDeviceSessions for retryable bridge failures,
including HTTP 429 and 5xx responses. Move deletion out of the unconditional
path and perform it only for terminal OAuth outcomes such as
expired/expired_token and invalid_grant, while preserving the existing pending
and slow_down behavior.
- Around line 563-572: Update resetEnvSessionIfCredentialChanged and the
environment refresh flow so credential rotation invalidates prior refresh
results without allowing their promise or finally handler to modify current
state. Capture a credential generation and refresh-promise identity when
starting each refresh, and commit envSession/envRefreshToken or clear
envRefreshInFlight only when both still match. Add a test covering
ADE_ACCOUNT_TOKEN changing during an in-flight refresh and verify stale
credentials are never returned.

In `@apps/desktop/src/main/services/adeActions/registry.ts`:
- Around line 139-148: Add the account status action to ADE_ACTION_CTO_ONLY so
the existing full status response cannot be called by non-CTO callers; update
the CTO-only allowlist alongside the account action definitions, preserving the
current status implementation and authorization flow.

---

Nitpick comments:
In `@apps/ade-cli/src/multiProjectRpcServer.test.ts`:
- Around line 225-233: Update the CTO-only action matrix loop in
multiProjectRpcServer.test.ts to include "pollLogin" alongside
"pollDeviceLogin", ensuring the loopback polling action receives the same
authorization coverage as the other credential-bearing actions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2572f2ad-8b0b-4cf6-a03a-b9f5b35d0f96

📥 Commits

Reviewing files that changed from the base of the PR and between 0c93b5a and 016fe0d.

⛔ Files ignored due to path filters (2)
  • docs/ARCHITECTURE.md is excluded by !docs/**
  • docs/features/agents/README.md is excluded by !docs/**
📒 Files selected for processing (17)
  • apps/account-directory/README.md
  • apps/account-directory/migrations/0002_device_authorization.sql
  • apps/account-directory/src/deviceAuthorization.ts
  • apps/account-directory/src/directory.ts
  • apps/account-directory/src/index.ts
  • apps/account-directory/test/directory.test.ts
  • apps/account-directory/wrangler.jsonc
  • apps/ade-cli/README.md
  • apps/ade-cli/src/cli.test.ts
  • apps/ade-cli/src/cli.ts
  • apps/ade-cli/src/multiProjectRpcServer.test.ts
  • apps/ade-cli/src/multiProjectRpcServer.ts
  • apps/ade-cli/src/services/account/accountAuthService.test.ts
  • apps/ade-cli/src/services/account/accountAuthService.ts
  • apps/ade-cli/src/services/account/sharedAccountAuthService.ts
  • apps/desktop/src/main/services/adeActions/registry.test.ts
  • apps/desktop/src/main/services/adeActions/registry.ts

Comment thread apps/account-directory/src/deviceAuthorization.ts
Comment thread apps/account-directory/test/directory.test.ts
Comment thread apps/ade-cli/src/cli.ts Outdated
Comment thread apps/ade-cli/src/cli.ts Outdated
Comment thread apps/ade-cli/src/cli.ts Outdated
Comment thread apps/ade-cli/src/services/account/accountAuthService.ts
Comment thread apps/ade-cli/src/services/account/accountAuthService.ts Outdated
Comment thread apps/ade-cli/src/services/account/accountAuthService.ts
Comment thread apps/desktop/src/main/services/adeActions/registry.ts
@arul28

arul28 commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 85f5408c4e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/main/services/adeActions/registry.ts Outdated
@arul28

arul28 commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/ade-cli/src/cli.test.ts`:
- Around line 3001-3016: Update the test around runCli and the mocked
stderrWrite spy to inspect all data written to stderr and assert it does not
contain either credential secret. Keep the existing result and request
assertions unchanged, and ensure the assertion covers the captured stderr output
rather than only result serialization.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 61f278de-af99-4879-84c4-26338686b30e

📥 Commits

Reviewing files that changed from the base of the PR and between 016fe0d and 7b6ea0c.

📒 Files selected for processing (12)
  • apps/account-directory/src/deviceAuthorization.ts
  • apps/account-directory/test/directory.test.ts
  • apps/ade-cli/src/adeRpcServer.test.ts
  • apps/ade-cli/src/adeRpcServer.ts
  • apps/ade-cli/src/cli.test.ts
  • apps/ade-cli/src/cli.ts
  • apps/ade-cli/src/multiProjectRpcServer.test.ts
  • apps/ade-cli/src/multiProjectRpcServer.ts
  • apps/ade-cli/src/services/account/accountAuthService.test.ts
  • apps/ade-cli/src/services/account/accountAuthService.ts
  • apps/desktop/src/main/services/adeActions/registry.test.ts
  • apps/desktop/src/main/services/adeActions/registry.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • apps/desktop/src/main/services/adeActions/registry.ts
  • apps/account-directory/test/directory.test.ts
  • apps/ade-cli/src/multiProjectRpcServer.test.ts
  • apps/desktop/src/main/services/adeActions/registry.test.ts
  • apps/ade-cli/src/cli.ts
  • apps/account-directory/src/deviceAuthorization.ts
  • apps/ade-cli/src/services/account/accountAuthService.ts

Comment thread apps/ade-cli/src/cli.test.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7b6ea0c685

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/ade-cli/src/services/account/accountAuthService.ts Outdated
Comment thread apps/ade-cli/src/cli.ts Outdated
@arul28

arul28 commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9f2baa16af

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/ade-cli/src/cli.ts Outdated
@arul28

arul28 commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3465f7eba1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/ade-cli/src/services/account/accountAuthService.ts Outdated
@arul28

arul28 commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f0984cd06

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/account-directory/src/deviceAuthorization.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/ade-cli/src/services/account/accountAuthService.ts (1)

1120-1125: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Do not discard a bridge-approved token after the local TTL elapses.

The bridge has already accepted and consumed the code when this successful response arrives. If the request crosses the local expiry boundary, this check loses the one-time token even though the server authorized it. Cancellation and sign-out remain covered by the epoch and map checks.

Proposed fix
     if (
       authEpoch !== epochAtPoll
-      || pendingDeviceSessions.get(normalizedSessionId) !== session
-      || session.expiresAtMs <= now()
+      || pendingDeviceSessions.get(normalizedSessionId) !== session
     ) {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/ade-cli/src/services/account/accountAuthService.ts` around lines 1120 -
1125, Update the success-response guard around pendingDeviceSessions so
session.expiresAtMs <= now() no longer causes an already bridge-approved token
to be discarded. Keep the authEpoch and pendingDeviceSessions map identity
checks unchanged to preserve cancellation and sign-out handling, and remove only
the local TTL condition from this post-authorization path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/ade-cli/src/cli.test.ts`:
- Around line 3131-3137: Add a separate headless login test around the existing
runCli call that omits --socket and uses a socketless environment, ensuring no
machine-brain socket exists. Assert that device login starts successfully, while
retaining the current socket-backed coverage to verify both headless mode and
desktop ADE RPC behavior.
- Around line 2902-2919: Update the token creation test around the tokenResult
assertion to verify that the --text output contains the durable credential, not
only a successful exit code. Assert the returned stdout or rendered text
includes the token value while preserving the existing account.call request
assertion.

In `@apps/ade-cli/src/services/account/accountAuthService.ts`:
- Around line 1003-1006: Update the device-token polling flow around the visible
authEpoch/requestDeviceBridge logic to maintain an in-flight polling promise
keyed by device session, returning the existing promise for concurrent polls and
clearing it when the poll settles. Ensure only one request can redeem a
session’s one-time code, preserve session identity validation, and add a
Promise.all regression test where a successful response races a terminal
response.

---

Outside diff comments:
In `@apps/ade-cli/src/services/account/accountAuthService.ts`:
- Around line 1120-1125: Update the success-response guard around
pendingDeviceSessions so session.expiresAtMs <= now() no longer causes an
already bridge-approved token to be discarded. Keep the authEpoch and
pendingDeviceSessions map identity checks unchanged to preserve cancellation and
sign-out handling, and remove only the local TTL condition from this
post-authorization path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 14408bd8-25ac-4863-ba51-21aaea97b2df

📥 Commits

Reviewing files that changed from the base of the PR and between 016fe0d and 2f0984c.

📒 Files selected for processing (12)
  • apps/account-directory/src/deviceAuthorization.ts
  • apps/account-directory/test/directory.test.ts
  • apps/ade-cli/src/adeRpcServer.test.ts
  • apps/ade-cli/src/adeRpcServer.ts
  • apps/ade-cli/src/cli.test.ts
  • apps/ade-cli/src/cli.ts
  • apps/ade-cli/src/multiProjectRpcServer.test.ts
  • apps/ade-cli/src/multiProjectRpcServer.ts
  • apps/ade-cli/src/services/account/accountAuthService.test.ts
  • apps/ade-cli/src/services/account/accountAuthService.ts
  • apps/desktop/src/main/services/adeActions/registry.test.ts
  • apps/desktop/src/main/services/adeActions/registry.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • apps/ade-cli/src/adeRpcServer.test.ts
  • apps/desktop/src/main/services/adeActions/registry.ts
  • apps/account-directory/test/directory.test.ts
  • apps/account-directory/src/deviceAuthorization.ts
  • apps/ade-cli/src/cli.ts

Comment thread apps/ade-cli/src/cli.test.ts
Comment thread apps/ade-cli/src/cli.test.ts
Comment thread apps/ade-cli/src/services/account/accountAuthService.ts
@arul28

arul28 commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de67f1cad8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/main/services/adeActions/registry.ts
@arul28

arul28 commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d179fe2b6a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/ade-cli/src/services/account/accountAuthService.ts
@arul28

arul28 commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f9a9e00021

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/ade-cli/src/cli.ts
@arul28

arul28 commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 95409b81f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/account-directory/src/deviceAuthorization.ts
@arul28

arul28 commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 8ef56032aa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@arul28
arul28 merged commit 12a3aca into main Jul 15, 2026
32 checks passed
@arul28
arul28 deleted the ade/accounts-headless-login-59857fcb branch July 15, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant