You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Queued message disappears after reload instead of persisting until turn ends #391
autonomous: likelyProbably hands-off: clearly worth fixing, agent can do it, minor judgment needed.bugSomething isn't workingfable-5Assigned to Fable-5 to fixpriority: mediumP2 - normal prioritytriage: unclearCannot reproduce / insufficient info
When a message is queued during an active turn and a reload happens, the queued message sometimes does not persist. Instead of staying queued, it just disappears.
Expected behavior
A queued message should remain in the queue across a reload. It should only be dequeued and sent once the current turn naturally completes (i.e. the model stops on its own, not because of the reload). Concretely:
Turn is in progress.
User queues a message.
Reload happens.
Turn continues after reload.
Model naturally finishes the turn.
The queued message is then sent.
Actual behavior
The queued message is sometimes dropped during/after the reload and never sent.
Notes
The dequeue should be tied to the turn naturally ending, not to the reload event itself.
The queue-persist-across-reload infrastructure already exists and is well-developed:
Queue field is App.queued_messages (crates/jcode-tui/src/tui/app/state_ui.rs:11).
On reload, save_input_for_reload() (state_ui.rs:182) serializes queued_messages (and interleave/soft-interrupts) to ~/.jcode/client-input-<session>. It is invoked from the reload paths (tui_lifecycle_runtime.rs:551/570, state_ui_maintenance.rs:234, remote/reconnect.rs:624, remote/key_handling.rs:839/851).
On restore, restore_input_for_reload() (state_ui.rs:305) + apply_restored_reload_input() (tui_lifecycle.rs:6) re-populate queued_messages and explicitly keep them as a 'wait-until-turn-end' queue for remote sessions until the history/Done event proves the turn is idle (tui_lifecycle.rs:64+).
So the expected behavior described in the issue is the intended design and the happy path is covered by tests (tests/remote_startup_input_03/part_01.rs, tests/remote_events_reload_*). The reported drop is intermittent ('sometimes'), pointing at a race in a specific reload path rather than a missing feature. Recommended next step: capture a repro with logs (the save/restore paths log Startup input restored: ... queued_messages=N) to identify which reload path skipped/clobbered the save (e.g. a save fired before the message was pushed to queued_messages, or a path that calls reload without save_input_for_reload). Cannot reproduce from a code read alone, hence unclear.
Root cause: a queued follow-up that had already been dequeued into an in-flight send lives only in rate_limit_pending_message with the shape is_system && !auto_retry. That shape has no retry path: the tick resend requires a rate_limit_reset timestamp and the disconnect resend requires auto_retry. So whenever a reload/disconnect, stream stall, failed send, or a server "Already processing" rejection raced the turn-end dispatch, the message was silently dropped. This matches the reported intermittency: it only happened when the reload landed in the window between dequeue and turn completion.
Fixes:
recover_undelivered_queued_continuation folds the in-flight continuation (and its hidden reminder) back onto the queue on disconnect and stream stall.
handle_tick / process_remote_followups restore dequeued messages to the queue when begin_remote_send fails instead of logging and dropping.
On "Already processing a message", the follow-up is re-queued and the running-turn state re-adopted.
save_input_for_reload persists the in-flight continuation at the front of the restored queue, and an empty save removes a stale restore file (>5 min old) so old state cannot resurrect, while preserving fresh files for multi-client safety.
The queue still only dispatches after the turn is proven idle post-reconnect, per the queue's contract.
autonomous: likelyProbably hands-off: clearly worth fixing, agent can do it, minor judgment needed.bugSomething isn't workingfable-5Assigned to Fable-5 to fixpriority: mediumP2 - normal prioritytriage: unclearCannot reproduce / insufficient info
Activity
1jehuang commentedon Jun 25, 2026
Triage:
triage: unclear(intermittent, not reproduced) / autonomous: likely / priority: medium.The queue-persist-across-reload infrastructure already exists and is well-developed:
App.queued_messages(crates/jcode-tui/src/tui/app/state_ui.rs:11).save_input_for_reload()(state_ui.rs:182) serializesqueued_messages(and interleave/soft-interrupts) to~/.jcode/client-input-<session>. It is invoked from the reload paths (tui_lifecycle_runtime.rs:551/570,state_ui_maintenance.rs:234,remote/reconnect.rs:624,remote/key_handling.rs:839/851).restore_input_for_reload()(state_ui.rs:305) +apply_restored_reload_input()(tui_lifecycle.rs:6) re-populatequeued_messagesand explicitly keep them as a 'wait-until-turn-end' queue for remote sessions until the history/Done event proves the turn is idle (tui_lifecycle.rs:64+).So the expected behavior described in the issue is the intended design and the happy path is covered by tests (
tests/remote_startup_input_03/part_01.rs,tests/remote_events_reload_*). The reported drop is intermittent ('sometimes'), pointing at a race in a specific reload path rather than a missing feature. Recommended next step: capture a repro with logs (the save/restore paths logStartup input restored: ... queued_messages=N) to identify which reload path skipped/clobbered the save (e.g. a save fired before the message was pushed toqueued_messages, or a path that calls reload withoutsave_input_for_reload). Cannot reproduce from a code read alone, hence unclear.fix(tui): stop losing queued follow-ups across disconnects and reloads (
test(tui): regression coverage for queued-message loss across reloads (…
1jehuang commentedon Jul 2, 2026
Fixed in 155902e, regression tests in 81f5d13.
Root cause: a queued follow-up that had already been dequeued into an in-flight send lives only in
rate_limit_pending_messagewith the shapeis_system && !auto_retry. That shape has no retry path: the tick resend requires arate_limit_resettimestamp and the disconnect resend requiresauto_retry. So whenever a reload/disconnect, stream stall, failed send, or a server "Already processing" rejection raced the turn-end dispatch, the message was silently dropped. This matches the reported intermittency: it only happened when the reload landed in the window between dequeue and turn completion.Fixes:
recover_undelivered_queued_continuationfolds the in-flight continuation (and its hidden reminder) back onto the queue on disconnect and stream stall.handle_tick/process_remote_followupsrestore dequeued messages to the queue whenbegin_remote_sendfails instead of logging and dropping.save_input_for_reloadpersists the in-flight continuation at the front of the restored queue, and an empty save removes a stale restore file (>5 min old) so old state cannot resurrect, while preserving fresh files for multi-client safety.The queue still only dispatches after the turn is proven idle post-reconnect, per the queue's contract.
1jehuang commentedon Jul 2, 2026
Released in v0.34.0. Run
jcode updateto get it.fix(server): dedup re-sent user submissions via a stable submission n…
fix(tui): bound both client-side queued-message resend storms (#52)
fix(tui): stop losing queued follow-ups across disconnects and reloads (
test(tui): regression coverage for queued-message loss across reloads (…
fix(tui): stop losing queued follow-ups across disconnects and reloads (
test(tui): regression coverage for queued-message loss across reloads (…
fix(review-loop): close Round-E premature re-check gap on failed disp…