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:
Bohdan Triapitsyn
2026-08-03 01:27:27 +03:00
parent e5799c0c67
commit 1d17cb87b3
39 changed files with 1027 additions and 81 deletions
+5
View File
@@ -1106,6 +1106,11 @@ export const dict = {
'walkthrough.scope.working': 'Unstaged',
'walkthrough.scope.branch': 'This branch',
'walkthrough.scope.selectorAria': 'Select what to review',
'walkthrough.language.menuLabel': 'Walkthrough language',
'walkthrough.missing.language': 'No walkthrough in {requested} yet — showing the one in {shown}.',
'walkthrough.missing.model': 'No walkthrough from {model} yet — showing the last one generated here.',
'walkthrough.missing.languageAndModel': 'No walkthrough in this language from this model yet — showing the last one generated here.',
'walkthrough.language.selectorAria': 'Select the walkthrough language',
'walkthrough.scope.pullRequest': 'PR #{number}',
'walkthrough.action.generate': 'Generate walkthrough',
'walkthrough.action.regenerate': 'Regenerate',
+5
View File
@@ -1107,6 +1107,11 @@ export const dict: Record<I18nKey, string> = {
"walkthrough.scope.working": "Sin preparar",
"walkthrough.scope.branch": "Esta rama",
"walkthrough.scope.selectorAria": "Elegir qué revisar",
"walkthrough.language.menuLabel": "Idioma del recorrido",
"walkthrough.missing.language": "Aún no hay un recorrido en {requested}: se muestra el de {shown}.",
"walkthrough.missing.model": "Aún no hay un recorrido de {model}: se muestra el último generado aquí.",
"walkthrough.missing.languageAndModel": "Aún no hay un recorrido en este idioma con este modelo: se muestra el último generado aquí.",
"walkthrough.language.selectorAria": "Elegir el idioma del recorrido",
"walkthrough.scope.pullRequest": "PR n.º {number}",
"walkthrough.action.generate": "Generar recorrido",
"walkthrough.action.regenerate": "Regenerar",
+5
View File
@@ -931,6 +931,11 @@ export const dict = {
'walkthrough.scope.working': 'Non indexées',
'walkthrough.scope.branch': 'Cette branche',
'walkthrough.scope.selectorAria': 'Choisir ce qui est examiné',
'walkthrough.language.menuLabel': 'Langue du parcours',
'walkthrough.missing.language': 'Pas encore de parcours en {requested} — voici celui en {shown}.',
'walkthrough.missing.model': 'Pas encore de parcours généré par {model} — voici le dernier généré ici.',
'walkthrough.missing.languageAndModel': 'Pas encore de parcours dans cette langue avec ce modèle — voici le dernier généré ici.',
'walkthrough.language.selectorAria': 'Choisir la langue du parcours',
'walkthrough.scope.pullRequest': 'PR n° {number}',
'walkthrough.action.generate': 'Générer le parcours',
'walkthrough.action.regenerate': 'Régénérer',
+5
View File
@@ -1103,6 +1103,11 @@ export const dict: Record<I18nKey, string> = {
'walkthrough.scope.working': '未ステージ',
'walkthrough.scope.branch': 'このブランチ',
'walkthrough.scope.selectorAria': 'レビュー対象を選択',
'walkthrough.language.menuLabel': 'ウォークスルーの言語',
'walkthrough.missing.language': '{requested}のウォークスルーはまだありません。{shown}のものを表示しています。',
'walkthrough.missing.model': '{model} が生成したウォークスルーはまだありません。ここで最後に生成されたものを表示しています。',
'walkthrough.missing.languageAndModel': 'この言語・このモデルのウォークスルーはまだありません。ここで最後に生成されたものを表示しています。',
'walkthrough.language.selectorAria': 'ウォークスルーの言語を選択',
'walkthrough.scope.pullRequest': 'PR #{number}',
'walkthrough.action.generate': 'ウォークスルーを生成',
'walkthrough.action.regenerate': '再生成',
+5
View File
@@ -1107,6 +1107,11 @@ export const dict: Record<I18nKey, string> = {
'walkthrough.scope.working': '스테이지 안 됨',
'walkthrough.scope.branch': '이 브랜치',
'walkthrough.scope.selectorAria': '리뷰 대상 선택',
'walkthrough.language.menuLabel': '워크스루 언어',
'walkthrough.missing.language': '{requested} 워크스루가 아직 없어 {shown} 워크스루를 표시합니다.',
'walkthrough.missing.model': '{model}(으)로 생성한 워크스루가 아직 없어 마지막으로 생성된 것을 표시합니다.',
'walkthrough.missing.languageAndModel': '이 언어와 이 모델로 생성한 워크스루가 아직 없어 마지막으로 생성된 것을 표시합니다.',
'walkthrough.language.selectorAria': '워크스루 언어 선택',
'walkthrough.scope.pullRequest': 'PR #{number}',
'walkthrough.action.generate': '워크스루 생성',
'walkthrough.action.regenerate': '다시 생성',
+5
View File
@@ -1419,6 +1419,11 @@ export const dict: Record<I18nKey, string> = {
'walkthrough.scope.working': 'Poza poczekalnią',
'walkthrough.scope.branch': 'Ta gałąź',
'walkthrough.scope.selectorAria': 'Wybierz, co przejrzeć',
'walkthrough.language.menuLabel': 'Język przewodnika',
'walkthrough.missing.language': 'Nie ma jeszcze przewodnika w języku {requested} — pokazujemy ten w języku {shown}.',
'walkthrough.missing.model': 'Nie ma jeszcze przewodnika od modelu {model} — pokazujemy ostatni wygenerowany tutaj.',
'walkthrough.missing.languageAndModel': 'Nie ma jeszcze przewodnika w tym języku od tego modelu — pokazujemy ostatni wygenerowany tutaj.',
'walkthrough.language.selectorAria': 'Wybierz język przewodnika',
'walkthrough.scope.pullRequest': 'PR #{number}',
'walkthrough.action.generate': 'Wygeneruj przewodnik',
'walkthrough.action.regenerate': 'Wygeneruj ponownie',
@@ -1107,6 +1107,11 @@ export const dict: Record<I18nKey, string> = {
"walkthrough.scope.working": "Fora do stage",
"walkthrough.scope.branch": "Este branch",
"walkthrough.scope.selectorAria": "Escolher o que revisar",
"walkthrough.language.menuLabel": "Idioma do percurso",
"walkthrough.missing.language": "Ainda não há um percurso em {requested} — exibindo o de {shown}.",
"walkthrough.missing.model": "Ainda não há um percurso gerado por {model} — exibindo o último gerado aqui.",
"walkthrough.missing.languageAndModel": "Ainda não há um percurso neste idioma com este modelo — exibindo o último gerado aqui.",
"walkthrough.language.selectorAria": "Escolher o idioma do percurso",
"walkthrough.scope.pullRequest": "PR nº {number}",
"walkthrough.action.generate": "Gerar percurso",
"walkthrough.action.regenerate": "Gerar novamente",
+5
View File
@@ -1107,6 +1107,11 @@ export const dict: Record<I18nKey, string> = {
"walkthrough.scope.working": "Поза індексом",
"walkthrough.scope.branch": "Ця гілка",
"walkthrough.scope.selectorAria": "Обрати, що розбирати",
"walkthrough.language.menuLabel": "Мова розбору",
"walkthrough.missing.language": "Розбору мовою {requested} ще немає — показано той, що мовою {shown}.",
"walkthrough.missing.model": "Розбору від {model} ще немає — показано останній згенерований тут.",
"walkthrough.missing.languageAndModel": "Розбору цією мовою від цієї моделі ще немає — показано останній згенерований тут.",
"walkthrough.language.selectorAria": "Обрати мову розбору",
"walkthrough.scope.pullRequest": "PR #{number}",
"walkthrough.action.generate": "Створити розбір",
"walkthrough.action.regenerate": "Створити заново",
@@ -1107,6 +1107,11 @@ export const dict: Record<I18nKey, string> = {
'walkthrough.scope.working': '未暂存',
'walkthrough.scope.branch': '当前分支',
'walkthrough.scope.selectorAria': '选择评审范围',
'walkthrough.language.menuLabel': '导读语言',
'walkthrough.missing.language': '尚无{requested}导读,当前显示的是{shown}版本。',
'walkthrough.missing.model': '尚无由 {model} 生成的导读,当前显示最近一次生成的版本。',
'walkthrough.missing.languageAndModel': '尚无使用该语言和该模型生成的导读,当前显示最近一次生成的版本。',
'walkthrough.language.selectorAria': '选择导读语言',
'walkthrough.scope.pullRequest': 'PR #{number}',
'walkthrough.action.generate': '生成导读',
'walkthrough.action.regenerate': '重新生成',
@@ -1119,6 +1119,11 @@ export const dict: Record<I18nKey, string> = {
'walkthrough.scope.working': '未暫存',
'walkthrough.scope.branch': '目前分支',
'walkthrough.scope.selectorAria': '選擇審閱範圍',
'walkthrough.language.menuLabel': '導讀語言',
'walkthrough.missing.language': '尚無{requested}導讀,目前顯示的是{shown}版本。',
'walkthrough.missing.model': '尚無由 {model} 產生的導讀,目前顯示最近一次產生的版本。',
'walkthrough.missing.languageAndModel': '尚無使用該語言與該模型產生的導讀,目前顯示最近一次產生的版本。',
'walkthrough.language.selectorAria': '選擇導讀語言',
'walkthrough.scope.pullRequest': 'PR #{number}',
'walkthrough.action.generate': '產生導讀',
'walkthrough.action.regenerate': '重新產生',
+4 -2
View File
@@ -31,13 +31,14 @@ const throwFromResponse = async (response: Response, fallback: string): Promise<
export async function fetchWalkthrough(
directory: string,
source: WalkthroughSource,
options: { model?: string; signal?: AbortSignal } = {}
options: { model?: string; language?: string; signal?: AbortSignal } = {}
): Promise<WalkthroughResult> {
const response = await runtimeFetch(BASE, {
query: {
directory,
source: JSON.stringify(source),
...(options.model ? { model: options.model } : {}),
...(options.language ? { language: options.language } : {}),
},
signal: options.signal,
});
@@ -50,7 +51,7 @@ export async function fetchWalkthrough(
export async function generateWalkthrough(
directory: string,
source: WalkthroughSource,
options: { force?: boolean; model?: string; signal?: AbortSignal } = {}
options: { force?: boolean; model?: string; language?: string; signal?: AbortSignal } = {}
): Promise<WalkthroughResult> {
const response = await runtimeFetch(`${BASE}/generate`, {
method: 'POST',
@@ -60,6 +61,7 @@ export async function generateWalkthrough(
source,
force: options.force === true,
...(options.model ? { model: options.model } : {}),
...(options.language ? { language: options.language } : {}),
}),
signal: options.signal,
});
+5
View File
@@ -62,6 +62,11 @@ export interface WalkthroughResult {
source: WalkthroughSource;
walkthrough: Walkthrough | null;
model?: WalkthroughModel;
/**
* Language the prose on screen is written in not necessarily the one being
* asked for now. Null for an entry written before the setting existed.
*/
language?: string | null;
generatedAt?: string;
fromCache?: boolean;
hunks: WalkthroughHunk[];