Skip to content

Conversation

@Achuan-2
Copy link
Member

@Achuan-2 Achuan-2 commented Sep 10, 2025

关联:#11189

最近文档改进

  • 最近文档改为默认基于文档最近浏览时间进行排序,而不是文档第一次被加载到页签的顺序,因为一个文档可能会很久之前就加载进页签,但是最近一直翻看,结果根据目前的最近文档排序逻辑是很末尾的
  • 在搜索栏右侧添加一个下拉框,支持以下筛选排序
    • 最近浏览
    • 最近修改
    • 最近打开
    • 最近关闭
  • 支持Ctrl+Shift+T打开最近关闭的文档,并移除表格插入行/列的默认快捷键,关联Support Ctrl+Shift+T to reopen the tab #11205
PixPin_2025-09-11_12-17-00

@wish5115
Copy link

还应该有个最近打开吧,官方默认的就是这个。

@TCOTC
Copy link
Contributor

TCOTC commented Sep 11, 2025

最近浏览已经包含了最近打开吧

@Achuan-2
Copy link
Member Author

还应该有个最近打开吧,官方默认的就是这个。

个人认为按打开顺序降序展示几乎没有什么场景,VSCode只有最近浏览顺序

@Achuan-2
Copy link
Member Author

终于支持Ctrl+Shift+T打开最近关闭的文档,舒服了

@wish5115
Copy link

wish5115 commented Sep 11, 2025

最近浏览已经包含了最近打开吧

是包含了,但要分别过滤,这样更方便。

比如,a最后打开,b,c晚于a打开,但b,c最仅浏览,那么在最近浏览器里,b,c靠前,但最近打开中a靠前,不一样的。

@Achuan-2

This comment was marked as outdated.

@wish5115
Copy link

我没这个需求,不考虑了,官方要加官方加吧

好吧,还应有个最近修改,哈哈

@Achuan-2
Copy link
Member Author

最近修改加了,我之前主要用插件实现的

@Achuan-2
Copy link
Member Author

@wish5115 想了一下,还是先加上最近打开

@Achuan-2 Achuan-2 changed the title ✨ Improve Recent documents Improve Recent documents Sep 11, 2025
@88250 88250 changed the title Improve Recent documents Improve Recent documents Oct 4, 2025
@88250 88250 mentioned this pull request Oct 4, 2025
@88250 88250 added this to the backlog milestone Oct 4, 2025
@TCOTC
Copy link
Contributor

TCOTC commented Oct 8, 2025

备注:

@Vanessa219
Copy link
Member

帮助文档需要同步进行更新

@Vanessa219 Vanessa219 merged commit d9e0c56 into siyuan-note:dev Oct 24, 2025
@TCOTC
Copy link
Contributor

TCOTC commented Oct 24, 2025

@Vanessa219 还需要修改代码吗?改完 @ 我一下

@88250
Copy link
Member

88250 commented Oct 24, 2025

正在改

@Vanessa219 Vanessa219 self-assigned this Oct 24, 2025
Copy link

Copilot AI left a 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.

Comment on lines +146 to +147
const sortSelect = dialog.element.querySelector("#recentDocsSort") as HTMLSelectElement;
sortSelect.addEventListener("change", () => {
Copy link

Copilot AI Oct 24, 2025

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.

Copilot uses AI. Check for mistakes.
}
(window as any).siyuan.closedTabs.push({
id: item.model.editor.protyle.block.rootID
});
Copy link

Copilot AI Oct 24, 2025

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.

Suggested change
});
});
// 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();
}

Copilot uses AI. Check for mistakes.
Comment on lines +1538 to +1542
openFileById({
app,
id: closedTab.id,
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
});
Copy link

Copilot AI Oct 24, 2025

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.

Suggested change
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: "该文档无法重新打开,可能已被删除或移动。",
});
}

Copilot uses AI. Check for mistakes.
"wysiwyg": "WYSIWYG",
"recentViewed": "最近閲覧",
"recentOpened": "最近開いた",
"recentClosed": "最近閉じる",
Copy link

Copilot AI Oct 24, 2025

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'.

Suggested change
"recentClosed": "最近閉じる",
"recentClosed": "最近閉じた",

Copilot uses AI. Check for mistakes.
Vanessa219 added a commit that referenced this pull request Oct 24, 2025
88250 added a commit that referenced this pull request Oct 24, 2025
Vanessa219 added a commit that referenced this pull request Oct 24, 2025
Vanessa219 added a commit that referenced this pull request Oct 24, 2025
Vanessa219 added a commit that referenced this pull request Oct 24, 2025
Vanessa219 added a commit that referenced this pull request Oct 24, 2025
@TCOTC
Copy link
Contributor

TCOTC commented Oct 25, 2025

01

这里需要持久化:

video.webm

@TCOTC
Copy link
Contributor

TCOTC commented Oct 25, 2025

02

在移动端需要支持切换显示“最近浏览”和“最近修改”

image

@TCOTC
Copy link
Contributor

TCOTC commented Oct 25, 2025

03

使用了快速制卡、更换了文档图标、更换了题头图、修改了块属性……的文档没有添加到“最近修改”中,这符合预期吗?

@TCOTC
Copy link
Contributor

TCOTC commented Oct 25, 2025

04

需要支持配置最近的文档的显示数量。

Vanessa219 added a commit that referenced this pull request Oct 25, 2025
@Vanessa219
Copy link
Member

Vanessa219 commented Oct 25, 2025

@88250
Copy link
Member

88250 commented Oct 25, 2025

03 更新时间获取的是 updated 字段,制卡、给图标、题头图不会更新 updated 字段,这个就不动了,符合预期。

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants