fix(editor): Restore Instance AI draft when thread creation fails - #37874
fix(editor): Restore Instance AI draft when thread creation fails#37874Ryner01 wants to merge 1 commit into
Conversation
PR review overviewBased on ownership of the 2 changed files in this PR:
|
Bundle ReportChanges will increase total bundle size by 179 bytes (0.0%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: editor-ui-esmAssets Changed:
Files in
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
2 issues found across 2 files
Confidence score: 3/5
InstanceAiEmptyView.vuecan fail to restore submitted text when an attachment is staged beforesyncThreadrejects, becauseisDirty()blocks the helper; preserve the text-only submission in this race, as tracked by INS-579.InstanceAiEmptyView.vuecan restore a stale submission into the active composer when the selected project changes during pendingsyncThread()orsendMessage()work; guard the continuation against the changed project or stale request before restoring content.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/frontend/editor-ui/src/features/ai/instanceAi/InstanceAiEmptyView.vue">
<violation number="1" location="packages/frontend/editor-ui/src/features/ai/instanceAi/InstanceAiEmptyView.vue:464">
P2: Custom agent: **Frontend**
When the selected project changes while `syncThread()` or `sendMessage()` is pending, this continuation restores the old submission into the currently active composer without checking its originating project or request. Capture and revalidate the originating project/component or request sequence before calling `restoreDraft` and focusing the input.</violation>
<violation number="2" location="packages/frontend/editor-ui/src/features/ai/instanceAi/InstanceAiEmptyView.vue:468">
P2: When a text-only submit is followed by staging an attachment before `syncThread` rejects, `isDirty()` prevents this helper from restoring the submitted text. According to linked Linear issue INS-579, preserve that text alongside newly staged attachments, or distinguish text edits from attachment state before applying the dirty guard.</violation>
</file>
Shadow auto-approve: would not auto-approve because issues were found.
Fix all with cubic | Re-trigger cubic
| void nextTick(() => { | ||
| // The input supplies the callback only when the draft has attachments. | ||
| // Restore text directly for a text-only draft. | ||
| if (!restoreDraft?.()) { |
There was a problem hiding this comment.
P2: When a text-only submit is followed by staging an attachment before syncThread rejects, isDirty() prevents this helper from restoring the submitted text. According to linked Linear issue INS-579, preserve that text alongside newly staged attachments, or distinguish text edits from attachment state before applying the dirty guard.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/frontend/editor-ui/src/features/ai/instanceAi/InstanceAiEmptyView.vue, line 468:
<comment>When a text-only submit is followed by staging an attachment before `syncThread` rejects, `isDirty()` prevents this helper from restoring the submitted text. According to linked Linear issue INS-579, preserve that text alongside newly staged attachments, or distinguish text edits from attachment state before applying the dirty guard.</comment>
<file context>
@@ -461,6 +461,18 @@ onMounted(() => {
+ void nextTick(() => {
+ // The input supplies the callback only when the draft has attachments.
+ // Restore text directly for a text-only draft.
+ if (!restoreDraft?.()) {
+ const input = chatInputRef.value;
+ if (input && !input.isDirty()) input.setText(message);
</file context>
|
|
||
| onUnmounted(clearPersonalizedPromptMetadataTimeout); | ||
|
|
||
| function restoreDraftAfterFailedSubmit(message: string, restoreDraft?: () => boolean) { |
There was a problem hiding this comment.
P2: Custom agent: Frontend
When the selected project changes while syncThread() or sendMessage() is pending, this continuation restores the old submission into the currently active composer without checking its originating project or request. Capture and revalidate the originating project/component or request sequence before calling restoreDraft and focusing the input.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/frontend/editor-ui/src/features/ai/instanceAi/InstanceAiEmptyView.vue, line 464:
<comment>When the selected project changes while `syncThread()` or `sendMessage()` is pending, this continuation restores the old submission into the currently active composer without checking its originating project or request. Capture and revalidate the originating project/component or request sequence before calling `restoreDraft` and focusing the input.</comment>
<file context>
@@ -461,6 +461,18 @@ onMounted(() => {
onUnmounted(clearPersonalizedPromptMetadataTimeout);
+function restoreDraftAfterFailedSubmit(message: string, restoreDraft?: () => boolean) {
+ void nextTick(() => {
+ // The input supplies the callback only when the draft has attachments.
</file context>
Summary
Restore the submitted Instance AI draft when thread creation fails.
How to test
Run
pnpm test src/features/ai/instanceAi/__tests__/InstanceAiEmptyView.test.tsfrompackages/frontend/editor-ui.Related Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/INS-579
Review / Merge checklist
Backport to Beta,Backport to Stable, orBackport to v1(if the PR is an urgent fix that needs to be backported)🤖 PR Summary generated by AI