Skip to content

feat(web/config): consolidate HEVC + AV1 into a single Codec Strategy#645

Merged
qiin2333 merged 3 commits into
masterfrom
feat/codec-strategy-ui
May 12, 2026
Merged

feat(web/config): consolidate HEVC + AV1 into a single Codec Strategy#645
qiin2333 merged 3 commits into
masterfrom
feat/codec-strategy-ui

Conversation

@qiin2333
Copy link
Copy Markdown
Collaborator

@qiin2333 qiin2333 commented May 12, 2026

背景

Advanced 设置里原本有两个独立下拉「HEVC Support」和「AV1 Support」,每个 4 档(auto/off/Main 8-bit/Main+Main10),分别写入 hevc_mode / av1_mode

普通用户面对这两个相互独立、又必须保持一致的数字档位很容易蒙:到底选哪个?要不要勾 HDR?两边要不要一致?我们自己也觉得这一块 UX 很差。

改动

把这两个下拉合并成一个 Codec Strategy 选项 + 一个 Enable HDR (Main 10) 复选框:

策略 hevc_mode av1_mode 适用场景
Auto (recommended) 0 0 让编码器能力决定,绝大多数用户的默认
Modern (HEVC + AV1) 2 或 3 2 或 3 主动通告现代编解码;HDR 复选框控制 8-bit/10-bit
H.264 only 1 1 强制客户端回退 H.264(兼容老设备/老驱动)
Custom (保留原值) (保留原值) 仅当当前组合不匹配任一预设时显示,开放折叠区让高级用户单独调

折叠的 "Show advanced" 区里仍保留原来的两个 HEVC/AV1 下拉,所以每一个原档位都还能直接配。

实现细节

  • 纯前端:hevc_mode / av1_mode 的语义和取值范围完全不变,老配置文件继续可读。
  • Vue 3 computed({ get, set }) 双向绑定:codecStrategyenableHdr 派生自 hevc_mode + av1_mode,set 时同步写两个字段。
  • 如果保存的组合偏离推荐值,会显示一条 alert 警告并允许直接展开高级面板。
  • HDR 复选框只在 modern 预设下可写;其他预设下读出当前 mode 的 HDR 状态但置灰。
  • 5 份 locale 同步增补:zhzh_TWenen_USen_GB

不影响

  • hevc_mode / av1_mode 的 backend 处理(config.cpp、stream 协商)零改动。
  • 其它 Advanced 设置项原样保留。

Summary by CodeRabbit

发布说明

  • 新功能

    • 编解码器配置界面现采用统一的策略选择器(自动/现代/仅H.264/自定义),替代独立的HEVC和AV1选项。
    • 新增HDR启用/禁用切换开关。
    • 添加可折叠的高级选项面板,用于手动调整编解码器设置。
  • 本地化

    • 添加中文、英文(英国/美国)等多种语言的编解码器策略UI文本支持。
  • 改进

    • 优化了输入设备驱动程序管理界面。

Review Change Stack

The Advanced tab used to expose two separate dropdowns ("HEVC Support" and "AV1 Support"), each with four numeric modes mapping to hevc_mode / av1_mode (0=auto, 1=off, 2=Main 8-bit, 3=Main+Main10/HDR). Most users have no idea which combination is sane and the two settings are almost always changed together.

Replace them with a single "Codec Strategy" select driven by a Vue computed setter, which writes both hevc_mode and av1_mode in lockstep:

- auto      -> 0/0  (let encoder capabilities decide; recommended)
- modern    -> 2/2 or 3/3 depending on the new HDR checkbox
- h264_only -> 1/1  (force clients to fall back to H.264)
- custom    -> exposed only when the saved values don't match a preset, lets advanced users open the collapsible block and tweak hevc_mode / av1_mode individually

An "Enable HDR (Main 10)" checkbox is rendered next to the strategy and only writable in the modern preset; toggling it flips both modes between 2 and 3 so HDR negotiation stays consistent across HEVC and AV1.

When the saved combination deviates from the recommended preset a warning alert is shown and the original two dropdowns are exposed in a "Show advanced" collapsible region, so power users can still reach every value without leaving the tab.

No backend changes: hevc_mode / av1_mode keep the exact same semantics and value range, so existing config files continue to load unchanged.

Locales: add codec_strategy / codec_enable_hdr / codec_advanced_* keys to zh, zh_TW and the three English variants.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

📝 Walkthrough

Walkthrough

在 Advanced.vue 中新增 codecStrategy 高层选择与 HDR 控制;替换原始 HEVC/AV1 下拉为策略选择器并添加可折叠的高级面板以支持手动编辑;在多语言 locale 文件中添加对应翻译键;在 Inputs.vue 中引入通用的 createDriverManager 抽象以合并 vmouse/ViGEmBus 逻辑并调整面板布局 CSS。

变更

编码策略UI重构

层级 / 文件 摘要
编码策略状态和计算逻辑
src_assets/common/assets/web/configs/tabs/Advanced.vue
<script setup> 中添加 codecStrategy 计算属性,映射 config.hevc_modeconfig.av1_mode 至策略(auto/modern/h264_only/custom),引入 showCodecAdvanced、数值 hevcModeNum/av1ModeNumenableHdr(读取模式==3,写入仅在 modern 策略下)及 hdrToggleDisabled
编码策略选择UI和模板
src_assets/common/assets/web/configs/tabs/Advanced.vue
将原有分离的 HEVC/AV1 下拉替换为 codec_strategy <select>,添加 HDR 启用复选框(受 enableHdrhdrToggleDisabled 控制)、非默认策略警告,以及可展开的“高级选项”面板以显示原有按编解码器粒度的下拉用于手动编辑。
多语言本地化文案
src_assets/common/assets/web/public/assets/locale/en.json, en_GB.json, en_US.json, zh.json, zh_TW.json
新增 codec strategy 相关翻译键:策略选项标签、描述、非默认警告、HDR 启用与禁用提示、以及高级选项显示/隐藏标签。

Inputs 驱动管理重构

层级 / 文件 摘要
驱动管理抽象与初始化
src_assets/common/assets/web/configs/tabs/Inputs.vue
新增 createDriverManager(driverKey, initialStatus) 抽象以统一管理每个驱动的 available/status/loading/operating 状态,提供 getStatus()runOp(),并为 vmouse 与 vigem 创建 manager 实例;移除先前重复实现并在 onMounted 根据 Tauri 的 window 对象初始化可用性并调用 refresh()
面板布局样式调整
src_assets/common/assets/web/configs/tabs/Inputs.vue
更新 .vmouse-panel-body 为 flex 布局,允许换行并设置子项间距(gap)。

🎯 3 (Moderate) | ⏱️ ~20 分钟

"我是一只小兔子,代码里跳舞欢喜,
策略选择像胡萝卜,HDR 闪亮眼底,
高级面板悄悄藏,手动模式任你试,
驱动管理也变清爽,组件更整齐,
编译通过我就笑,更新合并带礼物 🐇✨"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确描述了主要变更:将HEVC和AV1的两个独立设置合并为单一的编码策略选择器。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/codec-strategy-ui

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src_assets/common/assets/web/configs/tabs/Advanced.vue`:
- Around line 221-231: The collapse toggle button lacks ARIA attributes and the
target panel lacks an id which hurts screen-reader accessibility; add a stable
id (e.g., codecAdvancedId) to the panel div that wraps the advanced options and
set the button attributes aria-controls to that id and aria-expanded bound to
the showCodecAdvanced boolean (i.e., :aria-expanded="showCodecAdvanced" and
:aria-controls="codecAdvancedId"); implement codecAdvancedId as a data/computed
property so it’s unique/stable and update the div (the element with
v-if="showCodecAdvanced") to include that id.

In `@src_assets/common/assets/web/public/assets/locale/zh.json`:
- Line 231: The value for the "codec_strategy_desc" key contains a typo
"默认跳动【自动】"; update the zh.json string for codec_strategy_desc to remove "跳动" and
use a clear phrasing such as "默认【自动】" or "默认“自动”" so the sentence reads
correctly (e.g., replace "默认跳动【自动】按编码器能力选择" with "默认【自动】按编码器能力选择").
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 15b5be5f-0230-4942-8e7e-615d97c5f5bd

📥 Commits

Reviewing files that changed from the base of the PR and between f408d55 and bd2b8eb.

📒 Files selected for processing (6)
  • src_assets/common/assets/web/configs/tabs/Advanced.vue
  • src_assets/common/assets/web/public/assets/locale/en.json
  • src_assets/common/assets/web/public/assets/locale/en_GB.json
  • src_assets/common/assets/web/public/assets/locale/en_US.json
  • src_assets/common/assets/web/public/assets/locale/zh.json
  • src_assets/common/assets/web/public/assets/locale/zh_TW.json
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Windows
🧰 Additional context used
📓 Path-based instructions (1)
src_assets/**/*.{vue,js,html}

⚙️ CodeRabbit configuration file

src_assets/**/*.{vue,js,html}: 基于 Vue.js 的 Web 配置面板。审查 XSS/CSRF 安全性、 组件设计、状态管理和可访问性。

Files:

  • src_assets/common/assets/web/configs/tabs/Advanced.vue

Comment thread src_assets/common/assets/web/configs/tabs/Advanced.vue
Comment thread src_assets/common/assets/web/public/assets/locale/zh.json Outdated
qiin2333 added 2 commits May 12, 2026 14:36
Address CodeRabbit review on PR #645:

- Advanced.vue: add aria-expanded / aria-controls to the "Show advanced" toggle button and a stable id (codec-advanced-panel) on the collapsible div, so screen readers can announce the disclosure state correctly.

- zh.json: fix typo in codec_strategy_desc ("\u9ed8\u8ba4\u8df3\u52a8\u3010\u81ea\u52a8\u3011" -> "\u9ed8\u8ba4\u3010\u81ea\u52a8\u3011") and restore the full-width comma between clauses.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src_assets/common/assets/web/configs/tabs/Inputs.vue`:
- Around line 57-95: The template still references legacy aliases (e.g.,
hasVigemDriver, vigemDotClass, hasVmouseDriver) that were removed during the
createDriverManager refactor; add small compatibility computed aliases that map
the old names to the new driver manager state (use the existing vmouse and vigem
objects and their computed labels): define hasVigemDriver =>
vigem.available.value, hasVmouseDriver => vmouse.available.value, and create
vigemDotClass and vmouseDotClass computed values that derive the same CSS/class
semantics as the template expects by consulting vigem.status.value (and
vigemStatusLabel) and vmouse.status.value (and vmouseStatusLabel); keep these
minimal shim computed bindings so the template can continue to use the original
identifiers.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dc6a55df-efda-45d1-ad83-4b1e6a4ec59e

📥 Commits

Reviewing files that changed from the base of the PR and between 40b431b and 737e57a.

📒 Files selected for processing (1)
  • src_assets/common/assets/web/configs/tabs/Inputs.vue

Comment on lines +57 to 95
// vmouse 驱动管理
const vmouse = createDriverManager('vmouseDriver', { installed: false, running: false, status_text: '' })
const installVmouse = () => vmouse.runOp('config.vmouse_confirm_install', d => d.install())
const uninstallVmouse = () => vmouse.runOp('config.vmouse_confirm_uninstall', d => d.uninstall())

const vmouseStatusLabel = computed(() => {
if (vmouseStatus.value.running) return t('config.vmouse_status_running')
if (vmouseStatus.value.installed) return t('config.vmouse_status_installed')
if (vmouse.status.value.running) return t('config.vmouse_status_running')
if (vmouse.status.value.installed) return t('config.vmouse_status_installed')
return t('config.vmouse_status_not_installed')
})

const vigemDotClass = computed(() => {
if (vigemStatus.value.running) return 'dot-active'
if (vigemStatus.value.installed) return 'dot-warning'
return 'dot-inactive'
})
// ViGEmBus 虚拟手柄驱动管理
const vigem = createDriverManager('vigemDriver',
{ installed: false, running: false, version: '', version_ok: false, status_text: '' })
const installVigem = (force = false) => vigem.runOp(
force ? 'config.vigem_confirm_reinstall' : 'config.vigem_confirm_install',
d => d.install(force)
)
const uninstallVigem = () => vigem.runOp('config.vigem_confirm_uninstall', d => d.uninstall())

const vigemStatusLabel = computed(() => {
if (!vigemStatus.value.installed) return t('config.vigem_status_not_installed')
if (!vigemStatus.value.version_ok) return t('config.vigem_status_outdated')
if (vigemStatus.value.running) {
return vigemStatus.value.version
? `${t('config.vigem_status_running')} (${vigemStatus.value.version})`
: t('config.vigem_status_running')
const s = vigem.status.value
if (!s.installed) return t('config.vigem_status_not_installed')
if (!s.version_ok) return t('config.vigem_status_outdated')
if (s.running) {
const running = t('config.vigem_status_running')
return s.version ? `${running} (${s.version})` : running
}
return t('config.vigem_status_installed')
})

onMounted(async () => {
if (!window.isTauri) return
vmouse.available.value = !!window.vmouseDriver
vigem.available.value = !!window.vigemDriver
if (vmouse.available.value) await vmouse.refresh()
if (vigem.available.value) await vigem.refresh()
})
</script>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

重构后缺少模板绑定别名,导致页面绑定失效。

createDriverManager 重构后,模板仍在使用旧标识符(如 Line 134 的 hasVigemDriver、Line 143 的 vigemDotClass、Line 367 的 hasVmouseDriver 等),但 script 未定义这些变量,会导致模板解析/运行时报错。

建议补充兼容别名(最小改动)
 // vmouse 驱动管理
 const vmouse = createDriverManager('vmouseDriver', { installed: false, running: false, status_text: '' })
 const installVmouse = () => vmouse.runOp('config.vmouse_confirm_install', d => d.install())
 const uninstallVmouse = () => vmouse.runOp('config.vmouse_confirm_uninstall', d => d.uninstall())
+const hasVmouseDriver = computed(() => vmouse.available.value)
+const vmouseStatus = computed(() => vmouse.status.value)
+const vmouseLoading = computed(() => vmouse.loading.value)
+const vmouseOperating = computed(() => vmouse.operating.value)
+const vmouseDotClass = computed(() => vmouse.dotClass.value)
+const refreshVmouseStatus = () => vmouse.refresh()

 // ViGEmBus 虚拟手柄驱动管理
 const vigem = createDriverManager('vigemDriver',
   { installed: false, running: false, version: '', version_ok: false, status_text: '' })
 const installVigem = (force = false) => vigem.runOp(
   force ? 'config.vigem_confirm_reinstall' : 'config.vigem_confirm_install',
   d => d.install(force)
 )
 const uninstallVigem = () => vigem.runOp('config.vigem_confirm_uninstall', d => d.uninstall())
+const hasVigemDriver = computed(() => vigem.available.value)
+const vigemStatus = computed(() => vigem.status.value)
+const vigemLoading = computed(() => vigem.loading.value)
+const vigemOperating = computed(() => vigem.operating.value)
+const vigemDotClass = computed(() => vigem.dotClass.value)
+const refreshVigemStatus = () => vigem.refresh()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src_assets/common/assets/web/configs/tabs/Inputs.vue` around lines 57 - 95,
The template still references legacy aliases (e.g., hasVigemDriver,
vigemDotClass, hasVmouseDriver) that were removed during the createDriverManager
refactor; add small compatibility computed aliases that map the old names to the
new driver manager state (use the existing vmouse and vigem objects and their
computed labels): define hasVigemDriver => vigem.available.value,
hasVmouseDriver => vmouse.available.value, and create vigemDotClass and
vmouseDotClass computed values that derive the same CSS/class semantics as the
template expects by consulting vigem.status.value (and vigemStatusLabel) and
vmouse.status.value (and vmouseStatusLabel); keep these minimal shim computed
bindings so the template can continue to use the original identifiers.

@qiin2333 qiin2333 merged commit 2d1e6ad into master May 12, 2026
4 checks passed
@qiin2333 qiin2333 deleted the feat/codec-strategy-ui branch May 12, 2026 07:20
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.

1 participant