Skip to content

CLI: new feature: add collapsible notebooks functionality - #12718

Merged
laurent22 merged 7 commits into
laurent22:devfrom
miguelammatos:dev
Aug 18, 2025
Merged

laurent22 merged 7 commits into
laurent22:devfrom
miguelammatos:dev

Conversation

@miguelammatos

Copy link
Copy Markdown
Contributor
  • Allows to collapse notebooks with nested notebooks
  • Visual indicator for collapsed [+] and expanded [-] notebooks
  • Collapse states persistent across restarts (cli.folderCollapseState setting)
  • Keyboard shortcut 'z' toggles between collase/expand

Partially resolves #6475

collapsed2 collapsed1

- Allows to collapse notebooks with nested notebooks
- Visual indicator for collapsed [+] and expanded [-] notebooks
- Collapse states persistent across restarts (cli.folderCollapseState setting)
- Keyboard shortcut 'z' toggles between collase/expand

(partially addresses laurent22#6475)
@github-actions

github-actions Bot commented Jul 15, 2025 •

Copy link
Copy Markdown
Contributor

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@laurent22 laurent22 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thank you for implementing this! I've left a few comments below


export default class FolderListWidget extends ListWidget {
// Service for managing folder collapse states
class FolderCollapseService {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

What is the need for this service? Presumably it shouldn't need to manage any state since everything is saved/loaded from the settings? Settings already handle caching so it's fast to read/write from them

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Indeed, I cleaned this up while preserving the functionality

const folderIds = Array.from(this.collapsedFolders_);
Setting.setValue('cli.folderCollapseState', JSON.stringify(folderIds));
} catch (error) {
// Silently ignore save errors

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please don't ignore errors - our philosophy is to let things crash if there's an error. It's much easier to manage over the long term since there will be less hidden errors

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok.

}
} catch (error) {
// If there's an error loading, start with empty state
this.collapsedFolders_ = new Set();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Likewise, please don't catch the error. Not being able to read the settings is a critical error that needs to be fixed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok.

isGlobal: true,
},

'cli.folderCollapseState': {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We already have the setting collapsedFolderIds, please use this. Maybe you can also reuse some of the existing logic?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agree for reusing the logic.
As for using the same setting this would mean that the setting would be common across the desktop and cli right?
Is this what users would expect?
I don't have a strong opinion, most of the time I've everything collapsed anyway.

@miguelammatos

Copy link
Copy Markdown
Contributor Author

Any comments on the newer changes?

@mrjo118

mrjo118 commented Aug 5, 2025

Copy link
Copy Markdown
Collaborator

@miguelammatos FYI you need to sign the CLA, as per the comment from the bot

Comment on lines +56 to +58
Setting.value('showNoteCounts') &&
!item.deleted_time &&
item.id !== getTrashFolderId()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Put on one line please

Comment on lines +264 to +268
if (
item &&
item.type_ === Folder.modelType() &&
this.folderHasChildren_(this.folders, item.id)
) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

On one line please - there's a strange mix of tabs and spaces

isGlobal: true,
},


Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please remove the whitespace change

@laurent22

Copy link
Copy Markdown
Owner

@miguelammatos, that looks good but indeed please sign the CLA. If you need information on how to do this let us know. Also please check the few comments I left

@laurent22

Copy link
Copy Markdown
Owner

Just checking if you're ok with signing the CLA? I'll leave the PR open two more days and then will assume you're not interested anymore and will close it

@miguelammatos

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Aug 10, 2025
@miguelammatos

Copy link
Copy Markdown
Contributor Author

Fixed the remaining issues and signed the CLA.

@miguelammatos
miguelammatos marked this pull request as ready for review August 10, 2025 23:33
@mrjo118

mrjo118 commented Aug 12, 2025 •

Copy link
Copy Markdown
Collaborator

I'll leave the PR open two more days and then will assume you're not interested anymore and will close it

That was quite a short time-span for saying this since the last comments you left which had not been replied to. Was that a bluff? It seemed to work invoking a speedy response anyhow 😆

@laurent22

Copy link
Copy Markdown
Owner

No, not a bluff. I'm drowning in PR reviews so I need to clear the backlog. So if someone is not able to complete their PR, as it often happens, I need to close it. I appreciate that Miguel was able to complete it as it's definitely a good change

@miguelammatos

Copy link
Copy Markdown
Contributor Author

I was busy in the past few days hence the delay, apologies. All seems to be in order right?

@laurent22
laurent22 merged commit ae6b57c into laurent22:dev Aug 18, 2025
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.

Add notebook collapsing/expanding to CLI/Terminal app

3 participants