fix(web): let web clients open chat HTML/PDF file links in the system browser #7641
Closedsaphid(GitHub profile, opens in a new tab)wants to merge 2 commits into
main fromrefs/pull/7641/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/components/ChatMarkdown.tsx line 2627Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1834,3 +1855,18 @@18341855 },18351856 [createAssetUrl, openPreview, preparedConnection, threadRef],18361857 );1858+ const openMarkdownFileInExternalBrowser = useCallback(1859+ (path: string) => {1860+ const api = readLocalApi();1861+ if (!threadRef || preparedConnection._tag === "None" || !api) {1862+ return Promise.resolve(1863+ AsyncResult.failure<void, BrowserPreviewUnavailableError>(1864+ Cause.fail(1865+ new BrowserPreviewUnavailableError({1866+ message: "Environment is not connected.",1867+ }),1868+ ),1869+ ),1870+ );1871+ }1872+ return openFileInExternalBrowser({
- apps/web/src/browser/openFileInPreview.ts lines 128 to 132OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -97,2 +112,21 @@97112 });98113 }114+115+/**116+ * Open a workspace file in the user's real browser: the system default in the117+ * desktop app, a new tab in the web client. Workspace-file asset URLs carry118+ * their own signed token, so the target browser needs no T3 session — the URL119+ * works wherever the client's own connection to the environment works.120+ */121+export async function openFileInExternalBrowser<AssetError>(input: {122+ readonly threadRef: ScopedThreadRef;123+ readonly filePath: string;124+ readonly httpBaseUrl: string;125+ readonly createAssetUrl: CreateAssetUrl<AssetError>;126+ readonly openExternal: (url: string) => Promise<void>;127+}): Promise<AtomCommandResult<void, AssetError>> {128+ const assetUrl = await createWorkspaceFileAssetUrl(input);129+ if (assetUrl._tag === "Failure") {130+ return AsyncResult.failure(assetUrl.cause);131+ }132+ await input.openExternal(assetUrl.value);
- apps/web/src/browser/openFileInPreview.ts line 133OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -98 +113,21 @@98113 }114+115+/**116+ * Open a workspace file in the user's real browser: the system default in the117+ * desktop app, a new tab in the web client. Workspace-file asset URLs carry118+ * their own signed token, so the target browser needs no T3 session — the URL119+ * works wherever the client's own connection to the environment works.120+ */121+export async function openFileInExternalBrowser<AssetError>(input: {122+ readonly threadRef: ScopedThreadRef;123+ readonly filePath: string;124+ readonly httpBaseUrl: string;125+ readonly createAssetUrl: CreateAssetUrl<AssetError>;126+ readonly openExternal: (url: string) => Promise<void>;127+}): Promise<AtomCommandResult<void, AssetError>> {128+ const assetUrl = await createWorkspaceFileAssetUrl(input);129+ if (assetUrl._tag === "Failure") {130+ return AsyncResult.failure(assetUrl.cause);131+ }132+ await input.openExternal(assetUrl.value);133+ return AsyncResult.success(undefined);
- apps/web/src/browser/openFileInPreview.ts line 199Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -138,2 +177,21 @@138177 });139178 }179+180+/** Opens a browser document in a new system browser tab (web) or the default browser (desktop). */181+export async function openFileInExternalBrowser<AssetError>(input: {182+ readonly threadRef: ScopedThreadRef;183+ readonly filePath: string;184+ readonly workspaceRoot: string | undefined;185+ readonly httpBaseUrl: string;186+ readonly createAssetUrl: CreateAssetUrl<AssetError>;187+ /** Runs before the first await so a web click can reserve its tab synchronously. */188+ readonly beginOpen: () => ExternalFileOpenSession;189+}): Promise<AtomCommandResult<void, AssetError>> {190+ const session = input.beginOpen();191+ try {192+ const assetUrl = await createFileAssetUrl(input);193+ if (assetUrl._tag === "Failure") {194+ session.cancel();195+ return AsyncResult.failure(assetUrl.cause);196+ }197+ await session.open(assetUrl.value);
- apps/web/src/components/ChatMarkdown.tsx line 2637Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -2437,2 +2460,21 @@24372460 [createAssetUrl, cwd, openPreview, preparedConnection, threadRef],24382461 );2462+ const openMarkdownFileInExternalBrowser = useCallback(2463+ (path: string) => {2464+ const api = readLocalApi();2465+ if (!threadRef || preparedConnection._tag === "None" || !api) {2466+ return Promise.resolve(2467+ AsyncResult.failure<void, BrowserPreviewUnavailableError>(2468+ Cause.fail(2469+ new BrowserPreviewUnavailableError({2470+ message: "Environment is not connected.",2471+ }),2472+ ),2473+ ),2474+ );2475+ }2476+ return openFileInExternalBrowser({2477+ threadRef,2478+ filePath: path,2479+ workspaceRoot: cwd,2480+ httpBaseUrl: preparedConnection.value.httpBaseUrl,
juliusmarminge closed this
saphid(GitHub profile, opens in a new tab) changed the title
Sign in to join this conversation.












Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
Note
Reviews paused#
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
15fc55e0-115c-47a1-bd73-f6f7ed3dd797📥 Commits
Reviewing files that changed from the base of the PR and between 4edd1ff22c7744c2df9617c5ab833fa1f7479a45 and e408dc97d72c82571ea75bffe26aebba0aa9153d.
📒 Files selected for processing (1)
apps/web/src/components/ChatMarkdown.tsxIncluded review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
📝 Walkthrough
Walkthrough#
The PR adds system-browser opening for browser-previewable files. It supports desktop-shell delegation and web-tab navigation. It extracts signed URL creation, selects the asset scope, and cancels failed opens.
Changes#
Markdown file opening
apps/web/src/browser/openFileInPreview.ts,apps/web/src/browser/openFileInPreview.test.tsapps/web/src/browser/openFileInPreview.ts,apps/web/src/browser/openFileInPreview.test.tsworkspace-fileormedia-file, opens the resolved URL, and cancels reserved targets on failure.apps/web/src/components/ChatMarkdown.tsxPriority: ⬇️ Low
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Feature
Sequence Diagram(s)#
Suggested reviewers:
juliusmarminge,t3dotggMerge Risk: 🟡 Moderate · up to
e408dOpening a file through a non-loopback HTTP connection can expose its signed URL in transit. Restrict that path to encrypted transport or explicitly accept the risk before merging.
🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)#
✅ Passed checks (3 passed)
Full details: Description check
Explanation
The description clearly explains the problem, implementation, scope, overlap, and test results. However, it does not provide explicit maintainer approval or a triaged issue reference, and it states that current UI screenshots and interaction video are still missing.
Resolution
Add the required issue or discussion link with explicit maintainer approval. Add current before/after screenshots and an interaction recording for the new submenu, popup activation, remote file loading, and Electron OS launch, or document why each item is not required.
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.