Skip to content

feat: cherry-pick 3 shelf features (dropdown dedup, settings snapshot, historical fan context)#33

Merged
anantham merged 4 commits intomainfrom
feat/cherry-pick-shelf-features
Apr 4, 2026
Merged

feat: cherry-pick 3 shelf features (dropdown dedup, settings snapshot, historical fan context)#33
anantham merged 4 commits intomainfrom
feat/cherry-pick-shelf-features

Conversation

@anantham
Copy link
Copy Markdown
Owner

@anantham anantham commented Apr 4, 2026

Summary

Re-implements 3 features from codex/wip-book-switching-shelf-2026-03-29 cleanly on current main. The stale branch had 12 conflicting files making rebase infeasible, so each feature was re-implemented from scratch by reading the branch source.

  • Feature 1 — Dropdown chapter label dedup: Chapter dropdown no longer shows Ch 5: Chapter 5: The Title. Added titleAlreadyStartsWithNumber() and buildChapterDisplayLabel() (exported for tests). The old raw template-literal numPrefix + title concatenation is replaced by the dedup-aware function.

  • Feature 2 — Translation settings snapshot: New file services/translationSettingsSnapshot.ts. Defines TranslationSettingsSnapshot (a typed Pick of AppSettings), TranslationSettingsSnapshotInput, and normalizeTranslationSettingsSnapshot(). Standalone utility only — wiring into the translation pipeline is deferred; it touched too many files that diverged heavily.

  • Feature 3 — Historical fan context setting: Adds includeHistoricalFanTranslationsInContext?: boolean to AppSettings, defaults to false in defaultSettings, and surfaces a checkbox toggle in the Advanced panel's Translation Parameters section. Prompt injection is deferred for the same reason as Feature 2.

What was intentionally left out

Both Feature 2 and 3 stop short of wiring the settings into translationService.ts — that file changed significantly and was the source of most conflicts. The settings storage and UI are complete; the actual prompt injection can be a follow-up PR once that file stabilizes.

Test plan

  • npx tsc --noEmit — only pre-existing errors in scripts/sutta-studio/ and services/clientTelemetry.ts, zero new errors
  • Load a chapter with a translated title like "Chapter 5: The Dragon Awakens" — dropdown should show the title as-is, not "Ch 5: Chapter 5: The Dragon Awakens"
  • Load a chapter with a plain title like "The Dragon Awakens" — dropdown should show "Ch 5: The Dragon Awakens"
  • Open Advanced settings panel → confirm "Include Previous Fan Translations in Context" toggle appears below the fan translation reference toggle
  • Toggle persists across settings saves

🤖 Generated with Claude Code

MOTIVATION:
- Branch codex/wip-book-switching-shelf-2026-03-29 had 12 conflicting files,
  making rebase impractical. Re-implement 3 features cleanly on current main.

APPROACH:
- Feature 1: dedup chapter dropdown labels — add titleAlreadyStartsWithNumber()
  and buildChapterDisplayLabel() to the hook; replace the old numPrefix string
  concatenation so "Ch 5: Chapter 5: The Title" becomes "Chapter 5: The Title".
- Feature 2: translation settings snapshot — new utility file capturing the
  settings fields that affect translation output (provider, model, temperature,
  systemPrompt, contextDepth, fan-translation flags). Standalone utility only;
  wiring into the pipeline is deferred (touched too many conflicting files).
- Feature 3: historical fan context setting — add the
  includeHistoricalFanTranslationsInContext boolean to AppSettings, default it
  to false in defaultSettings, and surface a toggle in TranslationParametersSection
  (with AdvancedPanel wired to pass the value and handler through).

CHANGES:
- hooks/useChapterDropdownOptions.ts: add titleAlreadyStartsWithNumber() and
  buildChapterDisplayLabel() (exported for tests); replace raw template-literal
  label with buildChapterDisplayLabel() call
- services/translationSettingsSnapshot.ts: new file — TranslationSettingsSnapshot
  type, TranslationSettingsSnapshotInput, normalizeTranslationSettingsSnapshot()
- types.ts: add includeHistoricalFanTranslationsInContext?: boolean to AppSettings
- services/sessionManagementService.ts: default includeHistoricalFanTranslationsInContext to false
- components/settings/TranslationParametersSection.tsx: add prop and checkbox UI
  for includeHistoricalFanTranslationsInContext
- components/settings/AdvancedPanel.tsx: wire new prop and handler through to
  TranslationParametersSection

IMPACT:
- Dropdown no longer shows "Ch 5: Chapter 5: …" for chapters whose translated
  title already contains the chapter number.
- Translation settings are now snapshottable for reproducibility/comparison.
- Users can toggle historical fan-translation context inclusion in the Advanced panel.

TESTING:
- npx tsc --noEmit passes (only pre-existing errors in scripts/ and clientTelemetry.ts)
- buildChapterDisplayLabel is exported for unit tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexicon-forge Ready Ready Preview, Comment Apr 4, 2026 8:46pm

anantham and others added 3 commits April 4, 2026 16:38
…nto pipeline

MOTIVATION:
- Translation settings snapshot utility existed but was not called during
  actual translation, so results lacked reproducibility metadata
- Historical fan translation context toggle existed in UI but was not
  connected to the prompt builder, so enabling it had no effect
- Dropdown dedup utility existed and was verified as already properly wired

APPROACH:
- Call normalizeTranslationSettingsSnapshot() after translation completes
  and attach to TranslationResult.translationSettings
- Thread includeHistoricalFanTranslations through all three history-building
  paths (memory candidates, IDB hydration, prevUrl chain fallback)
- Render fanTranslationReference in formatHistory() prompt output
- Use normalized snapshots in shouldEnableRetranslation() for consistent
  comparison, including the new historicalFanChanged detection

CHANGES:
- types.ts: Add fanTranslationReference to HistoricalChapter, add
  includeHistoricalFanTranslationsInContext to TranslationSettingsSnapshot
- services/translationService.ts: Import and call normalize snapshot,
  pass fan context flag through all history builders, update
  extractSettingsSnapshot and shouldEnableRetranslation
- services/prompts.ts: Render fan translation reference block in
  formatHistory when present on a historical chapter

IMPACT:
- Translations now carry a settings snapshot for reproducibility
- Retranslation detection now catches changes to the historical fan
  context toggle
- When includeHistoricalFanTranslationsInContext is enabled, previous
  chapters' fan translations appear in the translation prompt context

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@anantham anantham merged commit 3f1f9f5 into main Apr 4, 2026
3 of 4 checks passed
@anantham anantham deleted the feat/cherry-pick-shelf-features branch April 5, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant