-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Improve Recent documents
#15824
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
Improve Recent documents
#15824
Conversation
|
还应该有个最近打开吧,官方默认的就是这个。 |
|
最近浏览已经包含了最近打开吧 |
个人认为按打开顺序降序展示几乎没有什么场景,VSCode只有最近浏览顺序 |
|
终于支持Ctrl+Shift+T打开最近关闭的文档,舒服了 |
是包含了,但要分别过滤,这样更方便。 比如,a最后打开,b,c晚于a打开,但b,c最仅浏览,那么在最近浏览器里,b,c靠前,但最近打开中a靠前,不一样的。 |
This comment was marked as outdated.
This comment was marked as outdated.
好吧,还应有个最近修改,哈哈 |
|
最近修改加了,我之前主要用插件实现的 |
|
@wish5115 想了一下,还是先加上最近打开 |
|
备注:
|
|
帮助文档需要同步进行更新 |
|
@Vanessa219 还需要修改代码吗?改完 @ 我一下 |
|
正在改 |
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.
Pull Request Overview
This PR improves the Recent Documents functionality by introducing time-based tracking and sorting options. The main goal is to make recently viewed documents more accessible by changing from tab-load-order to actual view-time sorting, and providing multiple sort options for document organization.
Key Changes
- Added three timestamp fields (
viewedAt,closedAt,openAt) to track document interaction times - Implemented a dropdown in the Recent Documents dialog supporting sort by: Recently Viewed, Recently Modified, Recently Opened, and Recently Closed
- Added Ctrl+Shift+T keyboard shortcut to reopen recently closed documents, replacing table insertion shortcuts
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| kernel/model/storage.go | Added timestamp fields to RecentDoc struct and implemented update/sort functions for view/open/close times |
| kernel/api/storage.go | Added API endpoints for updating document timestamps and modified getRecentDocs to accept sort parameter |
| kernel/api/router.go | Registered new API routes for timestamp updates |
| app/src/business/openRecentDocs.ts | Implemented sort dropdown UI and SQL query for "Recently Modified" option |
| app/src/layout/Wnd.ts | Added timestamp tracking when tabs are focused/added/closed and closedTabs array management |
| app/src/editor/util.ts | Added view time update when opening files |
| app/src/mobile/editor.ts | Added view time update for mobile file opening |
| app/src/mobile/menu/getRecentDocs.ts | Updated to request viewedAt sorting |
| app/src/boot/globalEvent/keydown.ts | Implemented Ctrl+Shift+T handler to reopen closed tabs |
| app/src/constants.ts | Removed default shortcuts for table row/column insertion |
| app/appearance/langs/*.json | Added translations for new sort options in all supported languages |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| const sortSelect = dialog.element.querySelector("#recentDocsSort") as HTMLSelectElement; | ||
| sortSelect.addEventListener("change", () => { |
Copilot
AI
Oct 24, 2025
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.
The variable 'sortSelect' is referenced before it is declared. Line 125 uses 'sortSelect.value' but the element is not queried until line 146. Move the querySelector for sortSelect to before line 125 where it's first used.
| } | ||
| (window as any).siyuan.closedTabs.push({ | ||
| id: item.model.editor.protyle.block.rootID | ||
| }); |
Copilot
AI
Oct 24, 2025
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.
Consider limiting the size of the closedTabs array to prevent unbounded memory growth. Implement a maximum size (e.g., 50) and remove oldest entries when the limit is reached.
| }); | |
| }); | |
| // Limit closedTabs array size to 50 to prevent unbounded memory growth | |
| if ((window as any).siyuan.closedTabs.length > 50) { | |
| (window as any).siyuan.closedTabs.shift(); | |
| } |
| openFileById({ | ||
| app, | ||
| id: closedTab.id, | ||
| action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL] | ||
| }); |
Copilot
AI
Oct 24, 2025
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.
No error handling is provided when reopening a closed tab fails (e.g., if the document was deleted). Add error handling to notify users when a document cannot be reopened.
| openFileById({ | |
| app, | |
| id: closedTab.id, | |
| action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL] | |
| }); | |
| try { | |
| const result = openFileById({ | |
| app, | |
| id: closedTab.id, | |
| action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL] | |
| }); | |
| if (result && typeof result.then === "function") { | |
| result.catch((error: any) => { | |
| Dialog.create({ | |
| title: "无法重新打开标签", | |
| content: "该文档无法重新打开,可能已被删除或移动。", | |
| }); | |
| }); | |
| } | |
| } catch (error) { | |
| Dialog.create({ | |
| title: "无法重新打开标签", | |
| content: "该文档无法重新打开,可能已被删除或移动。", | |
| }); | |
| } |
| "wysiwyg": "WYSIWYG", | ||
| "recentViewed": "最近閲覧", | ||
| "recentOpened": "最近開いた", | ||
| "recentClosed": "最近閉じる", |
Copilot
AI
Oct 24, 2025
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.
Corrected Japanese translation from '最近閉じる' (infinitive form) to '最近閉じた' (past tense) to match the context of 'recently closed'.
| "recentClosed": "最近閉じる", | |
| "recentClosed": "最近閉じた", |
Signed-off-by: Daniel <[email protected]>
01这里需要持久化: video.webm |
03使用了快速制卡、更换了文档图标、更换了题头图、修改了块属性……的文档没有添加到“最近修改”中,这符合预期吗? |
04需要支持配置最近的文档的显示数量。
|
|
|
03 更新时间获取的是 updated 字段,制卡、给图标、题头图不会更新 updated 字段,这个就不动了,符合预期。 |

关联:#11189
最近文档改进
Ctrl+Shift+Tto reopen the tab #11205