Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat(assistant): auto-send the fix-rule message instead of only populating the input#2907

Open
alexcf wants to merge 2 commits into
elie222:mainelie222/inbox-zero:mainfrom
alexcf:feat/fix-rule-autosendalexcf/inbox-zero:feat/fix-rule-autosendCopy head branch name to clipboard
Open

feat(assistant): auto-send the fix-rule message instead of only populating the input#2907
alexcf wants to merge 2 commits into
elie222:mainelie222/inbox-zero:mainfrom
alexcf:feat/fix-rule-autosendalexcf/inbox-zero:feat/fix-rule-autosendCopy head branch name to clipboard

Conversation

@alexcf

@alexcf alexcf commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What

In the Improve Rules dialog (FixWithChat), after the user selects the expected rule (new / none / existing) and clicks Next, the generated message is now sent automatically to the assistant instead of merely being written into the chat input for the user to send manually.

Why

The extra manual "press send" step is friction — the user already expressed full intent by choosing the rule and (optionally) an explanation. Auto-sending completes the action they started.

How

  • FixWithChat now pulls submitTextMessage and chat from useChat().
  • handleSubmit is async; after setContext(...) and opening the sidebar it calls await submitTextMessage(input).
  • submitTextMessage(text) takes the message as an argument, avoiding the setInput → submit state-closure race (the input would otherwise still be empty on the same tick).
  • Guarded by chat.status === "ready": if a response is already streaming/submitted, it falls back to the previous behaviour (setInput(input)) so we never interleave with an in-flight message.

Scope

Only the FixWithChat ("Improve Rules") flow. The separate "Edit via AI" dropdown action (which intentionally lets you tweak the prompt before sending) is unchanged.

Testing

Manual: select new/none/existing rule → Next → message is sent immediately; while a response is streaming, it populates the input instead.

Review in cubic

…ating

In the "Improve Rules" (FixWithChat) flow, after the user picks the
expected rule (new / none / existing) and clicks Next, the constructed
message was only written into the chat input via setInput — the user
then had to manually press send. Send it automatically.

Uses the provider's submitTextMessage(text), which takes the text as an
argument (avoiding the setInput state-closure race), and guards on
chat.status === "ready" so we never interleave with an in-flight
response — in that case we fall back to populating the input as before.
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Inbox Zero OSS Program Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Alex Cruz Farmer seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 1 file

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/web/app/(app)/[emailAccountId]/assistant/FixWithChat.tsx
Comment thread apps/web/app/(app)/[emailAccountId]/assistant/FixWithChat.tsx Outdated
Address review feedback on the auto-send flow:
- Add a submit-in-flight ref guard so the Next button can't trigger
  multiple sends in the brief async window before the modal closes.
- Wrap submitTextMessage in try/catch: on failure, fall back to
  populating the chat input (so the generated text isn't lost) and
  report via captureException.
@alexcf

alexcf commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @cubic — both valid, fixed in the latest commit:

  1. Double-submit guard: added an isSubmittingRef set at the top of handleSubmit (and cleared at the end), so repeated clicks in the async window before the modal closes are ignored.
  2. Send error handling: submitTextMessage is now wrapped in try/catch — on failure it falls back to populating the chat input (so the generated text isn't lost) and reports via captureException. State cleanup still runs.

@cubic-dev-ai

cubic-dev-ai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Thanks @cubic — both valid, fixed in the latest commit:

  1. Double-submit guard: added an isSubmittingRef set at the top of handleSubmit (and cleared at the end), so repeated clicks in the async window before the modal closes are ignored.
  2. Send error handling: submitTextMessage is now wrapped in try/catch — on failure it falls back to populating the chat input (so the generated text isn't lost) and reports via captureException. State cleanup still runs.

@alexcf Looks good — those two changes cover exactly what I flagged.

The isSubmittingRef guard is clean: checks at the top, reset in a finally-equivalent spot (the end of the handler), so even if submitTextMessage throws, the ref still gets cleared after the catch block runs. And the try/catch with captureException + setInput(input) fallback means a failed send doesn't silently eat the user's generated message.

The chat.status === "ready" guard also avoids the edge case where the chat is already streaming from a previous message — that'd be surprising in this modal flow but it's good to have it handled rather than assumed.

No further concerns from me.

Tip: get faster answers by chatting with cubic’s review copilot in the review UI

@alexcf
alexcf force-pushed the feat/fix-rule-autosend branch from bc8c655 to 65890fe Compare July 3, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.