Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mobile): a message queued offline no longer switches the thread to a stale model #24562

ClosedBelugaCrypto(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/24562/headopened View on GitHub

Showing 6 changed files with 54 additions and 2 deletions (loading 3).

x
0 of 6 viewed, 6 left
9 additions and 2 deletionsapps/mobile/src/state/thread-outbox-model.tsModified
View file
@@ -54,6 +54,9 @@
context: Schema.optional(OrchestrationMessageContext),
attachments: Schema.Array(DraftComposerAttachmentSchema),
modelSelection: Schema.optional(ModelSelection),
+ // Written with every stored model since follow-ups carry only the user's pick. Entries without it
+ // come from builds that stored this client's cached thread model on every follow-up.
+ modelPicked: Schema.optional(Schema.Literal(true)),
dispatchMode: Schema.optional(Schema.Literals(["auto", "queue", "steer", "restart"])),
runtimeMode: Schema.optional(RuntimeMode),
interactionMode: Schema.optional(ProviderInteractionMode),
@@ -131,12 +134,16 @@
return encodeStoredQueuedThreadMessage({
schemaVersion: THREAD_OUTBOX_SCHEMA_VERSION,
...message,
+ ...(message.modelSelection === undefined ? {} : { modelPicked: true as const }),
});
​
export function decodeQueuedThreadMessage(value: unknown): QueuedThreadMessage {
- const { schemaVersion: _, ...message } = decodeStoredQueuedThreadMessage(value);
- return message;
+ const { schemaVersion: _, modelPicked, ...message } = decodeStoredQueuedThreadMessage(value);
+ if (message.creation !== undefined || modelPicked === true) return message;
+ // Possibly a stale cached model rather than a pick: let the server use the thread's own.
+ const { modelSelection: _unconfirmed, ...followUp } = message;
+ return followUp;
​
export function groupQueuedThreadMessages(