Repository navigation
feat: GitHub-token heartbeat + real-CLI e2e (fixes 2 Codex /responses bugs) - #7
Merged
Merged
Conversation
Periodically (every 60s, plus once ~2s after boot) re-check whether the stored GitHub token still exchanges for a Copilot token, so an expired or revoked login surfaces within ~60s instead of only on the next failed request or a manual /status. - probeGithubAuth classifies a definitive 401/403 (→ expired) vs a transient timeout/5xx/network error (→ keep last-known-good), so a single GitHub hiccup never flips the UI to "expired". - GithubHeartbeat (supervisor-side) caches a GithubStatus via the pure, sticky nextGithubStatus reducer; exposed through a new optional `github` field on /api/status (absent until the first probe → existing consumers unaffected). - The TUI's existing 2s status poll drives a live footer badge (github ✓ / ✗ /login); /status reads the cached value (no redundant check). signed-out (no token) stays distinct from expired. Verified in-process against the real token: connected / signed-out / expired / sticky-on-transient all correct. Co-Authored-By: Claude <noreply@anthropic.com>
Boots the real control API + a real GithubHeartbeat.start() inside a Docker
(node:20) container, listens on a real port, and drives it over real HTTP
(GET /api/status) against the real GitHub API. All four states pass:
connected (real token → real Copilot token exchange, mounted read-only),
signed-out (creds removed), expired (bad token → a real GitHub 401), and
HTTP delivery of the github field.
The container's own network namespace sidesteps the host's port-7890
conflict; only the probe interval is shortened for the test, which required
making GithubHeartbeat's interval/initial-delay injectable (prod still
defaults to 60s/2s).
Adds e2e/docker/{Dockerfile,heartbeat-e2e.mjs,README.md} + .dockerignore.
Co-Authored-By: Claude <noreply@anthropic.com>
The login badge now reads "登录" and sits right after the model name (before daemon/web), making the login state the first status the eye lands on. Co-Authored-By: Claude <noreply@anthropic.com>
Row 1 now shows "github" login state and daemon; row 2 shows web search and the claude/codex client badges. Drop the model name from the footer (it still drives the model picker and chat). Revert the badge label to English. Co-Authored-By: Claude <noreply@anthropic.com>
- /status now does the live githubStatus() check first (the cached heartbeat can be up to ~60s stale after a revoke), restoring the on-demand authority that the cache-first ordering had turned into dead code. - isCopilotTokenValid delegates to probeGithubAuth — one token-exchange path. - Share SIGNED_OUT_DETAIL so /doctor and the HUD show the same "run /login" hint for the signed-out state (they had diverged). - start() is now idempotent (guard against leaking a second timer). - Comments on probeGithubAuth / nextGithubStatus now state the real limitations instead of over-promising: the transient stickiness is UNBOUNDED (a sustained non-401/403 fault never surfaces), 403 is treated as definitive despite GitHub using it for some rate-limits, and a boot-time transient leaves the badge pending/absent. Full suite green (379), build clean. Co-Authored-By: Claude <noreply@anthropic.com>
Driving the real codex CLI against the daemon surfaced two bugs that curl and
unit tests missed:
1. Tool translation 400. Codex sends `custom` (apply_patch) and `tool_search`
tools; the inbound translator forwarded every non-function tool as a bare
{type} with no name, so Copilot rejected the request with 400 "Missing
required parameter: tools[N].name" and the stream errored — surfacing to
Codex as "stream closed before response.completed". Fix: keep `custom`
tools as named tools, and allow-list only the nameless hosted tools Copilot
accepts (web_search); drop unknown nameless tools instead of forwarding a
malformed one. (tool_search is excluded — Copilot needs a deferred tool.)
2. Empty terminal events. ResponsesSSE sent output_text.done / content_part.done
/ output_item.done with empty text, so Codex completed the turn but rendered
no assistant text (it reconstructs the message from the done events, not just
the deltas). Fix: accumulate the streamed text and replay it in all three
done events, and populate response.completed.response.output.
Adds 12 hermetic in-process /responses cases (EP-27..EP-38) as fast regression
and extends wired() to forward a gateway runner.
Co-Authored-By: Claude <noreply@anthropic.com>
A true black-box e2e: the actual `claude` (Claude Code) and `codex` CLIs run inside a node:22 container against the real worker daemon, with a real GitHub token (+ optional WebIQ key) mounted read-only. Asserts codex exec round-trips /openai/responses (CODEX_OK), claude -p round-trips /anthropic (CLAUDE_OK), and claude's gateway web_search returns a grounded answer. Writes a markdown report after each run (mount -v <dir>:/out to capture it). No secrets committed: the only key in any file is the placeholder copilot-reverse-local; real creds/keys mount at runtime. Hardens .gitignore against creds.json / webiq.json / report artifacts. Adds Dockerfile.cli + cli-e2e.sh; documents both in e2e/docker/README.md and e2e/cases.md. Co-Authored-By: Claude <noreply@anthropic.com>
Merged
2 tasks done
wangcansunking
added a commit
that referenced
this pull request
Jun 29, 2026
…plate, config, banner (#15) * feat(tui): scope+model status, chat-setup confirmation, parity, report template, config, banner - #6 /status + HUD show each client's scope AND pinned model, not a bare check - #5 chat setup_claude/codex require scope+model (ask first, never assume) - #7 add recent_errors + metrics chat tools to match slash commands - #4 /report body follows the #5 template (Summary/Environment/Repro) - #3 GitHub heartbeat interval/delay now configurable via AppConfig - #1 versioned "what's new" banner, shown ~3 launches then suppressed - #2 README reflects guards, runaway reporting, scope+model, config knobs Co-Authored-By: Claude <noreply@anthropic.com> * feat(report): add #5-style issue template; banner = major changes only - .github/ISSUE_TEMPLATE/bug.yml (Summary/Environment/Repro/Diagnostics/fixes) so manual issues match the rich #5 shape; /report still auto-fills the same sections. - what's-new banner trimmed to major changes only (the freeze fix); minor polish dropped. Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two themes on this branch:
github ✓/✗ /loginbadge, so an expired/revoked login surfaces within ~60s instead of only on the next failed request or a manual/status.claudeandcodexCLIs against the real daemon. It caught (and this PR fixes) two Codex/responsesbugs that curl and unit tests missed.Heartbeat
probeGithubAuthclassifies a definitive 401/403 (→ expired) vs a transient timeout/5xx/network error (→ keep last-known-good), so a single GitHub hiccup never flips the badge to "expired".nextGithubStatusis a pure, sticky reducer.signed-out(no token) stays distinct fromexpired.githubfield on/api/status(absent until the first probe → existing consumers unaffected); the TUI's existing 2s poll drives the badge./statusdoes a live check; HUD footer restructured togithub · daemon/web · claude · codex./code-reviewfindings:/statusis authoritative again (was reading a stale cache),isCopilotTokenValiddelegates toprobeGithubAuth,/doctorshares the signed-out message,start()is idempotent. The unbounded-stickiness / 403 / boot-pending tradeoffs are documented in-code rather than half-fixed.Codex
/responsesbug fixes (found via the real codex CLI)custom(apply_patch) andtool_searchtools; the inbound translator forwarded every non-function tool as a bare{type}with no name → Copilot 400 "Missing required parameter: tools[N].name" → surfaced to Codex as "stream closed before response.completed". Fix: keepcustomtools as named tools; allow-list only the nameless hosted tools Copilot accepts (web_search); drop unknown nameless tools.ResponsesSSEsentoutput_text.done/content_part.done/output_item.donewith empty text, so Codex completed the turn but rendered nothing. Fix: replay the accumulated text in all three done events and populateresponse.completed.response.output.Tests
npm test→ 394 passed (56 files), tsc build clean. Adds: heartbeat unit tests, 12 hermetic in-process Codex/responsescases (EP-27…EP-38),probeGithubAuthcases, regression tests for both Codex fixes.e2e/docker/): the heartbeat (Dockerfile+heartbeat-e2e.mjs) and the real CLIs (Dockerfile.cli+cli-e2e.sh) — node:22, installs@anthropic-ai/claude-code+@openai/codex, mounts a real token, assertscodex exec → CODEX_OK,claude -p → CLAUDE_OK, andclaudegateway web search → a grounded answer. Writes a markdown report after each run. All passed.Security
No secrets committed — the only key in any file is the placeholder
copilot-reverse-local; the real GitHub token / WebIQ key mount at runtime via-v, and.gitignorenow guardscreds.json/webiq.json/ report artifacts.Test plan
npm testgreen;npm run buildclean.github ✓on a valid login; flips to✗ /loginwithin ~60s of revoking the token.docker build -f e2e/docker/Dockerfile.cli …then run with a mounted token → codex + claude + web-search checks all pass;report.mdwritten.codex exec) completes a turn against the daemon and renders text (regression for both/responsesfixes).🤖 Generated with Claude Code