Skip to content

feat: add direct sandbox workspace preview#7316

Open
c121914yu wants to merge 8 commits into
labring:mainfrom
c121914yu:feat-sandbox-preview
Open

feat: add direct sandbox workspace preview#7316
c121914yu wants to merge 8 commits into
labring:mainfrom
c121914yu:feat-sandbox-preview

Conversation

@c121914yu

@c121914yu c121914yu commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

What changed

  • Add a read-only workspace preview server to fastgpt-ide-agent and expose it through agent-sandbox-proxy at /preview/{token}/{path}.
  • Sign two-hour preview tickets in FastGPT, verify them through the existing backchannel, and resolve the matching sandbox endpoint without exposing upstream hosts to browsers.
  • Support GET, HEAD, ETag, content length/type, and single byte ranges while rejecting traversal and symlinks escaping the workspace.
  • Replace HTML preview and sandbox_get_file_url S3 uploads with direct workspace URLs so relative CSS, JavaScript, and image assets work.
  • Keep existing WebSocket claims and keepalive behavior unchanged, using a separate Preview claim contract.
  • Send proxy verification tickets through X-Sandbox-Ticket and keep preview content on the proxy origin.
  • Require a dedicated HTTP(S) AGENT_SANDBOX_PREVIEW_PROXY_URL; optionally use an independent PREVIEW_PORT.

Why

The previous flow copied generated files to S3. This added storage work and broke multi-file previews because relative assets no longer resolved against the sandbox workspace.

The new flow treats the signed preview ticket as a two-hour, read-only workspace capability and streams files directly from the running sandbox.

Impact and rollout

  • Preview links expire after two hours and grant read-only access to the ticket's workspace.
  • Absolute asset paths such as /assets/app.js are unsupported; generated previews must use relative paths.
  • Preview access refreshes sandbox activity when the proxy resolves the ticket; cached requests do not provide a persistent heartbeat.
  • Default deployments keep WebSocket and Preview traffic on the existing single proxy port, but require separate ws(s):// and http(s):// URL settings. A second listener is enabled only by explicitly setting PREVIEW_PORT.
  • FastGPT, agent-sandbox-proxy, and the sandbox runtime image must be deployed compatibly.
  • Existing editor upload/download, WebSocket terminal/fs behavior, and workspace archive paths remain unchanged.

Validation

  • Latest Service environment and Preview tests: 17 passed.
  • App TypeScript typecheck passed.
  • Rust CI passed fmt, clippy, and tests for both proxy and IDE Agent.
  • Proxy release image built successfully for linux/arm64.
  • Single-port compatibility and dual-port route isolation were verified against the local image.
  • git diff --check

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 18.4% 1632 / 8868
🔵 Statements 18.39% 1713 / 9313
🔵 Functions 16.2% 342 / 2110
🔵 Branches 15.12% 761 / 5032
File CoverageNo changed files found.
Generated in workflow #1581 for commit 9d1122e by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

Admin Preview Image Ready!

ghcr.io/labring/fastgpt-pr:admin_9d1122e19e02f38e4f0f9e8e2fee0fe1dd7a6536

🕒 Time: 2026-07-20 22:18:02 (UTC+8)

@github-actions

Copy link
Copy Markdown

Docs Preview Deployed!

🔗 👀 Click here to visit preview

ghcr.io/labring/fastgpt-docs-pr:cd498290d675add4928d4b3a2ed36f3cfdc85a6c

🕒 Time: 2026-07-16 16:27:22 (UTC+8)

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

Build Successful - Preview fastgpt Image for this PR:

ghcr.io/labring/fastgpt-pr:fastgpt_9d1122e19e02f38e4f0f9e8e2fee0fe1dd7a6536

🕒 Time: 2026-07-20 22:19:34 (UTC+8)

@c121914yu
c121914yu force-pushed the feat-sandbox-preview branch from cd49829 to b18bee0 Compare July 20, 2026 12:54
@c121914yu
c121914yu marked this pull request as ready for review July 20, 2026 13:18
Copilot AI review requested due to automatic review settings July 20, 2026 13:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants