Skip to content

fix(popup): return localization keys for unsupported pages - #30

Merged
setube merged 2 commits into
setube:mainfrom
Jacobinwwey:fix/page-support-reasons
Oct 17, 2026
Merged

setube merged 2 commits into
setube:mainfrom
Jacobinwwey:fix/page-support-reasons

Conversation

@Jacobinwwey

@Jacobinwwey Jacobinwwey commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

1. Context & Motivation (Context)

  • Issue: No linked issue; regression in the existing popup support check.
  • Problem: The popup reads support.reasonCode to select translated messages, but checkPageSupport() only returns a Chinese fallback string. Unsupported tabs therefore lose the expected localization key and produce three TS2339 errors.
  • Trade-offs: Add an optional reason code while retaining supported and the existing reason strings, preserving current consumers.

2. Implementation Details (Implementation)

  • Return the existing translation key for each unsupported protocol family. HTTP(S) results remain unchanged.
  • Add table-driven regression coverage for browser, extension, source, devtools, file, data/blob and unsupported protocols.
  • Note: Build-tool compatibility fixes are submitted separately; this PR changes only the page-support contract.

3. Testing Strategies (Validation)

  • node --test tests/page-support.test.mjs passes on this branch.
  • Verified HTTP(S) return values and existing fallback strings remain available.
  • Combined with the separate toolchain repair, bun run typecheck (including production extension build) and bun run lint pass on Windows x64 / Node 22.19.0.

Sourcery 摘要

通过从页面支持检查中公开稳定的原因代码,恢复对不受支持页面的本地化弹窗消息。

Bug 修复:

  • 为不受支持的页面类型返回本地化原因代码,使弹窗消息能够正确翻译,同时保留现有的回退原因。

增强:

  • 保持受支持的 HTTP(S) 结果不变,并为当前使用方保留现有的页面支持约定。

测试:

  • 添加针对不受支持协议的表驱动回归测试,并验证受支持的 HTTP(S) 行为保持不变。
Original summary in English

Sourcery 总结

通过页面支持检查返回稳定的原因代码,恢复不支持的页面的本地化弹窗消息。

Bug 修复:

  • 为不支持的页面类型提供本地化原因代码,让弹窗消息能够选择正确的译文,同时保留现有的回退原因。

增强功能:

  • 保持受支持的 HTTP(S) 页面支持检查结果不变,并继续兼容现有使用方。

测试:

  • 添加针对不支持的协议的表格驱动回归测试,并验证受支持的 HTTP(S) 行为保持不变。
Original summary in English

Summary by Sourcery

Restore localized popup messaging for unsupported pages by returning stable reason codes from page-support checks.

Bug Fixes:

  • Expose localization reason codes for unsupported page types so popup messages can select the correct translations while preserving existing fallback reasons.

Enhancements:

  • Keep supported HTTP(S) page-support results unchanged and retain compatibility with existing consumers.

Tests:

  • Add table-driven regression coverage for unsupported protocols and verify supported HTTP(S) behavior remains unchanged.

Signed-off-by: aliyun1121003339 <jacob.hxx.cn@outlook.com>
@sourcery-ai

sourcery-ai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

审查者指南

扩展页面支持契约,为每种不受支持的协议类型添加带类型的本地化原因代码,同时不更改现有的回退原因或 HTTP(S) 行为,并增加了针对性的表格驱动回归测试。

文件级变更

变更 详情 文件
为不受支持的页面支持结果添加可选的本地化原因代码,同时保留现有的支持标志和回退消息。
  • 引入带类型的联合类型,涵盖无页面、浏览器内置页面、扩展、内部页面、源代码、开发者工具、本地文件、data/blob 以及不支持的协议等情况。
  • 将每种不受支持的协议类型映射到弹出窗口使用的原因代码。
  • 保持 HTTP(S) 结果不变,并保留现有的本地化回退字符串。
src/utils/page-support.ts
为所有不受支持的页面类别及受支持的 HTTP(S) 页面添加针对本地化键的表格驱动回归测试。
  • 通过 esbuild 直接加载 TypeScript 工具,并将其作为 ESM 模块执行。
  • 验证不受支持的结果包含预期代码、false 支持状态和非空回退原因。
  • 验证 HTTP(S) 结果仍严格为 { supported: true, reason: '' }。
tests/page-support.test.mjs

提示与命令

与 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

Extends the page-support contract with typed localization reason codes for every unsupported protocol family, without changing existing fallback reasons or HTTP(S) behavior, and adds focused table-driven regression coverage.

File-Level Changes

Change Details Files
Adds optional localization reason codes to unsupported page-support results while preserving existing support flags and fallback messages.
  • Introduces a typed union covering no-page, browser built-in, extension, internal, source, devtools, local-file, data/blob, and unsupported-protocol cases.
  • Maps each unsupported protocol family to the reason code consumed by the popup.
  • Leaves HTTP(S) results unchanged and retains existing localized fallback strings.
src/utils/page-support.ts
Adds table-driven regression tests for localization keys across all unsupported page categories and supported HTTP(S) pages.
  • Loads the TypeScript utility directly through esbuild and executes it as an ESM module.
  • Verifies unsupported results include the expected code, false support status, and nonempty fallback reason.
  • Verifies HTTP(S) results remain exactly { supported: true, reason: '' }.
tests/page-support.test.mjs

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

嘿——我发现了 1 个问题

给 AI 智能体的提示
请处理此代码审查中的评论:

## 单条评论

### 评论 1
<location path="tests/page-support.test.mjs" line_range="34" />
<code_context>
   supported: boolean
   reason: string
+  reasonCode?: 'noPage' | 'browserBuiltin' | 'extensionPage' | 'about' | 'viewSource' | 'devtools' | 'localFile' | 'dataBlob' | 'unsupportedProtocol'
 }

 const getProtocol = (url: unknown): string => {
</code_context>
<issue_to_address>
**更改后的回退消息仍能通过测试**

当不受支持的情况返回非空但不正确的 `reason` 字符串时,测试 `unsupported protocols expose the localization key already consumed by the popup` 在第 33 行使用 `assert.ok(checkPageSupport(url).reason)`,因此即使将现有回退消息替换成任意其他非空字符串,测试仍会通过,无法发现回退消息发生了变化。

请针对每个不受支持的 URL 断言预期的回退 `reason` 字符串。
</issue_to_address>

Sourcery 为开源项目免费提供服务——如果您喜欢我们的审查,请考虑分享 ✨
Original comment in English

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tests/page-support.test.mjs" line_range="34" />
<code_context>
   supported: boolean
   reason: string
+  reasonCode?: 'noPage' | 'browserBuiltin' | 'extensionPage' | 'about' | 'viewSource' | 'devtools' | 'localFile' | 'dataBlob' | 'unsupportedProtocol'
 }

 const getProtocol = (url: unknown): string => {
</code_context>
<issue_to_address>
**Changed fallback messages pass**

When an unsupported case returns a nonempty but incorrect `reason` string, the test `unsupported protocols expose the localization key already consumed by the popup` uses `assert.ok(checkPageSupport(url).reason)` on line 33, so replacing an existing fallback message with any other nonempty string still passes and the test does not catch changed fallback messages.

Assert the expected fallback `reason` string for each unsupported URL.
</issue_to_address>

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

Comment thread tests/page-support.test.mjs Resolved
Signed-off-by: aliyun1121003339 <jacob.hxx.cn@outlook.com>
@setube
setube merged commit fec2ade into setube:main Oct 17, 2026
1 check passed
setube added a commit that referenced this pull request Oct 21, 2026
收录 Vue Devtools 误报修复(#34)、PR #30/#31/#32 修复和 #33 SDK,page-support.ts 按 Prettier 换行。

将版本号提升到 1.3.91。
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