Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix: show 0 tabs instead of undefined in workspace tooltip (#18106)#18175

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
mansichauhn wants to merge2 commits intojupyterlab:main
base:main
Choose a base branch
Loading
frommansichauhn:fix/workspaces-tooltip-18106

Conversation

@mansichauhn
Copy link

Fix: Tooltip in Workspaces Manager Shows Undefined Rather Than Number of Tabs

Closes#18106

Problem:
The workspace tooltip could display "undefined" because layout information was read without checks and passed directly into the translation function.

Solution:

  • Prefer reading 'layout-restorer:data' from workspace.metadata (canonical saved state).
  • In fetch/command paths, prefer metadata and fall back to workspace.data when necessary.
  • Use Array.isArray guard for widgets and default to 0 tabs when layout data is missing.
  • Remove unsafe casts and use proper type handling.

Files modified:

  • packages/workspaces-extension/src/sidebar.ts
  • packages/workspaces-extension/src/commands.ts

Manual verification:

  1. jlpm install && jlpm build
  2. jupyter lab --dev-mode --watch
  3. Open several tabs → hover workspace in the Workspaces sidebar.
    Tooltip now shows “N tabs” instead of “undefined”.

Screenshot: (
#18106.pdf
)

…b#18106)- Prefer reading layout from workspace.metadata (canonical saved state)- Use fallback pattern in fetch path (metadata then data)- Replace unsafe 'as any' with proper type guards- Add explicit Array.isArray() check for widgets- Fixes tooltip showing 'undefined' when layout data is missing
@jupyterlab-probot
Copy link

Thanks for making a pull request to jupyterlab!
To try out this branch onbinder, follow this link:Binder

…tibility- Add explicit return type annotation to labelTitle()- Use tryGet() helper for safe property access- Handle both object and string JSON payloads- Support multiple property naming conventions- Improve fallback chain for metadata/data/id/name- Add non-null assertions where paths are validated- Better error handling for JSON parsing- More robust type definitions using Record<string, unknown>- Fixes issuejupyterlab#18106: tooltip showing undefined instead of tab count
?.widgets?.length;
constworkspace=awaitapp.serviceManager.workspaces.fetch(workspaceId);

// Some workspace objects expose layout in metadata, others in data.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why is that?

// Prefer metadata, fall back to `.data`.
constrawLayout=
(workspaceasany)?.metadata?.['layout-restorer:data']??
(workspaceasany)?.data?.['layout-restorer:data'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We should not useany.any was the reason this bug crept in.

Comment on lines +75 to +88
// Helper: safely extract a field from rawMeta (supports string or object).
consttryGet=(obj:Record<string,unknown>|string,key:string)=>{
if(typeofobj==='string'){
returnundefined;
}
return(objasRecord<string,unknown>)[key];
};

// Candidate can be an object, or a JSON string containing layout info.
constcandidate=
tryGet(rawMeta,'layout-restorer:data')??
tryGet(rawMeta,'layout-restorer')??
tryGet(rawMeta,'layout')??
rawMeta;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We should not be guessing.

tryGet(rawMeta,'layout')??
rawMeta;

typeLayoutShape={main?:{dock?:{widgets?:unknown[]}}}|undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is a step in a good direction - we need to define the layout shape (but probably not in this package, but where it is actually being created) and import the type here.

this._workspace.metadata.id,
(this._workspace.data['layout-restorer:data']asany)?.main?.dock
?.widgets?.length,
this._workspace.metadata['last_modified']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Do you have an example of when last modified was wrong?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@krassowskikrassowskikrassowski requested changes

Requested changes must be addressed to merge this pull request.

Assignees

@mansichauhnmansichauhn

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Tooltip in workspaces manager showsundefined rather than a number of tabs

2 participants

@mansichauhn@krassowski

[8]ページ先頭

©2009-2025 Movatter.jp