feat(github): add GET_PREVIEW_DEPLOYMENT tool for deployment-based previews - #535
Merged
Conversation
…eviews Some hosts (VTEX FastStore WebOps) publish a PR's preview URL only as a GitHub Deployment's deployment_status.environment_url — not as a commit-status target_url and not as a bot comment. The upstream pull_request_read has no deployments method, so those previews are invisible to consumers like the Studio PR panel. Add a first-party GET_PREVIEW_DEPLOYMENT tool mirroring GET_CHECK_RUN: it reads the REST Deployments API with the caller's own token, scans a commit's deployments newest-first, and returns the newest successful status's environment_url (or null while a deploy is in-flight). Same segment validation, header, and error-mapping shape as check-run.ts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…l note Review follow-ups on GET_PREVIEW_DEPLOYMENT: - Scan candidate deployments' statuses concurrently (bounded by the slice) instead of a serial loop, so the in-flight case (deployments exist, none successful yet — exactly what this targets) costs one round-trip; a single deployment's status read failing now drops only that deployment, not the whole scan. Test added for that resilience. - Document that environmentUrl is untrusted (set by the deployer, not host-validated here) in the tool description and output schema, so a direct agent caller doesn't treat it as a safe-to-navigate URL. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
guitavano
added a commit
to decocms/studio
that referenced
this pull request
Aug 13, 2026
…e) (#6033) * feat(task-board): surface deployment-based PR previews (VTEX FastStore) 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> * refactor(task-board): address review — source head sha from the stable 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> --------- 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
Alguns hosts publicam a URL de preview de uma PR só como um GitHub Deployment (
deployment_status.environment_url) — não comotarget_urlde commit-status nem como comentário de bot. O caso concreto é a VTEX FastStore WebOps: o preview (https://<hash>--<store>.preview.vtex.app) vive no deployment status destaging, e opull_request_readdo upstream não tem método de deployments. Resultado: o painel de PR do Studio não enxerga esses previews.Correção
Adiciona a tool first-party
GET_PREVIEW_DEPLOYMENT, espelhando exatamente o padrão do já-existenteGET_CHECK_RUN(que preenche outro gap do upstream lendo a REST API com o token do próprio caller):GET /repos/{owner}/{repo}/deployments?sha=+/deployments/{id}/statuses) comenv.MESH_REQUEST_CONTEXT.authorization.environment_urldo statussuccessmais recente.environmentUrl: null(não erro) quando há deployment mas nenhum publicou url ainda (deploy em andamento).environment(ex.:staging).check-run.ts;shavalidado como hex 7–40.Registrada em
github/server/tools/index.ts.Testes
github/server/lib/deployment.test.ts— 12 casos (sucesso, skip até o próximo deployment, in-flight → empty, sem deployments → empty, filtro de environment, encode de segmentos, rejeição de path-injection em owner/repo/sha, token ausente, 403/404/5xx, body ilegível).bun testverde.tsc --noEmit: sem novos erros (os existentes são donode_modules/@decocms/runtime, pré-existentes).Próximo passo (outro repo)
PR companheiro no Studio (
decocms/studio) liga essa tool como terceiro fallback depreviewUrlemapps/api/src/tools/task-board/prs-get.ts, depois de commit-status e comentários. O host.preview.vtex.appjá está no allow-listisTrustedPreviewHost.🤖 Generated with Claude Code
Summary by cubic
Adds a first-party GET_PREVIEW_DEPLOYMENT tool to resolve a commit’s preview URL from GitHub Deployments, enabling previews that are published only as deployment-status environment_url. It scans candidate deployments’ statuses in parallel and surfaces environmentUrl as untrusted output.
Rollout
Written for commit a005f66. Summary will update on new commits.