Skip to content

feat(task-board): surface deployment-based PR previews (VTEX FastStore) - #6033

Merged
guitavano merged 2 commits into
mainfrom
guitavano/lilongwe
Aug 13, 2026
Merged

feat(task-board): surface deployment-based PR previews (VTEX FastStore)#6033
guitavano merged 2 commits into
mainfrom
guitavano/lilongwe

Conversation

@guitavano

@guitavano guitavano commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

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): o target_url de 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 como environment_url de um GitHub Deployment. Resultado: PRs desses repos (ex.: agencia-e-plus/faststoretorra#70, preview em https://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_DEPLOYMENT do MCP de github (mesma conexão e mesmo cachedPrRead que o já-existente GET_CHECK_RUN).

  • extractPreviewUrlFromDeployment(obj) — lê environmentUrl do resultado da tool, passando pelo mesmo isTrustedPreviewHost das outras fontes (.preview.vtex.app já 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.
  • A varredura de deployment roda quando o preview é desconhecido pelas fontes baratas e o sha é conhecido — repos com preview de Vercel/Cloudflare/deco não pagam nada.

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 pra extractPreviewUrlFromDeployment (url confiável / in-flight null / host não-confiável) e headShaFromStatus (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 environmentUrl when no status target_url or deploy bot comment is present. Now derives the head SHA from pull_request_read’s head.sha (stable) and falls back to get_status.sha, avoiding missed previews when CI is absent or flaky.

  • Keys the lookup on a validated 7–40 char hex head SHA.
  • Uses cachedPrRead and adds the MCP tool GET_PREVIEW_DEPLOYMENT.
  • Applies isTrustedPreviewHost (FastStore .preview.vtex.app already allow-listed).
  • Threads the shared pull_request_read get into status extras to supply the head SHA; falls back to get_status.
  • Adds unit tests for extractPreviewUrlFromDeployment, headShaFromPrGet, and headShaFromStatus.

Rollout

  • Requires decocms/mcps#535 (adds GET_PREVIEW_DEPLOYMENT); deploy the MCP first.
  • If the tool is unavailable, behavior falls back to existing sources; repos with Vercel/Cloudflare/deco previews are unaffected.

Written for commit 8f31887. Summary will update on new commits.

Review in cubic

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>
@github-actions github-actions Bot added the claude PR authored by a coding agent label Aug 13, 2026
…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>
@guitavano
guitavano merged commit 5e741aa into main Aug 13, 2026
24 checks passed
@guitavano
guitavano deleted the guitavano/lilongwe branch August 13, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude PR authored by a coding agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant