Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): restore cleared composer placeholder (#2286)

许君山 Junshan3e75d6da82a7
diff --git a/apps/desktop/src/renderer/__tests__/composerPlaceholderCss.test.ts b/apps/desktop/src/renderer/__tests__/composerPlaceholderCss.test.ts
new file mode 100644
index 0000000000..5dffa2a64d
--- /dev/null
+++ b/apps/desktop/src/renderer/__tests__/composerPlaceholderCss.test.ts
@@ -0,0 +1,19 @@
+import { readFileSync } from 'node:fs';
+import { resolve } from 'node:path';
+import { describe, expect, it } from 'vitest';
+
+const globalsSource = readFileSync(resolve(__dirname, '..', 'styles', 'globals.css'), 'utf8');
+
+describe('composer placeholder CSS', () => {
+ it('renders the placeholder when Tiptap leaves only the empty-node class', () => {
+ expect(globalsSource).toContain(
+ '.ProseMirror > p.is-empty:first-child:only-child::before {',
+ );
+ });
+
+ it('keeps the empty-node fallback hidden while a voice draft is active', () => {
+ expect(globalsSource).toContain(
+ "[data-voice-draft-active='true'] .ProseMirror > p.is-empty:first-child:only-child::before {",
+ );
+ });
+});
diff --git a/apps/desktop/src/renderer/styles/globals.css b/apps/desktop/src/renderer/styles/globals.css
index 5e70d14722..7a470caad6 100644
--- a/apps/desktop/src/renderer/styles/globals.css
+++ b/apps/desktop/src/renderer/styles/globals.css
@@ -390,15 +390,18 @@ html:lang(ko) {
/* Tiptap ChatInput — placeholder hook & chip alignment
(command-palette F2.5). The Placeholder extension injects
`p.is-editor-empty::before` with the placeholder text in a `data-*`
- attribute; we style it to match the old textarea placeholder. */
-.ProseMirror > p.is-editor-empty:first-child::before {
+ attribute; after a controlled clear it can leave only `is-empty`, so the
+ sole-empty-paragraph selector preserves the same truly-empty contract. */
+.ProseMirror > p.is-editor-empty:first-child::before,
+.ProseMirror > p.is-empty:first-child:only-child::before {
content: attr(data-placeholder);
color: var(--chat-input-placeholder-subtle);
float: left;
height: 0;
pointer-events: none;
}
-[data-voice-draft-active='true'] .ProseMirror > p.is-editor-empty:first-child::before {
+[data-voice-draft-active='true'] .ProseMirror > p.is-editor-empty:first-child::before,
+[data-voice-draft-active='true'] .ProseMirror > p.is-empty:first-child:only-child::before {
content: none;
}
.ProseMirror {