fix(chat): open drive file links instead of collapsing to /chat/naas_abi#1073
Open
Dr0p42 wants to merge 2 commits into
Open
fix(chat): open drive file links instead of collapsing to /chat/naas_abi#1073Dr0p42 wants to merge 2 commits into
Dr0p42 wants to merge 2 commits into
Conversation
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).
Deploying abi-docs with
|
| 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 |
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Opening a drive-file link such as:
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 inchat-interface.tsxthenrouter.replaces the URL to/chat/naas_abi, dropping the rest of the path. Because every drive path starts withnaas_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
drive-file-redirect.tsx: a small client component that maps the object path to{ source, path, previewPath }and calls the files store'ssetStarredNavigation— the exact mechanism the sidebar's starred-file click uses — then redirects to the Files page.chat/[[...slug]]/page.tsx, whenslug[0] === "naas_abi", render the redirect instead of the chat interface. All other slugs are unchanged.Drive-segment → source mapping:
platform-drive→platform-drive,my-drive→my-drive,workspace-drive→workspace, 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
files/page.tsxconsumes.next build/typecheck was not run locally (nonode_modulesin this checkout); please confirm on the dev env after deploy.