-
Notifications
You must be signed in to change notification settings - Fork 203
Copy absolute path ci fix #2121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
Adds a "Copy Absolute Path" option to the JupyterLab file browser context menu, allowing users to copy the full filesystem path of files. This is useful on JupyterHub where paths need to include the complete directory structure (e.g., /joyvan/work/file.csv) for cross-directory imports. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Prevents double slashes when serverRoot ends with a trailing slash. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| // Use PathExt.join to handle trailing slashes properly | ||
| const absolutePath = serverRoot | ||
| ? PathExt.join(serverRoot, item.path) | ||
| : PathExt.join('/', item.path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would test this on Windows, where the norm is to use backward slashs. For example, C:\Users\Name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, Cursor is saying:
On Windows, absolute paths need a drive letter (e.g., C:), so this produces an invalid path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I second @ngafar for Windows you gonna need to do something specific.
fcollonval
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments.
Of note, a more robust approach requires to do a round trip to the server to get the proper path. You can look at the following extension for inspiration: https://github.com/jupyterlab-contrib/jupyterlab-fileopen
One point that would be good too would be to enable the command only if the base url domain is localhost or 127.0.0.1.
| import { Token } from '@lumino/coreutils'; | ||
|
|
||
| // The Widget Rank determins where the ChatIcon is displayed | ||
| // in the left hand toolbar | ||
| const WIDGET_RANK = 2000 | ||
|
|
||
| /** | ||
| * Initialization data for the mito-ai extension. | ||
| */ | ||
| const AiChatPlugin: JupyterFrontEndPlugin<WidgetTracker> = { | ||
| id: 'mito_ai:chat', | ||
| description: 'AI chat for JupyterLab', | ||
| autoStart: true, | ||
| requires: [ | ||
| ILabShell, | ||
| INotebookTracker, | ||
| ICommandPalette, | ||
| IRenderMimeRegistry, | ||
| IContextManager, | ||
| IStreamlitPreviewManager, | ||
| ISettingRegistry, | ||
| IDocumentManager | ||
| IDocumentManager as unknown as Token<any> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess these are noisy changes by the AI
| id: 'mito_ai:copy-absolute-path', | ||
| description: 'Add Copy Absolute Path to file browser context menu', | ||
| autoStart: true, | ||
| requires: [IFileBrowserFactory as unknown as Token<any>], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, the typing should be resolved without issue:
| requires: [IFileBrowserFactory as unknown as Token<any>], | |
| requires: [IFileBrowserFactory], |
| // Use PathExt.join to handle trailing slashes properly | ||
| const absolutePath = serverRoot | ||
| ? PathExt.join(serverRoot, item.path) | ||
| : PathExt.join('/', item.path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I second @ngafar for Windows you gonna need to do something specific.
Description
Adds a "Copy Absolute Path" option to the JupyterLab file browser context menu. This allows users to copy the full filesystem path of files, which is especially useful on JupyterHub where paths need to include the complete directory structure (e.g.,
/joyvan/work/file.csv) for cross-directory imports between different folders.Testing
Documentation
Note if any new documentation needs to addressed or reviewed.
Note
Adds a plugin and context menu command to copy absolute file paths from the JupyterLab file browser, updates AiChat DI typing, and includes required JupyterLab deps.
src/Extensions/CopyAbsolutePath/CopyAbsolutePathPlugin.tsregistersmito_ai:copy-absolute-pathto copy absolute paths usingPageConfig.serverRootand adds the command to the app.src/index.tsexports.jupyter.lab.menus.contextentry inschema/toolbar-buttons.jsonto show the command for.jp-DirListing-item.requirestoIDocumentManager as Token<any>inAiChatPlugin.ts.@jupyterlab/docmanagerand@jupyterlab/filebrowserinpackage.json.Written by Cursor Bugbot for commit 602fec8. This will update automatically on new commits. Configure here.