From ca17893ba449e749e5e9b6415111d970f25b6ee4 Mon Sep 17 00:00:00 2001 From: BotHarness Date: Mon, 16 Nov 2026 21:03:32 +0900 Subject: [PATCH 1/5] fix: align approval rule numbers with their text Refs #4244 Agent-Task: codex/local/01a1df05-43d2-7380-84a0-99084cd0f49c Agent claim: https://github.com/BotHarness/DeepSeekBot/issues/4244#issuecomment-6915820816 --- changes/4244-rule-number-alignment.md | 11 +++++++++++ .../client/src/client/approval-template-library.tsx | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 changes/4244-rule-number-alignment.md diff --git a/changes/4244-rule-number-alignment.md b/changes/4244-rule-number-alignment.md new file mode 100644 index 0000000000..c46ab4ce71 --- /dev/null +++ b/changes/4244-rule-number-alignment.md @@ -0,0 +1,11 @@ +--- +section: Fixed +--- + +## en + +- Aligned approval-template rule numbers with the first text line in Always ask and Always allow lists ([#4244](https://github.com/BotHarness/DeepSeekBot/issues/4244)). + +## zh + +- 审批模板的 Always ask 与 Always allow 列表中,规则序号与文字首行对齐([#4244](https://github.com/BotHarness/DeepSeekBot/issues/4244))。 diff --git a/packages/client/src/client/approval-template-library.tsx b/packages/client/src/client/approval-template-library.tsx index aa7ee01a7d..c970259439 100644 --- a/packages/client/src/client/approval-template-library.tsx +++ b/packages/client/src/client/approval-template-library.tsx @@ -52,6 +52,8 @@ const NAME = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/u; const styles = stylex.create({ meta: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: space.x2 }, + ruleMain: { alignItems: 'baseline' }, + ruleNumber: { fontSize: text.bodySize, lineHeight: text.bodyLine }, ruleInput: { boxSizing: 'border-box', width: '100%', @@ -121,7 +123,12 @@ function GuidanceFields({ return ( {index + 1}} + mainClassName={stylex.props(styles.ruleMain).className} + leading={ + + {index + 1} + + } title={ Date: Mon, 16 Nov 2026 21:25:09 +0900 Subject: [PATCH 2/5] fix(ui): make approval guidance lists easier to extend Refs #4244 Agent-Task: codex/local/01a1df05-43d2-7380-84a0-99084cd0f49c Agent claim: https://github.com/BotHarness/DeepSeekBot/issues/4244#issuecomment-6916268261 --- .../features/approval-templates.md | 2 +- changes/4244-rule-number-alignment.md | 4 +- .../src/client/approval-template-library.tsx | 153 +++++++++++------- packages/client/src/client/locale.ts | 2 + .../test/approval-template-library.test.ts | 53 +++++- 5 files changed, 153 insertions(+), 61 deletions(-) diff --git a/.agents/skills/verify-deepseekbot/features/approval-templates.md b/.agents/skills/verify-deepseekbot/features/approval-templates.md index 7b2883ab4d..ec1b871411 100644 --- a/.agents/skills/verify-deepseekbot/features/approval-templates.md +++ b/.agents/skills/verify-deepseekbot/features/approval-templates.md @@ -5,7 +5,7 @@ A Bot inherits the optional global default, selects one complete shared template ## Sub-features - `library`: Bot settings → Auto approval → Global default template (DSH Select), existing template library and Reviewer model. No global default means inherited review is off. Read failures remain errors. -- `editor`: New template requires Blank or one selected source; edit independent Always ask/Always allow rows in the same grouped card list as External identities/connectors (outer top/bottom corners, straight middle joins), plus free text; save alone or apply to a named Bot. Copy a custom or built-in template independently; shared-original editing lists actual users including global inheritors. Read back full content and selection through CLI. +- `editor`: New template requires Blank or one selected source; edit independent Always ask/Always allow rows in the same grouped card list as External identities/connectors (outer top/bottom corners, straight middle joins, distinct list fill and spaced headings); top-right and bottom add actions append a draft row and focus/reveal its input, plus free text; save alone or apply to a named Bot. Copy a custom or built-in template independently; shared-original editing lists actual users including global inheritors. Read back full content and selection through CLI. - `cli`: `approval-template list --bot `, `approval-template-global-set `, `approval-template-set `; library create/edit commands retain existing Markdown contents. - `select`: Channel settings → Auto approval, or composer Workspace Grants panel → Auto approval, uses the same DSH Select. Inheritance shows its effective global source. Specific selection replaces global; Off retains deterministic rules. - `mobile`: Bot profile → Settings → Permissions → Workspace grants → Auto approval template, inside the existing iOS sheet / Android `ModalBottomSheet`. Inherit global shows the resolved global template (or Off); selecting Off then Inherit global writes null then @global through the same Host owner. Legacy Hosts without a global-selection field retain their supported choices. diff --git a/changes/4244-rule-number-alignment.md b/changes/4244-rule-number-alignment.md index c46ab4ce71..cd69961f70 100644 --- a/changes/4244-rule-number-alignment.md +++ b/changes/4244-rule-number-alignment.md @@ -4,8 +4,8 @@ section: Fixed ## en -- Aligned approval-template rule numbers with the first text line in Always ask and Always allow lists ([#4244](https://github.com/BotHarness/DeepSeekBot/issues/4244)). +- Improved approval-template rule lists with aligned numbers, clearer section spacing and surfaces, and top/bottom add actions that focus the new row ([#4244](https://github.com/BotHarness/DeepSeekBot/issues/4244)). ## zh -- 审批模板的 Always ask 与 Always allow 列表中,规则序号与文字首行对齐([#4244](https://github.com/BotHarness/DeepSeekBot/issues/4244))。 +- 改善审批模板规则列表:序号对齐文字,增加标题间距和底色区分,顶部与底部均可添加并聚焦新条目([#4244](https://github.com/BotHarness/DeepSeekBot/issues/4244))。 diff --git a/packages/client/src/client/approval-template-library.tsx b/packages/client/src/client/approval-template-library.tsx index c970259439..0faf463929 100644 --- a/packages/client/src/client/approval-template-library.tsx +++ b/packages/client/src/client/approval-template-library.tsx @@ -24,7 +24,7 @@ import { type BridgeCall, } from './bridge.js'; import { Callout } from './ds/callout.js'; -import { Field, FieldStack, TextAreaField, TextField } from './ds/field.js'; +import { FieldStack, TextAreaField, TextField } from './ds/field.js'; import { ConfirmDialog, DangerTextButton, FormDialog } from './ds/form-dialog.js'; import { Note } from './ds/note.js'; import { ReadFailure } from './ds/read-failure.js'; @@ -52,6 +52,20 @@ const NAME = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/u; const styles = stylex.create({ meta: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: space.x2 }, + ruleSection: { margin: 0, padding: 0, borderWidth: 0, minWidth: 0 }, + ruleLegend: { width: '100%', padding: 0, marginBottom: space.x3 }, + ruleHeader: { + display: 'flex', + alignItems: 'center', + justifyContent: 'space-between', + gap: space.x3, + color: color.fg, + fontSize: text.bodySize, + lineHeight: text.bodyLine, + fontWeight: text.strong, + }, + ruleList: { backgroundColor: color.surface }, + freeTextLabel: { display: 'inline-block', paddingBottom: space.x2 }, ruleMain: { alignItems: 'baseline' }, ruleNumber: { fontSize: text.bodySize, lineHeight: text.bodyLine }, ruleInput: { @@ -102,6 +116,7 @@ function GuidanceFields({ onChange(text: string): void; t: BotHarnessTranslate; }): ReactElement { + const focusAddedRow = useRef<{ section: 'alwaysAsk' | 'alwaysAllow'; index: number }>(); const parts = decodeApprovalTemplateGuidance(text); const update = (next: ApprovalTemplateGuidance): void => onChange(encodeApprovalTemplateGuidance(next)); @@ -114,67 +129,91 @@ function GuidanceFields({ ? 'autoApproval.library.alwaysAsk' : 'autoApproval.library.alwaysAllow', ); + const addRow = (): void => { + focusAddedRow.current = { section: key, index: parts[key].length }; + update({ ...parts, [key]: [...parts[key], ''] }); + }; + const addLabel = t('autoApproval.library.addRow', { section: label }); return ( - - {() => ( - - {parts[key].map((row, index) => { - const rowLabel = label + ' ' + String(index + 1); - return ( - - {index + 1} - - } - title={ - - update({ - ...parts, - [key]: parts[key].map((item, position) => - position === index ? event.currentTarget.value : item, - ), - }) - } - /> - } - trailing={ - + + + + {parts[key].map((row, index) => { + const rowLabel = label + ' ' + String(index + 1); + return ( + + {index + 1} + + } + title={ + { + const pending = focusAddedRow.current; + if (input && pending?.section === key && pending.index === index) { + focusAddedRow.current = undefined; + input.focus(); } - > - - - } - /> - ); - })} - update({ ...parts, [key]: [...parts[key], ''] })} - /> - - )} - + }} + aria-label={rowLabel} + className={stylex.props(styles.ruleInput).className ?? ''} + value={row} + onChange={(event) => + update({ + ...parts, + [key]: parts[key].map((item, position) => + position === index ? event.currentTarget.value : item, + ), + }) + } + /> + } + trailing={ + + } + /> + ); + })} + + + ); })} {t('autoApproval.library.freeText')} + } hint={t('autoApproval.library.freeTextHint')} value={parts.freeText} rows={8} diff --git a/packages/client/src/client/locale.ts b/packages/client/src/client/locale.ts index a94d71d8d9..634a00874e 100644 --- a/packages/client/src/client/locale.ts +++ b/packages/client/src/client/locale.ts @@ -4469,6 +4469,7 @@ export const zh = { 'autoApproval.library.guidanceHint': '这些是 Reviewer 的自然语言指导,不保证模型判断。总是询问优先;冲突、未覆盖或不确定时交给你。修改仅影响后续审批。', 'autoApproval.library.removeRow': '移除此行', + 'autoApproval.library.add': '添加', 'autoApproval.library.addRow': '添加{section}项', 'autoApproval.library.saveChoice': '保存方式', 'autoApproval.library.saveOnly': '仅保存', @@ -10579,6 +10580,7 @@ My relationship with you, established lore and topics to avoid: [fill in]. 'autoApproval.library.guidanceHint': 'Natural-language Reviewer guidance cannot guarantee model decisions. Always ask takes priority; conflicts, missing coverage and uncertainty go to you. Edits affect future Reviews.', 'autoApproval.library.removeRow': 'Remove row', + 'autoApproval.library.add': 'Add', 'autoApproval.library.addRow': 'Add {section} row', 'autoApproval.library.saveChoice': 'Save behavior', 'autoApproval.library.saveOnly': 'Save only', diff --git a/packages/client/test/approval-template-library.test.ts b/packages/client/test/approval-template-library.test.ts index fe7142d4f2..8fc4df5826 100644 --- a/packages/client/test/approval-template-library.test.ts +++ b/packages/client/test/approval-template-library.test.ts @@ -12,8 +12,8 @@ import { zhTranslate as t } from '../src/client/locale.js'; import { createStore } from '../src/client/store.js'; vi.mock('@deepseek-ai/dsh-client-ui-primitives', async () => ({ - ...(await import('./primitive-mocks.js')).dialogPrimitives(), ...(await import('./primitive-mocks.js')).comboboxPrimitives(), + ...(await import('./primitive-mocks.js')).dialogPrimitives(), Tag: ({ children }: { children: ReactNode }) => createElement('span', null, children), Menu: ({ items, @@ -542,6 +542,57 @@ it('keeps the visible View action in accessible template names', async () => { } }); +it.each(['alwaysAsk', 'alwaysAllow'] as const)( + 'adds and focuses a %s rule from either end without saving or changing other sections', + async (section) => { + const parts = { + alwaysAsk: Array.from({ length: 20 }, (_, index) => 'Ask ' + String(index + 1)), + alwaysAllow: Array.from({ length: 20 }, (_, index) => 'Allow ' + String(index + 1)), + freeText: 'Keep this note.', + }; + const calls: string[] = []; + const template = { ...customTemplate, usedBy: [], text: encodeApprovalTemplateGuidance(parts) }; + const call: BridgeCall = async (endpoint) => { + calls.push(endpoint); + if (endpoint === 'approvalTemplates') + return { ok: true, value: { templates: [template], globalDefault: null } }; + throw new Error('Adding a draft row must not write to the Host'); + }; + await render(call); + const edit = host.querySelector( + '[data-approval-template="night-shift"] button', + ); + if (!edit) throw new Error('Missing template'); + await act(async () => edit.click()); + const top = document.querySelector( + 'button[data-approval-guidance-add="' + section + '"]', + ); + if (!top) throw new Error('Missing top add action'); + const label = t( + section === 'alwaysAsk' + ? 'autoApproval.library.alwaysAsk' + : 'autoApproval.library.alwaysAllow', + ); + await act(async () => top.click()); + const added = document.querySelector('input[aria-label="' + label + ' 21"]'); + expect(added?.value).toBe(''); + expect(document.activeElement).toBe(added); + await clickText(t('autoApproval.library.addRow', { section: label })); + const last = document.querySelector('input[aria-label="' + label + ' 22"]'); + expect(last?.value).toBe(''); + expect(document.activeElement).toBe(last); + const other = t( + section === 'alwaysAsk' + ? 'autoApproval.library.alwaysAllow' + : 'autoApproval.library.alwaysAsk', + ); + expect(document.querySelector('input[aria-label="' + other + ' 21"]')).toBeNull(); + expect(document.querySelector('textarea')?.value).toBe(parts.freeText); + expect(calls).toEqual(['approvalTemplates']); + expect(decodeApprovalTemplateGuidance(template.text)).toEqual(parts); + }, +); + it('edits and removes independent guidance cards without changing neighbouring rules or applying', async () => { let template = { name: 'qa-rules', From 2f8cc32a1c4bebdbdd46be775410f193406c0e25 Mon Sep 17 00:00:00 2001 From: BotHarness Date: Mon, 16 Nov 2026 21:54:12 +0900 Subject: [PATCH 3/5] test: check expiry of the admitted native execution Refs #4212 Agent-Task: codex/local/01a1df05-43d2-7380-84a0-99084cd0f49c Agent claim: https://github.com/BotHarness/DeepSeekBot/issues/4212#issuecomment-6916931883 --- packages/core/test/tob-cli-invocation.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/test/tob-cli-invocation.test.ts b/packages/core/test/tob-cli-invocation.test.ts index e0b1aec083..b63c5ab912 100644 --- a/packages/core/test/tob-cli-invocation.test.ts +++ b/packages/core/test/tob-cli-invocation.test.ts @@ -431,11 +431,11 @@ describe('owned model-free Tob CLI invocation', () => { await f.native(); shouldDelegate = true; await f.authority.run(f.input, () => f.native()); + if (!captured) throw new Error('Native executor did not enter policy'); + const admitted = captured; + expect(() => f.authority.require(admitted)).toThrow(); shouldDelegate = false; await f.native(); - if (!captured) throw new Error('Native executor did not enter policy'); - const expired = captured; - expect(() => f.authority.require(expired)).toThrow(); expect(f.runHost).not.toHaveBeenCalled(); }); From 8925234e1cd05e61290259d7a694dde09dda89a5 Mon Sep 17 00:00:00 2001 From: BotHarness Date: Mon, 16 Nov 2026 22:24:50 +0900 Subject: [PATCH 4/5] test: verify approval privacy and deletion recovery Refs #4244 Refs #4212 Agent-Task: codex/local/01a1df05-43d2-7380-84a0-99084cd0f49c Agent claim: https://github.com/BotHarness/DeepSeekBot/issues/4244#issuecomment-6917599922 Agent claim: https://github.com/BotHarness/DeepSeekBot/issues/4212#issuecomment-6917600567 --- .../test/approval-template-library.test.ts | 23 +++++++++++++++---- packages/core/test/team-approvals.test.ts | 12 +++++----- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/packages/client/test/approval-template-library.test.ts b/packages/client/test/approval-template-library.test.ts index 8fc4df5826..1ae5d9f8eb 100644 --- a/packages/client/test/approval-template-library.test.ts +++ b/packages/client/test/approval-template-library.test.ts @@ -337,6 +337,7 @@ it.each(['immediate', 'retry'] as const)( let deleted = false; let writes = 0; let reads = 0; + let absentPreviews = 0; const call: BridgeCall = async (endpoint) => { if (endpoint === 'approvalTemplates') { reads++; @@ -349,10 +350,16 @@ it.each(['immediate', 'retry'] as const)( }, }; } - if (endpoint === 'approvalTemplateDeletePreview') - return deleted - ? { ok: false, error: { code: 'unknown-template', message: 'removed', details: {} } } - : { ok: true, value: { preview: deletePreview } }; + if (endpoint === 'approvalTemplateDeletePreview') { + if (deleted) { + absentPreviews++; + return { + ok: false, + error: { code: 'unknown-template', message: 'removed', details: {} }, + }; + } + return { ok: true, value: { preview: deletePreview } }; + } if (endpoint === 'approvalTemplateDelete') { writes++; deleted = true; @@ -365,7 +372,9 @@ it.each(['immediate', 'retry'] as const)( expect(writes).toBe(1); if (recovery === 'retry') { expect(trigger().textContent).toContain('读取失败'); - const retry = [...document.querySelectorAll('button')].find( + const dialog = confirmDeletion().closest('[role="dialog"]'); + if (!dialog) throw new Error('Missing deletion dialog'); + const retry = [...dialog.querySelectorAll('button')].find( (b) => b.textContent === t('autoApproval.reload'), ); if (!retry) throw new Error('Missing read recovery'); @@ -373,6 +382,10 @@ it.each(['immediate', 'retry'] as const)( } expect(host.querySelector('[data-approval-template="night-shift"]')).toBeNull(); expect(trigger().textContent).toContain(t('autoApproval.off')); + expect(document.body.textContent).not.toContain( + t('autoApproval.library.deleteTitle', { title: 'Night shift' }), + ); + expect(absentPreviews).toBe(1); expect(writes).toBe(1); }, ); diff --git a/packages/core/test/team-approvals.test.ts b/packages/core/test/team-approvals.test.ts index 0e436767a1..ceed82940d 100644 --- a/packages/core/test/team-approvals.test.ts +++ b/packages/core/test/team-approvals.test.ts @@ -1173,12 +1173,12 @@ describe('M5 approval projections and decisions', () => { expect(() => f.team.approvals.requireRequest(bob, memberDm.id, request.messageId), ).toThrow(); - masked( - f.team.approvals.project(bob, { - channelId: memberDm.id, - message: f.channels.message(memberDm.id, request.messageId), - }), - ); + const projection = f.team.approvals.project(bob, { + channelId: memberDm.id, + message: f.channels.message(memberDm.id, request.messageId), + }); + masked(projection); + expect(JSON.stringify(projection)).not.toContain('PARTICIPANT_PRIVATE_INPUT'); } expect(JSON.stringify(f.channels.readMessages(principalDm.id))).not.toContain( 'PARTICIPANT_', From 8f222e57d87c6d6f9b9fd7cf6fea51d61ca19d3d Mon Sep 17 00:00:00 2001 From: BotHarness Date: Mon, 16 Nov 2026 22:37:20 +0900 Subject: [PATCH 5/5] test: verify expiry inside the retained invocation context Refs #4212 Agent-Task: codex/local/01a1df05-43d2-7380-84a0-99084cd0f49c Agent claim: https://github.com/BotHarness/DeepSeekBot/issues/4212#issuecomment-6917911501 --- packages/core/test/tob-cli-invocation.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/core/test/tob-cli-invocation.test.ts b/packages/core/test/tob-cli-invocation.test.ts index b63c5ab912..fc141c54f2 100644 --- a/packages/core/test/tob-cli-invocation.test.ts +++ b/packages/core/test/tob-cli-invocation.test.ts @@ -419,11 +419,23 @@ describe('owned model-free Tob CLI invocation', () => { const f = await fixture(); let shouldDelegate = false; let captured: ToolExecution | undefined; + let retainedExpiry: Promise | undefined; + let resumeExpired: (() => void) | undefined; + const expiryReady = new Promise((resolve) => { + resumeExpired = resolve; + }); f.ctx.on( 'tools/pre-execute', async (execution) => { captured = execution; expect(f.authority.delegate(execution)).toBe(shouldDelegate ? 'delegated' : 'refused'); + if (shouldDelegate) { + expect(() => f.authority.require(execution)).not.toThrow(); + retainedExpiry = (async () => { + await expiryReady; + expect(() => f.authority.require(execution)).toThrow(); + })(); + } return { kind: 'deny', reason: 'Origin probe completed before body' }; }, { global: true, prepend: true }, @@ -434,6 +446,9 @@ describe('owned model-free Tob CLI invocation', () => { if (!captured) throw new Error('Native executor did not enter policy'); const admitted = captured; expect(() => f.authority.require(admitted)).toThrow(); + if (!retainedExpiry || !resumeExpired) throw new Error('Missing retained invocation context'); + resumeExpired(); + await retainedExpiry; shouldDelegate = false; await f.native(); expect(f.runHost).not.toHaveBeenCalled();