Skip to content

feat: add custom text input via tabbed InputBar#25

Merged
anantham merged 11 commits intoanantham:mainfrom
orpheuslummis:feat/opus-custom-text-input
Apr 4, 2026
Merged

feat: add custom text input via tabbed InputBar#25
anantham merged 11 commits intoanantham:mainfrom
orpheuslummis:feat/opus-custom-text-input

Conversation

@orpheuslummis
Copy link
Copy Markdown
Contributor

@orpheuslummis orpheuslummis commented Feb 4, 2026

Summary

Adds a "Paste Text" tab to the InputBar so users can paste raw text directly for reading and translation, without needing a URL from a supported website. Useful for classical texts, poetry, sutras, or anything not hosted online.

How it works

The InputBar gains two tabs: From URL (existing behavior, unchanged) and Paste Text (new). The paste tab has fields for title, source language, and a textarea for content. The landing page heading and divider text are updated to be mode-neutral.

Under the hood, importCustomText constructs an ImportedChapter with a synthetic URL (custom.lexiconforge.local/text/{timestamp}) and feeds it into the existing transformImportedChaptersImportOps.importStableSessionData → Zustand store merge pipeline. No changes to adapters, navigation service, stable ID generation, or persistence layer.

Files changed

  • components/InputBar.tsx — Tabbed UI: "From URL" / "Paste Text". All existing URL-mode behavior preserved identically.
  • components/LandingPage.tsx — Updated heading, subtitle, and divider to be mode-neutral ("Translate Any Text", "OR START FROM SCRATCH").
  • store/slices/chaptersSlice.ts — New importCustomText action on ChaptersActions interface + implementation.
  • services/telemetryService.ts — Unrelated bugfix: crypto.randomUUID() fallback for non-HTTPS contexts.

What doesn't change

  • services/adapters.ts — custom text bypasses adapters entirely
  • services/navigationService.ts — the store action handles everything directly
  • services/stableIdService.tstransformImportedChapters works as-is with synthetic URLs
  • services/db/operations/imports.tsimportStableSessionData works as-is
  • types.tsImportedChapter, EnhancedChapter already have all needed fields

Test plan

  • vite build passes
  • TypeScript: no errors in changed files
  • All 822 existing tests pass (0 regressions)
  • Manual: open app → Paste Text tab → paste text → Import Text → chapter appears in reader
  • Manual: translation works on pasted text
  • Manual: page reload preserves the chapter (IndexedDB persistence)

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 4, 2026

@orpheuslummis is attempting to deploy a commit to the Aditya's projects Team on Vercel.

A member of the Team first needs to authorize it.

crypto.randomUUID() requires a secure context (HTTPS or localhost).
Add a typeof check with Date.now + Math.random fallback so the app
loads when accessed via plain HTTP on a network IP.
Add a "Paste Text" tab to InputBar alongside the existing "From URL"
tab. Users can paste raw text with a title and source language for
reading and translation, bypassing the URL fetch pipeline entirely.

The new importCustomText store action constructs an ImportedChapter
with a synthetic URL (custom.lexiconforge.local), runs it through
the existing transformImportedChapters pipeline, persists to IndexedDB,
and merges into the Zustand store — same path as URL-fetched chapters.
@orpheuslummis orpheuslummis force-pushed the feat/opus-custom-text-input branch from 1218e0e to c4133c1 Compare February 4, 2026 17:16
@orpheuslummis orpheuslummis changed the title feat: add custom text input for direct text pasting feat: add custom text input via tabbed InputBar Feb 4, 2026
orpheuslummis and others added 3 commits February 4, 2026 17:23
The heading, subtitle, and divider were all URL-specific, which
doesn't make sense when the Paste Text tab is active.

- "OR START FROM A URL" → "OR START FROM SCRATCH"
- "Translate Any Web Novel Chapter" → "Translate Any Text"
- "Paste a URL from supported sites..." → "Fetch from a supported
  site or paste your own text"
The default viewMode is 'english', which shows translationResult.translation.
Since freshly imported custom text has no translation yet, the content area
appeared empty. Now we switch to 'original' view after import so the user
immediately sees their pasted text.
Copy link
Copy Markdown
Owner

anantham commented Apr 4, 2026

Applied in place to the existing PR branch.

Commit: 014546f fix(input): preserve pasted text on import failure

What changed:

  • components/InputBar.tsx: only clear the paste form after importCustomText(...) returns a chapter id
  • tests/components/InputBar.test.tsx: regression coverage for failure-preserve and success-clear behavior
  • docs/WORKLOG.md: recorded the fix and verification

Validation:

  • npx vitest run tests/components/InputBar.test.tsx

The earlier separate branch is no longer needed for PR review; the fix now lives on feat/opus-custom-text-input itself.

anantham added 3 commits April 3, 2026 23:46
Context: the custom text import flow swallowed persistence failures in the store layer, but the paste form still cleared its fields unconditionally.\n\nChanges: wait for importCustomText to return a chapter id before resetting the pasted title, language, and body fields.\n\nImpact: failed custom-text imports now preserve the user\'s pasted content for retry or manual recovery.\n\nTests: /Users/aditya/Documents/Ongoing Local/LexiconForge.worktrees/pr25-fixes/node_modules/.bin/vite build\n\nDocs: none
# Conflicts:
#	components/InputBar.tsx
#	store/slices/chaptersSlice.ts
anantham added 3 commits April 4, 2026 00:00
…into codex/pr25-fixes

# Conflicts:
#	components/InputBar.tsx
#	docs/WORKLOG.md
#	tests/components/InputBar.test.tsx
@anantham anantham merged commit c8f26ff into anantham:main Apr 4, 2026
1 check failed
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.

2 participants