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): 首页首次发送不再闪现两个空行

Dashab9170758f62
diff --git a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
index 480720d3ed..b313076c2f 100644
--- a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
@@ -5690,7 +5690,7 @@ export function ChatInput({
};
const restoreRemoteComposerAndRelease = () => {
try {
- restoreOptimisticallyClearedComposer();
+ if (sourceSessionId) restoreOptimisticallyClearedComposer();
} finally {
releaseRemoteComposerTransition();
}
@@ -5699,15 +5699,21 @@ export function ChatInput({
// the user bubble. Device-link already did this; local/SSH used to wait
// until onSend resolved, so the same text sat in both the transcript
// and the composer while enqueue / effort / slash / auth settled.
- try {
- clearSentComposer();
- } catch (error) {
- restoreRemoteComposerAndRelease();
- throw error;
- }
- dispatchSendClearedKeysRef.current.add(sendInFlightKey);
- if (lockCurrentComposer && storageKeyForDraftRef.current === sourceStorageKey) {
- setAllowTypeDuringSend(true);
+ // Home owns the asynchronous creation handoff: onSend returns false
+ // while it is still creating the session, then clears the draft itself.
+ // Keep that draft intact instead of clearing and restoring it as though
+ // an existing-session send had failed.
+ if (sourceSessionId) {
+ try {
+ clearSentComposer();
+ } catch (error) {
+ restoreRemoteComposerAndRelease();
+ throw error;
+ }
+ dispatchSendClearedKeysRef.current.add(sendInFlightKey);
+ if (lockCurrentComposer && storageKeyForDraftRef.current === sourceStorageKey) {
+ setAllowTypeDuringSend(true);
+ }
}
if (
optimisticallyClearRemoteComposer &&
@@ -5804,6 +5810,7 @@ export function ChatInput({
restoreRemoteComposerAndRelease();
return;
}
+ if (!sourceSessionId) clearSentComposer();
releaseRemoteComposerTransition();
markRecentPluginUsage();
} finally {