Skip to content

fix(chat): open drive file links instead of collapsing to /chat/naas_abi#1073

Open
Dr0p42 wants to merge 2 commits into
mainfrom
fix/chat-drive-file-link-redirect
Open

fix(chat): open drive file links instead of collapsing to /chat/naas_abi#1073
Dr0p42 wants to merge 2 commits into
mainfrom
fix/chat-drive-file-link-redirect

Conversation

@Dr0p42

@Dr0p42 Dr0p42 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Problem

Opening a drive-file link such as:

/workspace/<ws>/chat/naas_abi/platform-drive/<folder>/<file>.pptx

redirects to /workspace/<ws>/chat/naas_abi, losing the file entirely.

Root cause

naas_abi/<drive>/… is a storage object path, not a conversation id. These paths get emitted as relative file links and are resolved by the browser against the current /chat/ page, landing on the chat catch-all route (chat/[[...slug]]/page.tsx).

The route treats slug[0] ("naas_abi") as a conversation id, and the URL-sync effect in chat-interface.tsx then router.replaces the URL to /chat/naas_abi, dropping the rest of the path. Because every drive path starts with naas_abi, any such link collapses to /chat/naas_abi.

There is no legitimate /chat/<object-path> route — the canonical way to open a drive file is the Files page (via the files store) or /api/files/preview/pdf/<path>.

Fix

  • Add drive-file-redirect.tsx: a small client component that maps the object path to { source, path, previewPath } and calls the files store's setStarredNavigation — the exact mechanism the sidebar's starred-file click uses — then redirects to the Files page.
  • In chat/[[...slug]]/page.tsx, when slug[0] === "naas_abi", render the redirect instead of the chat interface. All other slugs are unchanged.

Drive-segment → source mapping: platform-driveplatform-drive, my-drivemy-drive, workspace-driveworkspace, anything else → system-drive. File vs. folder is detected by whether the last segment has an extension (files open a preview; folders just navigate into the listing).

Testing

  • Verified the path-mapping logic against the reported URL and edge cases (my-drive, workspace-drive, folder links, unknown drive) — output matches what files/page.tsx consumes.
  • Full next build/typecheck was not run locally (no node_modules in this checkout); please confirm on the dev env after deploy.

Drive object paths (naas_abi/<drive>/...) are sometimes emitted as relative
file links and get resolved against the current /chat/ URL, landing on the
chat catch-all route. The route treated slug[0] ("naas_abi") as a conversation
id and the URL-sync effect rewrote the URL to /chat/naas_abi, dropping the file
path.

Detect a naas_abi/<drive>/... object path in the chat slug and redirect to the
Files page, opening the file's preview via the files store (the same navigation
the sidebar's starred-file click uses).
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploying abi-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: ed27ade
Status: ✅  Deploy successful!
Preview URL: https://87bc4738.abi-docs-76c.pages.dev
Branch Preview URL: https://fix-chat-drive-file-link-red.abi-docs-76c.pages.dev

View logs

…chat/

Bob emits drive objects as relative markdown links (naas_abi/<drive>/...).
The browser resolved them against the current /chat/ URL, landing on the chat
catch-all route and collapsing the URL to /chat/naas_abi.

Intercept drive object paths in the markdown link renderer so no /chat/ URL is
produced: a file downloads directly (same /api/files/raw endpoint, scope and
params as the Files page), a folder opens the Files page at that folder. Add a
shared drive-links helper (isDriveObjectPath / parseDriveObjectPath /
driveNavigationFor / driveScopeForSource) and reuse it from the /chat/ safety-net
redirect (DriveFileRedirect), which now only handles shared/bookmarked URLs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant