fix(sessions): preserve prompt when sending while offline#1971
Merged
Conversation
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
apps/code/src/renderer/features/sessions/components/SessionView.tsx:249-255
**No user feedback when submit is blocked offline**
`handleBeforeSubmit` silently returns `false` when offline, so the editor content is preserved (correct) but the user gets no indication of *why* their submit was ignored. The PR description and test plan explicitly state "a 'Can't send while offline' toast appears," but no such toast is fired here.
The existing connectivity toast in `connectivityToast.ts` is debounced by 5 s, so if the user goes offline and tries to send within that window, the submit silently no-ops with zero feedback. A `toast.error(…)` call is needed inside the `if (!isOnline)` branch.
```suggestion
const handleBeforeSubmit = useCallback(
(text: string, clearEditor: () => void): boolean => {
if (!isOnline) {
toast.error("Can't send while offline", {
id: "send-offline",
description: "Reconnect to the network and try again.",
});
return false;
}
return onBeforeSubmit ? onBeforeSubmit(text, clearEditor) : true;
},
[isOnline, onBeforeSubmit],
);
```
Reviews (1): Last reviewed commit: "fix(sessions): drop redundant offline to..." | Re-trigger Greptile |
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
apps/code/src/renderer/features/task-detail/hooks/useTaskCreation.ts:145-158
**Undocumented UX change for the new-task submit button**
`isOnline` has been removed from `canSubmit` and the corresponding `!isOnline` flag has been dropped from `submitDisabledExternal` in `TaskInput.tsx`. Before this PR the new-task submit button was visually disabled when offline; after, it is enabled and clicking it fires the offline toast. The PR description explicitly states "The new-task input (TaskInput) already disables submit when offline, so it isn't affected," which is the opposite of what the diff does. If the change is intentional (unifying both inputs to the toast pattern), it is worth documenting — if it was accidental, the old `isOnline` guard in `canSubmit` should be restored.
Reviews (2): Last reviewed commit: "align offline submit handling across inp..." | Re-trigger Greptile |
b074003 to
92f36e7
Compare
Contributor
|
Reviews (3): Last reviewed commit: "chore: untrack accidentally committed lo..." | Re-trigger Greptile |
added 4 commits
May 7, 2026 15:23
Pressing Enter in the message editor while offline used to clear the input even though the prompt never reached the agent — the connectivity check in sendPrompt() throws asynchronously, but the editor's doClear() already ran synchronously after onSubmit fired. Wraps the editor's onBeforeSubmit at the SessionView level with an offline guard. Returning false short-circuits both onSubmit and the editor's auto-clear, so the typed message stays put. A stable-id toast gives immediate feedback that the send didn't go through. Generated-By: PostHog Code Task-Id: ba36fa8e-ca18-4fd5-9d57-9bca8825814a
Generated-By: PostHog Code Task-Id: ba36fa8e-ca18-4fd5-9d57-9bca8825814a
Within the 5s offline-debounce window, blocking submit silently was indistinguishable from a no-op. Reuse the same global connectivity toast (same id, same message) instead of inventing a new one. Generated-By: PostHog Code Task-Id: ba36fa8e-ca18-4fd5-9d57-9bca8825814a
Generated-By: PostHog Code Task-Id: ba36fa8e-ca18-4fd5-9d57-9bca8825814a
92f36e7 to
07a6147
Compare
Contributor
|
Reviews (4): Last reviewed commit: "chore: untrack accidentally committed lo..." | Re-trigger Greptile |
adboio
approved these changes
May 13, 2026
5 tasks
This was referenced May 13, 2026
charlescook-ph
pushed a commit
that referenced
this pull request
May 14, 2026
## Summary Pressing Enter in the message editor while offline used to clear the typed prompt even though the message never reached the agent. The connectivity check inside `service.sendPrompt()` throws asynchronously, but `useTiptapEditor.submit()` already runs `doClear()` synchronously after `onSubmit` fires — so the input was wiped before the offline error could be caught. This wraps the existing `onBeforeSubmit` hook (which is already designed to gate clearing — returning `false` short-circuits both `onSubmit` and the editor's auto-clear) at the `SessionView` level with a connectivity check. The typed message stays in the editor, and a stable-id toast gives immediate feedback that the send didn't go through. Both `TaskLogsPanel` and `CommandCenterSessionView` benefit since they share `SessionView`. The new-task input (`TaskInput`) already disables submit when offline, so it isn't affected. ## Test plan - [ ] Disconnect from the network, type a prompt in an existing task's editor, press Enter → prompt remains in the editor and a "Can't send while offline" toast appears. - [ ] Reconnect, press Enter → the prompt sends as normal. - [ ] Branch-mismatch flow still triggers when expected (the wrapped `onBeforeSubmit` still delegates to `useBranchMismatchDialog.handleBeforeSubmit`). - [ ] Same offline behavior works in the command center session view. --- *Created with [PostHog Code](https://posthog.com/code?ref=pr)*
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pressing Enter in the message editor while offline used to clear the typed prompt even though the message never reached the agent. The connectivity check inside
service.sendPrompt()throws asynchronously, butuseTiptapEditor.submit()already runsdoClear()synchronously afteronSubmitfires — so the input was wiped before the offline error could be caught.This wraps the existing
onBeforeSubmithook (which is already designed to gate clearing — returningfalseshort-circuits bothonSubmitand the editor's auto-clear) at theSessionViewlevel with a connectivity check. The typed message stays in the editor, and a stable-id toast gives immediate feedback that the send didn't go through. BothTaskLogsPanelandCommandCenterSessionViewbenefit since they shareSessionView.The new-task input (
TaskInput) already disables submit when offline, so it isn't affected.Test plan
onBeforeSubmitstill delegates touseBranchMismatchDialog.handleBeforeSubmit).Created with PostHog Code