Skip to content

Conversation

@aarondr77
Copy link
Member

@aarondr77 aarondr77 commented Dec 19, 2025

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

  • Right-click on files in the file browser and verify "Copy Absolute Path" appears in the context menu
  • Verify the menu item appears with a file icon, positioned directly below "Copy Path"
  • Click "Copy Absolute Path" and paste into a notebook to verify the correct absolute path is copied

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.

  • JupyterLab Extension:
    • New Plugin: src/Extensions/CopyAbsolutePath/CopyAbsolutePathPlugin.ts registers mito_ai:copy-absolute-path to copy absolute paths using PageConfig.serverRoot and adds the command to the app.
    • Export Wiring: Includes the plugin in src/index.ts exports.
    • Context Menu: Adds jupyter.lab.menus.context entry in schema/toolbar-buttons.json to show the command for .jp-DirListing-item.
  • AI Chat:
    • Adjusts requires to IDocumentManager as Token<any> in AiChatPlugin.ts.
  • Dependencies:
    • Adds @jupyterlab/docmanager and @jupyterlab/filebrowser in package.json.

Written by Cursor Bugbot for commit 602fec8. This will update automatically on new commits. Configure here.

aarondr77 and others added 3 commits December 19, 2025 12:34
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>
@vercel
Copy link

vercel bot commented Dec 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
monorepo Ready Ready Preview, Comment Dec 19, 2025 6:16pm

// Use PathExt.join to handle trailing slashes properly
const absolutePath = serverRoot
? PathExt.join(serverRoot, item.path)
: PathExt.join('/', item.path);
Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Collaborator

@fcollonval fcollonval left a 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.

Comment on lines 24 to 45
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>
Copy link
Collaborator

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>],
Copy link
Collaborator

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:

Suggested change
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);
Copy link
Collaborator

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.

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.

4 participants