Skip to content

feat: add configurable queue parameters#926

Open
yrom wants to merge 1 commit intomengxi-ream:mainfrom
yrom:feature/request-queue-more-options
Open

feat: add configurable queue parameters#926
yrom wants to merge 1 commit intomengxi-ream:mainfrom
yrom:feature/request-queue-more-options

Conversation

@yrom
Copy link
Contributor

@yrom yrom commented Jan 28, 2026

Type of Changes

  • ✨ New feature (feat)

Description

Expose hardcoded queue parameters as user-configurable options:

  • requestQueueConfig:

    • timeoutMs: Request timeout (default: 30s, min: 5s, max: 120s)
    • maxRetries: Maximum retry attempts (default: 2, min: 0, max: 5)
    • baseRetryDelayMs: Base delay before retry (default: 1.5s, min: 0.5s, max: 10s)
  • batchQueueConfig:

    • batchDelay: Delay between batch processing (default: 250ms, min: 50ms, max: 2000ms)

Implementation details:

  • Zod schema updates with validation bounds (min/max)
  • Migration script v051-to-v052 for backward compatibility
  • UI updates with proper min/max validation in settings pages
  • Translations for all 8 locales (zh-CN, zh-TW, en, ja, ko, ru, tr, vi)
  • BatchQueue runtime config update support
  • CONFIG_SCHEMA_VERSION bumped to 52

Modified files:

  • Added config schema and validation in src/types/config/translate.ts
  • Updated translation queue initialization in src/entrypoints/background/translation-queues.ts
  • Enhanced UI settings pages for both translation and video subtitles
  • Added migration script src/utils/config/migration-scripts/v051-to-v052.ts
  • Added config example src/utils/config/__tests__/example/v052.ts
  • Updated all locale files with new translations

Related Issue

N/A

How Has This Been Tested?

  • Verified through manual testing
  • Tested config migration from v051 to v052
  • Verified UI validation (min/max bounds) in settings pages
  • Tested queue behavior with different parameter values
  • Verified translations across multiple locales

Checklist

  • I have tested these changes locally
  • I have updated the documentation accordingly if necessary
  • My code follows the code style of this project
  • My changes do not break existing functionality
  • If my code was generated by AI, I have proofread and improved it as necessary.

Summary by cubic

Made request and batch queue settings configurable (timeout, retries, retry delay, batch delay) for translation and video subtitles, with UI controls and validation. This gives users finer control over performance and reliability.

  • New Features

    • Request queue: added timeoutMs, maxRetries, and baseRetryDelayMs with min/max validation and settings UI.
    • Batch queue: added batchDelay with validation and settings UI (translation + video subtitles).
    • Zod schema updates, defaults/constants, and runtime support in BatchQueue.
    • Updated locales for 8 languages.
  • Migration

    • Automatically migrates config v051 → v052, adding new fields with safe defaults; schema version set to 52.

Written for commit 4b0855b. Summary will update on new commits.

Expose hardcoded queue parameters as user-configurable options:
- requestQueueConfig: timeoutMs, maxRetries, baseRetryDelayMs
- batchQueueConfig: batchDelay

Includes:
- Zod schema updates with validation bounds (min/max)
- Default values and constants
  (timeoutMs: 30s, maxRetries: 2, baseRetryDelayMs: 1.5s, batchDelay: 250ms)
- Migration script v051-to-v052 for backward compatibility
- UI updates with proper min/max validation
- Translations for all 8 locales
  (zh-CN, zh-TW, en, ja, ko, ru, tr, vi)
- BatchQueue runtime config update support

BREAKING CHANGE: CONFIG_SCHEMA_VERSION bumped to 52
@changeset-bot
Copy link

changeset-bot bot commented Jan 28, 2026

🦋 Changeset detected

Latest commit: 4b0855b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@read-frog/extension Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jan 28, 2026
@github-actions github-actions bot added the feat label Jan 28, 2026
@dosubot
Copy link

dosubot bot commented Jan 28, 2026

Related Documentation

Checked 6 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6 issues found across 21 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/locales/ja.yml">

<violation number="1" location="src/locales/ja.yml:263">
P2: Japanese locale is missing new video subtitles queue parameter labels (timeoutMs/maxRetries/baseRetryDelayMs/batchDelay) that the subtitles settings UI now renders.</violation>
</file>

<file name="src/locales/zh-CN.yml">

<violation number="1" location="src/locales/zh-CN.yml:264">
P2: Missing zh-CN translations for new queue parameters under videoSubtitles settings if the UI exposes the same fields.</violation>
</file>

<file name="src/locales/zh-TW.yml">

<violation number="1" location="src/locales/zh-TW.yml:264">
P2: zh-TW locale is missing videoSubtitles queue parameter labels (timeoutMs/maxRetries/baseRetryDelayMs/batchDelay) even though the UI renders these keys, so subtitle settings will show fallback/missing labels.</violation>
</file>

<file name="src/utils/config/migration-scripts/v051-to-v052.ts">

<violation number="1" location="src/utils/config/migration-scripts/v051-to-v052.ts:29">
P2: Default batch queue values overwrite any existing config during migration, discarding user-provided `batchDelay` settings.</violation>
</file>

<file name="src/types/config/translate.ts">

<violation number="1" location="src/types/config/translate.ts:30">
P2: maxRetries represents a count but schema allows fractional values; retry logic compares an integer counter against this number, so decimals can yield unexpected retry counts.</violation>
</file>

<file name="src/locales/ko.yml">

<violation number="1" location="src/locales/ko.yml:264">
P2: Missing Korean i18n keys for new video subtitles queue parameters; UI now expects timeoutMs/maxRetries/baseRetryDelayMs and batchDelay labels under options.videoSubtitles.*, so Korean UI will show raw keys or blanks.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

rate:
title: 秒間平均リクエスト数
description: 平均秒間リクエスト数(ただし、最大バーストリクエスト数を設定し一時的な超過リクエスト送信を許可)
timeoutMs:
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Japanese locale is missing new video subtitles queue parameter labels (timeoutMs/maxRetries/baseRetryDelayMs/batchDelay) that the subtitles settings UI now renders.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/locales/ja.yml, line 263:

<comment>Japanese locale is missing new video subtitles queue parameter labels (timeoutMs/maxRetries/baseRetryDelayMs/batchDelay) that the subtitles settings UI now renders.</comment>

<file context>
@@ -260,6 +260,15 @@ options:
       rate:
         title: 秒間平均リクエスト数
         description: 平均秒間リクエスト数(ただし、最大バーストリクエスト数を設定し一時的な超過リクエスト送信を許可)
+      timeoutMs:
+        title: リクエストタイムアウト
+        description: 翻訳リクエストのタイムアウト時間(ミリ秒)。この時間を超えるとリクエストがキャンセルされ、再試行されます(再試行が有効な場合)。
</file context>
Fix with Cubic

rate:
title: 每秒平均请求数量
description: 平均每秒的请求数量,不过允许配置最大突发请求数来短暂发送超量请求。
timeoutMs:
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Missing zh-CN translations for new queue parameters under videoSubtitles settings if the UI exposes the same fields.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/locales/zh-CN.yml, line 264:

<comment>Missing zh-CN translations for new queue parameters under videoSubtitles settings if the UI exposes the same fields.</comment>

<file context>
@@ -261,6 +261,15 @@ options:
       rate:
         title: 每秒平均请求数量
         description: 平均每秒的请求数量,不过允许配置最大突发请求数来短暂发送超量请求。
+      timeoutMs:
+        title: 请求超时时间
+        description: 单个翻译请求的超时时长(毫秒),超时后将取消请求并进行重试(如果启用了重试)
</file context>
Fix with Cubic

rate:
title: 每秒平均請求數量
description: 平均每秒的請求數量,但允許設定最大突發請求數來短暫發送超量請求
timeoutMs:
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: zh-TW locale is missing videoSubtitles queue parameter labels (timeoutMs/maxRetries/baseRetryDelayMs/batchDelay) even though the UI renders these keys, so subtitle settings will show fallback/missing labels.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/locales/zh-TW.yml, line 264:

<comment>zh-TW locale is missing videoSubtitles queue parameter labels (timeoutMs/maxRetries/baseRetryDelayMs/batchDelay) even though the UI renders these keys, so subtitle settings will show fallback/missing labels.</comment>

<file context>
@@ -261,6 +261,15 @@ options:
       rate:
         title: 每秒平均請求數量
         description: 平均每秒的請求數量,但允許設定最大突發請求數來短暫發送超量請求
+      timeoutMs:
+        title: 請求超時時間
+        description: 單個翻譯請求的超時時長(毫秒),超時後將取消請求並進行重試(如果啟用了重試)
</file context>
Fix with Cubic


// Helper to merge requestQueueConfig
const mergeRequestQueueConfig = (existing: any) => ({
...existing,
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Default batch queue values overwrite any existing config during migration, discarding user-provided batchDelay settings.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/utils/config/migration-scripts/v051-to-v052.ts, line 29:

<comment>Default batch queue values overwrite any existing config during migration, discarding user-provided `batchDelay` settings.</comment>

<file context>
@@ -0,0 +1,60 @@
+
+  // Helper to merge requestQueueConfig
+  const mergeRequestQueueConfig = (existing: any) => ({
+    ...existing,
+    ...defaultRequestQueueConfig,
+  })
</file context>
Fix with Cubic

capacity: z.number().gte(MIN_TRANSLATE_CAPACITY),
rate: z.number().gte(MIN_TRANSLATE_RATE),
timeoutMs: z.number().min(MIN_REQUEST_TIMEOUT_MS).max(MAX_REQUEST_TIMEOUT_MS),
maxRetries: z.number().min(MIN_MAX_RETRIES).max(MAX_MAX_RETRIES),
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: maxRetries represents a count but schema allows fractional values; retry logic compares an integer counter against this number, so decimals can yield unexpected retry counts.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/types/config/translate.ts, line 30:

<comment>maxRetries represents a count but schema allows fractional values; retry logic compares an integer counter against this number, so decimals can yield unexpected retry counts.</comment>

<file context>
@@ -1,17 +1,40 @@
   capacity: z.number().gte(MIN_TRANSLATE_CAPACITY),
   rate: z.number().gte(MIN_TRANSLATE_RATE),
+  timeoutMs: z.number().min(MIN_REQUEST_TIMEOUT_MS).max(MAX_REQUEST_TIMEOUT_MS),
+  maxRetries: z.number().min(MIN_MAX_RETRIES).max(MAX_MAX_RETRIES),
+  baseRetryDelayMs: z.number().min(MIN_BASE_RETRY_DELAY_MS).max(MAX_BASE_RETRY_DELAY_MS),
 })
</file context>
Suggested change
maxRetries: z.number().min(MIN_MAX_RETRIES).max(MAX_MAX_RETRIES),
maxRetries: z.number().int().min(MIN_MAX_RETRIES).max(MAX_MAX_RETRIES),
Fix with Cubic

rate:
title: 초당 평균 요청 수
description: 초당 평균 요청 수 (단, 최대 버스트 요청 수 설정을 통한 일시적 초과 요청 전송 허용)
timeoutMs:
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Missing Korean i18n keys for new video subtitles queue parameters; UI now expects timeoutMs/maxRetries/baseRetryDelayMs and batchDelay labels under options.videoSubtitles.*, so Korean UI will show raw keys or blanks.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/locales/ko.yml, line 264:

<comment>Missing Korean i18n keys for new video subtitles queue parameters; UI now expects timeoutMs/maxRetries/baseRetryDelayMs and batchDelay labels under options.videoSubtitles.*, so Korean UI will show raw keys or blanks.</comment>

<file context>
@@ -261,6 +261,15 @@ options:
       rate:
         title: 초당 평균 요청 수
         description: 초당 평균 요청 수 (단, 최대 버스트 요청 수 설정을 통한 일시적 초과 요청 전송 허용)
+      timeoutMs:
+        title: 요청 시간 초과
+        description: 단일 번역 요청의 시간 초과 기간(밀리초)입니다. 이 시간이 지나면 요청이 취소되고 재시도됩니다(재시도가 활성화된 경우).
</file context>
Fix with Cubic

@mengxi-ream
Copy link
Owner

any specific reason we need to expose these to users? I don't want to make the software too complicated

@yrom
Copy link
Contributor Author

yrom commented Feb 3, 2026 via email

@mengxi-ream
Copy link
Owner

mengxi-ream commented Feb 3, 2026

Because I often encounter http 409 errors, the model service complains that the request frequency is too high, even if it is configured to request 2 times per second on average, it can only reduce this problem by increasing the number of text translated per translation and using a long timeout time.

---Original--- From: @.> Date: Tue, Feb 3, 2026 12:23 PM To: @.>; Cc: "Yrom @.@.>; Subject: Re: [mengxi-ream/read-frog] feat: add configurable queue parameters(PR #926) mengxi-ream left a comment (mengxi-ream/read-frog#926) any specific reason we need to expose these to users? I don't want to make the software too complicated — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

Have you tried to make this burst count lower?

CleanShot 2026-02-02 at 20 43 53@2x

and make these higher?

CleanShot 2026-02-02 at 20 44 37@2x

@yrom
Copy link
Contributor Author

yrom commented Feb 3, 2026

Maximum 3 burst requests, 2 per second. Max 4000 characters, 4 paragraphs.

@mengxi-ream
Copy link
Owner

Maximum 3 burst requests, 2 per second. Max 4000 characters, 4 paragraphs.

Are you saying that this setting won't resolve the issue because lengthy characters in a single batch may lead to a timeout?

@yrom
Copy link
Contributor Author

yrom commented Feb 3, 2026 via email

@mengxi-ream
Copy link
Owner

right. The request timeout needs to be increased.

---Original--- From: @.> Date: Tue, Feb 3, 2026 12:53 PM To: @.>; Cc: "Yrom @.@.>; Subject: Re: [mengxi-ream/read-frog] feat: add configurable queue parameters(PR #926) mengxi-ream left a comment (mengxi-ream/read-frog#926) Maximum 3 burst requests, 2 per second. Max 4000 characters, 4 paragraphs. Are you saying that this setting won't resolve the issue because lengthy characters in a single batch may lead to a timeout? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

if so, could you only export the timeout setting to users so they won't be freaking out to see so many settings.

can put it here:

CleanShot 2026-02-02 at 20 57 47@2x

@claude
Copy link

claude bot commented Feb 8, 2026

Code Review: feat: add configurable queue parameters

Overall Assessment

Solid feature addition. The implementation follows the established patterns well (Zod schemas, migration scripts, UI components, i18n). The code is clean and the migration path is well-considered.

Code Quality & Best Practices

Strengths:

  • Consistent use of Zod schemas for validation with min/max bounds
  • Proper config migration script with clear documentation comments
  • All 8 locales updated with appropriate translations
  • Good separation of constants (defaults, min/max) in constants/translate.ts
  • BatchQueue.setBatchConfig properly extended to support batchDelay

Issues:

  1. Default value inconsistency (bug): The previous hardcoded values and the new defaults don't match:

    • DEFAULT_REQUEST_TIMEOUT_MS = 20_000 but the old hardcoded value was 20_000
    • DEFAULT_BASE_RETRY_DELAY_MS = 1_500 but the old hardcoded value was 1_000
    • DEFAULT_BATCH_DELAY_MS = 100 but the old hardcoded value was 100 ✅ (for batchQueue), but the old batchDelay in translation-queues.ts line 63 was 100, not 250 as stated in the PR description

    The DEFAULT_BASE_RETRY_DELAY_MS being 1_500 while the migration script injects 1_000 means: users who migrate get 1_000, but fresh installs get 1_500. This silent behavioral divergence should be intentional and documented, or aligned.

  2. Nullable fallback pattern in createTranslationQueues:

    timeoutMs: timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS,

    Since these fields are now required in the Zod schema (z.number().min(...).max(...)), the ?? fallback should never trigger after migration. This is defensive but potentially masks schema validation bugs. Consider whether the ?? is truly needed after the Zod schema guarantees the fields exist.

  3. Missing max validation for capacity and rate: The new fields (timeoutMs, maxRetries, baseRetryDelayMs) all have both min and max constraints, but the existing capacity and rate fields only have gte (min). The propertyMaxAllowedValue map in the UI uses as keyof typeof propertyMaxAllowedValue which is a type assertion that hides the fact that capacity and rate have no max. This inconsistency could lead to users entering extremely large values for capacity/rate. Consider this for a follow-up.

  4. DRY concern in UI components: request-rate.tsx, subtitles-request-rate.tsx, request-batch.tsx, and subtitles-request-batch.tsx all follow nearly identical patterns. The translation vs subtitles variants are almost copy-paste. This isn't introduced by this PR (pre-existing), but the PR extends the duplication. A future refactor to share the number selector logic could help.

Security Concerns

  • No security issues. Input validation is properly handled via Zod schemas and HTML min/max attributes on inputs.

Test Coverage

  • Migration test example (v052.ts) is provided ✅
  • No unit tests for the new Zod schema validation boundaries (e.g., verifying that out-of-range values are rejected). Consider adding schema validation tests.
  • No tests for BatchQueue.setBatchConfig with the new batchDelay parameter.

Performance Considerations

  • No performance concerns. The changes are configuration-driven and don't affect hot paths.

Summary

Good PR overall. The main actionable item is the DEFAULT_BASE_RETRY_DELAY_MS = 1500 vs migration default of 1000 discrepancy -- this should either be aligned or explicitly documented as intentional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments