Skip to content

Commit f31e29d

Browse files
committed
refactor(prompt-editor): 优化多行方法链调用
- 将 setContent 与 setTextSelection 链式调用合并,提升代码可读性 - 调整 CSS 中 transition 属性为多行更易维护格式 - 合并移动端 CSS 中的 radial-gradient 以简化样式定义 - 新增测试以验证 PromptEditorProvider 中的 Tab 填充行为 Change-Id: If3c41d498ba21ee4b63148d41586c3dbde24f675 Co-developed-by: Qoder <noreply@qoder.com>
1 parent caafdbc commit f31e29d

4 files changed

Lines changed: 18 additions & 13 deletions

File tree

apps/webui/src/app/desktop.css

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5102,7 +5102,9 @@ dialog.case-modal-overlay {
51025102
padding: 0;
51035103
background: var(--soft);
51045104
cursor: pointer;
5105-
transition: border-color 0.15s, box-shadow 0.15s;
5105+
transition:
5106+
border-color 0.15s,
5107+
box-shadow 0.15s;
51065108
}
51075109

51085110
.inline-artifact-img-wrap:hover {
@@ -5129,7 +5131,9 @@ dialog.case-modal-overlay {
51295131
background: var(--soft);
51305132
cursor: pointer;
51315133
color: var(--ink);
5132-
transition: border-color 0.15s, background 0.15s;
5134+
transition:
5135+
border-color 0.15s,
5136+
background 0.15s;
51335137
}
51345138

51355139
.inline-artifact-video-wrap:hover {
@@ -5163,7 +5167,9 @@ dialog.case-modal-overlay {
51635167
font-size: 13px;
51645168
color: var(--ink);
51655169
max-width: 320px;
5166-
transition: border-color 0.15s, background 0.15s;
5170+
transition:
5171+
border-color 0.15s,
5172+
background 0.15s;
51675173
}
51685174

51695175
.inline-artifact-card:hover {

apps/webui/src/app/mobile.css

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,7 @@
287287
border-radius: 24px;
288288
padding: var(--composer-shine-border-width);
289289
pointer-events: none;
290-
background-image: radial-gradient(
291-
transparent,
292-
transparent,
293-
#45ebac,
294-
#8ec5ff,
295-
#ab8aff,
296-
transparent,
297-
transparent
298-
);
290+
background-image: radial-gradient(transparent, transparent, #45ebac, #8ec5ff, #ab8aff, transparent, transparent);
299291
background-size: 300% 300%;
300292
-webkit-mask:
301293
linear-gradient(#fff 0 0) content-box,

apps/webui/src/components/prompt-editor/PromptEditorProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export function PromptEditorProvider({
169169
? slotConfigRef.current.bottomBar.tabFillText
170170
: slotConfigRef.current.composer.tabFillText;
171171
if (fill) {
172-
ed.commands.setContent(plainTextToDocJson(fill));
172+
ed.chain().setContent(plainTextToDocJson(fill)).setTextSelection(1).run();
173173
}
174174
return true;
175175
}

apps/webui/tests/role-prompt-focus.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@ import { expect, test } from "bun:test";
22

33
const appSource = await Bun.file(new URL("../src/App.tsx", import.meta.url)).text();
44
const composerSource = await Bun.file(new URL("../src/components/Composer.tsx", import.meta.url)).text();
5+
const providerSource = await Bun.file(
6+
new URL("../src/components/prompt-editor/PromptEditorProvider.tsx", import.meta.url),
7+
).text();
58

69
test("role prompt selection focuses the beginning of the prefilled prompt", () => {
710
expect(appSource).toContain("composerHandleRef.current?.focusStart()");
811
expect(composerSource).toContain('editor?.commands.focus("start", { scrollIntoView: false })');
912
});
13+
14+
test("Tab fill keeps the beginning of the prompt visible", () => {
15+
expect(providerSource).toContain(".setContent(plainTextToDocJson(fill)).setTextSelection(1).run()");
16+
});

0 commit comments

Comments
 (0)