Skip to content

feat: 更新时间着色支持搜索结果与范围开关 - #41

Merged
setube merged 5 commits into
setube:mainfrom
Aludel:feat/search-freshness
Dec 4, 2026
Merged

setube merged 5 commits into
setube:mainfrom
Aludel:feat/search-freshness

Conversation

@Aludel

@Aludel Aludel commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

背景

Closes #40

为搜索结果列表中的更新时间提供按距今远近着色的支持,便于在浏览搜索结果时直观识别存储库或条目的近期活跃度,并支持按范围独立开关。

做法

  • 范围设置(src/shared/freshness.ts、src/shared/settings.ts):新增 freshnessScopes('repository' 文件列表与最近提交、'search' 搜索结果),沿用 scope-list.ts 的校验与切换逻辑;默认两项均选中(总开关仍默认关闭),兼容已有配置。
  • 页面着色与清理(src/core/freshness.ts、src/entrypoints/content.ts):搜索结果范围匹配 [data-testid="results-list"] relative-time, .codesearch-results relative-time;单独关闭某一范围或软导航切换页面时,自动移除不再命中启用范围的元素的 data-gcn-freshness 属性,全部范围关闭时一并移除样式。
  • 设置页与多语言文案(FreshnessSection.vue、src/i18n/、README.md):在「更新时间着色」开关下方新增「范围」区块,同步简体中文、繁体中文(台湾用语:檔案清單與最近提交、搜尋結果)与英文界面文案,并更新 README.md 说明。
  • 测试:补充 shared/freshness.test.ts、shared/settings.test.ts、core/freshness.test.ts、ui/options-freshness.test.ts 单元测试。

截图

设置页(增强设置 → 更新时间着色)

浅色主题 深色主题
设置页浅色 设置页深色

搜索结果页着色效果

浅色主题 深色主题
搜索结果浅色 搜索结果深色

验证

  • bun run lint、bun run compile、bun run check:parity、bun run check:locale(含 --locale=zh-TW)、bun run test、bun run build:all 与 bun run lint:firefox 在 GitHub Actions 中均通过;
  • 加载构建产物 .output/chrome-mv3 实测设置页与搜索结果页浅色、深色主题显示与切换正常。

Sourcery 摘要

为更新时间着色功能添加搜索结果支持,并允许分别控制不同页面范围。

新功能:

  • 支持根据更新时间距今的远近,为搜索结果着色。
  • 在设置页提供两个独立的着色范围开关:文件列表与最近提交、搜索结果。

改进:

  • 切换页面或关闭某个范围后,会清除不再属于启用范围的着色;关闭所有范围时,也会移除着色样式。

文档:

  • 更新 README 中关于更新时间着色支持范围、范围开关及默认状态的说明。

测试:

  • 新增范围设置、配置兼容性、搜索结果着色清理及设置页交互的单元测试。

维护:

  • 为简体中文、繁体中文(台湾)和英文界面新增范围选项文案。
Original summary in English

Sourcery 摘要

将新鲜度着色功能扩展到搜索结果,并允许用户选择应用此功能的页面区域。

新功能:

  • 为 GitHub 搜索结果中的时间戳添加新鲜度着色。
  • 分别为仓库文件/最新提交时间戳和搜索结果时间戳添加独立设置。

错误修复:

  • 当导航或范围变更导致元素不再属于已启用的范围时,移除这些元素上的新鲜度标记和样式。

文档:

  • 更新 README,介绍搜索结果的新鲜度着色、范围控制选项及其默认状态。

测试:

  • 为新鲜度范围、设置兼容性、搜索页面标记与清理,以及选项页面控件添加单元测试覆盖。

杂项:

  • 添加简体中文、繁体中文(台湾)和英语的新鲜度范围标签。
Original summary in English

Sourcery 摘要

将新鲜度着色扩展到搜索结果,并允许用户控制应用此功能的页面。

新功能:

  • 为 GitHub 搜索结果中的时间戳添加新鲜度着色。
  • 为仓库文件列表/最新提交和搜索结果分别添加新鲜度范围控制;默认情况下,两个范围均已启用,但整体功能仍处于关闭状态。

错误修复:

  • 当导航或范围变更导致元素不再属于已启用的范围时,移除这些元素的新鲜度标记和样式。

文档:

  • 更新 README,介绍搜索结果着色、范围控制及其默认设置。

测试:

  • 增加对范围清理和设置兼容性、搜索结果标记与清理,以及选项页范围控制的测试覆盖。

杂项:

  • 添加英语、简体中文和繁体中文的新鲜度范围标签。
Original summary in English

Sourcery 摘要

将新鲜度着色功能扩展到搜索结果,并允许用户控制该功能适用的页面。

新功能:

  • 为 GitHub 搜索结果中的时间戳添加新鲜度着色。
  • 添加独立的仓库和搜索新鲜度范围设置;默认选中这两个范围,但整体功能仍处于关闭状态。

错误修复:

  • 当导航或范围变更导致元素不再属于已启用的范围时,移除这些元素的新鲜度标记和样式。

文档:

  • 更新 README,介绍搜索结果着色、范围控制及其默认状态。

测试:

  • 为范围清理、设置兼容性、新鲜度标记与清理,以及选项页中的范围控制添加单元测试覆盖。

杂项:

  • 添加英文、简体中文和繁体中文(台湾)版的新鲜度范围标签。
Original summary in English

Sourcery 摘要

扩展更新时间着色功能,使其支持搜索结果,并提供按页面范围独立控制的设置。

新功能:

  • 支持为 GitHub 搜索结果中的更新时间着色,并可独立控制搜索结果、文件列表和最近提交这三个应用范围。

错误修复:

  • 范围设置变更或通过软导航离开适用页面时,会清除不再适用的着色标记;关闭所有范围时也会移除着色样式。

文档:

  • 更新 README 和隐私说明,记录更新时间着色范围及搜索结果支持。

测试:

  • 新增针对范围设置默认值、配置兼容性、着色清理及设置页交互的单元测试。

杂项:

  • 为简体中文、繁体中文(台湾)和英文界面新增范围选项文案。
Original summary in English

Sourcery 摘要

扩展更新时间着色功能,使其支持搜索结果,并允许用户分别控制着色范围。

新功能:

  • 为 GitHub 搜索结果中的更新时间添加新鲜度着色支持。
  • 在设置页提供两个独立的着色范围选项:文件列表与最近提交、搜索结果。两项默认均选中;整体功能仍默认关闭。

错误修复:

  • 更改范围设置或通过软导航离开适用页面时,会清除不再适用的着色标记;关闭所有范围时也会移除着色样式。

文档:

  • 更新 README,说明更新时间着色的支持范围和设置页选项;并在隐私说明中列出新增的范围设置。

测试:

  • 补充单元测试,涵盖范围默认值与配置兼容性、搜索结果着色和清理,以及设置页范围开关的交互。

杂项:

  • 为简体中文、繁体中文(台湾)和英文界面新增范围选项文案。
Original summary in English

Sourcery 摘要

将新鲜度着色扩展至搜索结果,并允许用户控制其适用的页面范围。

新功能:

  • 为 GitHub 搜索结果中的更新时间添加新鲜度着色,并分别设置此功能在仓库页面和搜索结果中的适用范围;默认选中这两个范围,但整体功能仍处于关闭状态。

错误修复:

  • 当导航或范围变更导致先前标记的时间戳不再符合条件时,移除相应的新鲜度标记和样式。

文档:

  • 更新 README 和隐私文档,说明搜索结果着色功能和已保存的范围设置。

测试:

  • 增加单元测试,覆盖范围默认值与持久化、搜索结果时间戳着色与清理,以及选项页面的范围控制。

杂项:

  • 添加新鲜度范围标签的英文、简体中文和繁体中文(台湾)版本。
Original summary in English

Summary by Sourcery

Extend freshness coloring to search results and let users control which page scopes it applies to.

New Features:

  • Add freshness coloring to update timestamps in GitHub search results, with separate settings for repository pages and search results; both scopes are selected by default while the overall feature remains off.

Bug Fixes:

  • Remove freshness marks and styling when navigation or scope changes make previously marked timestamps ineligible.

Documentation:

  • Update the README and privacy documentation to describe search-result coloring and the saved scope settings.

Tests:

  • Add unit coverage for scope defaults and persistence, search timestamp coloring and cleanup, and the options-page scope controls.

Chores:

  • Add freshness-scope labels in English, Simplified Chinese, and Traditional Chinese (Taiwan).

@sourcery-ai

sourcery-ai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

审阅者指南

数据结构

定义更新时间着色的范围及默认值,并将范围纳入设置模型、校验、旧版设置兼容与同步存储。

  • src/shared/freshness.ts L1-4, L10-27
  • src/shared/settings.ts L5-12, L246-251, L258-299 (+4 small edits)

API 使用方式

将保存的范围传给着色器,并在软导航后刷新着色以匹配当前页面。

  • src/entrypoints/content.ts L368-375, L519

实现

扩展更新时间着色逻辑以识别仓库和搜索结果时间、解析搜索结果提示时间,并在范围或页面变化后清理过期标记。

  • src/core/freshness.ts L19-30, L54-103, L266-306 (+8 small edits)

用户界面

在更新时间着色设置中新增范围开关,并提供中文、繁体中文和英文标签。

  • src/entrypoints/options/FreshnessSection.vue L15-29, L159-164, L191-194 (+5 small edits)
  • src/i18n/en.ts L245-246
  • src/i18n/zh-CN.ts L243-244
  • src/i18n/zh-TW.ts L245-246

文档

更新功能说明和隐私声明,记录搜索结果支持、范围开关及范围设置的存储。

  • README.md L81, L92, L405
  • docs/PRIVACY.md L10

测试

补充范围默认值与设置兼容、搜索时间识别和清理、设置页交互及相关测试夹具覆盖。

  • tests/e2e/fixtures.ts L6, L69
  • tests/unit/core/content.test.ts L1829-1854 (+3 small edits)
  • tests/unit/core/controller.test.ts L8, L44
  • tests/unit/core/freshness.test.ts L1, L92, L195-284
  • tests/unit/core/translator-labels.test.ts L11, L660
  • tests/unit/core/turbo-bridge.test.ts L13, L1674
  • tests/unit/shared/freshness.test.ts L5, L14-15, L174-182
  • tests/unit/shared/settings.test.ts L3, L297-306, L475-514
  • tests/unit/ui/options-freshness.test.ts L235-243, L676-694
  • tests/unit/ui/options.test.ts L144-373 (5 small edits)

提示与命令

与 Sourcery 互动

  • 触发新的审阅: 在拉取请求中评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的审阅评论。
  • 根据审阅评论创建 GitHub issue: 回复审阅评论,请 Sourcery 根据该评论创建 issue。你也可以在审阅评论中回复 @sourcery-ai issue,根据该评论创建 issue。
  • 生成拉取请求标题: 在拉取请求标题的任意位置写入 @sourcery-ai,即可随时生成标题。你也可以在拉取请求中评论 @sourcery-ai title,随时(重新)生成标题。
  • 生成拉取请求摘要: 在拉取请求正文中你希望摘要出现的位置写入 @sourcery-ai summary,即可随时生成 PR 摘要。你也可以在拉取请求中评论 @sourcery-ai summary,随时(重新)生成摘要。
  • 生成审阅者指南: 在拉取请求中评论 @sourcery-ai guide,即可随时(重新)生成审阅者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已处理完所有评论且不想再看到它们,这会很有用。
  • 忽略所有 Sourcery 审阅: 在拉取请求中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审阅。如果你想从头开始进行新的审阅,这尤其有用——别忘了评论 @sourcery-ai review 以触发新的审阅!

自定义你的使用体验

访问你的控制面板,以便:

  • 启用或停用审阅功能,例如 Sourcery 生成的拉取请求摘要、审阅者指南等。
  • 更改审阅语言。
  • 添加、移除或编辑自定义审阅说明。
  • 调整其他审阅设置。

获取帮助

Original review guide in English

Reviewer's Guide

Data structures

定义更新时间着色的范围及默认值,并将范围纳入设置模型、校验、旧版设置兼容与同步存储。

  • src/shared/freshness.ts L1-4, L10-27
  • src/shared/settings.ts L5-12, L246-251, L258-299 (+4 small edits)

Uses of the API

将保存的范围传给着色器,并在软导航后刷新着色以匹配当前页面。

  • src/entrypoints/content.ts L368-375, L519

Implementation

扩展更新时间着色逻辑以识别仓库和搜索结果时间、解析搜索结果提示时间,并在范围或页面变化后清理过期标记。

  • src/core/freshness.ts L19-30, L54-103, L266-306 (+8 small edits)

UI

在更新时间着色设置中新增范围开关,并提供中文、繁体中文和英文标签。

  • src/entrypoints/options/FreshnessSection.vue L15-29, L159-164, L191-194 (+5 small edits)
  • src/i18n/en.ts L245-246
  • src/i18n/zh-CN.ts L243-244
  • src/i18n/zh-TW.ts L245-246

Documentation

更新功能说明和隐私声明,记录搜索结果支持、范围开关及范围设置的存储。

  • README.md L81, L92, L405
  • docs/PRIVACY.md L10

Tests

补充范围默认值与设置兼容、搜索时间识别和清理、设置页交互及相关测试夹具覆盖。

  • tests/e2e/fixtures.ts L6, L69
  • tests/unit/core/content.test.ts L1829-1854 (+3 small edits)
  • tests/unit/core/controller.test.ts L8, L44
  • tests/unit/core/freshness.test.ts L1, L92, L195-284
  • tests/unit/core/translator-labels.test.ts L11, L660
  • tests/unit/core/turbo-bridge.test.ts L13, L1674
  • tests/unit/shared/freshness.test.ts L5, L14-15, L174-182
  • tests/unit/shared/settings.test.ts L3, L297-306, L475-514
  • tests/unit/ui/options-freshness.test.ts L235-243, L676-694
  • tests/unit/ui/options.test.ts L144-373 (5 small edits)

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai

sourcery-ai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

关联问题

在提交 ff81908 时检查

#40 [建议] 希望能增加一个 搜索结果更新时间着色 · 1 项中有 1 项符合要求

# 需求 状态 备注
1 为搜索结果中的更新时间着色 ✅ 符合 搜索页中识别更新时间并按距今远近着色;设置页也提供了独立的搜索结果范围开关。
Original linked issues in English

Linked issues

Checked at commit ff81908

#40 [建议] 希望能增加一个 搜索结果更新时间着色 · 1 of 1 met

# Requirement Status Notes
1 为搜索结果中的更新时间着色 ✅ Met 搜索页中识别更新时间并按距今远近着色;设置页也提供了独立的搜索结果范围开关。

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

嘿——我发现了 4 个问题

Sourcery 评估

等待批准。 请先处理 3 项发现。

阻塞性发现:src/shared/settings.ts:226、src/entrypoints/options/FreshnessSection.vue:192、src/core/freshness.ts:65


Sourcery 对开源项目免费——如果您喜欢我们的评审,欢迎分享 ✨
Original comment in English

Hey - I've found 4 issues

Sourcery assessment

Approval pending. 3 findings to address first.

Blocking findings: src/shared/settings.ts:226, src/entrypoints/options/FreshnessSection.vue:192, src/core/freshness.ts:65


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/shared/settings.ts Resolved
Comment thread src/shared/settings.ts Resolved
Comment thread src/core/freshness.ts Resolved
@Aludel
Aludel force-pushed the feat/search-freshness branch from bd8181f to 81d5f9f Compare December 4, 2026 01:51
@Aludel

Aludel commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

已处理 Sourcery 评审意见:

  • docs/PRIVACY.md:已在设置项说明中补充「更新时间着色的范围」。
  • settings.ts 同步合并 & FreshnessSection.vue 并发写入:均与仓库内 autoLoadScopes、newTabScopes、bilingualScopes 的既有实现保持一致,全局存储层的跨版本/跨标签页并发控制超出本 PR 范围。
  • freshness.ts 搜索结果选择器:已将搜索范围限制在 GitHub /search 页面;搜索结果中的 <relative-time> 无区分创建/更新的稳定属性,且统一按距今远近着色本身便于判断结果的新旧活跃度,属于有意设计。

@setube
setube marked this pull request as draft December 4, 2026 07:21
@setube
setube marked this pull request as ready for review December 4, 2026 07:21

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

嘿——我发现了 4 个问题

Sourcery 评估

等待批准。 请先处理 4 项发现。

阻塞性发现:src/shared/settings.ts:226、src/core/freshness.ts:229、src/entrypoints/options/FreshnessSection.vue:192、src/core/freshness.ts:68


Sourcery 对开源项目免费——如果您喜欢我们的评审,请考虑分享 ✨
Original comment in English

Hey - I've found 4 issues

Sourcery assessment

Approval pending. 4 findings to address first.

Blocking findings: src/shared/settings.ts:226, src/core/freshness.ts:229, src/entrypoints/options/FreshnessSection.vue:192, src/core/freshness.ts:68


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/shared/settings.ts Resolved
Comment thread src/core/freshness.ts Resolved
Comment thread src/core/freshness.ts Resolved

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sourcery assessment

Approved.

@Aludel
Aludel requested a review from setube December 4, 2026 09:35
@setube
setube merged commit 58813e8 into setube:main Dec 4, 2026
7 checks passed
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.

[建议] 希望能增加一个 搜索结果更新时间着色

2 participants