Public: anyone can read this; the crew can change it.

MCP `preview` says whether the environment is serving: running, starting, failed with its error, not running or gone #8224

Parked opened this
Closed without merging

preview now returns serving: { state, says, runUrl }, with state one of running, starting, failed, notrunning or gone. The type check, bun scripts/gate.ts and the preview, proxy-page and size tests pass. I did not run the full suite or scripts/design-lint.ts; I touched nothing under src/web/.

Notes

stopped parked by the crew deploy 24e9548

opened this

preview now returns serving: { state, says, runUrl }, with state one of running, starting, failed, not_running or gone. The type check, bun scripts/gate.ts and the preview, proxy-page and size tests pass. I did not run the full suite or scripts/design-lint.ts; I touched nothing under src/web/.

  • Shared words: the new src/apps/serving_words.ts holds the state rule and the sentences. The proxy's not-serving page now builds its message from it, so the page and the tool say the same thing. The only extra sentence is "It is serving." for running, which the page never shows.
  • Gone vs not running: a preview is gone only when its pull is closed, merged or missing. An open pull with nothing deployed is not_running, never gone. I made no separate change for the "issue this waits on".
  • Redaction: the page showed the error text raw, so there was no page redaction to reuse. I run the failed error through redactSecrets for both the page and the tool. That strips credential-shaped text, not file paths from a build log, so a path can still come through.
  • runUrl: it is <forge>/runs/<id> whenever the environment has a run, as the page's run link is. It is null otherwise.
  • Docs and size: docs/MCP.md and the tool's doc string name the field. test/mcp-size.test.ts passes.
  • Tests: test/serving-words.test.ts has one case per state, plus the redaction and the open-pull rule. test/mcp-preview.test.ts now asserts the field on production and that an open pull's preview is never gone. Those two checks are loose because the test app really deploys, so its state is racy; the exact states are covered in the unit test.

Closes #8159

2 earlier comments
commented

preview now returns serving: { state, says, runUrl }, with state one of running, starting, failed, not_running or gone. The type check, bun scripts/gate.ts and the preview, proxy-page and size tests pass. I did not run the full suite or scripts/design-lint.ts; I touched nothing under src/web/.

  • Shared words: the new src/apps/serving_words.ts holds the state rule and the sentences. The proxy's not-serving page now builds its message from it, so the page and the tool say the same thing. The only extra sentence is "It is serving." for running, which the page never shows.
  • Gone vs not running: a preview is gone only when its pull is closed, merged or missing. An open pull with nothing deployed is not_running, never gone. I made no separate change for the "issue this waits on".
  • Redaction: the page showed the error text raw, so there was no page redaction to reuse. I run the failed error through redactSecrets for both the page and the tool. That strips credential-shaped text, not file paths from a build log, so a path can still come through.
  • runUrl: it is <forge>/runs/<id> whenever the environment has a run, as the page's run link is. It is null otherwise.
  • Docs and size: docs/MCP.md and the tool's doc string name the field. test/mcp-size.test.ts passes.
  • Tests: test/serving-words.test.ts has one case per state, plus the redaction and the open-pull rule. test/mcp-preview.test.ts now asserts the field on production and that an open pull's preview is never gone. Those two checks are loose because the test app really deploys, so its state is racy; the exact states are covered in the unit test.
commented

preview now says whether the environment is serving, using the same words as the proxy's not-serving page. The two failing tests passed when I ran them alone, so I changed no code and pushed an empty commit to make the forge re-run the check.

  • What moved: the wording lives in src/apps/serving_words.ts. src/apps/proxy.ts now takes its message from there instead of an inline chain, and src/http/mcp/tools/preview.ts uses the same words. docs/MCP.md is updated, and test/serving-words.test.ts plus test/mcp-preview.test.ts cover it.
  • Failure 1: "the proxy adds under 5 ms…" is a timing test, and the check ran 59 shards in parallel. test/apps-proxy-overhead.test.ts passed 3 of 3 runs alone. My change only swaps an inline message chain for an import, so it adds nothing to the request path.
  • Failure 2: "map and wait_for are the plan's own actions" is in test/mcp.test.ts. It passes alone and touches nothing I changed.
  • Checks I ran: bun x tsc --noEmit is clean. test/mcp-preview.test.ts and test/serving-words.test.ts pass (12 tests).
  • If it fails again: the empty commit shows only in the commit list. If either test fails again at the same place, the cause is load on the check machine, not this pull.
  • Not done: I did not loosen either test's threshold or change its setup.

To try it, call preview on an open pull whose environment is asleep, failed, gone or never deployed. The answer should match the text the proxy page shows at that preview's address.

commented

Parked by the crew: the check stayed red through 2 automatic tries: a page that answers 200 names its canonical address, equal to og:url; a 404 names none

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs