From db2342aed65182920c2aad6e17ba9fe26af84eda Mon Sep 17 00:00:00 2001 From: Bolin Chen Date: Fri, 13 Nov 2026 13:01:32 +0000 Subject: [PATCH] fix(i18n): say the crewmate schedule countdowns in unit words MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The crewmate Schedules tab formatted its countdowns and the patrol's time limit with fmtUnit's narrow default, so Japanese sentences read 次回は13m後, 13m後に実行 and 7dの時間制限に達しました, and English read Next in 13m and Hit its 7d time limit. inDuration, the one source for all three, now uses the short unit display, the form the patrol interval already uses: 13 分後 and 7 日 in Japanese, 13 min and 7 days in English. Closes #35442 Co-Authored-By: Claude Opus 5.5 --- docs/system-specs/modules/crew-mode.md | 18 +++++++++-------- website/scripts/capture-crewmate-panel-ia.mjs | 2 +- website/src/i18n/en.context.json | 2 +- .../src/pages/members/CrewOnItsOwn.test.tsx | 20 ++++++++++++++----- .../pages/members/CrewScheduleList.test.tsx | 20 ++++++++++++++++--- .../src/pages/members/CrewScheduleList.tsx | 4 +++- 6 files changed, 47 insertions(+), 19 deletions(-) diff --git a/docs/system-specs/modules/crew-mode.md b/docs/system-specs/modules/crew-mode.md index 48d7050f2d1f..900ed4a78bb3 100644 --- a/docs/system-specs/modules/crew-mode.md +++ b/docs/system-specs/modules/crew-mode.md @@ -2563,14 +2563,16 @@ says what wakes it ("Wakes when a task reports back, or every 15 min", the loop's interval in short unit words, so a translation reads `15 分ごと`, never `15mごと`); line three is the facts a person acts on -- last check (or "Has not checked yet"), "Next in" only while the next due time is still -ahead (a late loop promises nothing), and the open-item count from the masked -crew-board read (`GET /api/crew-board`, omitted while unread or when the slot -owns no ledger, a 404 that is not retried). A stopped patrol replaces last/next -with one phrase: "You paused it" (`manual` / `user_stop`), "Hit its 7d time -limit" (`runtime_budget`), "Hit its check limit" (`cycle_cap`), "Stopped while -waiting for your approval" (`approval_stalled` / `approval_stall`), "Its chat -was closed" (`session_close`), and the plain "Stopped" for every other code, -never the raw value. A stop that is a FAILURE +ahead (a late loop promises nothing; "Next in 13 min", the same short unit +words the schedule rows' countdowns use, so ja reads `次回は13 分後`), and +the open-item count from the masked crew-board read (`GET /api/crew-board`, +omitted while unread or when the slot owns no ledger, a 404 that is not +retried). A stopped patrol replaces last/next with one phrase: "You paused +it" (`manual` / `user_stop`), "Hit its 7 days time limit" (`runtime_budget`, +the limit in short unit words too), "Hit its check limit" (`cycle_cap`), +"Stopped while waiting for your approval" (`approval_stalled` / +`approval_stall`), "Its chat was closed" (`session_close`), and the plain +"Stopped" for every other code, never the raw value. A stop that is a FAILURE (`session_start_failures`, `session_unavailable`: "It could not start a check"; `structural_terminal`, `model_refused`, `interrupted_cycle`, `consecutive_failures`: "Its last check failed"; `sentinel_dropped`, diff --git a/website/scripts/capture-crewmate-panel-ia.mjs b/website/scripts/capture-crewmate-panel-ia.mjs index acd8773589a0..a8305f8a7f5e 100644 --- a/website/scripts/capture-crewmate-panel-ia.mjs +++ b/website/scripts/capture-crewmate-panel-ia.mjs @@ -264,7 +264,7 @@ async function captureScheduleVariant(frame, file, expected) { 'Last check 2m ago', 'Next in 1', '3 tasks open', 'Pause', 'Your schedules', ]) await captureScheduleVariant('ledger-stopped', '02d-card-schedules-patrol-paused-light.png', [ - 'Watching its tasks', 'Paused', 'Hit its 7d time limit', '3 tasks still open', 'Resume', + 'Watching its tasks', 'Paused', 'Hit its 7 days time limit', '3 tasks still open', 'Resume', ]) await browser.close() await new Promise((resolve) => srv.close(resolve)) diff --git a/website/src/i18n/en.context.json b/website/src/i18n/en.context.json index 9c7d256ec2b8..7f02eb88d8a1 100644 --- a/website/src/i18n/en.context.json +++ b/website/src/i18n/en.context.json @@ -1114,7 +1114,7 @@ "pages.membersPage.patrol_wakes": "Second line of that row: the Bot wakes when one of its tasks reports back, and otherwise at most every {{interval}} (a duration in unit words, like '15 min' or '1 hr 30 min').", "pages.membersPage.patrol_pause": "Verb on a button: pause the Bot's watch over its tasks. Not the noun.", "pages.membersPage.patrol_resume": "Verb on a button: resume a paused watch. Not the noun.", - "pages.membersPage.patrol_stopped_runtime": "One-phrase reason the watch stopped: it ran up to its time budget of {{limit}} (a short duration like '7d').", + "pages.membersPage.patrol_stopped_runtime": "One-phrase reason the watch stopped: it ran up to its time budget of {{limit}} (a duration in unit words, like '7 days').", "pages.membersPage.patrol_stopped_cycles": "One-phrase reason the watch stopped: it did as many checks as it was allowed.", "components.markdownPanel.select_any_text_or_drag_across_an_image_to_add_i": "One-time tip at the top of the file viewer, shown only when the device has a mouse or trackpad: the reader can select text, or drag a box across an image, to add comments, then send them to the chat together. On a touch-only device the text-only tip shows instead.", "components.commentOverlay.comment_on_the_boxed_area": "Accessible name of the text field in the comment box for a box drawn on an image in the file viewer (also opened by the keyboard 'Comment on this image' button). It parallels the text composer's 'Comment on the selected text', so the field and its 'Add comment' button never read the same; 'boxed area' is the part of the image inside the drawn box.", diff --git a/website/src/pages/members/CrewOnItsOwn.test.tsx b/website/src/pages/members/CrewOnItsOwn.test.tsx index 70cff5b47824..b7b84d009907 100644 --- a/website/src/pages/members/CrewOnItsOwn.test.tsx +++ b/website/src/pages/members/CrewOnItsOwn.test.tsx @@ -1,4 +1,4 @@ -import { render, screen, fireEvent, within } from '@testing-library/react' +import { cleanup, render, screen, fireEvent, within } from '@testing-library/react' // `/all` for the Japanese catalog: `../../i18n` registers English only. import { i18next } from '../../i18n/all' import type { LegacyGoalLoop, StructuredMonitor } from '../../monitoring/automation' @@ -76,7 +76,7 @@ describe('CrewOnItsOwn', () => { expect(row).toHaveTextContent('Watching its tasks') expect(row).toHaveTextContent('Wakes when a task reports back, or every 15 min') const facts = within(row).getByTestId('crew-patrol-facts') - expect(facts).toHaveTextContent('Last check 2m ago · Next in 13m · 3 tasks open') + expect(facts).toHaveTextContent('Last check 2m ago · Next in 13 min · 3 tasks open') const toggle = within(row).getByTestId('crew-patrol-toggle') expect(toggle).toHaveTextContent('Pause') fireEvent.click(toggle) @@ -91,6 +91,16 @@ describe('CrewOnItsOwn', () => { expect(row).toHaveTextContent('タスクから報告があったとき、または15 分ごとに起動します') }) + it('says the next check and the time limit in unit words inside the Japanese sentence (#35442)', async () => { + onTestFinished(() => i18next.changeLanguage('en')) + await i18next.changeLanguage('ja') + const { row } = setup() + expect(within(row).getByTestId('crew-patrol-facts')).toHaveTextContent('次回は13 分後') + cleanup() + const stopped = setup({ loop: { ...LOOP, active: false, stoppedReason: 'runtime_budget', nextDueAt: 0 } }).row + expect(within(stopped).getByTestId('crew-patrol-facts')).toHaveTextContent('7 日の時間制限に達しました') + }) + it('shows none of the budget bookkeeping the Profile readout used to, and leaks no prompt or path', () => { const { row } = setup() const text = row.textContent ?? '' @@ -109,11 +119,11 @@ describe('CrewOnItsOwn', () => { it('an unknown open count and a patrol that never checked read as such', () => { const { row } = setup({ loop: { ...LOOP, lastFireAt: 0 }, openTasks: null }) - expect(within(row).getByTestId('crew-patrol-facts')).toHaveTextContent(/^Has not checked yet · Next in 13m$/) + expect(within(row).getByTestId('crew-patrol-facts')).toHaveTextContent(/^Has not checked yet · Next in 13 min$/) }) it.each([ - ['runtime_budget', 'Hit its 7d time limit'], + ['runtime_budget', 'Hit its 7 days time limit'], ['cycle_cap', 'Hit its check limit'], ['manual', 'You paused it'], ['user_stop', 'You paused it'], @@ -153,7 +163,7 @@ describe('CrewOnItsOwn', () => { it('a failed open-task count is said under the row, and the facts carry no count', () => { const { row } = setup({ openTasks: null, countFailed: true }) expect(screen.getByTestId('crew-patrol-count-error')).toHaveTextContent('Could not count its open tasks.') - expect(within(row).getByTestId('crew-patrol-facts')).toHaveTextContent(/^Last check 2m ago · Next in 13m$/) + expect(within(row).getByTestId('crew-patrol-facts')).toHaveTextContent(/^Last check 2m ago · Next in 13 min$/) }) it('a write in flight disables the control; a refused write shows as an error notice', () => { diff --git a/website/src/pages/members/CrewScheduleList.test.tsx b/website/src/pages/members/CrewScheduleList.test.tsx index a6b548fbfbec..602c469fd1f4 100644 --- a/website/src/pages/members/CrewScheduleList.test.tsx +++ b/website/src/pages/members/CrewScheduleList.test.tsx @@ -1,5 +1,7 @@ -import { describe, it, expect, vi } from 'vitest' +import { describe, it, expect, vi, onTestFinished } from 'vitest' import { render, screen, fireEvent, within } from '@testing-library/react' +// `/all` for the Japanese catalog: `../../i18n` registers English only. +import { i18next } from '../../i18n/all' import CrewScheduleList from './CrewScheduleList' import type { CronJob } from '../../types' @@ -103,7 +105,7 @@ describe('CrewScheduleList rows', () => { job({ id: 'late', name: 'late', next_run_ts: NOW - 300 }), ]) const byName = rowByName - expect(byName('soon')).toHaveTextContent(/Next in 1h.*30m/) + expect(byName('soon')).toHaveTextContent(/Next in 1 hr.*30 min/) expect(byName('paused')).not.toHaveTextContent(/Next in/) expect(byName('late')).not.toHaveTextContent(/Next in/) }) @@ -120,7 +122,19 @@ describe('CrewScheduleList rows', () => { const next = screen.getByTestId('crew-schedule-next') expect(next).toHaveTextContent('Up next') expect(next).toHaveTextContent('sooner') - expect(next).toHaveTextContent('Runs in 10m') + expect(next).toHaveTextContent('Runs in 10 min') + }) + + it('says the countdowns in unit words inside the Japanese sentences (#35442)', async () => { + onTestFinished(() => i18next.changeLanguage('en')) + await i18next.changeLanguage('ja') + setup([ + job({ id: 'a', name: 'sooner', next_run_ts: NOW + 13 * 60 }), + job({ id: 'b', name: 'later', next_run_ts: NOW + 90 * 60 }), + ]) + expect(screen.getByTestId('crew-schedule-next')).toHaveTextContent('13 分後に実行') + expect(rowByName('sooner')).toHaveTextContent('次回は13 分後') + expect(rowByName('later')).toHaveTextContent('次回は1 時間30 分後') }) it('has no Up next card when nothing enabled is due', () => { diff --git a/website/src/pages/members/CrewScheduleList.tsx b/website/src/pages/members/CrewScheduleList.tsx index ea978ac33643..66fe667c78ac 100644 --- a/website/src/pages/members/CrewScheduleList.tsx +++ b/website/src/pages/members/CrewScheduleList.tsx @@ -20,7 +20,9 @@ export function inDuration(remaining: number): string { const h = Math.floor((remaining % 86400) / 3600) const m = Math.floor((remaining % 3600) / 60) const parts: Array<[number, 'day' | 'hour' | 'minute']> = d > 0 ? [[d, 'day'], [h, 'hour']] : h > 0 ? [[h, 'hour'], [m, 'minute']] : [[Math.max(m, 1), 'minute']] - return fmtDuration(parts, { dropZero: true }) + // `short`, not fmtUnit's narrow default: it sits inside a sentence, where ja + // reads `13 分後`, not `13m後`. + return fmtDuration(parts, { dropZero: true, unitDisplay: 'short' }) } function lastRunFailed(job: CronJob): boolean {