Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

fix(sessions): preserve prompt when sending while offline - #1971

Merged
adboio merged 4 commits into
mainfrom
posthog-code/preserve-prompt-when-offline
May 13, 2026
Merged

adboio merged 4 commits into
mainfrom
posthog-code/preserve-prompt-when-offline

Conversation

@posthog

@posthog posthog Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

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

@sakce
sakce requested a review from jonathanlab May 1, 2026 10:16
@sakce
sakce marked this pull request as ready for review May 1, 2026 10:16
@greptile-apps

greptile-apps Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix 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

@greptile-apps

greptile-apps Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix 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

@charlesvien
charlesvien force-pushed the posthog-code/preserve-prompt-when-offline branch 2 times, most recently from b074003 to 92f36e7 Compare May 7, 2026 22:19
@greptile-apps

greptile-apps Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

Reviews (3): Last reviewed commit: "chore: untrack accidentally committed lo..." | Re-trigger Greptile

PostHog Code 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
@charlesvien
charlesvien force-pushed the posthog-code/preserve-prompt-when-offline branch from 92f36e7 to 07a6147 Compare May 7, 2026 22:23
@greptile-apps

greptile-apps Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

Reviews (4): Last reviewed commit: "chore: untrack accidentally committed lo..." | Re-trigger Greptile

@adboio adboio added the Create Release This will trigger a new release label May 13, 2026 — with Graphite App
@adboio
adboio merged commit 8c92638 into main May 13, 2026
15 checks passed
@adboio
adboio deleted the posthog-code/preserve-prompt-when-offline branch May 13, 2026 18:38
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)*
charlesvien pushed a commit that referenced this pull request May 22, 2026
Adds @reforged/maker-appimage so Forge produces x64 and arm64 AppImages
alongside the existing macOS/Windows artifacts. The release workflow gains
a publish-linux matrix job (ubuntu-latest + ubuntu-24.04-arm) which
installs the AppImage tooling (squashfs-tools, zsync, libfuse2t64) before
running electron-forge publish, and finalize-release now depends on it.

Also includes a make:linux script that builds the AppImage from macOS via
Docker for local verification, since electron-forge can't natively
cross-build AppImages from darwin.

Drive-by fix: remove a duplicate `const { isOnline } = useConnectivity()`
in SessionView.tsx that came in via a merge collision between #1971 and
#2121 and was failing typecheck on main.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
gantoine added a commit that referenced this pull request May 28, 2026
Adds @reforged/maker-appimage so Forge produces x64 and arm64 AppImages
alongside the existing macOS/Windows artifacts. The release workflow gains
a publish-linux matrix job (ubuntu-latest + ubuntu-24.04-arm) which
installs the AppImage tooling (squashfs-tools, zsync, libfuse2t64) before
running electron-forge publish, and finalize-release now depends on it.

Also includes a make:linux script that builds the AppImage from macOS via
Docker for local verification, since electron-forge can't natively
cross-build AppImages from darwin.

Drive-by fix: remove a duplicate `const { isOnline } = useConnectivity()`
in SessionView.tsx that came in via a merge collision between #1971 and

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Create Release This will trigger a new release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants