feat(mobile): add configurable default effort level#2406
Merged
Conversation
Adds a "Default effort level" setting that lets users choose a fixed reasoning effort (low/medium/high/xhigh/max) or "Last used" for new tasks. Mirrors the existing defaultInitialTaskMode pattern and the desktop implementation. Changes: - Add DefaultReasoningEffort type plus defaultReasoningEffort and lastUsedReasoningEffort state to the mobile preferences store (persisted; defaults to "last_used" / "high") - Pre-fill the new-task composer's reasoning pill from the default, falling back to lastUsedReasoningEffort when set to "last_used" - Persist the user's choice to lastUsedReasoningEffort whenever they pick a reasoning level in the new-task or per-task composer - Add "Default effort level" row in the Settings > Input section Generated-By: PostHog Code Task-Id: c9a0b0d8-fd48-4cd1-a18f-b7a2cfa93020
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
apps/mobile/src/features/preferences/stores/preferencesStore.test.ts:24-39
The setter tests only spot-check one or two values each, missing "low", "medium", "high", and "xhigh" for `setDefaultReasoningEffort` and all values except "xhigh" for `setLastUsedReasoningEffort`. The team's convention is to prefer parameterised tests — using `it.each` here would cover every valid effort level without the repetition.
```suggestion
it.each(["low", "medium", "high", "xhigh", "max", "last_used"] as const)(
"updates defaultReasoningEffort to %s via setter",
(effort) => {
usePreferencesStore.getState().setDefaultReasoningEffort(effort);
expect(usePreferencesStore.getState().defaultReasoningEffort).toBe(
effort,
);
},
);
it.each(["low", "medium", "high", "xhigh", "max"] as const)(
"updates lastUsedReasoningEffort to %s via setter",
(effort) => {
usePreferencesStore.getState().setLastUsedReasoningEffort(effort);
expect(usePreferencesStore.getState().lastUsedReasoningEffort).toBe(
effort,
);
},
);
```
Reviews (1): Last reviewed commit: "feat(mobile): add configurable default e..." | Re-trigger Greptile |
Comment on lines
+24
to
+39
| it("updates defaultReasoningEffort via setter", () => { | ||
| usePreferencesStore.getState().setDefaultReasoningEffort("max"); | ||
| expect(usePreferencesStore.getState().defaultReasoningEffort).toBe("max"); | ||
|
|
||
| usePreferencesStore.getState().setDefaultReasoningEffort("last_used"); | ||
| expect(usePreferencesStore.getState().defaultReasoningEffort).toBe( | ||
| "last_used", | ||
| ); | ||
| }); | ||
|
|
||
| it("updates lastUsedReasoningEffort via setter", () => { | ||
| usePreferencesStore.getState().setLastUsedReasoningEffort("xhigh"); | ||
| expect(usePreferencesStore.getState().lastUsedReasoningEffort).toBe( | ||
| "xhigh", | ||
| ); | ||
| }); |
Contributor
There was a problem hiding this comment.
The setter tests only spot-check one or two values each, missing "low", "medium", "high", and "xhigh" for
setDefaultReasoningEffort and all values except "xhigh" for setLastUsedReasoningEffort. The team's convention is to prefer parameterised tests — using it.each here would cover every valid effort level without the repetition.
Suggested change
| it("updates defaultReasoningEffort via setter", () => { | |
| usePreferencesStore.getState().setDefaultReasoningEffort("max"); | |
| expect(usePreferencesStore.getState().defaultReasoningEffort).toBe("max"); | |
| usePreferencesStore.getState().setDefaultReasoningEffort("last_used"); | |
| expect(usePreferencesStore.getState().defaultReasoningEffort).toBe( | |
| "last_used", | |
| ); | |
| }); | |
| it("updates lastUsedReasoningEffort via setter", () => { | |
| usePreferencesStore.getState().setLastUsedReasoningEffort("xhigh"); | |
| expect(usePreferencesStore.getState().lastUsedReasoningEffort).toBe( | |
| "xhigh", | |
| ); | |
| }); | |
| it.each(["low", "medium", "high", "xhigh", "max", "last_used"] as const)( | |
| "updates defaultReasoningEffort to %s via setter", | |
| (effort) => { | |
| usePreferencesStore.getState().setDefaultReasoningEffort(effort); | |
| expect(usePreferencesStore.getState().defaultReasoningEffort).toBe( | |
| effort, | |
| ); | |
| }, | |
| ); | |
| it.each(["low", "medium", "high", "xhigh", "max"] as const)( | |
| "updates lastUsedReasoningEffort to %s via setter", | |
| (effort) => { | |
| usePreferencesStore.getState().setLastUsedReasoningEffort(effort); | |
| expect(usePreferencesStore.getState().lastUsedReasoningEffort).toBe( | |
| effort, | |
| ); | |
| }, | |
| ); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/mobile/src/features/preferences/stores/preferencesStore.test.ts
Line: 24-39
Comment:
The setter tests only spot-check one or two values each, missing "low", "medium", "high", and "xhigh" for `setDefaultReasoningEffort` and all values except "xhigh" for `setLastUsedReasoningEffort`. The team's convention is to prefer parameterised tests — using `it.each` here would cover every valid effort level without the repetition.
```suggestion
it.each(["low", "medium", "high", "xhigh", "max", "last_used"] as const)(
"updates defaultReasoningEffort to %s via setter",
(effort) => {
usePreferencesStore.getState().setDefaultReasoningEffort(effort);
expect(usePreferencesStore.getState().defaultReasoningEffort).toBe(
effort,
);
},
);
it.each(["low", "medium", "high", "xhigh", "max"] as const)(
"updates lastUsedReasoningEffort to %s via setter",
(effort) => {
usePreferencesStore.getState().setLastUsedReasoningEffort(effort);
expect(usePreferencesStore.getState().lastUsedReasoningEffort).toBe(
effort,
);
},
);
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Use it.each to cover every reasoning effort level in the setter tests, matching the convention used across the desktop test suite. Generated-By: PostHog Code Task-Id: c9a0b0d8-fd48-4cd1-a18f-b7a2cfa93020
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
last_used, which remembers the user's most recent pick.lastUsedReasoningEffortis updated whenever the user picks a reasoning level in either composer, so thelast_useddefault has something to fall back on.preferencesStore. UI added under Settings > Input below "Initial task mode".Test plan
pnpm --filter @posthog/mobile test(preferences store unit tests + existing suite)