mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-07 01:21:37 +00:00
fix(opencode): use ACP-reported reasoning effort options (#853)
* fix(opencode): use ACP-reported reasoning effort options Expose thought_level options from OpenCode ACP to the web UI via RPC/API instead of hardcoded presets, and validate effort values before setConfigOption. Fixes #852 Co-authored-by: Cursor <cursoragent@cursor.com> * fix(opencode): sync hub effort after coerced setConfigOption When resolveThoughtLevelEffort falls back to a different supported value, roll back session state after a successful ACP update so keepalive and the web UI do not keep advertising the rejected effort. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { resolveThoughtLevelEffort } from './thoughtLevelEffort';
|
||||
|
||||
const thoughtLevelOption = {
|
||||
id: 'effort',
|
||||
category: 'thought_level',
|
||||
currentValue: 'low',
|
||||
options: [
|
||||
{ value: 'low', name: 'Low' },
|
||||
{ value: 'medium', name: 'Medium' }
|
||||
]
|
||||
};
|
||||
|
||||
describe('resolveThoughtLevelEffort', () => {
|
||||
it('returns the requested value when it is supported', () => {
|
||||
expect(resolveThoughtLevelEffort('medium', thoughtLevelOption, 'low')).toBe('medium');
|
||||
});
|
||||
|
||||
it('falls back to the current backend effort when the request is unsupported', () => {
|
||||
expect(resolveThoughtLevelEffort('high', thoughtLevelOption, 'low')).toBe('low');
|
||||
});
|
||||
|
||||
it('falls back to the ACP current value when the backend effort is also unsupported', () => {
|
||||
expect(resolveThoughtLevelEffort('high', thoughtLevelOption, 'max')).toBe('low');
|
||||
});
|
||||
|
||||
it('falls back to the first supported option when nothing else matches', () => {
|
||||
const option = {
|
||||
...thoughtLevelOption,
|
||||
currentValue: 'high'
|
||||
};
|
||||
expect(resolveThoughtLevelEffort('max', option, null)).toBe('low');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user