Skip to content

Commit 9302d3b

Browse files
committed
fix: force async claw reply submit handling
1 parent 6026233 commit 9302d3b

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

apps/novelclaw/local_web_portal/app/static/idea_copilot_live.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,23 @@
439439
document.querySelectorAll('[data-idea-copilot-root]').forEach(init);
440440
}
441441

442+
window.__novelclawReplySubmit = function (form, event) {
443+
const root = form ? form.closest('[data-idea-copilot-root]') : null;
444+
if (!root) return true;
445+
if (root.dataset.liveInitialized !== 'true') {
446+
init(root);
447+
}
448+
if (form && form.__ideaLiveHandleSubmit) {
449+
if (event) {
450+
event.preventDefault();
451+
event.stopPropagation();
452+
}
453+
form.__ideaLiveHandleSubmit(event || new Event('submit', { bubbles: true, cancelable: true }));
454+
return false;
455+
}
456+
return true;
457+
};
458+
442459
document.addEventListener('submit', function (event) {
443460
const form = event.target;
444461
if (!(form instanceof HTMLFormElement)) return;

apps/novelclaw/local_web_portal/app/templates/dashboard.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ <h2>{{ ui_text('对话流', 'Conversation') }}</h2>
225225

226226
<div class="chat-composer-stack chat-composer-stack--docked">
227227
{% if chat_session and chat_session.status == 'active' and not compose_new %}
228-
<form method="post" action="{{ app_path('/idea-copilot/' ~ chat_session.id ~ '/reply') }}" class="chat-input-form chat-input-form--floating" data-idea-reply-form>
228+
<form method="post" action="{{ app_path('/idea-copilot/' ~ chat_session.id ~ '/reply') }}" class="chat-input-form chat-input-form--floating" data-idea-reply-form onsubmit="return window.__novelclawReplySubmit ? window.__novelclawReplySubmit(this, event) : true;">
229229
<div data-idea-status class="console-alert" hidden></div>
230230
<textarea name="reply" rows="4" required placeholder="{{ ui_text('继续补充需求、修改方向,或者直接告诉 NovelClaw 下一步做什么。', 'Add details, change direction, or tell NovelClaw what to do next.') }}"></textarea>
231231
<div class="chat-input-actions">
@@ -268,7 +268,7 @@ <h2>{{ ui_text('对话流', 'Conversation') }}</h2>
268268
</div>
269269
</section>
270270

271-
<script src="{{ static_asset_path('idea_copilot_live.js') }}?v=20260330d"></script>
271+
<script src="{{ static_asset_path('idea_copilot_live.js') }}?v=20260330e"></script>
272272
<script src="{{ static_asset_path('chat_run_live.js') }}?v=20260330b"></script>
273273
{% if chat_session %}
274274
<script>

apps/novelclaw/local_web_portal/app/templates/idea_copilot.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ <h3 style="margin-top: 0;">{{ ui_text('本轮 Claw 关注点', 'Current Claw Foc
7676
</div>
7777

7878
{% if session_data.status == "active" %}
79-
<form method="post" action="{{ app_path('/idea-copilot/' ~ session_data.id ~ '/reply') }}" class="form-stack" data-idea-reply-form>
79+
<form method="post" action="{{ app_path('/idea-copilot/' ~ session_data.id ~ '/reply') }}" class="form-stack" data-idea-reply-form onsubmit="return window.__novelclawReplySubmit ? window.__novelclawReplySubmit(this, event) : true;">
8080
<div data-idea-status class="console-alert" hidden></div>
8181
<div>
8282
<label>{{ ui_text('继续补充本轮信息', 'Add more details for this round') }}</label>

0 commit comments

Comments
 (0)