-
Notifications
You must be signed in to change notification settings - Fork 44
fix(inbox): validate persisted model before one-click cloud tasks #2728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
andrewm4894
wants to merge
4
commits into
main
Choose a base branch
from
posthog-code/fix-stale-model-cloud-tasks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f0a2e54
fix(inbox): validate persisted model before one-click cloud tasks
andrewm4894 40ed207
Merge remote-tracking branch 'origin/main' into posthog-code/fix-stal…
andrewm4894 b1b6bee
fix(inbox): degrade gracefully on model resolver failure + flatten gr…
andrewm4894 a422ac6
fix(inbox): extend graceful model fallback to setup + report task ser…
andrewm4894 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { | ||
| type PreviewConfigOption, | ||
| selectModelFromOptions, | ||
| } from "./reportTaskCreation"; | ||
|
|
||
| function modelOption( | ||
| currentValue: string, | ||
| available: string[], | ||
| ): PreviewConfigOption { | ||
| return { | ||
| id: "model", | ||
| category: "model", | ||
| type: "select", | ||
| currentValue, | ||
| options: available.map((value) => ({ value })), | ||
| }; | ||
| } | ||
|
|
||
| describe("selectModelFromOptions", () => { | ||
| it.each([ | ||
| { | ||
| name: "returns the server default when no preferred model is given", | ||
| options: [modelOption("claude-opus-4-8", ["claude-opus-4-8"])], | ||
| preferredModel: undefined, | ||
| expected: "claude-opus-4-8", | ||
| }, | ||
| { | ||
| name: "honours the preferred model when the gateway still offers it", | ||
| options: [ | ||
| modelOption("claude-opus-4-8", [ | ||
| "claude-opus-4-8", | ||
| "claude-sonnet-4-6", | ||
| ]), | ||
| ], | ||
| preferredModel: "claude-sonnet-4-6", | ||
| expected: "claude-sonnet-4-6", | ||
| }, | ||
| { | ||
| // The persisted model (e.g. a de-listed fable) is not in the available | ||
| // options, so it must not be returned — otherwise the run 403s. | ||
| name: "falls back to the server default when the preferred model is no longer offered", | ||
| options: [modelOption("claude-opus-4-8", ["claude-opus-4-8"])], | ||
| preferredModel: "claude-fable-5", | ||
| expected: "claude-opus-4-8", | ||
| }, | ||
| { | ||
| name: "ignores an empty string preferred model", | ||
| options: [modelOption("claude-opus-4-8", ["claude-opus-4-8"])], | ||
| preferredModel: "", | ||
| expected: "claude-opus-4-8", | ||
| }, | ||
| { | ||
| name: "ignores a null preferred model", | ||
| options: [modelOption("claude-opus-4-8", ["claude-opus-4-8"])], | ||
| preferredModel: null, | ||
| expected: "claude-opus-4-8", | ||
| }, | ||
| { | ||
| // The gateway can return models wrapped in labelled groups; a preferred | ||
| // model nested inside a group must still count as available. | ||
| name: "honours a preferred model nested in a labelled group", | ||
| options: [ | ||
| { | ||
| id: "model", | ||
| category: "model", | ||
| type: "select", | ||
| currentValue: "claude-opus-4-8", | ||
| options: [ | ||
| { options: [{ value: "claude-opus-4-8" }] }, | ||
| { options: [{ value: "claude-sonnet-4-6" }] }, | ||
| ], | ||
| } satisfies PreviewConfigOption, | ||
| ], | ||
| preferredModel: "claude-sonnet-4-6", | ||
| expected: "claude-sonnet-4-6", | ||
| }, | ||
| { | ||
| name: "returns undefined when there is no model option", | ||
| options: [ | ||
| { id: "mode", category: "mode", type: "select", currentValue: "plan" }, | ||
| ] satisfies PreviewConfigOption[], | ||
| preferredModel: "claude-opus-4-8", | ||
| expected: undefined, | ||
| }, | ||
| ])("$name", ({ options, preferredModel, expected }) => { | ||
| expect(selectModelFromOptions(options, preferredModel)).toBe(expected); | ||
| }); | ||
| }); | ||
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.