CL-6463: Fix connect-github card never flipping to connected on its own submit - #205
Merged
Merged
Conversation
The container currently has no wiring that can flip it to connected as a consequence of its own successful PAT submit: it fetches state once on mount, then only folds `subscribeConnectState` updates a host chooses to publish. These tests use a host that resolves the token submit ok but never notifies the subscription, matching real-world hosts that only re-fetch rather than fan out — proving the flip has to come from the container itself, not from trusting the host. Fixes CL-6463
A successful `submitAccessToken` was invisible to the card: the container only ever read state once on mount and otherwise folded whatever `subscribeConnectState` happened to publish, and the room's `chat.settings` event (the only thing the stream fold reacts to) is written by the later repo-review PATCH, not by the credential save. The container now runs its own `getConnectState` refetch as the direct consequence of its own submit succeeding, so the flip to connected never depends on a host also fanning the change out on its own. This is the only refetch outside the mount effect; every other update still rides the existing subscription fold. Fixes CL-6463
Merged
5 tasks
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
The owner-reported symptom: pasting a GitHub PAT into the in-room "Connect GitHub" card does nothing visible, even though Settings/Plugins shows GitHub connected and a live repro confirmed
POST /connections/github/completereturns 200 and the credential row is written.Root cause.
ConnectGithubBlockContainer(packages/chat-ui/src/blocks/connect-github-block-container.tsx) readgetConnectStateonce on mount and afterward only updated throughsubscribeConnectState's fold.connect-github-block.tsx'ssubmit()on a successful token save only closed the inline field — it never called back into the container's state or triggered any refetch. The only fold source,applyConnectGithubSettingsEvent(connect-github-stream.ts), reacts tochat.settingsevents carryingtemplate/pendingConnections/template/selectedRepos, which are written by the later, unrelated "start reviewing" PATCH — never by the PAT-submit/credential path. So a successful submit was structurally invisible to the card.Fix.
ConnectGithubBlockContainernow runs its owngetConnectStaterefetch as the direct consequence of its own submit succeeding (submitAccessTokenAndRefresh), rather than depending on any host to fan the change out throughsubscribeConnectState. This is the only refetch outside the mount effect — every other update (repo-selection, start-reviewing, skip) still rides the existing subscription fold. One path only; no legacy branch left beside it.What I verified
apps/web/src/connect-github-actions.ts: itssubmitAccessTokenalready calls a localrefresh()that fans out to the container'ssubscribeConnectStatelistener after a successful credential save. On today'smainthis specific host should already flip the card, given a working/github/stateread. I could not reproduce the reported dead-card symptom purely by code trace against this file.ConnectGithubBlockContainer's contract does not itself guarantee this — it depends entirely on whateverConnectGithubActionsimplementation a host supplies choosing to fan out on submit. The type's own doc comments (connect-github-actions.ts) even describe an alternate expectation (clearingtemplate/pendingConnectionson submit) that no implementation actually does. A container that self-sufficiently refetches after its own submit is correct regardless of host behavior, and is the fix that matches the ticket's own suggested shape ("give the container an explicit post-submit refresh that the submit path calls").bun testfor the fullpackages/chat-uipackage: 651 pass, 0 fail (including the 2 new tests below).bun run typecheckandeslint/prettierclean for the touched files.What I did not verify
ConnectGithubQueryto detect that condition. If CL-6454 lands separately, this card will need a follow-up to surface that honestly.packages/chat/src/connect-pending.ts'ssettleConnectedService, the genericconnections/pending+ "{service} is connected now — go ahead." message) is architecturally separate from this GitHub card'stemplate/pendingConnectionsmechanism and was never unified with it. This PR does not unify them — it only fixes the card's own visible-state bug. Whether the room's agent actually resumes/wakes after a GitHub PAT connect (as opposed to the card visually updating) rides on that separate, unaddressed gap.Tests
packages/chat-ui/test/connect-github-block-container.test.tsx(new): mountsConnectGithubBlockContainerdirectly against a fake host that resolves the token submitok: truebut never notifiessubscribeConnectState— this fails against the pre-fix container (proven before implementing) and passes after, since the container now drives its own state off the submit's own result.Do not merge — reporting for peer review per the fix-lane process.