feat: 支持子配置项收起/展开 - #308
Open
WindDrift wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Hey - 我发现了 1 个问题
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/stores/appStore.ts" line_range="764-773" />
<code_context>
),
})),
+ toggleOptionCollapsed: (instanceId, taskId, optionKey) =>
+ set((state) => ({
+ instances: state.instances.map((i) =>
+ i.id === instanceId
+ ? {
+ ...i,
+ selectedTasks: i.selectedTasks.map((t) =>
+ t.id === taskId
+ ? {
+ ...t,
+ collapsedOptions: {
+ ...t.collapsedOptions,
+ [optionKey]: !t.collapsedOptions?.[optionKey],
+ },
+ }
</code_context>
<issue_to_address>
**issue:** 在展开(spread)`collapsedOptions` 之前,需要防止它为 `undefined`。
由于 `collapsedOptions` 的类型是 `Record<string, boolean> | undefined`,直接展开它(`{ ...t.collapsedOptions }`)会在严格模式下导致类型检查失败,错误为 “Object is possibly 'undefined'”。为了保持当前的运行时行为并满足类型要求,你可以在为 `undefined` 时将其默认处理为空对象:
```ts
collapsedOptions: {
...(t.collapsedOptions ?? {}),
[optionKey]: !t.collapsedOptions?.[optionKey],
},
```
</issue_to_address>帮我变得更有用!请对每条评论点击 👍 或 👎,我会根据这些反馈来改进对你代码的审查。
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="src/stores/appStore.ts" line_range="764-773" />
<code_context>
),
})),
+ toggleOptionCollapsed: (instanceId, taskId, optionKey) =>
+ set((state) => ({
+ instances: state.instances.map((i) =>
+ i.id === instanceId
+ ? {
+ ...i,
+ selectedTasks: i.selectedTasks.map((t) =>
+ t.id === taskId
+ ? {
+ ...t,
+ collapsedOptions: {
+ ...t.collapsedOptions,
+ [optionKey]: !t.collapsedOptions?.[optionKey],
+ },
+ }
</code_context>
<issue_to_address>
**issue:** Guard against `collapsedOptions` being undefined before spreading it.
Because `collapsedOptions` is typed as `Record<string, boolean> | undefined`, spreading it directly (`{ ...t.collapsedOptions }`) will fail type-checking in strict mode with “Object is possibly 'undefined'”. To keep the current runtime behavior and satisfy the types, you can default to an empty object when undefined:
```ts
collapsedOptions: {
...(t.collapsedOptions ?? {}),
[optionKey]: !t.collapsedOptions?.[optionKey],
},
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
为带嵌套选项(switch / 下拉框)的配置项增加收起/展开功能,减少界面视觉噪音。
变更内容
OptionCollapseArrow组件,位于开关/下拉框左侧,支持键盘与无障碍属性(aria-expanded、aria-label)grid-template-rows展开动画SelectedTask.collapsedOptions,缺省展开、向后兼容);全局作用域(globalScope)用本地 state 兜底toggleOptionCollapsedstore action 及类型定义ml-auto吸收行内空白,紧贴开关/下拉框;select 类型无子选项时由下拉框自身贴右演示
涉及文件
src/components/OptionEditor.tsxsrc/stores/appStore.ts、src/stores/types.tssrc/types/interface.tssrc/i18n/locales/{en-US,ja-JP,ko-KR,zh-CN,zh-TW}.ts涉及 issue #180 支持子选项折叠
本 PR 更改代码由 DeepSeek V4 Flash (effort:Max) 生成,构建和本地测试均通过,转到演示 mxu 版本Summary by Sourcery
为开关(switch)和选择(select)配置项添加可折叠的子选项,支持按任务持久化折叠状态,并提供兼容无障碍访问的 UI 控件。
新功能:
OptionCollapseArrowUI 控件,用于在开关和选择输入旁切换嵌套选项的可见性。增强:
Original summary in English
Summary by Sourcery
Add collapsible sub-options for switch and select configuration items, with persisted per-task collapse state and accessibility-aware UI controls.
New Features:
Enhancements: