feat(task-board): surface deployment-based PR previews (VTEX FastStore) - #6033
Merged
Conversation
The PR panel lifts a preview URL from two sources — a commit-status target_url and the deploy bot's PR comment. Some hosts publish it in neither: VTEX FastStore WebOps records the preview only as a GitHub Deployment's environment_url, so those PRs showed no preview button. Add a third, last-resort source: when neither cheap source hits, resolve the preview from the head commit's GitHub Deployments via the new github MCP GET_PREVIEW_DEPLOYMENT tool (same connection/cache as GET_CHECK_RUN). The head sha comes free from the combined-status response, and the result passes the same isTrustedPreviewHost gate — .preview.vtex.app was already allow-listed. The scan runs only when a preview is otherwise unknown, so repos with a Vercel/Cloudflare/deco preview pay nothing. Requires decocms/mcps#535 (adds GET_PREVIEW_DEPLOYMENT). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…e get.head.sha Review follow-up on the deployment-preview fallback: derive the head sha from the shared `pull_request_read get` response's head.sha (documented, present regardless of CI) instead of get_status.sha, falling back to the latter. get_status.sha was fragile — a PR with no CI, or a transient get_status failure, left headSha null and silently skipped the deployment lookup even when a deployment existed. The `get` is already fetched in the same round-trip window and is now threaded into fetchPrStatusExtras. Adds headShaFromPrGet + unit tests; TODO(e2e) note on the untested wiring. Co-Authored-By: Claude Opus 4.8 <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.
Problema
O painel de PR do task board pega o link de preview de duas fontes (
apps/api/src/tools/task-board/prs-get.ts): otarget_urlde um commit-status e o comentário do bot de deploy. Alguns hosts não publicam em nenhuma das duas — a VTEX FastStore WebOps registra o preview só comoenvironment_urlde um GitHub Deployment. Resultado: PRs desses repos (ex.:agencia-e-plus/faststoretorra#70, preview emhttps://sfj-b212cf4--torrafaststore.preview.vtex.app) ficam sem botão de preview.Correção
Adiciona uma terceira fonte, de último recurso: quando nenhuma das duas fontes baratas acha o preview, resolve pela GitHub Deployments API do commit head via a nova tool
GET_PREVIEW_DEPLOYMENTdo MCP de github (mesma conexão e mesmocachedPrReadque o já-existenteGET_CHECK_RUN).extractPreviewUrlFromDeployment(obj)— lêenvironmentUrldo resultado da tool, passando pelo mesmoisTrustedPreviewHostdas outras fontes (.preview.vtex.appjá estava no allow-list).headShaFromStatus(statusObj)— pega o sha do head de graça da resposta do combined-status (get_status); valida como hex 7–40 antes de ir pra query.Testes
apps/api/src/tools/task-board/checks-status.test.ts(lógica pura, sem I/O — o fetch e seus modos de falha são e2e): novos casos praextractPreviewUrlFromDeployment(url confiável / in-flight null / host não-confiável) eheadShaFromStatus(sha válido / ausente / não-hex / path-injection). bun test verde (43 pass); bun run check e bun run lint limpos.Dependência
Requer decocms/mcps#535 (adiciona a tool
GET_PREVIEW_DEPLOYMENT). Mergear o mcps primeiro / esperar o deploy do MCP; sem a tool, o cachedPrRead só retorna null e as duas fontes atuais seguem funcionando (degradação graciosa).🤖 Generated with Claude Code
Summary by cubic
Surfaces deployment-based PR previews by falling back to a GitHub Deployment
environmentUrlwhen no statustarget_urlor deploy bot comment is present. Now derives the head SHA frompull_request_read’shead.sha(stable) and falls back toget_status.sha, avoiding missed previews when CI is absent or flaky.cachedPrReadand adds the MCP toolGET_PREVIEW_DEPLOYMENT.isTrustedPreviewHost(FastStore.preview.vtex.appalready allow-listed).pull_request_read getinto status extras to supply the head SHA; falls back toget_status.extractPreviewUrlFromDeployment,headShaFromPrGet, andheadShaFromStatus.Rollout
decocms/mcps#535(addsGET_PREVIEW_DEPLOYMENT); deploy the MCP first.Written for commit 8f31887. Summary will update on new commits.