Skip to content

fix(web): apply sticky model when reusing existing draft thread#1291

Open
murataslan1 wants to merge 2 commits intopingdotgg:mainfrom
murataslan1:fix/model-reset-new-thread
Open

fix(web): apply sticky model when reusing existing draft thread#1291
murataslan1 wants to merge 2 commits intopingdotgg:mainfrom
murataslan1:fix/model-reset-new-thread

Conversation

@murataslan1
Copy link

@murataslan1 murataslan1 commented Mar 22, 2026

Summary

Fixes the model selection resetting to GPT 5.4 when creating a new thread.

Root Cause

handleNewThread() in useHandleNewThread.ts has 3 code paths:

  1. Reuse stored draft thread (line 57) — sticky model was NOT applied
  2. Reuse active draft in same project (line 79) — sticky model was NOT applied
  3. Create brand new thread (line 95) — sticky model was applied

When a user clicks "New Thread" and a draft already exists for that project, path 1 was taken — navigating to the old draft without updating its model to match the user's last selection.

Fix

Apply stickyModel and stickyModelOptions to the draft thread in the stored draft path (path 1), matching the behavior already present in path 3.

Test plan

  1. Select Claude Opus 4.6 and create a thread
  2. Click "New Thread" on the same project
  3. Verify the model picker shows Claude Opus 4.6 (not GPT 5.4)

Fixes #1276

Note

Apply sticky model when reusing an existing draft thread

When handleNewThread reuses an existing draft thread (stored or current route), it now sets the thread's provider and model from the composer's sticky model preference and applies any sticky model options. Previously, sticky model preferences were ignored in these reuse paths, so the thread would not reflect the user's saved model choice.

Macroscope summarized cf46b91.

Copilot AI review requested due to automatic review settings March 22, 2026 00:05
@coderabbitai
Copy link

coderabbitai bot commented Mar 22, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 104c97a9-f8c1-44d0-9c94-32d807eac0ef

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can enable review details to help with troubleshooting, context usage and more.

Enable the reviews.review_details setting to include review details such as the model used, the time taken for each step and more in the review comments.

@github-actions github-actions bot added size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 22, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes the web “New Thread” flow so that when an existing project draft thread is reused, it is updated to the user’s sticky model selection instead of reverting to the default model (e.g., GPT 5.4).

Changes:

  • Apply stickyModel and stickyModelOptions when reusing a stored draft thread in useHandleNewThread.
  • Set settingSources: ["user", "project"] for Claude Agent SDK query options in the server Claude adapter.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
apps/web/src/hooks/useHandleNewThread.ts Updates the stored-draft reuse path to also apply sticky model + options before navigating/reusing.
apps/server/src/provider/Layers/ClaudeAdapter.ts Adds Claude Agent SDK settingSources to query options (behavioral change to session startup).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 2578 to 2580
env: process.env,
settingSources: ["user", "project"],
...(input.cwd ? { additionalDirectories: [input.cwd] } : {}),
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

This PR is labeled/-described as a web-only fix for sticky model selection, but this change alters server-side Claude Agent session startup behavior by explicitly setting settingSources. Please either (a) document in the PR description why this server behavior change is required for the web sticky-model fix, including expected impact, or (b) move it to a separate PR to avoid shipping unrelated runtime behavior changes together.

Copilot uses AI. Check for mistakes.
Comment on lines +66 to +72
if (stickyModel) {
setProvider(storedDraftThread.threadId, inferProviderForModel(stickyModel));
setModel(storedDraftThread.threadId, stickyModel);
}
if (Object.keys(stickyModelOptions).length > 0) {
setModelOptions(storedDraftThread.threadId, stickyModelOptions);
}
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

This adds sticky model/modelOptions application when reusing a stored draft thread, but the other reuse path (when latestActiveDraftThread exists for the same project and you return early around lines 86–100) still doesn’t apply stickyModel/stickyModelOptions. If the project->draft mapping is missing but the user is currently on a draft thread, clicking “New Thread” can still leave the draft on an outdated/default model. Consider applying the same sticky-model update in that early-return branch (or factor the sticky application into a shared helper).

Copilot uses AI. Check for mistakes.
@UtkarshUsername
Copy link
Contributor

Also see #1277

@github-actions github-actions bot added size:S 10-29 changed lines (additions + deletions). and removed size:XS 0-9 changed lines (additions + deletions). labels Mar 22, 2026
@murataslan1
Copy link
Author

murataslan1 commented Mar 22, 2026

Addressed the feedback:

@UtkarshUsername
Copy link
Contributor

Are you a bot?

@murataslan1
Copy link
Author

Nope, just using Claude Code as my coding assistant.

@UtkarshUsername
Copy link
Contributor

The settingSources is still in this PR

When creating a new thread, if a stored draft thread already existed
for the project, the sticky model was not applied to it. This caused
the model picker to show the default model (GPT 5.4) instead of the
user's last selected model.

Apply stickyModel and stickyModelOptions to the draft thread in all
code paths, not just when creating a brand new thread.

Fixes pingdotgg#1276
Address review feedback: the second reuse path (when
latestActiveDraftThread exists for the same project) also needs
stickyModel/stickyModelOptions applied, otherwise clicking "New Thread"
while on an existing draft can leave it on an outdated model.
@murataslan1 murataslan1 force-pushed the fix/model-reset-new-thread branch from 21f3e9b to cf46b91 Compare March 22, 2026 10:55
@murataslan1
Copy link
Author

murataslan1 commented Mar 22, 2026

You're right, my bad, the branch had the settingSources commit mixed in. Rebased on main so the diff only contains the sticky model fix now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Model selection resets to GPT 5.4 when creating a new thread

3 participants