Repository navigation
fix: hold Connect until the preview answers, and stop calling every refusal expired - #5
Merged
Merged
Conversation
…efusal expired - Map the preview the way redeem is mapped: only a 400 is an invalid link. A 401, 403 or 404 (the API key, or an agent it doesn't own or that is gone), a 5xx, a network failure or a malformed answer is "unreachable", so the person isn't sent for a new link that fails the same way - Return why there is nothing to show (`PreviewResult`) instead of null, and have `handlePreviewRequest` answer 400 or 502 to match - Offer no Connect button until the preview has named the account, and none when it fails. Before, the button showed straight away against "Slack, Teams, or Copilot", which is the case `preview` exists to stop - Write Teams and Copilot names without an "@"; only Slack shows people as "@name" - Take the `?platform=` Agenta sends as an optional prop, for naming the app before the preview has answered, as AGENTS.md already describes - Document that only redeem reports a used link: a spent link still previews until it expires Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013TYQ7D3Pk6WDSYuhCUvtGN
- Compare ?platform= against the three surfaces instead of indexing APP_NAMES with it, so "constructor" or "toString" names all three apps rather than a function from Object.prototype - Send `platform` back through sign-in with the token, so the messages shown before the preview still name the app Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013TYQ7D3Pk6WDSYuhCUvtGN
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
previewexists to stop.previewLinkTokenreturnednullfor every non-200 answer and for network failures, andhandlePreviewRequestturned all of them into "This link has expired". That included a bad API key (401), an agent the key doesn't own (403), an agent that's gone (404), and Agenta being down. Those now come back asunreachable, and the handler answers 502, matching howredeemLinkTokenalready maps redeem. A malformed answer is alsounreachable, where beforeresponse.json()could throw.previewLinkTokenreturns why it has nothing to show (PreviewResult), notnull.@for Teams or Copilot. channel-run fillsplatformUserNamefrom Slack's display name, which Slack writes as@name, and from the Microsoft display name, which Teams and Copilot show without one.platformprop. The page takes the?platform=Agenta sends, but only to name the app before the preview has answered, never for who is connecting. It's checked against the three surfaces, so?platform=constructorcan't name a function fromObject.prototype, and it's kept through sign-in. AGENTS.md already told adopters to wire it up, but the page had no prop for it.The same in all three
This PR is one of three that make Agenta's own
/connect, its example, and Bookable's Connect page behave the same: buildagenta/app#73, buildagenta/connect-example#5, The-Bookings-Group/bookable-app#394. The behaviour follows Agenta's API and channel gateway, read from their source.@. Slack always gets one, because Agenta sends Slack's display name and Slack writes it with an@?platform=teams?platform=?platform=slack,teamsorcopilotcount (constructornames all three). Kept through sign-inapplication/jsontext/plainone can carry a body that parses as JSON. The example didn't check until buildagenta/connect-example#6; Bookable's bearer-header sign-in already stopped forms, and #394 adds the check anywayChecks
bun run check,bun run typecheckandbun testpass: 36 tests. The new preview tests fail onmain, and theconstructorandtoStringcases fail on this PR's first commit.mainAlice Smith?platform=slackOn the final commit, the same cases as Bookable's proof gave the same results as Bookable. That covers the Slack display name with
@, Teams without,?platform=teams,copilotandconstructor, a spent link (named, then "already used" on Connect), a 502 with no button, and sign-in returning to/connect?token=…&platform=teams.https://claude.ai/code/session_013TYQ7D3Pk6WDSYuhCUvtGN
Generated by Claude Code