feat(walkthrough): write walkthroughs in the reader's language
A guided explanation is only useful in a language the reader reads, so the panel header gets a language picker alongside the model one, defaulting to the interface language. Like the model, it is request state rather than a setting: the language travels with the read and the generation, and the one a walkthrough was written in is stored with it, so reopening a review describes what is there instead of what a fresh one would be. Only prose is translated. Hunk aliases resolve back to hunk ids and icon/importance are validated against fixed English values, so a translated one would be dropped by the normalizer — silently losing an anchor or a style. Identifiers and paths stay as they appear in the code. The language is part of the cache key, and a read now asks the cache for the exact request it was given before falling back to the pointer. Without that the panel answered a request to switch languages with the text it already had, leaving the other language unused in the cache. Alongside it: - The answer budget is derived from the resolved model instead of a flat 24k. That number was the same for a 64k-context model and for one that admits to 384k output tokens, and on the latter it was the only reason generation failed: the model spent the whole allowance reasoning and returned nothing. It is now min(96k, max(24k, a quarter of the context)) capped by the catalog's output limit, decided once so the input reserve and the request cannot drift apart. - A read no longer offers Cancel. It is a few hundred milliseconds of git with nothing to cancel, and the button flickered on every model or language change. When the panel is showing a fallback, a banner names what is on screen versus what was asked for — only once the read has settled. - The header keeps one 32px control height and drops its labels below 680px instead of squeezing them to two letters and an ellipsis. Docs and module documentation updated in every locale.
This commit is contained in:
@@ -137,6 +137,25 @@ describe('generation jobs', () => {
|
||||
.toEqual({ cancelled: false });
|
||||
});
|
||||
|
||||
// The reserve and the request must be the same number: asking for more than
|
||||
// was subtracted from the input allowance overruns the context mid-answer.
|
||||
it('requests exactly the budget the model resolution reserved', async () => {
|
||||
describeSmallModel.mockResolvedValue({
|
||||
providerID: 'opencode-go',
|
||||
modelID: 'deepseek-v4-flash',
|
||||
source: 'config',
|
||||
inputCharBudget: 1_000_000,
|
||||
structuredOutput: true,
|
||||
outputTokens: 96_000,
|
||||
outputTokenLimit: 384_000,
|
||||
});
|
||||
generateSmallModelText.mockResolvedValue({ text: RESPONSE });
|
||||
|
||||
await generateWalkthrough({ directory: '/repo', source: SOURCE });
|
||||
|
||||
expect(generateSmallModelText.mock.calls.at(-1)[0].maxOutputTokens).toBe(96_000);
|
||||
});
|
||||
|
||||
it('serves the cache once the job has finished, without calling the model again', async () => {
|
||||
generateSmallModelText.mockResolvedValue({ text: RESPONSE });
|
||||
|
||||
@@ -171,6 +190,34 @@ describe('generation timeout', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// The failure this replaced: a flat 24k ask, spent entirely on reasoning by a
|
||||
// model that advertises 384k output tokens and a million of context. The ceiling
|
||||
// exists because the same number is reserved out of the input allowance.
|
||||
describe('output budget', () => {
|
||||
const { walkthroughOutputTokens } = walkthroughTesting;
|
||||
|
||||
it('asks a roomy model for far more than the old fixed budget', () => {
|
||||
expect(walkthroughOutputTokens({ contextTokens: 1_000_000, outputTokenLimit: 384_000 })).toBe(96_000);
|
||||
});
|
||||
|
||||
it('never asks for more than the model says it can emit', () => {
|
||||
expect(walkthroughOutputTokens({ contextTokens: 202_752, outputTokenLimit: 32_768 })).toBe(32_768);
|
||||
});
|
||||
|
||||
it('keeps the reserve to a share of the context', () => {
|
||||
expect(walkthroughOutputTokens({ contextTokens: 200_000, outputTokenLimit: 64_000 })).toBe(50_000);
|
||||
});
|
||||
|
||||
it('holds the old floor for a small or uncatalogued model', () => {
|
||||
expect(walkthroughOutputTokens({ contextTokens: 64_000, outputTokenLimit: null })).toBe(24_000);
|
||||
expect(walkthroughOutputTokens({ contextTokens: 0, outputTokenLimit: null })).toBe(24_000);
|
||||
});
|
||||
|
||||
it('yields to a model whose own limit is below the floor', () => {
|
||||
expect(walkthroughOutputTokens({ contextTokens: 128_000, outputTokenLimit: 8_192 })).toBe(8_192);
|
||||
});
|
||||
});
|
||||
|
||||
describe('generation stages', () => {
|
||||
beforeEach(() => {
|
||||
// Without this the previous suite's cache entry is a hit for the same
|
||||
|
||||
Reference in New Issue
Block a user