Compare commits

...
37 Commits
Author SHA1 Message Date
poli0981 5edd0d6bfd Merge pull request #148 from poli0981/feat/v0.36.0-locales
feat: v0.38.0 — Portuguese (Brazil) and Indonesian
2026-08-17 12:50:12 +07:00
poli0981andClaude Opus 5 b920d3567e chore(release): v0.38.0 — Portuguese (Brazil) and Indonesian
Two new locales, 1,562 strings each, complete: titles, every description
block, all 248 content warnings, tech notes, playthrough notes, pinned
comments, playlist copy, and the whole interface.

Brazil is a top-three market for gameplay viewing and Indonesia the largest in
Southeast Asia. Both use Latin script, so neither needed font or layout work.

**docs/I18N.md was wrong about what registering a locale takes**, and this
release is where that bit. It claimed `SUPPORTED_LANGUAGES` was "the only
registration step". It is one of four, and they fail differently:

  SupportedLanguage union        compile error
  CORE_TAGS_BY_LANG              compile error  (there are TWO such records,
  MULTILINGUAL_TAGS              compile error   not one — the doc mentioned one)
  detectBrowserLanguage          SILENT

The silent one matters most: the language works perfectly and simply never
auto-selects for a visitor whose browser is set to it. `SUPPORTED_LANGUAGES`
also wasn't type-bound to the union, and every consumer casts, so a mismatch
between the first two compiled cleanly — it now carries a `satisfies` clause.

`tests/i18n/locale-registration.test.ts` exists to close those gaps: it checks
the picker list against the locale directories on disk in BOTH directions, plus
namespace files, flags, native names and tag pools.

Browser-language detection now matches the full BCP-47 tag before the bare
language, or `pt-BR` would be reduced to `pt` and never found. Any other
Portuguese variant resolves to pt-BR rather than falling through to English.

115 UI keys were not hand-translated at all: their English text is
byte-identical to a string already translated in templates.json (graphics
presets, ray-tracing modes, difficulty names, content-warning labels), so they
are copied across. Translating those twice risks a checkbox and the rendered
description disagreeing about what the same option is called.

Deliberately left in English, matching what the Spanish locale already does:
vendor product names (NVIDIA DLSS, AMD FSR, Intel XeSS, Fluid Motion Frames),
platform brands, hardware acronyms, genre terms that are loanwords in both
languages, and example URLs/emails in placeholders. So pt-BR reads 1,344/1,562
and id 1,308/1,562 "differing from English" — the remainder are those
pass-throughs, not gaps.

Both are AI-translated and NOT native-reviewed. Recorded in DISCLAIMER.md
alongside JA/ES/KO/ZH.

Also replaces `__dirname` in the Vite and Vitest configs with
`import.meta.dirname` — Vite 8's native config loader doesn't provide the CJS
global and warned on every run.

v0.36.0 is skipped: the dependency release shipped first and took 0.37.0.

Tests 692 → 698. Validator now 1,562 keys x 8 locales.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 12:46:54 +07:00
poli0981andClaude Opus 5 3b0db9a95f feat(i18n): translate the editor's game-info and video-settings labels
120 more keys per locale: section headings, game / channel / boss / DLC / mod
fields, the gacha quest taxonomy, GPU-RAM-OS pickers, the Vietnamese donate
block, graphics-preset and video-style options, timestamps and store links.

Vendor tech names stay in English throughout — DLSS, FSR, XeSS, DLAA, the frame
generation multipliers, NVIDIA / AMD / Intel. They are product names, and the
templates locale already keeps them, so translating the picker but not the
rendered line would make the two disagree.

Note for anyone editing these files by script: `ui.json` contains literal keys
that themselves contain dots — `"frameGenMultiplier.nvidia"` sits directly
beside a plain `"frameGenMultiplier"` leaf — so a naive split-on-dot path walk
resolves to the wrong node, or crashes.

pt-BR now 1039/1562 translated, id 1003/1562. The remainder is `editor.*`
content-warning and tech-note checkbox labels.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 12:37:52 +07:00
poli0981andClaude Opus 5 bbf201c30f feat(i18n): translate the UI chrome for pt-BR and id
~500 keys per locale: tabs, About, Output, common actions, error pages, the
consent gate, video types, genres, rig labels, Profiles / Presets / Templates /
History, the whole Settings page, Social, Batch, shortcuts, validation
messages, Playlist and Logs.

115 of them were not translated by hand at all — their English text is
byte-identical to a string already translated in templates.json (graphics
presets, ray-tracing modes, difficulty names, content-warning labels), so they
are copied across. Translating those twice risks a checkbox and the rendered
description disagreeing about what the same option is called.

Left as English on purpose: brand and product names (Ko-fi, Patreon, PayPal,
GitHub, Discord, Steam, Twitch, TikTok, Mastodon, Bluesky), hardware acronyms
(CPU, GPU, RAM), genre terms that are loanwords in both languages (RPG, JRPG,
FPS, MMO, Indie, Metroidvania, Roguelike, Souls-like, SHMUP, Battle Royale),
and resolution / FPS values.

Still to do: `editor.*`, the largest single block.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 12:37:52 +07:00
poli0981andClaude Opus 5 e56c32e76a feat(i18n): translate templates.json for pt-BR and id
563 keys per locale — the strings YouTube viewers actually read: titles,
description blocks, all 250 content warnings, tech notes, playthrough notes,
pinned comments, playlist copy and timeline keywords.

Left identical to English on purpose, matching what the existing Spanish locale
does: separator glyphs, empty video-type keys, vendor product names (NVIDIA
DLSS / AMD FSR / Intel XeSS / Frame Generation), and loanwords that are the
same word in both target languages (Demo, Beta, Speedrun, New Game+, Normal,
Ultra, Jumpscare, Doomscrolling).

Not yet registered in code — the locales are inert until `SUPPORTED_LANGUAGES`,
the `SupportedLanguage` union, `detectBrowserLanguage` and `MULTILINGUAL_TAGS`
name them. ui.json and that wiring follow.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 12:37:52 +07:00
poli0981 841df7d246 Merge pull request #146 from poli0981/fix/android-release-upload
fix(ci): upload the Android APK with gh instead of action-gh-release
2026-08-17 12:07:25 +07:00
poli0981andClaude Opus 5 b244063555 fix(ci): upload the Android APK with gh instead of action-gh-release
The v0.35.0 APK built successfully three times and was never attached. The
build was fine every time; the upload step failed with "Resource not accessible
by integration" on update-a-release.

`softprops/action-gh-release@v3` was resolving the target release from
GITHUB_REF rather than from the `tag_name` it was handed. On the tag push it
looked for a release tagged `refs/tags/v0.35.0`; on the workflow_dispatch re-run
it looked for one tagged `refs/heads/main`. Neither exists, so it fell through
to CREATING a release against a branch ref, which the token is quite right to
refuse. The permissions were never the problem — the job log shows
`Contents: write` on every run.

Replaced with `gh release upload`, which is pre-installed on every runner and
takes the tag as a positional argument, so it cannot make that substitution.
`--clobber` makes a re-run idempotent.

Also uploads the APK as a workflow artifact first, so a failed release upload
never costs another 20-minute NDK build to recover from — which is what it cost
to diagnose this.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 12:06:07 +07:00
poli0981 bb0a40cfae Merge pull request #145 from poli0981/chore/v0.37.0-deps
chore: v0.37.0 — dependency modernization
2026-08-17 11:46:29 +07:00
poli0981andClaude Opus 5 0c7fb31165 chore(release): v0.37.0 — dependency modernization
Every major the project had been sitting on, brought current. No user-facing
feature changes; the app should behave identically.

  React 18 → 19 (+ types, @vitejs/plugin-react 6)
  Tailwind 3 → 4
  ESLint 9 → 10 (+ eslint-plugin-react-hooks 5 → 7)
  Zustand 4 → 5
  i18next 23 → 26, react-i18next 15 → 17
  @testing-library/*, typescript-eslint 8.67, Vite/Vitest/tsx/knip patches

**React 19** needed exactly one source change: `useRef<T>(null)` is now typed
`RefObject<T | null>` rather than `RefObject<T>`. The old type quietly claimed a
ref was non-null before its element mounted; ScrollToTopButton now matches,
which makes its existing null check honest rather than defensive.

**Tailwind 4** moves configuration from `tailwind.config.ts` (deleted) into
CSS. The tokens live in an `@theme` block that maps Tailwind's names onto the
existing `:root` / `.light` variables, so the runtime theme toggle still owns
the values and keeps working untouched. `darkMode: "class"` becomes
`@custom-variant dark` — the app toggles a class on <html> rather than
following the OS, so the default prefers-color-scheme variant would be wrong.
Verified in the browser in both themes; a CSS migration fails visually, not at
build time.

**The lint upgrade earned its keep.** `react-hooks/set-state-in-effect` (new in
v7, React Compiler-aware) flagged seven sites. Four were real extra render
passes:

  - use-online-status rewritten to `useSyncExternalStore`. It had been
    re-reading `navigator.onLine` inside an effect to close the gap between
    first render and the listeners attaching — subscribing properly removes the
    gap instead of patching it.
  - ShortcutHelpModal derives its filter from `open` instead of resetting state
    in an effect, so a modal that is closed most of the time stops scheduling
    work on unrelated parent updates.
  - DraftIndicator and use-languages-ready now guard their setters.

Three remain as warnings, deliberately. They genuinely sync state FROM an
external source (i18next bundle readiness, a text mirror of a numeric store
field, a useMemo the compiler cannot preserve) and need a restructure rather
than a guard. Recorded in eslint.config.js with the reason — downgraded, not
silenced, and not a reason to hold back ESLint 10.

**lucide-react deliberately stays at 0.577.0.** 1.x removes every brand icon;
upstream dropped them for trademark reasons. Taking it would mean either a
generic globe beside a Facebook link or re-adding the marks ourselves and
inheriting the exposure lucide just shed. 0.577 already delivered the win —
main bundle 175 kB → 137 kB.

knip now ignores `tailwindcss`: after the migration its only reference is
`@import "tailwindcss"` in CSS, which knip does not follow.

Full gate green — typecheck, typecheck:all, lint, format:check,
validate:locales, knip, check:version, 692 tests, build — plus a browser check
of both themes with the editor and batch pages functional.

0.36.0 is reserved for the two new locales.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 11:43:51 +07:00
poli0981 11a822a881 Merge pull request #144 from poli0981/docs/v0.35.0
docs: correct the i18n registration claim, document v0.35.0
2026-08-17 11:33:23 +07:00
poli0981andClaude Opus 5 08be7d1ff8 docs: correct the i18n guide's registration claim, document v0.35.0
**docs/I18N.md was wrong in a way that would waste a contributor's afternoon.**
It said adding a locale to `SUPPORTED_LANGUAGES` was "the only registration
step". It is one of four, and the missing ones fail differently: the
`SupportedLanguage` union is a compile error, `MULTILINGUAL_TAGS` is a compile
error, but `detectBrowserLanguage`'s own hardcoded copy of the list fails
*silently* — the language works and simply never auto-selects for a visitor
whose browser is set to it. Also noted: `SUPPORTED_LANGUAGES` is not type-bound
to the union and every consumer casts, so a mismatch compiles cleanly.

Also documents the `--copy-english` / `--force` flags on the locale generator,
which only started existing in v0.35.0 despite having been advertised in
package.json since v0.1.

Elsewhere:

- **DEVELOPMENT.md** — the five new npm scripts, including why `format:check`
  excludes markdown and locale JSON, and why `typecheck:all` exists.
- **TECH-SPEC.md** — the real CI job, a new Field Limits section, and how
  over-limit enforcement derives from the engine's long-ignored `warnings`.
- **ARCHITECTURE.md** — the settings→engine mapping and its two guards, the
  two-source validation state, and an honest note that the first Strict Mode
  implementation typechecked, passed tests, and did nothing.
- **FEATURES.md** — the settings table still listed `Default Genre` and
  `Auto-save Draft`, removed in v0.22.0 and v0.3. Replaced, plus a guardrails
  section.
- **README.md** — guardrails in the feature list, and a link to the wiki.

The wiki itself (12 pages: quick start, glossary, field reference, guardrails,
batch/social, import-export, languages, privacy, troubleshooting, FAQ, release
process) is published separately — it lives in its own repository.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 11:32:09 +07:00
poli0981 03174084cf Merge pull request #143 from poli0981/chore/deps-minor
chore(deps): consolidate the six Dependabot minor bumps
2026-08-17 11:29:16 +07:00
poli0981andClaude Opus 5 d6de8764f1 chore(deps): consolidate the six Dependabot minor bumps into one lockfile
The new grouped Dependabot config opened six PRs within minutes of landing.
Merging them one at a time would mean six lockfile rebases and six CI runs for
what is a single dependency resolution, so this applies all of them together:

  i18next-resources-to-backend 1.2.1 → 1.2.3
  @tauri-apps/{api,plugin-dialog,plugin-fs,plugin-opener} → latest 2.x
  lucide-react 0.400.0 → 0.577.0
  eslint + @eslint/js 9.39.4 → 9.39.5, typescript-eslint 8.58 → 8.67
  knip 6.14.1 → 6.32.2, prettier 3.8.1 → 3.9.6,
  prettier-plugin-tailwindcss 0.6.14 → 0.8.1
  vite 8.0.16 → 8.2.1, vitest 4.1.8 → 4.1.10, tsx 4.22 → 4.23,
  postcss 8.5.15 → 8.5.26, autoprefixer 10.4.27 → 10.5.4

All within-major; the majors (React 19, Tailwind 4, ESLint 10, i18next 26,
Zustand 5) are held back by the Dependabot ignore rule and belong to their own
planned release.

The `lint-and-format` group's own PR was RED, and correctly so: prettier 3.9
formats six files differently, and Dependabot cannot run `npm run format` for
itself. Reformatted here — which is the format gate doing exactly its job on
its first real outing.

lucide-react's jump also drops the main bundle 175 kB → 137 kB (gzip 48 → 37).

Verified: typecheck, typecheck:all, lint, format:check, validate:locales, knip,
check:version, 692 tests and build all pass, and the app renders with icons
intact in the browser.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 11:21:30 +07:00
poli0981 ff8c1133e6 Merge pull request #137 from poli0981/dependabot/github_actions/actions-859475a651
ci: bump the actions group with 4 updates
2026-08-17 11:18:43 +07:00
poli0981 c9facc59ec Merge pull request #142 from poli0981/feat/v0.35.0-guardrails
feat: v0.35.0 — guardrails
2026-08-17 11:16:50 +07:00
poli0981andClaude Opus 5 b8f245dee4 chore(release): v0.35.0 — guardrails
Splits SettingsPage (544 → 347 lines), extracting the import/export IO and the
42-input Genre Playlists section — the two pieces with no reason to sit inside
a page component.

Bumps all six version manifests and adds the CHANGELOG entry. `npm run
check:version`, added earlier in this cycle, confirms they agree.

Deliberately NOT split: `description-builder.ts` (974) and `editor-store.ts`
(998). Both are large, but this release changes almost nothing in either, and
carving up a 20-section render pipeline or a migration ladder is a test-heavy
refactor with real regression surface and no connection to guardrails.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 11:15:08 +07:00
poli0981andClaude Opus 5 8c32435d8a fix(strict-mode): derive the gate from state, not from mounted inputs
The first cut had each input register its own error into a shared store as it
rendered, clearing on unmount. That read as reasonable and was quietly useless:
the fields live on the Editor page, the gates live on Batch / Social / Output /
Profiles, and unmounting the Editor took every issue with it. Verified in the
browser — typing a malformed Steam URL, navigating to Batch, and finding
Generate perfectly enabled with no banner.

Replaced with two sources that between them cover what the setting promises:

- `collectEditorIssues` (pure, `@utils/editor-issues`) walks the editor STATE
  against the same validators and the same `PLATFORMS` / `SOCIAL_FIELDS` config
  the inputs use — one rule set, two consumers, no duplicated regexes. This is
  what catches data that never passed through an input at all: an imported
  profile, a preset shared by someone else, a draft persisted before a
  validator got stricter. Since `ValidatedInput` refuses to commit invalid
  text, imports are in fact the main way bad data reaches the store.
- `pending-invalid-store` holds text that is invalid and therefore *not*
  committed. Without it, a field showing a red error would still be invisible
  to every gate, because the store behind it holds the last good value. It has
  no unmount cleanup — that was the original bug — so an entry lives until the
  field is valid again.

Both are filtered through one relevance check, so a field nobody can see never
blocks: `adEmail` / `gameKeyEmail` while the split toggle is off, `zaloGroupLink`
outside Vietnamese output. Without that, Strict Mode could become an
unresolvable dead end — blocked on a field with no visible input to fix it.

Dropping the registry also removes the render-loop hazard it carried: the
effect published on every render of every input, guarded only by a deep-equal
bail-out.

Verified end to end in the browser: a bad Steam URL now disables Generate on
Batch and names the field in the banner; fixing it re-enables; and a Ko-fi link
on a vanity domain shows its inline prefix warning without blocking anything.

Tests 687 → 696.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 11:11:20 +07:00
poli0981andClaude Opus 5 1f9621b5cd feat: enforce the field caps everywhere they can be reached
Completes the field-limit work: `maxLength` is now wired at 53 call sites
across every editor form, the Settings genre-playlist inputs, the save dialogs
and the Playlist notes — grouped by what the field holds rather than named one
by one, so a new input inherits a sensible cap instead of inventing a number.

Two gaps that a `maxLength` attribute alone cannot close:

- **Imports bypass it entirely.** `maxLength` constrains typing and pasting;
  a profile, preset or template — including one saved before the caps existed
  — never passes through an input at all. `normalizeEditorPatch` now clamps on
  the way in, covering the flat fields plus the nested `social` and
  `storeLinks` URL maps. Without this the cap was decorative for exactly the
  path most likely to violate it.
- **Strict Mode could not see any field.** The registry landed in the previous
  commit, but nothing registered with it. Every `ValidatedInput` now carries a
  stable `fieldId` (composed for loop-rendered fields: `editor.social.twitch`,
  `settings.genrePlaylists.horror`), so the banner can name the offending
  input rather than saying "something is wrong".

Also fixed: `liveUrl` was a plain `Input` with no validation at all — the only
URL field in the app that would accept anything and pass it straight into the
description.

Tests 681 → 687.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 11:00:51 +07:00
poli0981andClaude Opus 5 f69941aae3 feat: block copying over-limit output, and add an opt-in Strict Mode
**Over-limit output could always be copied.** `renderAll` has returned
`warnings: CharLimitWarning[]` since v0.5 and nothing in the UI ever read it.
Three ad-hoc checks had grown up in the components instead, each with a
different blind spot:

  - `CopyButton` turned red and stayed clickable.
  - `CopyAllBar` checked title and description but not tags — and bailed out of
    every check when its `extraText` prop was set. Exactly one caller set that
    prop: OutputPage, whenever more than one language was selected. So picking
    a second language silently disabled limit checking on the main copy path.
  - BatchPage passed no limits at all, so a 6000-character description copied
    without a word.

`src/engine/limits.ts` is now the single derivation, and the requested rule is
all-or-nothing per output: if any one of title / description / tags is over,
none of them can be copied. Copying two fields and silently leaving the third
is how a half-populated description gets published.

Scoping decisions worth stating:
  - Batch blocks the offending part's own buttons plus Copy All Batch, but not
    the other 99 parts. Freezing an entire batch because part 7 is three
    characters long would be useless.
  - On Output, per-field buttons use the ACTIVE TAB's status while Copy All
    uses the merge — an over-long Japanese title must not disable the English
    copy button the user is looking at, but it must block the blob containing it.
  - `OutputExtras` (thumbnail text, pinned comment) and Playlist stay ungated:
    different YouTube surfaces with different limits, so reusing YT_LIMITS
    there would be wrong.

Batch also gained the description and tag counters it never had — a row could
be 1500 characters over with nothing on screen saying so. Social bulk Copy All
now respects each platform's own cap (TikTok 4000, Reels 2200).

**Strict Mode** (Settings → Guardrails, default OFF). Blocks Generate, Copy and
Export while any field carries a hard error. This needed something that did not
exist: an app-wide view of which fields are invalid. Every error lived in the
private `useState` of the input that produced it, so no caller could ask the
question. `src/store/validation-store.ts` is that registry — ephemeral, not
persisted, since an error rehydrated from disk would describe text the user can
no longer see.

Errors only. `validateUrlWithPrefix` returns a soft warning for a link that
works but doesn't match a platform's usual prefix; blocking on that would
strand anyone on a vanity domain or a regional mirror.

Two exemptions: the log .txt/.json export stays ungated (a debugging export
must not be held hostage by an unrelated bad URL), and the Editor gets the
banner but no gate — it is where you go to FIX the fields, so disabling
anything there would be backwards. Unmounted fields deregister, so a hidden
`adEmail` or a swapped-out video-type field can never block.

**Settings sections are collapsible.** Genre Playlists renders one input per
genre — 42 of them — and was the tallest block on the page. It now ships
collapsed with a filled-count badge. The other eight sections became accordions
too (defaulting OPEN) because a page mixing bare headings with chevrons reads
as broken, and unknown ids default open so a section added later cannot vanish
for an existing user.

Settings persist v11 → v12 (`strictMode`, `settingsAccordionState`), with
`SCHEMA_VERSIONS.settings` bumped in lockstep. Both are coerced, not just
back-filled: a hand-edited `"strictMode": "yes"` is truthy in JS, and silently
switching a seatbelt on is the opposite of an opt-in. Also corrected
`SCHEMA_VERSIONS.profile` 1 → 2, left behind when profile-store bumped in v0.34.0.

16 UI keys across all six locales (validator 999 ui / 563 templates).
Tests 665 → 681.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 10:56:05 +07:00
dependabot[bot] 913e82f6b5 ci: bump the actions group with 4 updates
Bumps the actions group with 4 updates: [actions/checkout](https://github.com/actions/checkout), [actions/setup-node](https://github.com/actions/setup-node), [actions/cache](https://github.com/actions/cache) and [tauri-apps/tauri-action](https://github.com/tauri-apps/tauri-action).


Updates `actions/checkout` from 6 to 7
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6...v7)

Updates `actions/setup-node` from 6 to 7
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v6...v7)

Updates `actions/cache` from 5 to 6
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v5...v6)

Updates `tauri-apps/tauri-action` from 0 to 1
- [Release notes](https://github.com/tauri-apps/tauri-action/releases)
- [Changelog](https://github.com/tauri-apps/tauri-action/blob/dev/CHANGELOG.md)
- [Commits](https://github.com/tauri-apps/tauri-action/compare/v0...v1)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: actions/setup-node
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: actions/cache
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: tauri-apps/tauri-action
  dependency-version: '1'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-17 03:42:57 +00:00
poli0981andClaude Opus 5 6e0b02a050 feat: ask where to save exports, and cap what can be typed into a field
Two independent guardrails; both were missing outright rather than broken.

**Exports never asked where to save.** There were two writers that disagreed:
`saveFile` branched correctly per platform but had exactly one caller (the log
.txt export), while every JSON export went through a private blob-download
helper with no platform branch at all. So "Export" on Settings, Profiles,
Presets, Templates, Social and the log JSON dumped straight into Downloads —
even on desktop, where a native Save As dialog had been available and
capability-approved the whole time.

Now one writer, `saveTextFile`, with three branches:
  1. Tauri desktop — native Save As, then the existing `save_to_file` command.
     No Rust or capability change was needed; the permissions were already there.
  2. Web with the File System Access API — a real picker. It must be the FIRST
     await in a click handler because it needs transient user activation, so
     every call site now builds its payload synchronously first. A
     `NotAllowedError` from a spent activation degrades to (3) instead of
     losing the file.
  3. Everything else (Android WebView, Firefox, Safari) — blob download.

`exportTypedToJsonFile` is now async and returns the outcome, so **cancelling
is silent**: dismissing a save dialog is a decision, not a failure, and
toasting "Export failed" at someone who pressed Escape is how people learn to
ignore toasts. The shared `useFileExport` hook holds that rule in one place and
retires the hardcoded English "Exported!" / "Export failed" strings.

Settings Import/Export is no longer desktop-only. That gate was a leftover from
when export meant dumping the on-disk settings.json; import has always been a
plain <input type="file">, and export now offers a real dialog on the web too.

**No field had a length cap** — `maxLength` appeared nowhere in the codebase, so
a pasted novel in the game-name field produced a title YouTube would reject.
`FIELD_LIMITS` groups caps by what a field holds (URL 200, email 320, short
name 100, label 300, long text 2000, timestamps = the 5000 description budget)
so a new input inherits a sensible limit instead of inventing one. `clampField`
covers the paths `maxLength` cannot: profile/preset/template import and
paste-autofill.

**Emails hard-stop at three per field.** The cap is enforced on the increase,
not the absolute count, which buys two things: a field that already holds four
(legacy profile, hand-edited import) stays editable down to three instead of
freezing, and a half-typed `a@b.com,c@` is never punished. Per field rather
than across the split — each of the three renders its own labelled line, so
filling the advertising address must not retroactively invalidate the contact.

**`ValidatedInput` no longer destroys good input.** On an invalid value it used
to call `onChange("")`, wiping the stored value while the box still showed the
user's text — so backspacing one character out of a complete URL silently
emptied the field, and autosave then persisted the empty value with no signal.
It now simply doesn't commit, leaving the last valid value in place; bad input
is kept out just as effectively. Also fixed while here: `displayValue` never
re-synced when the prop changed, so applying a profile or preset left the box
showing stale text that disagreed with the store.

i18n keys for the new strings land in the following commit.

Tests 629 → 655.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 10:41:33 +07:00
poli0981andClaude Opus 5 6b6613cca0 fix(batch): render split contact emails in Batch, and make the drift impossible
Reported: with Settings → "Split contact email by purpose" ON, the Batch tab
showed only the old single "📧 Business inquiries:" line, while the Output tab
correctly showed the grouped 📧 BUSINESS / CONTACT block with all three
addresses.

Root cause is not in the engine. `renderAll` had three call sites, each
hand-copying the same twelve settings fields into an options object, and
BatchPage's copy was missing two: `splitContactEmail` and `showThirdPartyAds`
(plus `tEn`). An absent flag defaults to `false` inside `buildDescription`, so
the else-branch emitted the legacy single line — silently, with no type error
and no failing test, because the engine tests call `buildDescription` directly
with an explicit options object and never exercise the wiring.

Rather than add a third copy of the list, the mapping now lives in one place:

- `SettingsRenderOptions` (settings-derived) is split from
  `RenderOptionOverrides` (per-caller: `tEn`, `bilingualContentBlocks`), and
  `RenderOptions` is their intersection. Same shape as before for `renderAll`.
- New `useRenderOptions` / `buildRenderOptions` produce the settings half; all
  three call sites consume it and layer only their own overrides.

Two guards, both verified to fail when the original bug is reintroduced:

- Compile-time: `buildRenderOptions` builds a `Required<SettingsRenderOptions>`,
  so dropping a key is `TS2741: Property 'splitContactEmail' is missing`.
- Runtime: `tests/hooks/render-options-parity.test.ts` diffs the produced keys
  against `SETTINGS_DERIVED_RENDER_KEYS` in both directions and names the
  offending key in the failure message.

Also fixed by the same change, since Batch was dropping it too:
`showThirdPartyAds` — the SPONSORS & PARTNERS block now renders in Batch.

Batch deliberately still passes no `tEn`: its rows are one language each, so
the bilingual `EN · LOCAL` treatment would duplicate every content-warning line.

Note for the changelog: Batch descriptions get *longer* for anyone who had
either toggle on, because those blocks were being silently dropped.

Tests 621 → 629.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 10:41:33 +07:00
poli0981 31fa18627e Merge pull request #135 from poli0981/chore/security-and-format
ci: enforce existing checks, patch advisories, backfill CHANGELOG
2026-08-17 10:41:30 +07:00
poli0981andClaude Opus 5 7b0189a1f9 test: assert the (free) suffix by adjacency instead of a URL substring
The first attempt at this alert swapped the bare host substring for the full
URL, which CodeQL still flags — `js/incomplete-url-substring-sanitization`
fires on `.includes()` against any URL-shaped value, not on the needle's
length, so the change produced two alerts where there had been one.

A store line renders as `🎮 {label}{suffix}: {url}`, so asserting
`(free): <url>` against the whole description tests the actual adjacency the
case is about, drops `.includes()` entirely, and no longer needs to locate a
line by host at all.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 10:33:57 +07:00
poli0981andClaude Opus 5 d2100d2d40 ci: enforce the checks the repo already had, and close the CHANGELOG gap
CI ran typecheck/lint/locales/test/build. Everything else the repo owned was
configured but never executed — `knip` was installed and configured yet ran
nowhere, Prettier had a config and no gate, and the six version fields the
release ritual bumps by hand had nothing watching them. This wires all of it
into the pipeline.

Correctness gaps this immediately caught:

- `tsconfig.json` covers only `src`, so tests/ and scripts/ were NEVER
  type-checked. Adding `tsconfig.check.json` (+ `typecheck:all`) surfaced 53
  errors, including three fields silently missing from the editor→engine
  parity fixture: `videoStyleEra` (v0.22.0), `adEmail` + `gameKeyEmail`
  (v0.34.0), and the four `endings*` fields (v0.16.0/v0.17.1). The fixture is
  the guard against exactly that class of drift, and it had drifted itself.
- `vitest.config.ts` `include` matched only `*.test.ts`, so any `.test.tsx`
  would have been collected by nobody and "passed" silently. Now `{ts,tsx}`.

New gates in ci.yml: `typecheck:all`, `format:check`, `knip`, `check:version`,
and an advisory `npm audit --audit-level=high` (advisory so a fresh transitive
advisory cannot redden every unrelated PR before Dependabot opens its fix).
Plus least-privilege `permissions: contents: read` — which also clears the
`actions/missing-workflow-permissions` code-scanning alert — and a
concurrency group that cancels superseded runs everywhere except `main`.

New scripts:

- `scripts/check-version-sync.ts` — asserts all SIX version fields agree
  (package.json, package-lock root AND packages[""], tauri.conf.json,
  Cargo.toml, Cargo.lock self-entry). Nothing else notices a missed one, and a
  stale tauri.conf.json ships an installer that disagrees with its tag.
- `scripts/generate-locale-template.ts` — `npm run generate:locale` has been
  advertised in package.json and docs/I18N.md step 1 since v0.1, but the file
  was never committed, so the documented first step of adding a language
  failed outright. Blocks the planned pt-BR + id work.

Dead code removed: the Rust `ensure_dir` command and its two scoped `opener:`
capabilities. Its documented caller, `openSettingsFolder()`, no longer exists
in `src/` — `opener:default` (all `openExternal` needs) is untouched. Also
`@tauri-apps/plugin-opener` left knip's ignore list now that it is genuinely
imported, and `DroppedReasonId` went from unused export to typing
PlaylistPage's dropped-reason state.

Security: the `js/incomplete-url-substring-sanitization` alert in
description-builder.test.ts was a real (if low-stakes) weak assertion —
`includes("itch.io")` also matches `https://itch.io.example.com/`, so the
test could pass on the wrong line. Now matches the full URL.

CHANGELOG: v0.31.0, v0.32.0 and v0.32.1 shipped as tagged releases but were
never logged, leaving the file jumping v0.33.0 → v0.30.0. Reconstructed from
the release commits in the file's existing house style.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 10:28:00 +07:00
poli0981andClaude Opus 5 48d5bb035c style: apply Prettier across src, tests and scripts
`prettier --check` failed on 81 files: the repo had a Prettier config and a
`format` script from day one, but nothing ever enforced them, so formatting
drifted file by file. This is that pass, isolated in its own commit so the
CI gate added alongside it lands on an already-clean tree and no future
feature diff has to carry whitespace noise.

Formatting only — no behavioural change. Verified by `npm run test:run`
(621 passing, unchanged) and `npm run typecheck`.

Markdown, `_schema.json` and the workflow YAML are deliberately excluded:
Prettier reflows prose and expands the locale schema's compact arrays by
~1600 lines, which makes both harder to review for zero benefit. The
`format` script is scoped to `{src,tests,scripts}/**/*.{ts,tsx,css}` to
match.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 10:27:24 +07:00
poli0981andClaude Opus 5 86c5dec087 chore(deps): patch nanoid DoS advisory via npm audit fix
`nanoid` <3.3.18 (GHSA-2v37-7h3g-55p8 — custom generators can loop
indefinitely when size is zero) reached the tree transitively through
postcss. `npm audit` now reports 0 vulnerabilities; the brace-expansion
advisories were cleared separately by #134.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 10:16:56 +07:00
poli0981 216eabcec8 Merge pull request #134 from poli0981/dependabot/npm_and_yarn/brace-expansion-1.1.18
chore(deps-dev): bump brace-expansion from 1.1.13 to 1.1.18
2026-08-17 10:16:32 +07:00
poli0981 69f6e32ebf Merge pull request #126 from poli0981/dependabot/cargo/src-tauri/serde_with-3.21.0 2026-08-13 09:45:25 +07:00
poli0981 779aa1943e Merge pull request #131 from poli0981/dependabot/npm_and_yarn/postcss-8.5.25 2026-08-13 09:43:20 +07:00
poli0981 1a67dc6901 Merge pull request #133 from poli0981/dependabot/npm_and_yarn/multi-2181bdc769 2026-08-13 09:42:20 +07:00
dependabot[bot] 967c0c4024 chore(deps-dev): bump brace-expansion from 1.1.13 to 1.1.18
Bumps [brace-expansion](https://github.com/juliangruber/brace-expansion) from 1.1.13 to 1.1.18.
- [Release notes](https://github.com/juliangruber/brace-expansion/releases)
- [Commits](https://github.com/juliangruber/brace-expansion/compare/v1.1.13...v1.1.18)

---
updated-dependencies:
- dependency-name: brace-expansion
  dependency-version: 1.1.18
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-13 02:42:07 +00:00
dependabot[bot] 2408c40e50 chore(deps): bump react-router and react-router-dom
Bumps [react-router](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router) to 7.18.2 and updates ancestor dependency [react-router-dom](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom). These dependencies need to be updated together.


Updates `react-router` from 6.30.4 to 7.18.2
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/react-router@7.18.2/packages/react-router/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/react-router@7.18.2/packages/react-router)

Updates `react-router-dom` from 6.30.4 to 7.18.2
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/react-router-dom@7.18.2/packages/react-router-dom/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/react-router-dom@7.18.2/packages/react-router-dom)

---
updated-dependencies:
- dependency-name: react-router
  dependency-version: 7.18.2
  dependency-type: indirect
- dependency-name: react-router-dom
  dependency-version: 7.18.2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-13 02:41:01 +00:00
poli0981 d955d045f0 Merge pull request #132 from poli0981/dependabot/npm_and_yarn/js-yaml-4.3.1 2026-08-13 09:39:45 +07:00
dependabot[bot] 8c064ebd98 chore(deps-dev): bump js-yaml from 4.2.0 to 4.3.1
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 4.2.0 to 4.3.1.
- [Changelog](https://github.com/nodeca/js-yaml/blob/4.3.1/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/4.2.0...4.3.1)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 4.3.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-12 00:51:36 +00:00
dependabot[bot] e138758656 chore(deps-dev): bump postcss from 8.5.15 to 8.5.25
Bumps [postcss](https://github.com/postcss/postcss) from 8.5.15 to 8.5.25.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.5.15...8.5.25)

---
updated-dependencies:
- dependency-name: postcss
  dependency-version: 8.5.25
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-02 02:38:44 +00:00
dependabot[bot] 938d35b613 chore(deps): bump serde_with from 3.18.0 to 3.21.0 in /src-tauri
Bumps [serde_with](https://github.com/jonasbb/serde_with) from 3.18.0 to 3.21.0.
- [Release notes](https://github.com/jonasbb/serde_with/releases)
- [Commits](https://github.com/jonasbb/serde_with/compare/v3.18.0...v3.21.0)

---
updated-dependencies:
- dependency-name: serde_with
  dependency-version: 3.21.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-15 23:29:04 +00:00
195 changed files with 10254 additions and 4602 deletions

No files matched your search

+47 -5
View File
@@ -1,10 +1,11 @@
# Dependabot configuration.
#
# This file exists only to configure SECURITY updates for cargo in /src-tauri.
# Version updates stay disabled (open-pull-requests-limit: 0); npm and
# GitHub Actions keep GitHub's default security-update behavior.
# Three ecosystems: npm (the app), cargo (the Tauri shell), and github-actions
# (the workflows). Security updates are on repo-wide by default; the entries
# below add scheduled VERSION updates so the tree does not silently rot between
# advisories, and carry the ignore rules that keep unfixable alerts quiet.
#
# Why the ignores: `rand` and `glib` are transitive dependencies of tauri,
# Why the cargo ignores: `rand` and `glib` are transitive dependencies of tauri,
# and their security fixes require semver-major bumps that the dependency
# tree does not allow, so every Dependabot security-update job for them
# fails with `security_update_not_possible` (runs 27387346373, 27387346324):
@@ -20,12 +21,53 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 5
commit-message:
prefix: "chore(deps)"
prefix-development: "chore(deps-dev)"
groups:
# One PR per family instead of one per package. A split React or
# typescript-eslint bump is never independently mergeable anyway, and
# CI has to run for each PR.
react:
patterns: ["react", "react-dom", "@types/react", "@types/react-dom"]
i18n:
patterns: ["i18next*", "react-i18next"]
tauri:
patterns: ["@tauri-apps/*"]
lint-and-format:
patterns: ["eslint*", "@eslint/*", "typescript-eslint", "prettier*", "knip"]
build-tooling:
patterns: ["vite", "vitest", "@vitejs/*", "tailwindcss", "postcss", "autoprefixer", "tsx"]
ignore:
# Majors land in their own planned release (see docs/ROADMAP.md) because
# each one needs a real migration — React 19, Tailwind 4 and ESLint 10 all
# change APIs the app uses directly. Dependabot handles minor + patch.
- dependency-name: "*"
update-types: ["version-update:semver-major"]
- package-ecosystem: "cargo"
directory: "/src-tauri"
schedule:
interval: "weekly"
# No version-update PRs; this entry only feeds ignore rules to security updates.
# No version-update PRs; this entry only feeds ignore rules to security
# updates. The Rust side is pinned to whatever tauri's tree allows.
open-pull-requests-limit: 0
ignore:
- dependency-name: "rand"
- dependency-name: "glib"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 3
commit-message:
prefix: "ci"
groups:
actions:
patterns: ["*"]
+53 -7
View File
@@ -6,18 +6,64 @@ on:
pull_request:
branches: [main]
# Least privilege. The job only reads the repo — it publishes nothing, comments
# nowhere. Declaring it explicitly also silences CodeQL's
# `actions/missing-workflow-permissions`, which otherwise flags the implicit
# (and much wider) default token scope.
permissions:
contents: read
# A force-push or a quick follow-up commit makes the older run worthless. Cancel
# it instead of paying for both — except on `main`, where every commit's result
# is a historical record the release process reads back.
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run typecheck
- run: npm run lint
- run: npm run validate:locales
- run: npm run test:run
- run: npm run build
# --- correctness ------------------------------------------------------
# `typecheck` covers src/ (what Vite actually builds); `typecheck:all`
# adds tests/ and scripts/, which went unchecked until v0.35.0 and were
# hiding three silently-stale fixture fields.
- name: Type check (src)
run: npm run typecheck
- name: Type check (tests + scripts)
run: npm run typecheck:all
- name: Lint
run: npm run lint
- name: Validate locales
run: npm run validate:locales
- name: Test
run: npm run test:run
# --- consistency ------------------------------------------------------
- name: Check formatting
run: npm run format:check
- name: Check dead code
run: npm run knip
# The release ritual bumps SIX version fields by hand. This is the only
# thing that notices when one is missed — see scripts/check-version-sync.ts.
- name: Check version sync
run: npm run check:version
# --- security ---------------------------------------------------------
# Advisory-only: a fresh high-severity advisory in a transitive dep must
# not turn every unrelated PR red before Dependabot has had a chance to
# open its fix PR. The Dependabot alerts tab is the source of truth.
- name: Audit dependencies
run: npm audit --audit-level=high
continue-on-error: true
# --- build ------------------------------------------------------------
- name: Build
run: npm run build
+2 -2
View File
@@ -16,8 +16,8 @@ jobs:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
cache: npm
+28 -9
View File
@@ -17,11 +17,11 @@ jobs:
build-android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
ref: ${{ github.event.inputs.tag || github.ref }}
- uses: actions/setup-node@v6
- uses: actions/setup-node@v7
with:
node-version: 22
cache: npm
@@ -41,7 +41,7 @@ jobs:
targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android
- name: Cache cargo
uses: actions/cache@v5
uses: actions/cache@v6
with:
path: |
~/.cargo/registry
@@ -79,11 +79,30 @@ jobs:
NDK_HOME: ${{ env.ANDROID_HOME }}/ndk/27.3.13750724
run: cargo tauri android build --apk
- name: Upload APK to draft release
uses: softprops/action-gh-release@v3
# Keep the APK regardless of whether the release upload works, so a
# broken upload never costs a 20-minute rebuild.
- name: Upload APK as workflow artifact
uses: actions/upload-artifact@v6
with:
tag_name: ${{ github.event.inputs.tag || github.ref_name }}
draft: true
files: src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk
name: ytdescgen-android-apk
path: src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk
if-no-files-found: error
# Uses `gh` (pre-installed on every runner) rather than a third-party
# action. `softprops/action-gh-release@v3` resolved the target release
# from GITHUB_REF instead of the `tag_name` it was given, so on a tag push
# it looked for a release tagged `refs/tags/v0.35.0` and on a
# workflow_dispatch it looked for one tagged `refs/heads/main` — neither
# exists, so it tried to CREATE a release on a branch ref and got
# "Resource not accessible by integration". The v0.35.0 APK was built
# three times before this was pinned down.
#
# `gh release upload` takes the tag as a positional argument and cannot
# make that mistake. `--clobber` makes a re-run idempotent.
- name: Upload APK to draft release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.event.inputs.tag || github.ref_name }}
APK: src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk
run: |
gh release upload "$TAG" "$APK" --clobber --repo "${{ github.repository }}"
+3 -3
View File
@@ -52,12 +52,12 @@ jobs:
bundleArgs: ""
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
# On `workflow_dispatch` checkout the requested tag; on a
# tag push we already get the tag commit by default.
ref: ${{ github.event.inputs.tag || github.ref }}
- uses: actions/setup-node@v6
- uses: actions/setup-node@v7
with:
node-version: 22
cache: npm
@@ -75,7 +75,7 @@ jobs:
librsvg2-dev \
patchelf
- run: npm ci
- uses: tauri-apps/tauri-action@v0
- uses: tauri-apps/tauri-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# AppImage bundling on hosted runners flakes: linuxdeploy (itself
+137
View File
@@ -2,6 +2,94 @@
All notable changes to YTDescGen ship as tagged releases on `main`.
## v0.38.0 — 2026-08-17
Two new languages: **Portuguese (Brazil)** and **Indonesian**. Brazil is a
top-three market for gameplay viewing and Indonesia the largest in Southeast
Asia; both use Latin script, so neither needed font or layout work.
### Added
- **`pt-BR` and `id` locales** — 1,562 strings each. Both are complete: titles, every description block, all 248 content warnings, tech notes, playthrough notes, pinned comments, playlist copy, and the whole interface from the editor through Settings, Batch, Social and Logs.
- **Per-language tag pools** ([src/engine/tag-generator.ts](src/engine/tag-generator.ts)) — `CORE_TAGS_BY_LANG` and `MULTILINGUAL_TAGS` gained entries for both, so a Brazilian video gets `gameplay sem comentários` and `detonado` rather than falling back to English tags.
- **Region-aware browser detection** ([src/store/settings-heal.ts](src/store/settings-heal.ts)) — `detectBrowserLanguage` now matches the full BCP-47 tag before the bare language, or `pt-BR` would be reduced to `pt` and never found. Any other Portuguese variant also resolves to `pt-BR` rather than falling through to English.
### Fixed
- **`docs/I18N.md` was wrong about what registering a locale takes.** It said `SUPPORTED_LANGUAGES` was "the only registration step". It is one of four, and they fail differently: the `SupportedLanguage` union and the two tag-pool records are compile errors, but `detectBrowserLanguage`'s own hardcoded copy of the list fails **silently** — the language works and simply never auto-selects for a visitor whose browser is set to it. `SUPPORTED_LANGUAGES` is also not type-bound to the union, and every consumer casts, so a mismatch between the first two compiles cleanly. Corrected, and `SUPPORTED_LANGUAGES` now carries a `satisfies` clause that binds it to the union.
- **`__dirname` in the Vite and Vitest configs** replaced with `import.meta.dirname`. Vite 8's native config loader — planned to become the default — doesn't provide the CJS global, and warned on every run.
### Under the hood
- **New guard: [tests/i18n/locale-registration.test.ts](tests/i18n/locale-registration.test.ts)** checks the picker list against the locale directories on disk *in both directions*, plus namespace files, flags, native names and tag pools. It exists specifically to close the two registration gaps that fail silently.
- 115 UI keys were not hand-translated at all — their English text is byte-identical to a string already translated in `templates.json` (graphics presets, ray-tracing modes, difficulty names, content-warning labels), so they are copied across. Translating those twice risks a checkbox and the rendered description disagreeing about what the same option is called.
- Left as English on purpose, matching what the Spanish locale already does: vendor product names (NVIDIA DLSS, AMD FSR, Intel XeSS, Fluid Motion Frames), platform brands (Ko-fi, Patreon, Discord, Steam, TikTok), hardware acronyms (CPU, GPU, RAM), genre terms that are loanwords in both languages (RPG, FPS, MMO, Indie, Metroidvania, Roguelike, Battle Royale), and example URLs / emails in placeholders. **pt-BR 1,344 / 1,562 and id 1,308 / 1,562 strings differ from English**; the remainder are those pass-throughs, not gaps.
- Both are **AI-translated and not native-reviewed** — recorded in [DISCLAIMER.md](DISCLAIMER.md) alongside JA / ES / KO / ZH. Native-speaker corrections are the most welcome contribution to this project; `src/i18n/locales/<code>/*.json` can be edited straight from GitHub's web UI.
- Validator now **1,562 keys × 8 locales**. typecheck, typecheck:all, lint, format:check, validate:locales, knip, check:version, **698 tests** and build all pass; verified live in the browser — both languages appear in every picker, generate correctly translated titles and descriptions, and translate the interface itself.
- Six manifests bumped 0.37.0 → 0.38.0. (v0.36.0 was skipped: the dependency release shipped first and had already taken 0.37.0.)
## v0.37.0 — 2026-08-17
A **dependency modernization** release. No user-facing feature changes; the app
should behave identically. Every major the project had been sitting on is now
current, and the two new lint rules that came with them found four real
performance bugs.
### Changed
- **React 18 → 19**, `@types/react` 19, `@vitejs/plugin-react` 6. One source change: React 19 types `useRef<T>(null)` as `RefObject<T | null>` rather than `RefObject<T>` — the old type quietly claimed a ref was non-null before its element mounted. [ScrollToTopButton](src/components/layout/ScrollToTopButton.tsx) now matches, which keeps its existing null check honest.
- **Tailwind 3 → 4** ([src/styles/globals.css](src/styles/globals.css)) — configuration moves from `tailwind.config.ts` (deleted) into CSS. The design tokens live in an `@theme` block that maps Tailwind's names onto the existing `:root` / `.light` variables, so the runtime theme toggle keeps working exactly as before. `darkMode: "class"` becomes `@custom-variant dark`, because the app toggles a class on `<html>` rather than following the OS. PostCSS now loads `@tailwindcss/postcss`. Verified in the browser in both themes.
- **ESLint 9 → 10** + `eslint-plugin-react-hooks` 5 → 7, which enables the React Compiler diagnostics.
- **Zustand 4 → 5**, **i18next 23 → 26**, **react-i18next 15 → 17**, `@testing-library/*`, `typescript-eslint` 8.67, plus the Vite / Vitest / tsx / knip / Tauri-plugin patch line.
### Fixed
The new `react-hooks/set-state-in-effect` rule flagged seven call sites. Four were real extra render passes and are fixed:
- **[use-online-status](src/hooks/use-online-status.ts)** rewritten to `useSyncExternalStore`. It was re-reading `navigator.onLine` inside an effect to close the gap between the first render and the listeners attaching — subscribing properly removes the gap rather than patching it, and costs one render fewer on every mount.
- **[ShortcutHelpModal](src/components/ui/ShortcutHelpModal.tsx)** derives its filter from `open` instead of resetting state in an effect, so a modal that spends most of its life closed no longer schedules work on unrelated parent updates.
- **[DraftIndicator](src/components/editor/DraftIndicator.tsx)** and **[use-languages-ready](src/hooks/use-languages-ready.ts)** now guard their setters.
Three remain as **warnings**, deliberately: they genuinely sync state *from* an external source (i18next bundle readiness, a text mirror of a numeric store field, and a `useMemo` the compiler can't preserve). Each needs a restructure rather than a guard, so they are recorded in [eslint.config.js](eslint.config.js) rather than silenced or used as a reason to hold back the upgrade.
### Not upgraded
- **`lucide-react` stays at 0.577.0.** 1.x removes every brand icon (Instagram, Facebook, GitHub, YouTube, X) — upstream dropped them for trademark reasons. Taking 1.x would mean either a generic globe next to a Facebook link, or re-adding the marks ourselves and inheriting the exposure lucide just shed. Neither is worth it: 0.577 already delivered the win, cutting the main bundle **175 kB → 137 kB**.
### Under the hood
- `knip` now ignores `tailwindcss`, whose only reference after the migration is `@import "tailwindcss"` in CSS — which knip doesn't follow.
- Full gate green: typecheck, typecheck:all, lint, format:check, validate:locales, knip, check:version, **692 tests**, build. Verified live in the browser: both themes render, icons intact, editor and batch functional.
- Six manifests bumped 0.35.0 → 0.37.0. (0.36.0 is reserved for the two new locales.)
## v0.35.0 — 2026-08-17
A **guardrails** release. Four things the app quietly let you do wrong — publish
a Batch description missing its contact block, copy output YouTube would reject,
paste a novel into a field, and export a file without being asked where to put
it — now can't happen.
### Fixed
- **Split contact emails now render in Batch** ([src/hooks/use-render-options.ts](src/hooks/use-render-options.ts), [src/pages/BatchPage.tsx](src/pages/BatchPage.tsx)) — with **Settings → Split contact email** on, the Batch tab showed only the legacy single `📧 Business inquiries:` line while the Output tab correctly showed the grouped `📧 BUSINESS / CONTACT` block. The engine was never at fault: `renderAll` had three call sites each hand-copying the same twelve settings fields, and BatchPage's copy was missing `splitContactEmail` and `showThirdPartyAds`. An absent flag defaults to `false`, so the wrong branch ran silently. The mapping now lives in one hook, guarded from both sides — a missing key is a compile error (`Required<SettingsRenderOptions>`) *and* a named test failure. **The SPONSORS & PARTNERS block was being dropped in Batch for the same reason and now renders too, so Batch descriptions get longer if you had either toggle on.**
- **Exports ask where to save** ([src/utils/file-ops.ts](src/utils/file-ops.ts)) — every JSON export (Settings, Profiles, Presets, Templates, Social, Log) bypassed the one writer that branched per platform and dumped straight into `Downloads`, even on desktop where a native Save As dialog was available the whole time. One writer now serves all seven: native **Save As** on Tauri desktop, the **file picker** on Chromium browsers, and the download fallback on Android / Firefox / Safari. Cancelling is silent — dismissing a dialog is a decision, not a failure. Settings Import/Export is also no longer desktop-only.
- **`ValidatedInput` no longer destroys good input** ([src/components/ui/ValidatedInput.tsx](src/components/ui/ValidatedInput.tsx)) — on an invalid value it called `onChange("")`, wiping the stored value while the box still showed your text. Backspacing one character out of a complete URL silently emptied the field, and autosave persisted the empty. It now simply doesn't commit, keeping the last valid value. Separately, the box never re-synced when the value changed underneath it, so applying a profile or preset left stale text on screen disagreeing with the store.
### Added
- **Over-limit output can't be copied** ([src/engine/limits.ts](src/engine/limits.ts)) — if any one of title / description / tags is over its YouTube limit, none of them can be copied, on **Output and Batch**. The engine has returned `warnings` since v0.5 and nothing ever read it; three ad-hoc checks had grown up instead, and the one in `CopyAllBar` skipped every check whenever more than one output language was selected. Batch also gained the description and tag counters it never had. Scoped sensibly: one over-limit part blocks itself and Copy All Batch, not the other 99.
- **Strict Mode** ([src/utils/editor-issues.ts](src/utils/editor-issues.ts)) — a **Settings → Guardrails** toggle, off by default. When on, Generate / Copy / Export are blocked while any field has a hard error, with a banner naming each one. Errors only: a working link that merely doesn't match a platform's usual prefix stays a warning, because blocking it would strand anyone on a vanity domain. Derived from state rather than from mounted inputs, so it works from any page and also catches bad data that arrived by import. The log export stays ungated — a debugging export shouldn't be held hostage by an unrelated bad URL.
- **Field length caps** ([src/config/field-limits.ts](src/config/field-limits.ts)) — `maxLength` appeared nowhere in the codebase before this release. Caps are grouped by what a field holds (URL 200, email 320, short name 100, label 300, long text 2000, timestamps 5000) and wired at 53 call sites. Imports are clamped too, since `maxLength` only constrains typing.
- **Emails hard-stop at three per field** ([src/utils/validation.ts](src/utils/validation.ts)) — typing a fourth is refused outright instead of wiping the field. Enforced on the *increase*, so a field that already holds four (from an older profile) stays editable down to three, and a half-typed `a@b.com,c@` is never punished.
- **Collapsible Settings sections** ([src/pages/settings/GenrePlaylistsSection.tsx](src/pages/settings/GenrePlaylistsSection.tsx)) — **Genre Playlists** renders one input per genre (42 of them) and was the tallest block on the page. It now ships collapsed with a filled-count badge. The other eight sections became accordions too, defaulting open.
### Under the hood
- Settings persist **v11 → v12** (`strictMode`, `settingsAccordionState`), with `SCHEMA_VERSIONS.settings` bumped in lockstep. Both are *coerced*, not merely back-filled — a hand-edited `"strictMode": "yes"` is truthy in JS, and switching a seatbelt on by accident is the opposite of an opt-in. `SCHEMA_VERSIONS.profile` corrected 1 → 2, left behind when profile-store bumped in v0.34.0.
- `SettingsPage` split 544 → 347 lines, extracting the import/export IO and the Genre Playlists section.
- 16 i18n keys per locale across all six locales (validator **999 ui / 563 templates**). typecheck, lint, locale validation, dead-code, formatting, version-sync and **692 tests** (621 + 71) pass; verified live in the browser — Batch renders all three contact lines, a bad Steam URL disables Batch generation and names the field, a fourth email is refused with the three intact, and Genre Playlists opens to 42 inputs behind a `0/42` badge.
- Six manifests bumped 0.34.0 → 0.35.0.
## v0.34.0 — 2026-07-20
A **feature** release that lets creators publish a different email per purpose instead of a
@@ -35,6 +123,55 @@ and **Facebook Group** moved in from the generic Social list.
- Nine i18n keys per locale added, one (`social.fb_group`) removed, across all six locales (validator **975 ui / 559 templates**). typecheck, lint, locale validation, and **613 tests** (583 + 30: three new validators, v17 migration incl. the fb_group lift, community render/order/all-language cases, mapping parity) pass; verified live — Vietnamese output shows all five lines in order with a localized heading, English output drops the Zalo line while keeping the rest, and a malformed Signal link surfaces an inline hard-reject error.
- Five manifests bumped 0.32.1 → 0.33.0.
## v0.32.1 — 2026-07-12
A **hotfix** to v0.32.0. The Messenger Community field accepted the wrong link
shape: `https://m.me/[id]` is a personal-page link, while a community/channel
invite is `https://m.me/ch/[id]` (e.g. `https://m.me/ch/Abb1hmBhU_97UMCF/`).
Creators following the in-app example published a link that did not open the
community.
### Fixed
- **Messenger community link format** ([src/utils/validation.ts](src/utils/validation.ts)) — `MESSENGER_URL_REGEX` now requires the `/ch/` segment (trailing slash optional) and hard-rejects the old bare form, so a wrong link can no longer reach the description. The shown example (`MESSENGER_URL_EXPECTED`) and the placeholder in all six locales moved to `https://m.me/ch/yourid`; stale doc comments were refreshed alongside.
### Under the hood
- Engine and store are untouched — the link is printed verbatim and the field's type and persist shape are unchanged, so no migration was needed. Validation, engine, and migration tests updated, with new trailing-slash-accept and bare-form-reject cases.
- Five manifests bumped 0.32.0 → 0.32.1.
## v0.32.0 — 2026-07-08
A **feature** release adding the first two "join the chat" community links, in a
single `💬 COMMUNITY` description block — the block that v0.33.0 later grew to
five entries.
### Added
- **Messenger community + Zalo group** ([src/components/editor/CommunityEditor.tsx](src/components/editor/CommunityEditor.tsx), [src/utils/validation.ts](src/utils/validation.ts)) — a new **Community** section feeding a localized `💬 COMMUNITY` block. Messenger renders for **every** output language. Zalo is a Vietnam-audience app, so its input only appears — and its line only renders — when the output language is Vietnamese, mirroring the existing VN donate block; a value entered while in Vietnamese survives a language switch. Both links are hard-validated (`validateMessengerUrl` / `validateZaloGroupUrl`) so a malformed URL never reaches the output.
### Under the hood
- Two editor fields (`messengerCommunityLink`, `zaloGroupLink`) thread through defaults, the store (persist **v15 → v16**, an additive back-fill), `GeneratorInput`, the editor → engine mapping, and template snapshots — guarded by the existing parity test.
- i18n across all six locales (validator **967 ui / 559 templates**). typecheck, lint, locale validation, and **581 tests** (560 + 21: two new validators, the v16 migration, and community render/language-gating cases) pass.
- Five manifests bumped 0.31.0 → 0.32.0.
## v0.31.0 — 2026-06-28
A **feature** release for the Playlist Generator: the pinned comment a series
needs on its latest video, and an honest answer to "why did this playlist stop?"
### Added
- **Status-adaptive playlist pinned comment** ([src/engine/playlist-builder.ts](src/engine/playlist-builder.ts)) — a new `buildPlaylistComment` engine function produces a pinned comment for the series' latest video whose wording follows the playlist status (completed / dropped / incomplete / in progress), rather than one generic template for all four.
- **Dropped reasons** ([src/config/dropped-reasons.ts](src/config/dropped-reasons.ts), [src/pages/PlaylistPage.tsx](src/pages/PlaylistPage.tsx)) — when a series is marked **dropped**, a multi-select of six predefined reasons (`😴 boring`, `🐌 performance`, `🐛 bugs`, `🗑️ delisted`, `📉 low views`, `⏳ time`) plus a free-text "other reason" field. Selected reasons render in **both** the playlist description and the pinned comment. Reason labels are localized in both namespaces — `ui` for the selection chips, `templates` for the rendered output — the same split content warnings use.
### Under the hood
- Playlist state stays local to the page; nothing was added to the editor store, so there is no migration in this release.
- i18n across all six locales (validator **959 ui / 558 templates**). `playlist-builder` gained its first test file — **197 lines** covering comment generation per status and dropped-reason rendering.
- Five manifests bumped 0.30.0 → 0.31.0.
## v0.30.0 — 2026-06-27
A **feature** release adding two things creators kept doing by hand: advertising a
+1 -1
View File
@@ -41,7 +41,7 @@ Use the templates in `.github/ISSUE_TEMPLATE/`:
If your change adds or removes any user-facing string:
1. Update the locale schema at `src/i18n/locales/_schema.json` first.
2. Add the key to **all 6 locales** (`en` / `vi` / `ja` / `es` / `ko` / `zh`).
2. Add the key to **all 8 locales** (`en` / `vi` / `ja` / `es` / `ko` / `zh` / `pt-BR` / `id`).
3. `npm run validate:locales` must pass.
Native-speaker corrections to AI-translated locales (JA / ES / KO / ZH) are especially welcome — see [DISCLAIMER.md](./DISCLAIMER.md) for the current translation-quality status.
+3 -1
View File
@@ -17,7 +17,7 @@ See also: [`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md) § "AI-Assisted D
## Translation quality
The application UI ships in six languages. Authoring quality varies:
The application UI ships in eight languages. Authoring quality varies:
| Locale | Authoring | Notes |
| --- | --- | --- |
@@ -27,6 +27,8 @@ The application UI ships in six languages. Authoring quality varies:
| Spanish (`es`) | AI-translated | Not native-reviewed. Regional voice (LatAm vs. Castilian) not specifically targeted. |
| Korean (`ko`) | AI-translated | Not native-reviewed. Honorific register chosen for neutrality, not specific cultural fit. |
| Chinese (`zh`) | AI-translated | Simplified Chinese only. Not native-reviewed. |
| Portuguese, Brazil (`pt-BR`) | AI-translated | Not native-reviewed. Brazilian Portuguese specifically — European Portuguese is not separately targeted. |
| Indonesian (`id`) | AI-translated | Not native-reviewed. Standard Indonesian; gaming loanwords kept in English where that is the common usage. |
If you're a native speaker and spot mistranslations, please open an issue or PR — see [CONTRIBUTING.md](./CONTRIBUTING.md) § "i18n Contributions".
+5 -3
View File
@@ -2,7 +2,7 @@
**YouTube Gameplay Description Generator** — an offline-first template engine for Gameplay No Commentary YouTube channels.
Generate YouTube titles, descriptions, and tags in six languages with one click. Save channel, rig, and game presets to skip repetitive data entry. Works in the browser (GitHub Pages), as a ~8 MB native desktop app (Windows / macOS / Linux), or as an installable Android APK — all from one Tauri 2 codebase.
Generate YouTube titles, descriptions, and tags in eight languages with one click. Save channel, rig, and game presets to skip repetitive data entry. Works in the browser (GitHub Pages), as a ~8 MB native desktop app (Windows / macOS / Linux), or as an installable Android APK — all from one Tauri 2 codebase.
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](./LICENSE)
[![Node](https://img.shields.io/badge/node-%E2%89%A522-brightgreen)](./docs/DEVELOPMENT.md)
@@ -22,14 +22,15 @@ Built for the gameplay no-commentary niche — especially horror / scary games
## Features
- **20 video types** — Full Gameplay, Part, Boss Fight, Boss No-Hit, Ending, Speedrun, 100%, DLC, NG+, Challenge, Side Quest, Secret, Comparison, Guide, Mods, Collectibles, Livestream, Gacha Quest, Demo, Demo Part.
- **6 UI languages** — English, Vietnamese, Japanese, Spanish, Korean, Chinese. *(VI authored by a native speaker; JA / ES / KO / ZH AI-translated — see [DISCLAIMER.md](./DISCLAIMER.md).)*
- **8 UI languages** — English, Vietnamese, Japanese, Spanish, Korean, Chinese, Portuguese (Brazil), Indonesian. *(VI authored by a native speaker; JA / ES / KO / ZH / PT-BR / ID AI-translated — see [DISCLAIMER.md](./DISCLAIMER.md).)*
- **40+ game genres** — across action, RPG, FPS, horror, soulslike, indie, simulation, fighting, and more.
- **248 content-warning IDs** across 12 groups — spoilers, photosensitive/VFX, audio, dialogue/language, phobias (incl. color phobias), mental health, social phenomena, internet/digital life, sensitive themes (incl. method-specific death/violence and suggestive imagery), horror-specific, playstyle, and gameplay disclosure (mods / cheats / glitches / guide-assisted / educational purpose). Sets viewer expectations before they hit play.
- **Profile system** — save channel / social / rig info once, reuse across every video.
- **Game presets** — save game name + store links once, reuse across the entire part series.
- **Snapshot templates** — save full-form configurations and recall in one click.
- **Smart tag generation** — combines genre pool, platform, quality tier, multilingual hooks, and trending terms; auto-dedup and 500-char-limit aware.
- **Character counters** — real-time limits for title (100), description (5000), tags (500).
- **Character counters** — real-time limits for title (100), description (5000), tags (500). If **any one** is over, no field can be copied — partial copying is how a half-finished description gets published.
- **Guardrails** — hard length caps on every input field, a three-address cap per email field, and an opt-in **Strict Mode** that blocks Generate / Copy / Export while any field holds an error.
- **Batch mode** — generate metadata for all parts of a series in one pass.
- **Cross-post captions** — a dedicated **Social** tab re-packages the same YouTube source into short-form captions for **TikTok** (4,000-char), **Instagram Reels**, and **Facebook Reels** — title, rig, content warnings, copyright, thanks, and hashtags (game + genre + curated per-platform popular tags). Single + bulk modes, per-platform character limits with smart overflow trimming, and JSON import/export.
- **Desktop app** — Windows, macOS & Linux native binaries via Tauri (~8 MB).
@@ -87,6 +88,7 @@ Architecture overview: [`docs/ARCHITECTURE.md`](./docs/ARCHITECTURE.md).
| Document | What's in it |
| --- | --- |
| **[Wiki](https://github.com/poli0981/youtube-generator/wiki)** | **User documentation** — quick start, glossary, every field and its limit, guardrails, troubleshooting, FAQ. Start here if you're using the app rather than building it. |
| [Development Guide](./docs/DEVELOPMENT.md) | Toolchain, IDE setup, build commands, troubleshooting. *(Also: [Vietnamese](./docs/i18n/vi/DEVELOPMENT.md).)* |
| [Architecture](./docs/ARCHITECTURE.md) | Layer model, data flow, engine design. |
| [Features](./docs/FEATURES.md) | Full feature matrix. |
+44 -2
View File
@@ -261,13 +261,55 @@ Zustand Stores:
├───────────────────────────────────────────────┤
│ SettingsStore │
│ - theme: "dark" | "light" │
│ - defaultLanguage: SupportedLanguage │
│ - defaultGenres: GenreId[] │
│ - appLanguage / defaultOutputLanguage │
│ - strictMode, settingsAccordionState (v12) │
│ - (flags: quality badge / copyright / ...) │
│ Middleware: persist (localStorage + file) │
├───────────────────────────────────────────────┤
│ PendingInvalidStore (0.35) │
│ - entries: Record<fieldId, PendingInvalid> │
│ Middleware: NONE — in-flight typing, not data │
└───────────────────────────────────────────────┘
```
### Settings → engine options
`renderAll` is called from three places (the Output hook, the multi-language
Output hook, BatchPage). Each used to hand-copy the same twelve settings fields
into an options object, and they had drifted — BatchPage's copy silently omitted
`splitContactEmail` and `showThirdPartyAds`, so Batch rendered a different
description than Output from identical data.
`src/hooks/use-render-options.ts` is now the single mapping, with two guards:
- **Compile-time** — `buildRenderOptions` builds a
`Required<SettingsRenderOptions>`, so omitting a key is a type error.
- **Runtime** — `tests/hooks/render-options-parity.test.ts` diffs the produced
keys against `SETTINGS_DERIVED_RENDER_KEYS` in both directions.
`RenderOptions` is split accordingly: `SettingsRenderOptions` (from the user)
plus `RenderOptionOverrides` (`tEn`, `bilingualContentBlocks` — decided per call
site, since Output wants bilingual content blocks and Batch does not).
### Validation state
Two sources, unioned by `useStrictBlock`, because neither alone is sufficient:
| Source | Catches | Why it's needed |
|---|---|---|
| `collectEditorIssues` (pure, over `EditorData`) | Saved values that fail validation | Bad data from imports — `ValidatedInput` refuses to commit invalid text, so imports are the main way it gets in |
| `PendingInvalidStore` | Typed text that is invalid and therefore **not** saved | Otherwise a field showing a red error is invisible to every gate, because the store behind it holds the last good value |
Both are filtered through `isRelevantIssueId`, so a field that isn't currently
shown (`adEmail` with split-email off, `zaloGroupLink` outside Vietnamese
output) can never block on a value with no visible input to fix it.
The first implementation registered issues from the inputs themselves and
cleared on unmount. It typechecked and had passing tests, and did nothing: the
fields live on the Editor page while the gates live on Batch / Social / Output,
so navigating away cleared every issue. Deriving from state removes the mount
coupling entirely.
## 4. i18n Architecture
```
+9 -5
View File
@@ -86,14 +86,18 @@ npm run dev
| `npm run dev` | Vite dev server, hot reload, web only. |
| `npm run build` | Production web bundle into `dist/`. |
| `npm run preview` | Serve the production bundle for sanity-testing. |
| `npm run typecheck` | `tsc --noEmit`. Run before every PR. |
| `npm run typecheck` | `tsc --noEmit` over `src/` — what Vite actually builds. |
| `npm run typecheck:all` | Same, plus `tests/` and `scripts/`, which the base config deliberately excludes. Added in v0.35.0 after it turned out they had **never** been type-checked — and immediately found three fields silently missing from the editor→engine parity fixture. |
| `npm run lint` | ESLint. Use `npm run lint:fix` to autofix. |
| `npm run format` | Prettier write across `src/`. |
| `npm run format` | Prettier write across `src/`, `tests/`, `scripts/`. |
| `npm run format:check` | Same, read-only. CI gate. Markdown and the locale JSON are deliberately out of scope — Prettier reflows prose and expands the schema's compact arrays by ~1600 lines for no benefit. |
| `npm run knip` | Dead-code / unused-dependency check. CI gate. |
| `npm run check:version` | Asserts all **six** version fields agree (`package.json`, both `package-lock.json` entries, `tauri.conf.json`, `Cargo.toml`, `Cargo.lock`). The only thing that notices a missed one. |
| `npm run test` | Vitest watch mode. |
| `npm run test:run` | Vitest single-run (for CI / pre-commit). |
| `npm run test:coverage` | Coverage report into `coverage/`. |
| `npm run validate:locales` | Enforces all 6 locales match `_schema.json` exactly. **Must pass before any locale-touching PR merges.** |
| `npm run generate:locale` | Scaffold an empty locale from `_schema.json` for a new language. |
| `npm run validate:locales` | Enforces all 8 locales match `_schema.json` exactly. **Must pass before any locale-touching PR merges.** |
| `npm run generate:locale` | Scaffold a locale from the English source. `--lang <code>`, plus optional `--copy-english` / `--force`. (Advertised since v0.1 but only actually written in v0.35.0.) |
| `npm run tauri:dev` | Tauri desktop in dev mode (auto-restarts on Rust or frontend changes). |
| `npm run tauri:build` | Tauri release binary for the current platform. |
@@ -136,7 +140,7 @@ docs/I18N.md). The restart advice above still applies to all of them.
### Pre-commit hook fails on `validate:locales` but I didn't touch locales
You probably added a new key to `_schema.json` indirectly via the engine types (`src/engine/types.ts` → `CONTENT_WARNINGS`). New IDs require translations in all 6 locales.
You probably added a new key to `_schema.json` indirectly via the engine types (`src/engine/types.ts` → `CONTENT_WARNINGS`). New IDs require translations in all 8 locales.
## See Also
+39 -10
View File
@@ -11,9 +11,9 @@ structure, and tag bias. The complete table — every type with its icon and
the extra fields the editor reveals — is in
[Content Inventory](./CONTENT-INVENTORY.md).
## 🌐 Languages (6 shipped)
## 🌐 Languages (8 shipped)
All six locales ship today — UI strings and description templates fully
All eight locales ship today — UI strings and description templates fully
translated and parity-validated by `npm run validate:locales`.
| Code | Language | Native Name | Status |
@@ -24,9 +24,12 @@ translated and parity-validated by `npm run validate:locales`.
| `es` | Spanish | Español | ✅ Shipped |
| `ko` | Korean | 한국어 | ✅ Shipped |
| `zh` | Chinese (Simplified) | 简体中文 | ✅ Shipped |
| `pt-BR` | Portuguese (Brazil) | Português (BR) | ✅ Shipped |
| `id` | Indonesian | Bahasa Indonesia | ✅ Shipped |
Further locales (French, German, Portuguese, Russian, Thai, Arabic) are
tracked in [Roadmap § 5.3](./ROADMAP.md).
Further locales (French, German, Russian, Thai, Arabic) are tracked in
[Roadmap § 5.3](./ROADMAP.md). Arabic additionally needs RTL layout work —
see [I18N.md](./I18N.md).
Each language requires:
- `ui.json` — UI labels, buttons, placeholders, error messages
@@ -227,16 +230,42 @@ interface HistoryEntry {
| Setting | Type | Default | Description |
|---------|------|---------|-------------|
| Theme | dark / light | dark | App color theme |
| Default UI Language | SupportedLanguage | en | Language for app interface |
| Default Output Language | SupportedLanguage | en | Default language for generated output |
| Default Genre | Genre | action | Pre-selected genre on new session |
| Auto-save Draft | boolean | true | Auto-save form state to localStorage |
| Show Character Count | boolean | true | Display char counters on output |
| App Language | SupportedLanguage | browser-detected | Language of the interface |
| Default Output Language | SupportedLanguage | en | Pre-selected for new drafts |
| Show Character Count | boolean | true | Display char counters on output. **Does not** affect copy blocking |
| Compact Tag Display | boolean | false | Tags as comma list vs chip display |
| **Strict Mode** | boolean | **false** | v0.35.0. Blocks Generate / Copy / Export while any field has a hard error |
| History Limit | number | 100 | Max history entries to keep |
| Include Multilingual Tags | boolean | true | Add JA/VI tags to tag output |
| Log Retention | 1–90 days | 7 | Log files older than this are deleted at boot |
| Include Multilingual Tags | boolean | true | Add per-language tags to tag output |
| Include Trending Tags | boolean | true | Add year-based trending tags |
| Hashtag Count | 1-3 | 3 | Number of hashtags to generate |
| Genre Playlists | map | `{}` | One playlist URL per genre (42), collapsed by default |
`Default Genre` and `Auto-save Draft` were removed in v0.22.0 and v0.3
respectively — the draft autosaves unconditionally, so the toggle was dead.
### Description toggles
`showCopyright` · `showUsagePolicy` · `showSponsorCredit` · `showGameCopyright`
· `showThirdPartyAds` · `showTranslationQuality` · `splitContactEmail` ·
`showPinnedCommentTemplate` · `pinnedCommentIncludeAskNextGame` ·
`pinnedCommentIncludeGenrePlaylist`
## 🛡 Guardrails (v0.35.0)
Three independent mechanisms. The first two are always on.
| Mechanism | Scope |
|---|---|
| **Character limits** | Title 100 / description 5,000 / tags 500. If **any one** is over, **no** field can be copied — on Output and Batch. Batch scopes per part; Copy All Batch blocks if any part is over |
| **Field limits** | Hard `maxLength` per category: URL 200, email 320, short name 100, label 300, long text 2,000, timestamps 5,000, numeric 10. Imported values are clamped too |
| **Strict Mode** | Opt-in. Blocks Generate / Copy / Export on hard errors only; warnings (e.g. a working link on a non-standard prefix) never block. Log export is exempt |
Emails are capped at **three per field**, enforced on the increase so an
over-cap legacy value stays editable. Invalid input is never committed to the
store, so a malformed URL cannot reach the generated description whether Strict
Mode is on or off.
## 🖥 Desktop App Features (Tauri)
+32 -1
View File
@@ -45,8 +45,18 @@ npm run generate:locale -- --lang es
# This creates:
# src/i18n/locales/es/ui.json (all keys, empty values)
# src/i18n/locales/es/templates.json (all keys, empty values)
# Prefer editing in place over working from blanks? Pre-fill with English:
npm run generate:locale -- --lang es --copy-english
# Overwrite an existing locale directory:
npm run generate:locale -- --lang es --force
```
The output is key-for-key identical to English, so `npm run validate:locales`
passes the moment the files are written — it checks key parity, not whether the
values were actually translated.
Or copy from English and translate:
```bash
@@ -205,16 +215,37 @@ cp -r src/i18n/locales/en src/i18n/locales/es
### Step 4: Register the language
**Four edits, not one.** This section previously claimed `SUPPORTED_LANGUAGES`
was the only registration step; it isn't, and the missing edits fail in
different ways — one at compile time, one silently at runtime.
```typescript
// src/i18n/index.ts — add to SUPPORTED_LANGUAGES (the only registration step)
// 1. src/i18n/index.ts — the flag + native name shown in every language picker
export const SUPPORTED_LANGUAGES = [
{ id: "en", label: "English", flag: "🇬🇧", nativeName: "English" },
{ id: "vi", label: "Vietnamese", flag: "🇻🇳", nativeName: "Tiếng Việt" },
{ id: "ja", label: "Japanese", flag: "🇯🇵", nativeName: "日本語" },
{ id: "es", label: "Spanish", flag: "🇪🇸", nativeName: "Español" }, // ← Add here
] as const;
// 2. src/engine/types.ts — the union the whole engine is typed against
export type SupportedLanguage = "en" | "vi" | "ja" | "es" | "ko" | "zh";
// 3. src/store/settings-heal.ts — detectBrowserLanguage's own hardcoded copy.
// Miss this and the language works, but is never auto-selected for a
// first-time visitor whose browser is set to it.
const supported: SupportedLanguage[] = ["en", "vi", "ja", "es", "ko", "zh"];
// 4. src/engine/tag-generator.ts — MULTILINGUAL_TAGS (see Step 5).
// Typed `Record<SupportedLanguage, …>`, so TypeScript catches this one.
```
> `SUPPORTED_LANGUAGES` is **not** type-bound to `SupportedLanguage`, and every
> consumer casts (`lang.id as SupportedLanguage`). A mismatch between edits 1
> and 2 therefore compiles cleanly and fails at runtime. Do both.
`npm run generate:locale` prints this checklist on success.
No import or `resources` edits needed (v0.26+): locales are lazy-loaded
through a dynamic `import("./locales/<code>/<ns>.json")`, so Vite picks the
new files up automatically as async chunks — **the file names must stay
+67 -1
View File
@@ -323,13 +323,40 @@ jobs:
node-version: 22
cache: npm
- run: npm ci
- run: npm run typecheck
# correctness
- run: npm run typecheck # src/
- run: npm run typecheck:all # + tests/ and scripts/
- run: npm run lint
- run: npm run validate:locales
- run: npm run test:run
# consistency
- run: npm run format:check
- run: npm run knip
- run: npm run check:version
# security (advisory — a fresh transitive advisory must not redden
# every unrelated PR before Dependabot opens its fix)
- run: npm audit --audit-level=high
continue-on-error: true
- run: npm run build
```
The workflow also declares `permissions: contents: read` (least privilege, and
it clears CodeQL's `actions/missing-workflow-permissions` alert) and a
`concurrency` group that cancels superseded runs everywhere except `main`, where
each commit's result is a historical record the release process reads back.
**Why these gates exist.** Every one of them was already installed and
configured before v0.35.0, and none of them ran. `knip` was in `package.json`
with a `knip.json` beside it. Prettier had a config and a `format` script.
Turning them on found real problems immediately — most notably that
`tsconfig.json` covers only `src/`, so `tests/` and `scripts/` had **never** been
type-checked, which was hiding three fields silently missing from the
editor→engine parity fixture whose entire job is catching that class of drift.
```yaml
# .github/workflows/deploy-web.yml
name: Deploy to GitHub Pages
@@ -418,3 +445,42 @@ describe("buildTitle", () => {
| Single Tag | 30 chars | YouTube rejects that tag |
| Hashtags in description | 60 max, 3 shown | First 3 shown above title |
| Playlist title | 150 chars | Truncated |
### Enforcement (v0.35.0)
`renderAll` has always returned `warnings: CharLimitWarning[]`; until v0.35.0
nothing in the UI read it. `src/engine/limits.ts` is now the single derivation,
consumed by `useOutputLimits` on Output and precomputed per row in Batch.
The rule is **all-or-nothing per output**: one over-limit field disables every
copy button for that output. `checkTitleWarning` / `checkDescriptionWarning`
only fire when a field is *strictly over*, never at the 80 % counter threshold,
so a non-empty `warnings` array is an exact "YouTube will reject this" signal.
Deliberately not gated by `YT_LIMITS`: thumbnail text and the pinned comment
(different surfaces), the Playlist tab (150-char title, not 100), and social
captions (per-platform caps in `SOCIAL_PLATFORMS`).
## 7. Field Limits (v0.35.0)
`src/config/field-limits.ts` — caps on what can be *typed*, distinct from
YouTube's caps on what is *generated*.
```typescript
export const FIELD_LIMITS = {
URL: 200,
EMAIL_FIELD: 320, // 3 addresses; RFC 5321 caps a single one at 254
SHORT_NAME: 100,
LABEL: 300,
LONG_TEXT: 2000,
TIMESTAMPS: YT_LIMITS.DESCRIPTION_MAX,
NUMERIC: 10,
} as const;
```
Values are UTF-16 code units, matching the DOM `maxLength` attribute — an emoji
costs 2. Grapheme counting would be more correct but cannot be enforced by the
browser, and these are ceilings against absurd input, not a character budget.
`maxLength` only constrains typing and pasting, so `clampField` is applied in
`normalizeEditorPatch` to cover profile / preset / template imports.
+29
View File
@@ -13,6 +13,35 @@ export default tseslint.config(
...reactHooks.configs.recommended.rules,
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
// eslint-plugin-react-hooks 7 turned on the React Compiler diagnostics.
// They are worth having — four of the seven they flagged on arrival were
// real extra render passes and were fixed (use-online-status moved to
// `useSyncExternalStore`, ShortcutHelpModal now derives instead of
// resetting in an effect, DraftIndicator and use-languages-ready were
// guarded).
//
// Three remain, all genuinely syncing state FROM an external source:
// src/hooks/use-languages-ready.ts — i18next bundle readiness
// src/components/editor/PlaytestEditor.tsx — text mirror of a store number
// src/components/editor/StoreLinkEditor.tsx — compiler can't preserve a useMemo
//
// Each needs a real restructure, not a guard, so they are warnings rather
// than a reason to hold back the ESLint 10 upgrade or to delete the rule.
// Downgrade — do not remove: the signal is the point.
"react-hooks/set-state-in-effect": "warn",
"react-hooks/preserve-manual-memoization": "warn",
},
},
{
// Tests index into fixture arrays constantly, and `noUncheckedIndexedAccess`
// makes every one of those reads `T | undefined`. A `!` there asserts the
// fixture the test itself just built — the alternative is a guard clause per
// lookup that can only ever fail if the test is already broken. Production
// code keeps the rule.
files: ["tests/**/*.ts", "tests/**/*.tsx"],
rules: {
"@typescript-eslint/no-non-null-assertion": "off",
},
},
{
+1 -1
View File
@@ -5,8 +5,8 @@
"ignoreExportsUsedInFile": true,
"ignoreDependencies": [
"@tauri-apps/plugin-fs",
"@tauri-apps/plugin-opener",
"@tauri-apps/plugin-shell",
"tailwindcss",
"@testing-library/jest-dom",
"@testing-library/react"
],
+1425 -1966
View File
File diff suppressed because it is too large. Load diff
+42 -37
View File
@@ -1,6 +1,6 @@
{
"name": "yt-desc-gen",
"version": "0.34.0",
"version": "0.38.0",
"private": true,
"license": "Apache-2.0",
"type": "module",
@@ -11,11 +11,14 @@
"test": "vitest",
"test:run": "vitest run",
"test:coverage": "vitest run --coverage",
"lint": "eslint src/",
"lint:fix": "eslint src/ --fix",
"lint": "eslint src/ tests/ scripts/",
"lint:fix": "eslint src/ tests/ scripts/ --fix",
"knip": "knip",
"typecheck": "tsc --noEmit",
"format": "prettier --write \"src/**/*.{ts,tsx,json,css}\"",
"typecheck:all": "tsc --noEmit -p tsconfig.check.json",
"format": "prettier --write \"{src,tests,scripts}/**/*.{ts,tsx,css}\"",
"format:check": "prettier --check \"{src,tests,scripts}/**/*.{ts,tsx,css}\"",
"check:version": "tsx scripts/check-version-sync.ts",
"validate:locales": "tsx scripts/validate-locales.ts",
"generate:locale": "tsx scripts/generate-locale-template.ts",
"tauri": "tauri",
@@ -23,41 +26,43 @@
"tauri:build": "tauri build"
},
"dependencies": {
"@tauri-apps/api": "^2.11.0",
"@tauri-apps/plugin-dialog": "^2.0.0",
"@tauri-apps/plugin-fs": "^2.0.0",
"@tauri-apps/plugin-opener": "^2.0.0",
"@tauri-apps/plugin-shell": "^2.0.0",
"clsx": "^2.1.0",
"i18next": "^23.15.0",
"i18next-resources-to-backend": "^1.2.1",
"lucide-react": "^0.400.0",
"react": "^18.3.0",
"react-dom": "^18.3.0",
"react-hot-toast": "^2.4.0",
"react-i18next": "^15.0.0",
"react-router-dom": "^6.26.0",
"zustand": "^4.5.0"
"@tauri-apps/api": "^2.11.1",
"@tauri-apps/plugin-dialog": "^2.7.2",
"@tauri-apps/plugin-fs": "^2.5.1",
"@tauri-apps/plugin-opener": "^2.5.4",
"@tauri-apps/plugin-shell": "^2.3.5",
"clsx": "^2.1.1",
"i18next": "^26.3.6",
"i18next-resources-to-backend": "^1.2.3",
"lucide-react": "^0.577.0",
"react": "^19.2.8",
"react-dom": "^19.2.8",
"react-hot-toast": "^2.6.0",
"react-i18next": "^17.0.11",
"react-router-dom": "^7.18.2",
"zustand": "^5.0.15"
},
"devDependencies": {
"@eslint/js": "^9.0.0",
"@testing-library/jest-dom": "^6.4.0",
"@testing-library/react": "^16.0.0",
"@types/react": "^18.3.0",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^5.2.0",
"autoprefixer": "^10.4.0",
"eslint": "^9.0.0",
"eslint-plugin-react-hooks": "^5.0.0",
"knip": "^6.14.1",
"postcss": "^8.5.14",
"prettier": "^3.3.0",
"prettier-plugin-tailwindcss": "^0.6.0",
"tailwindcss": "^3.4.0",
"tsx": "^4.22.4",
"@eslint/js": "^10.0.1",
"@tailwindcss/postcss": "^4.3.3",
"@testing-library/jest-dom": "^7.0.1",
"@testing-library/react": "^16.3.2",
"@types/node": "^26.2.0",
"@types/react": "^19.2.18",
"@types/react-dom": "^19.2.4",
"@vitejs/plugin-react": "^6.0.5",
"autoprefixer": "^10.5.4",
"eslint": "^10.8.1",
"eslint-plugin-react-hooks": "^7.1.1",
"knip": "^6.32.2",
"postcss": "^8.5.26",
"prettier": "^3.9.6",
"prettier-plugin-tailwindcss": "^0.8.1",
"tailwindcss": "^4.3.3",
"tsx": "^4.23.12",
"typescript": "^5.5.0",
"typescript-eslint": "^8.0.0",
"vite": "^8.0.16",
"vitest": "^4.1.8"
"typescript-eslint": "^8.67.0",
"vite": "^8.2.1",
"vitest": "^4.1.10"
}
}
+2 -1
View File
@@ -1,6 +1,7 @@
export default {
plugins: {
tailwindcss: {},
// Tailwind 4 ships its PostCSS plugin as a separate package.
"@tailwindcss/postcss": {},
autoprefixer: {},
},
};
+111
View File
@@ -0,0 +1,111 @@
/**
* Verify that every manifest carrying the app version agrees.
*
* A release bumps SIX places, and nothing but this script notices when one is
* missed. A stale `tauri.conf.json` ships an installer whose About screen and
* updater metadata disagree with the tag; a stale `Cargo.lock` self-entry makes
* the next `cargo build` rewrite the lockfile mid-release.
*
* Run via `npm run check:version`. Exits non-zero (and prints every mismatch,
* not just the first) so CI fails the PR rather than the release.
*/
import { readFileSync } from "fs";
import { resolve } from "path";
interface VersionSource {
/** Human-readable location, printed on mismatch. */
label: string;
/** Repo-relative path. */
file: string;
/** Pull the version out of the file's raw text. */
extract: (raw: string) => string | null;
}
/** Read `version` from a top-level JSON object. */
function jsonVersion(raw: string): string | null {
const parsed: unknown = JSON.parse(raw);
if (typeof parsed !== "object" || parsed === null) return null;
const version = (parsed as Record<string, unknown>).version;
return typeof version === "string" ? version : null;
}
const SOURCES: VersionSource[] = [
{
label: "package.json → version",
file: "package.json",
extract: jsonVersion,
},
{
label: "package-lock.json → version",
file: "package-lock.json",
extract: jsonVersion,
},
{
label: 'package-lock.json → packages[""].version',
file: "package-lock.json",
extract: (raw) => {
const parsed: unknown = JSON.parse(raw);
if (typeof parsed !== "object" || parsed === null) return null;
const packages = (parsed as Record<string, unknown>).packages;
if (typeof packages !== "object" || packages === null) return null;
const root = (packages as Record<string, unknown>)[""];
if (typeof root !== "object" || root === null) return null;
const version = (root as Record<string, unknown>).version;
return typeof version === "string" ? version : null;
},
},
{
label: "src-tauri/tauri.conf.json → version",
file: "src-tauri/tauri.conf.json",
extract: jsonVersion,
},
{
label: "src-tauri/Cargo.toml → [package] version",
file: "src-tauri/Cargo.toml",
// Anchor on the [package] table so a dependency's `version = "…"` in the
// same file can never be picked up instead.
extract: (raw) => /^\[package\][\s\S]*?^version\s*=\s*"([^"]+)"/m.exec(raw)?.[1] ?? null,
},
{
label: "src-tauri/Cargo.lock → yt-desc-gen entry",
file: "src-tauri/Cargo.lock",
extract: (raw) => /^name = "yt-desc-gen"\r?\nversion = "([^"]+)"/m.exec(raw)?.[1] ?? null,
},
];
function main(): void {
const found: { label: string; version: string | null }[] = SOURCES.map((source) => {
let raw: string;
try {
raw = readFileSync(resolve(source.file), "utf8");
} catch {
return { label: source.label, version: null };
}
try {
return { label: source.label, version: source.extract(raw) };
} catch {
return { label: source.label, version: null };
}
});
const missing = found.filter((entry) => entry.version === null);
const versions = [...new Set(found.map((entry) => entry.version).filter(Boolean))];
if (missing.length === 0 && versions.length === 1) {
console.log(`✓ All ${found.length} manifests agree on version ${versions[0]}`);
return;
}
console.error("✗ Version manifests are out of sync.\n");
for (const entry of found) {
const mark = entry.version === null ? "?" : entry.version === versions[0] ? " " : "!";
console.error(` ${mark} ${entry.version ?? "<not found>"} ${entry.label}`);
}
console.error(
"\nBump every manifest to the same version before tagging. `npm version --no-git-tag-version <v>`",
);
console.error("covers package.json + package-lock.json; the three Rust/Tauri files are manual.");
process.exit(1);
}
main();
+133
View File
@@ -0,0 +1,133 @@
/**
* Scaffold a new locale directory from the English source.
*
* `package.json` has advertised `npm run generate:locale` since v0.1, and
* `docs/I18N.md` step 1 tells contributors to run it — but the script was never
* committed, so the documented first step of adding a language failed outright.
* This is that script.
*
* Usage:
* npm run generate:locale -- --lang pt-BR # empty values to translate
* npm run generate:locale -- --lang id --copy-english # pre-fill with EN text
* npm run generate:locale -- --lang id --force # overwrite an existing dir
*
* Output mirrors `src/i18n/locales/en/{ui,templates}.json` key-for-key, so
* `npm run validate:locales` passes the moment the files are written (it checks
* key parity, not whether the values were actually translated).
*
* Registering the locale in code is NOT done here — see the checklist printed
* on success, and docs/I18N.md.
*/
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
import { join, resolve } from "path";
const LOCALES_DIR = resolve("src/i18n/locales");
const SOURCE_LOCALE = "en";
const NAMESPACES = ["ui", "templates"] as const;
/** BCP-47-ish: `pt`, `pt-BR`, `zh-Hant`. Keeps a typo from creating a junk dir. */
const LANG_PATTERN = /^[a-z]{2,3}(-[A-Za-z]{2,8})*$/;
interface Options {
lang: string;
copyEnglish: boolean;
force: boolean;
}
function parseArgs(argv: string[]): Options {
let lang = "";
let copyEnglish = false;
let force = false;
for (let i = 0; i < argv.length; i++) {
const arg = argv[i];
if (arg === "--lang" || arg === "-l") {
lang = argv[++i] ?? "";
} else if (arg?.startsWith("--lang=")) {
lang = arg.slice("--lang=".length);
} else if (arg === "--copy-english") {
copyEnglish = true;
} else if (arg === "--force") {
force = true;
}
}
if (!lang) {
console.error("Missing --lang.\n\n npm run generate:locale -- --lang pt-BR\n");
process.exit(1);
}
if (!LANG_PATTERN.test(lang)) {
console.error(`Invalid language code "${lang}". Expected e.g. "id", "pt-BR", "zh-Hant".\n`);
process.exit(1);
}
return { lang, copyEnglish, force };
}
/**
* Rebuild the tree with every leaf replaced by `""`, preserving key order so
* the generated file diffs cleanly against the English source.
*/
function blankLeaves(value: unknown): unknown {
if (Array.isArray(value)) return value.map(blankLeaves);
if (typeof value === "object" && value !== null) {
const out: Record<string, unknown> = {};
for (const [key, child] of Object.entries(value as Record<string, unknown>)) {
out[key] = blankLeaves(child);
}
return out;
}
return "";
}
function countLeaves(value: unknown): number {
if (Array.isArray(value)) return value.reduce<number>((n, v) => n + countLeaves(v), 0);
if (typeof value === "object" && value !== null) {
return Object.values(value as Record<string, unknown>).reduce<number>(
(n, v) => n + countLeaves(v),
0,
);
}
return 1;
}
function main(): void {
const { lang, copyEnglish, force } = parseArgs(process.argv.slice(2));
const targetDir = join(LOCALES_DIR, lang);
if (existsSync(targetDir) && !force) {
console.error(`✗ ${targetDir} already exists. Pass --force to overwrite.\n`);
process.exit(1);
}
mkdirSync(targetDir, { recursive: true });
let total = 0;
for (const ns of NAMESPACES) {
const sourcePath = join(LOCALES_DIR, SOURCE_LOCALE, `${ns}.json`);
if (!existsSync(sourcePath)) {
console.error(`✗ Source locale missing: ${sourcePath}`);
process.exit(1);
}
const source: unknown = JSON.parse(readFileSync(sourcePath, "utf-8"));
const output = copyEnglish ? source : blankLeaves(source);
const outPath = join(targetDir, `${ns}.json`);
// Two-space indent + trailing newline matches the existing locale files.
writeFileSync(outPath, `${JSON.stringify(output, null, 2)}\n`, "utf-8");
const leaves = countLeaves(source);
total += leaves;
console.log(
`✓ ${lang}/${ns}.json — ${leaves} keys${copyEnglish ? " (English text)" : " (empty)"}`,
);
}
console.log(`\n${total} strings to translate. Remaining steps to register "${lang}":
1. src/i18n/index.ts — add to SUPPORTED_LANGUAGES (flag + nativeName)
2. src/engine/types.ts — add to the SupportedLanguage union
3. src/store/settings-heal.ts — add to detectBrowserLanguage's supported list
4. src/engine/tag-generator.ts— add a MULTILINGUAL_TAGS entry (TS enforces this)
5. npm run validate:locales — must pass before committing
See docs/I18N.md for the full checklist.`);
}
main();
+1 -3
View File
@@ -74,9 +74,7 @@ function validate(): void {
console.log(`✓ ${locale}/${filename} — ${actualKeys.length}/${expectedKeys.length} keys`);
} else {
hasErrors = true;
console.error(
`✗ ${locale}/${filename} — ${actualKeys.length}/${expectedKeys.length} keys`,
);
console.error(`✗ ${locale}/${filename} — ${actualKeys.length}/${expectedKeys.length} keys`);
if (missing.length > 0) {
console.error(` Missing: ${missing.join(", ")}`);
}
+41 -47
View File
@@ -307,6 +307,15 @@ dependencies = [
"alloc-stdlib",
]
[[package]]
name = "bs58"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4"
dependencies = [
"tinyvec",
]
[[package]]
name = "bumpalo"
version = "3.20.2"
@@ -1629,7 +1638,7 @@ dependencies = [
"js-sys",
"log",
"wasm-bindgen",
"windows-core 0.62.2",
"windows-core",
]
[[package]]
@@ -3389,11 +3398,12 @@ dependencies = [
[[package]]
name = "serde_with"
version = "3.18.0"
version = "3.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd5414fad8e6907dbdd5bc441a50ae8d6e26151a03b1de04d89a5576de61d01f"
checksum = "76a5c54c7310e7b8b9577c286d7e399ddd876c3e12b3ed917a8aabc4b96e9e8c"
dependencies = [
"base64 0.22.1",
"bs58",
"chrono",
"hex",
"indexmap 1.9.3",
@@ -3408,9 +3418,9 @@ dependencies = [
[[package]]
name = "serde_with_macros"
version = "3.18.0"
version = "3.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3db8978e608f1fe7357e211969fd9abdcae80bac1ba7a3369bb7eb6b404eb65"
checksum = "84d57bc0c8b9a17920c178daa6bb924850d54a9c97ab45194bb8c17ad66bb660"
dependencies = [
"darling",
"proc-macro2",
@@ -3768,7 +3778,7 @@ dependencies = [
"unicode-segmentation",
"url",
"windows",
"windows-core 0.61.2",
"windows-core",
"windows-version",
"x11-dl",
]
@@ -4237,6 +4247,21 @@ dependencies = [
"zerovec",
]
[[package]]
name = "tinyvec"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb4ebadaa0af04fab11ae01eb5f9fdb5f9c5b875506e210e71c07873528baa7f"
dependencies = [
"tinyvec_macros",
]
[[package]]
name = "tinyvec_macros"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
version = "1.51.0"
@@ -4862,7 +4887,7 @@ dependencies = [
"webview2-com-macros",
"webview2-com-sys",
"windows",
"windows-core 0.61.2",
"windows-core",
"windows-implement",
"windows-interface",
]
@@ -4886,7 +4911,7 @@ checksum = "381336cfffd772377d291702245447a5251a2ffa5bad679c99e61bc48bacbf9c"
dependencies = [
"thiserror 2.0.18",
"windows",
"windows-core 0.61.2",
"windows-core",
]
[[package]]
@@ -4942,7 +4967,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893"
dependencies = [
"windows-collections",
"windows-core 0.61.2",
"windows-core",
"windows-future",
"windows-link 0.1.3",
"windows-numerics",
@@ -4954,7 +4979,7 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8"
dependencies = [
"windows-core 0.61.2",
"windows-core",
]
[[package]]
@@ -4966,21 +4991,8 @@ dependencies = [
"windows-implement",
"windows-interface",
"windows-link 0.1.3",
"windows-result 0.3.4",
"windows-strings 0.4.2",
]
[[package]]
name = "windows-core"
version = "0.62.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
dependencies = [
"windows-implement",
"windows-interface",
"windows-link 0.2.1",
"windows-result 0.4.1",
"windows-strings 0.5.1",
"windows-result",
"windows-strings",
]
[[package]]
@@ -4989,7 +5001,7 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e"
dependencies = [
"windows-core 0.61.2",
"windows-core",
"windows-link 0.1.3",
"windows-threading",
]
@@ -5034,7 +5046,7 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1"
dependencies = [
"windows-core 0.61.2",
"windows-core",
"windows-link 0.1.3",
]
@@ -5047,15 +5059,6 @@ dependencies = [
"windows-link 0.1.3",
]
[[package]]
name = "windows-result"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
dependencies = [
"windows-link 0.2.1",
]
[[package]]
name = "windows-strings"
version = "0.4.2"
@@ -5065,15 +5068,6 @@ dependencies = [
"windows-link 0.1.3",
]
[[package]]
name = "windows-strings"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
dependencies = [
"windows-link 0.2.1",
]
[[package]]
name = "windows-sys"
version = "0.45.0"
@@ -5484,7 +5478,7 @@ dependencies = [
"webkit2gtk-sys",
"webview2-com",
"windows",
"windows-core 0.61.2",
"windows-core",
"windows-version",
"x11-dl",
]
@@ -5535,7 +5529,7 @@ dependencies = [
[[package]]
name = "yt-desc-gen"
version = "0.34.0"
version = "0.38.0"
dependencies = [
"tauri",
"tauri-build",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "yt-desc-gen"
version = "0.34.0"
version = "0.38.0"
description = "YouTube Gameplay Description Generator"
authors = ["poli0981"]
edition = "2021"
+1 -9
View File
@@ -11,14 +11,6 @@
"fs:allow-read-text-file",
"fs:allow-write-text-file",
"shell:default",
"opener:default",
{
"identifier": "opener:allow-open-path",
"allow": [{ "path": "$APPDATA" }, { "path": "$APPDATA/**" }]
},
{
"identifier": "opener:allow-reveal-item-in-dir",
"allow": [{ "path": "$APPDATA" }, { "path": "$APPDATA/**" }]
}
"opener:default"
]
}
+1 -1
View File
@@ -1 +1 @@
{"default":{"identifier":"default","description":"Default capabilities for YTDescGen","local":true,"windows":["main"],"permissions":["core:default","dialog:default","dialog:allow-save","dialog:allow-open","fs:default","fs:allow-read-text-file","fs:allow-write-text-file","shell:default","opener:default",{"identifier":"opener:allow-open-path","allow":[{"path":"$APPDATA"},{"path":"$APPDATA/**"}]},{"identifier":"opener:allow-reveal-item-in-dir","allow":[{"path":"$APPDATA"},{"path":"$APPDATA/**"}]}]}}
{"default":{"identifier":"default","description":"Default capabilities for YTDescGen","local":true,"windows":["main"],"permissions":["core:default","dialog:default","dialog:allow-save","dialog:allow-open","fs:default","fs:allow-read-text-file","fs:allow-write-text-file","shell:default","opener:default"]}}
-14
View File
@@ -27,19 +27,6 @@ fn read_from_file(path: String) -> Result<String, String> {
std::fs::read_to_string(&path).map_err(|e| e.to_string())
}
/// Ensure a directory exists on disk, creating it (and any missing
/// parents) if necessary. No-op when the path already exists as a
/// directory. Fixes the "Windows cannot find ... AppData\Roaming\
/// com.skullmute.ytdescgen" Explorer error on first launch — see
/// `openSettingsFolder()` in `SettingsPage.tsx`, where this is called
/// before `openPath(dir)` so the OS shell never sees a non-existent
/// path. Returns the OS error string on failure (e.g. permission
/// denied) so the caller can surface it via the in-app log.
#[tauri::command]
fn ensure_dir(path: String) -> Result<(), String> {
std::fs::create_dir_all(&path).map_err(|e| e.to_string())
}
/// Append `content` to the file at `path`, creating the file (and any
/// missing parent directories) if necessary. Used by the v0.17.0 log
/// persistence pipeline to write JSONL entries one line at a time,
@@ -111,7 +98,6 @@ pub fn run() {
.invoke_handler(tauri::generate_handler![
save_to_file,
read_from_file,
ensure_dir,
append_to_file,
list_dir,
delete_file
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/crates/tauri-cli/schema.json",
"productName": "YTDescGen",
"version": "0.34.0",
"version": "0.38.0",
"identifier": "com.skullmute.ytdescgen",
"build": {
"beforeBuildCommand": "npm run build",
+45 -21
View File
@@ -24,24 +24,16 @@ const HistoryPage = lazy(() =>
const SettingsPage = lazy(() =>
import("@pages/SettingsPage").then((m) => ({ default: m.SettingsPage })),
);
const BatchPage = lazy(() =>
import("@pages/BatchPage").then((m) => ({ default: m.BatchPage })),
);
const SocialPage = lazy(() =>
import("@pages/SocialPage").then((m) => ({ default: m.SocialPage })),
);
const BatchPage = lazy(() => import("@pages/BatchPage").then((m) => ({ default: m.BatchPage })));
const SocialPage = lazy(() => import("@pages/SocialPage").then((m) => ({ default: m.SocialPage })));
const PlaylistPage = lazy(() =>
import("@pages/PlaylistPage").then((m) => ({ default: m.PlaylistPage })),
);
const LogPage = lazy(() =>
import("@pages/LogPage").then((m) => ({ default: m.LogPage })),
);
const AboutPage = lazy(() =>
import("@pages/AboutPage").then((m) => ({ default: m.AboutPage })),
);
const LogPage = lazy(() => import("@pages/LogPage").then((m) => ({ default: m.LogPage })));
const AboutPage = lazy(() => import("@pages/AboutPage").then((m) => ({ default: m.AboutPage })));
function PageLoader() {
return <div className="flex items-center justify-center p-12 text-text-muted">Loading...</div>;
return <div className="text-text-muted flex items-center justify-center p-12">Loading...</div>;
}
/**
@@ -152,35 +144,67 @@ export default function App() {
/>
<Route
path="profiles"
element={<PageBoundary label="Profiles"><ProfilesPage /></PageBoundary>}
element={
<PageBoundary label="Profiles">
<ProfilesPage />
</PageBoundary>
}
/>
<Route
path="history"
element={<PageBoundary label="History"><HistoryPage /></PageBoundary>}
element={
<PageBoundary label="History">
<HistoryPage />
</PageBoundary>
}
/>
<Route
path="settings"
element={<PageBoundary label="Settings"><SettingsPage /></PageBoundary>}
element={
<PageBoundary label="Settings">
<SettingsPage />
</PageBoundary>
}
/>
<Route
path="batch"
element={<PageBoundary label="Batch"><BatchPage /></PageBoundary>}
element={
<PageBoundary label="Batch">
<BatchPage />
</PageBoundary>
}
/>
<Route
path="social"
element={<PageBoundary label="Social"><SocialPage /></PageBoundary>}
element={
<PageBoundary label="Social">
<SocialPage />
</PageBoundary>
}
/>
<Route
path="playlist"
element={<PageBoundary label="Playlist"><PlaylistPage /></PageBoundary>}
element={
<PageBoundary label="Playlist">
<PlaylistPage />
</PageBoundary>
}
/>
<Route
path="logs"
element={<PageBoundary label="Logs"><LogPage /></PageBoundary>}
element={
<PageBoundary label="Logs">
<LogPage />
</PageBoundary>
}
/>
<Route
path="about"
element={<PageBoundary label="About"><AboutPage /></PageBoundary>}
element={
<PageBoundary label="About">
<AboutPage />
</PageBoundary>
}
/>
</Route>
{/* Designed error pages — siblings of the AppShell group so they
+8 -8
View File
@@ -33,15 +33,15 @@ export function ConsentGate() {
role="dialog"
aria-modal="true"
aria-labelledby="consent-title"
className="flex min-h-screen flex-col items-center justify-center gap-6 bg-surface-0 px-6 py-12 text-center"
className="bg-surface-0 flex min-h-screen flex-col items-center justify-center gap-6 px-6 py-12 text-center"
>
<ShieldCheck className="h-14 w-14 text-accent" aria-hidden />
<ShieldCheck className="text-accent h-14 w-14" aria-hidden />
<div className="max-w-md space-y-2">
<h1 id="consent-title" className="text-2xl font-semibold text-text-primary">
<h1 id="consent-title" className="text-text-primary text-2xl font-semibold">
{t("consentGate.title")}
</h1>
<p className="text-sm text-text-secondary">{t("consentGate.intro")}</p>
<p className="text-text-secondary text-sm">{t("consentGate.intro")}</p>
</div>
<div className="grid w-full max-w-md gap-2 sm:grid-cols-2">
@@ -51,15 +51,15 @@ export function ConsentGate() {
href={doc.url}
target="_blank"
rel="noopener noreferrer"
className="flex items-center gap-3 rounded-lg border border-border bg-surface-1 px-3 py-2.5 text-sm text-text-primary transition-colors hover:border-accent hover:bg-surface-2"
className="border-border bg-surface-1 text-text-primary hover:border-accent hover:bg-surface-2 flex items-center gap-3 rounded-lg border px-3 py-2.5 text-sm transition-colors"
>
<span className="flex-1 truncate text-left">{t(doc.labelKey)}</span>
<ExternalLink className="h-3.5 w-3.5 shrink-0 text-text-muted" />
<ExternalLink className="text-text-muted h-3.5 w-3.5 shrink-0" />
</a>
))}
</div>
<div className="w-full max-w-md rounded-lg border border-border bg-surface-1 p-4">
<div className="border-border bg-surface-1 w-full max-w-md rounded-lg border p-4">
<Checkbox checked={agreed} onChange={setAgreed} label={t("consentGate.agreeLabel")} />
</div>
@@ -67,7 +67,7 @@ export function ConsentGate() {
<Button variant="primary" onClick={onContinue} disabled={!agreed}>
{t("consentGate.continue")}
</Button>
{!agreed && <p className="text-xs text-text-muted">{t("consentGate.mustAgree")}</p>}
{!agreed && <p className="text-text-muted text-xs">{t("consentGate.mustAgree")}</p>}
</div>
</div>
);
+18 -4
View File
@@ -8,6 +8,7 @@ import {
validateInstagramInviteUrl,
validateFacebookGroupUrl,
} from "@utils/validation";
import { FIELD_LIMITS } from "@config/field-limits";
/**
* Community invite links. A single section for "join the chat" links that
@@ -42,14 +43,15 @@ export function CommunityEditor() {
return (
<div className="flex flex-col gap-3">
<div className="flex flex-col gap-1">
<span className="text-sm font-medium text-text-secondary">
{t("editor.community")}
</span>
<p className="text-xs text-text-muted">{t("editor.communityHelp")}</p>
<span className="text-text-secondary text-sm font-medium">{t("editor.community")}</span>
<p className="text-text-muted text-xs">{t("editor.communityHelp")}</p>
</div>
<ValidatedInput
fieldId="messengerCommunityLink"
labelKey="editor.messengerCommunityLink"
label={t("editor.messengerCommunityLink")}
maxLength={FIELD_LIMITS.URL}
placeholder={t("editor.messengerCommunityLinkPlaceholder")}
value={messengerCommunityLink}
onChange={(v) => setField("messengerCommunityLink", v)}
@@ -59,7 +61,10 @@ export function CommunityEditor() {
/>
<ValidatedInput
fieldId="signalGroupLink"
labelKey="editor.signalGroupLink"
label={t("editor.signalGroupLink")}
maxLength={FIELD_LIMITS.URL}
placeholder={t("editor.signalGroupLinkPlaceholder")}
value={signalGroupLink}
onChange={(v) => setField("signalGroupLink", v)}
@@ -69,7 +74,10 @@ export function CommunityEditor() {
/>
<ValidatedInput
fieldId="instagramGroupLink"
labelKey="editor.instagramGroupLink"
label={t("editor.instagramGroupLink")}
maxLength={FIELD_LIMITS.URL}
placeholder={t("editor.instagramGroupLinkPlaceholder")}
value={instagramGroupLink}
onChange={(v) => setField("instagramGroupLink", v)}
@@ -79,7 +87,10 @@ export function CommunityEditor() {
/>
<ValidatedInput
fieldId="facebookGroupLink"
labelKey="editor.facebookGroupLink"
label={t("editor.facebookGroupLink")}
maxLength={FIELD_LIMITS.URL}
placeholder={t("editor.facebookGroupLinkPlaceholder")}
value={facebookGroupLink}
onChange={(v) => setField("facebookGroupLink", v)}
@@ -90,7 +101,10 @@ export function CommunityEditor() {
{isVi && (
<ValidatedInput
fieldId="zaloGroupLink"
labelKey="editor.zaloGroupLink"
label={t("editor.zaloGroupLink")}
maxLength={FIELD_LIMITS.URL}
placeholder={t("editor.zaloGroupLinkPlaceholder")}
value={zaloGroupLink}
onChange={(v) => setField("zaloGroupLink", v)}
+29 -13
View File
@@ -2,7 +2,8 @@ import { useTranslation } from "react-i18next";
import { ValidatedInput } from "@components/ui/ValidatedInput";
import { useEditorStore } from "@store/editor-store";
import { useSettingsStore } from "@store/settings-store";
import { validateEmails } from "@utils/validation";
import { validateEmails, canAcceptEmailInput, MAX_EMAILS } from "@utils/validation";
import { FIELD_LIMITS } from "@config/field-limits";
/**
* Contact email input(s). Two modes, driven by the `splitContactEmail`
@@ -27,17 +28,32 @@ export function ContactEmailEditor() {
const setField = useEditorStore((s) => s.set);
const splitContactEmail = useSettingsStore((s) => s.splitContactEmail);
// Shared by all three fields. The cap is per field, not across the split:
// each one renders its own labelled description line, so filling the
// advertising address must not retroactively invalidate the contact one.
const emailGuard = {
validate: validateEmails,
// Accept the change verbatim, or reject the keystroke with `null` so the
// three addresses already typed survive untouched.
beforeChange: (next: string, prev: string): string | null =>
canAcceptEmailInput(next, prev) ? next : null,
blockedMessage: t("validation.emailMaxReached", { max: MAX_EMAILS }),
maxLength: FIELD_LIMITS.EMAIL_FIELD,
inputMode: "email" as const,
autoComplete: "email",
};
if (!splitContactEmail) {
return (
<ValidatedInput
fieldId="contactEmail"
labelKey="editor.contactEmail"
label={t("editor.contactEmail")}
placeholder={t("editor.contactEmailPlaceholder")}
value={contactEmail ?? ""}
onChange={(v) => setField("contactEmail", v)}
validate={validateEmails}
helpText={t("editor.contactEmailHelp")}
inputMode="email"
autoComplete="email"
{...emailGuard}
/>
);
}
@@ -45,34 +61,34 @@ export function ContactEmailEditor() {
return (
<div className="flex flex-col gap-3">
<ValidatedInput
fieldId="contactEmail"
labelKey="editor.contactEmail"
label={t("editor.contactEmail")}
placeholder={t("editor.contactEmailPlaceholder")}
value={contactEmail ?? ""}
onChange={(v) => setField("contactEmail", v)}
validate={validateEmails}
helpText={t("editor.contactEmailHelp")}
inputMode="email"
autoComplete="email"
{...emailGuard}
/>
<ValidatedInput
fieldId="adEmail"
labelKey="editor.adEmail"
label={t("editor.adEmail")}
placeholder={t("editor.adEmailPlaceholder")}
value={adEmail ?? ""}
onChange={(v) => setField("adEmail", v)}
validate={validateEmails}
helpText={t("editor.adEmailHelp")}
inputMode="email"
autoComplete="email"
{...emailGuard}
/>
<ValidatedInput
fieldId="gameKeyEmail"
labelKey="editor.gameKeyEmail"
label={t("editor.gameKeyEmail")}
placeholder={t("editor.gameKeyEmailPlaceholder")}
value={gameKeyEmail ?? ""}
onChange={(v) => setField("gameKeyEmail", v)}
validate={validateEmails}
helpText={t("editor.gameKeyEmailHelp")}
inputMode="email"
autoComplete="email"
{...emailGuard}
/>
</div>
);
@@ -3,10 +3,7 @@ import { useTranslation } from "react-i18next";
import { ChevronDown, ChevronRight, Search, X } from "lucide-react";
import clsx from "clsx";
import { useEditorStore } from "@store/editor-store";
import {
CONTENT_WARNING_GROUPS,
type ContentWarningGroup,
} from "@config/content-warning-groups";
import { CONTENT_WARNING_GROUPS, type ContentWarningGroup } from "@config/content-warning-groups";
import type { ContentWarning } from "@engine/types";
/**
@@ -69,30 +66,26 @@ export function ContentWarningChecklist() {
return (
<div className="flex flex-col gap-2">
<div className="flex items-baseline justify-between">
<span className="text-sm font-medium text-text-secondary">
{t("editor.warnings")}
</span>
<span className="text-text-secondary text-sm font-medium">{t("editor.warnings")}</span>
{selected.length > 0 && (
<span className="text-xs text-text-muted">
{selected.length} selected
</span>
<span className="text-text-muted text-xs">{selected.length} selected</span>
)}
</div>
<div className="relative">
<Search className="pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-text-muted" />
<Search className="text-text-muted pointer-events-none absolute top-1/2 left-2.5 h-3.5 w-3.5 -translate-y-1/2" />
<input
type="text"
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder={t("editor.contentWarningSearchPlaceholder")}
className="w-full rounded-md border border-border bg-surface-1 py-1.5 pl-8 pr-7 text-sm text-text-primary placeholder:text-text-muted focus:border-accent focus:outline-none"
className="border-border bg-surface-1 text-text-primary placeholder:text-text-muted focus:border-accent w-full rounded-md border py-1.5 pr-7 pl-8 text-sm focus:outline-none"
/>
{query && (
<button
type="button"
onClick={() => setQuery("")}
className="absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-primary"
className="text-text-muted hover:text-text-primary absolute top-1/2 right-2 -translate-y-1/2"
aria-label="Clear search"
>
<X className="h-3.5 w-3.5" />
@@ -101,25 +94,23 @@ export function ContentWarningChecklist() {
</div>
{isFiltering && totalMatching === 0 ? (
<p className="py-2 text-center text-xs text-text-muted">
<p className="text-text-muted py-2 text-center text-xs">
{t("editor.contentWarningEmpty")}
</p>
) : (
<div className="flex flex-col gap-1">
{filteredGroups.map((group) => {
const isOpen = isFiltering || openGroups[group.id];
const groupSelectedCount = group.items.filter((id) =>
selected.includes(id),
).length;
const groupSelectedCount = group.items.filter((id) => selected.includes(id)).length;
return (
<div
key={group.id}
className="overflow-hidden rounded-md border border-border bg-surface-1"
className="border-border bg-surface-1 overflow-hidden rounded-md border"
>
<button
type="button"
onClick={() => toggleGroup(group.id)}
className="flex w-full items-center justify-between px-3 py-2 text-left text-xs font-medium text-text-secondary hover:bg-surface-2"
className="text-text-secondary hover:bg-surface-2 flex w-full items-center justify-between px-3 py-2 text-left text-xs font-medium"
aria-expanded={isOpen}
>
<span className="flex items-center gap-1.5">
@@ -131,13 +122,13 @@ export function ContentWarningChecklist() {
{t(group.labelKey)}
</span>
{groupSelectedCount > 0 && (
<span className="rounded-full bg-accent/15 px-2 py-0.5 text-[10px] font-medium text-accent">
<span className="bg-accent/15 text-accent rounded-full px-2 py-0.5 text-[10px] font-medium">
{groupSelectedCount}
</span>
)}
</button>
{isOpen && (
<div className="grid grid-cols-1 gap-x-3 gap-y-1 border-t border-border bg-surface-1 px-3 py-2 sm:grid-cols-2">
<div className="border-border bg-surface-1 grid grid-cols-1 gap-x-3 gap-y-1 border-t px-3 py-2 sm:grid-cols-2">
{group.items.map((id) => {
const checked = selected.includes(id);
return (
@@ -154,7 +145,7 @@ export function ContentWarningChecklist() {
type="checkbox"
checked={checked}
onChange={() => toggleItem(id)}
className="h-3.5 w-3.5 shrink-0 cursor-pointer rounded border-border text-accent focus:ring-1 focus:ring-accent/40"
className="focus:ring-accent/40 border-border text-accent h-3.5 w-3.5 shrink-0 cursor-pointer rounded focus:ring-1"
/>
<span>{t(`editor.contentWarningOptions.${id}`)}</span>
</label>
+11 -4
View File
@@ -10,15 +10,22 @@ export function DraftIndicator() {
const videoType = useEditorStore((s) => s.videoType);
useEffect(() => {
setShowSaved(true);
const timer = setTimeout(() => setShowSaved(false), 2000);
return () => clearTimeout(timer);
// Show, then hide 2s later. Both transitions go through the timer rather
// than one synchronous `setShowSaved(true)` on every dependency change,
// which cost an extra render pass each keystroke-driven update
// (react-hooks/set-state-in-effect).
const show = setTimeout(() => setShowSaved(true), 0);
const hide = setTimeout(() => setShowSaved(false), 2000);
return () => {
clearTimeout(show);
clearTimeout(hide);
};
}, [gameName, videoType]);
if (!showSaved) return null;
return (
<span className="flex items-center gap-1 text-xs text-success">
<span className="text-success flex items-center gap-1 text-xs">
<Check className="h-3 w-3" />
{t("editor.draftSaved")}
</span>
+30 -45
View File
@@ -4,13 +4,11 @@ import { Plus, Minus, AlertTriangle } from "lucide-react";
import { Input } from "@components/ui/Input";
import { Button } from "@components/ui/Button";
import { Select } from "@components/ui/Select";
import {
useEditorStore,
computeContiguousRanges,
} from "@store/editor-store";
import { useEditorStore, computeContiguousRanges } from "@store/editor-store";
import { parseTimeline } from "@engine/timeline-parser";
import { formatEndingEntry } from "@engine/endings-format";
import type { EndingEntry, EndingVideoRange } from "@engine/types";
import { FIELD_LIMITS } from "@config/field-limits";
/** Editor cap, matching the original spec ("Giá trị từ 1 - 100"). */
const MAX_ENDINGS = 100;
@@ -78,7 +76,10 @@ export function EndingsEditor() {
const nextEndings: EndingEntry[] =
clamped <= count
? endings.slice(0, clamped)
: [...endings, ...Array.from({ length: clamped - count }, () => ({ number: null, name: "" }))];
: [
...endings,
...Array.from({ length: clamped - count }, () => ({ number: null, name: "" })),
];
set("endings", nextEndings);
// Re-derive endingVideoCount + ranges so the schema invariants
@@ -86,10 +87,7 @@ export function EndingsEditor() {
// stay true after a shrink/grow.
const nextVideoCount = clamped === 0 ? 1 : Math.min(endingVideoCount, clamped);
set("endingVideoCount", nextVideoCount);
set(
"endingVideoRanges",
clamped === 0 ? [] : computeContiguousRanges(clamped, nextVideoCount),
);
set("endingVideoRanges", clamped === 0 ? [] : computeContiguousRanges(clamped, nextVideoCount));
};
/** Update one ending row's number / name. */
@@ -119,9 +117,7 @@ export function EndingsEditor() {
* configurations after the fact, since mid-edit overlaps are
* expected. */
const updateRange = (i: number, patch: Partial<EndingVideoRange>) => {
const next = endingVideoRanges.map((r, idx) =>
idx === i ? { ...r, ...patch } : r,
);
const next = endingVideoRanges.map((r, idx) => (idx === i ? { ...r, ...patch } : r));
set("endingVideoRanges", next);
};
@@ -206,13 +202,11 @@ export function EndingsEditor() {
)}
</div>
{count === 0 && (
<p className="text-xs text-text-muted">{t("editor.endings.emptyHint")}</p>
)}
{count === 0 && <p className="text-text-muted text-xs">{t("editor.endings.emptyHint")}</p>}
{/* CASE A: single ending — number + name pair, with preview. */}
{count === 1 && endings[0] && (
<div className="flex flex-col gap-2 rounded-lg border border-border bg-surface-1 p-3">
<div className="border-border bg-surface-1 flex flex-col gap-2 rounded-lg border p-3">
<div className="grid grid-cols-[100px_1fr] gap-2">
<Input
label={t("editor.endings.numberLabel")}
@@ -228,17 +222,18 @@ export function EndingsEditor() {
/>
<Input
label={t("editor.endings.nameLabel")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("editor.endings.namePlaceholder")}
value={endings[0].name}
onChange={(e) => updateEnding(0, { name: e.target.value })}
/>
</div>
<p className="text-xs text-text-muted">
<p className="text-text-muted text-xs">
{t("editor.endings.previewLabel")}:{" "}
<span className="font-mono text-text-secondary">{previewFor(endings[0])}</span>
<span className="text-text-secondary font-mono">{previewFor(endings[0])}</span>
</p>
{!endings[0].number && !endings[0].name.trim() && (
<p className="flex items-center gap-1.5 text-xs text-warning">
<p className="text-warning flex items-center gap-1.5 text-xs">
<AlertTriangle className="h-3 w-3" />
{t("editor.endings.warnings.singleEmpty")}
</p>
@@ -249,9 +244,9 @@ export function EndingsEditor() {
{/* CASE B / C: multi-ending table. */}
{count >= 2 && (
<div className="flex flex-col gap-2">
<div className="overflow-hidden rounded-lg border border-border">
<div className="border-border overflow-hidden rounded-lg border">
<table className="w-full text-sm">
<thead className="bg-surface-1 text-xs uppercase text-text-muted">
<thead className="bg-surface-1 text-text-muted text-xs uppercase">
<tr>
<th className="px-2 py-1.5 text-left">#</th>
<th className="w-[100px] px-2 py-1.5 text-left">
@@ -263,8 +258,8 @@ export function EndingsEditor() {
</thead>
<tbody>
{endings.map((entry, i) => (
<tr key={i} className="border-t border-border">
<td className="px-2 py-1.5 text-text-muted">{i + 1}</td>
<tr key={i} className="border-border border-t">
<td className="text-text-muted px-2 py-1.5">{i + 1}</td>
<td className="px-2 py-1.5">
<Input
type="number"
@@ -284,7 +279,7 @@ export function EndingsEditor() {
onChange={(e) => updateEnding(i, { name: e.target.value })}
/>
</td>
<td className="px-2 py-1.5 font-mono text-xs text-text-muted">
<td className="text-text-muted px-2 py-1.5 font-mono text-xs">
{previewFor(entry)}
</td>
</tr>
@@ -297,7 +292,7 @@ export function EndingsEditor() {
{/* Case B: timeline gate banner. */}
{isMultiEnding && !isMultiVideo && timelineEndingCount < count && (
<p className="flex items-start gap-1.5 rounded border border-warning/40 bg-warning/10 p-2 text-xs text-warning">
<p className="border-warning/40 bg-warning/10 text-warning flex items-start gap-1.5 rounded border p-2 text-xs">
<AlertTriangle className="mt-0.5 h-3.5 w-3.5 shrink-0" />
<span>
{t("editor.endings.warnings.timelineShort", {
@@ -310,7 +305,7 @@ export function EndingsEditor() {
{/* CASE C: video-count input + per-video ranges. */}
{isMultiEnding && (
<div className="flex flex-col gap-2 rounded-lg border border-border bg-surface-1 p-3">
<div className="border-border bg-surface-1 flex flex-col gap-2 rounded-lg border p-3">
<Input
label={t("editor.endings.videoCountLabel")}
type="number"
@@ -321,23 +316,19 @@ export function EndingsEditor() {
/>
{isMultiVideo && (
<>
<p className="text-xs text-text-muted">
{t("editor.endings.videoRangeHint")}
</p>
<div className="overflow-hidden rounded border border-border">
<p className="text-text-muted text-xs">{t("editor.endings.videoRangeHint")}</p>
<div className="border-border overflow-hidden rounded border">
<table className="w-full text-sm">
<thead className="bg-surface-2 text-xs uppercase text-text-muted">
<thead className="bg-surface-2 text-text-muted text-xs uppercase">
<tr>
<th className="px-2 py-1.5 text-left">
{t("editor.endings.videoLabel")}
</th>
<th className="px-2 py-1.5 text-left">{t("editor.endings.videoLabel")}</th>
<th className="px-2 py-1.5 text-left">From</th>
<th className="px-2 py-1.5 text-left">To</th>
</tr>
</thead>
<tbody>
{endingVideoRanges.map((r, i) => (
<tr key={i} className="border-t border-border">
<tr key={i} className="border-border border-t">
<td className="px-2 py-1.5">{i + 1}</td>
<td className="px-2 py-1.5">
<Input
@@ -345,9 +336,7 @@ export function EndingsEditor() {
min={1}
max={count}
value={String(r.from)}
onChange={(e) =>
updateRange(i, { from: Number(e.target.value) || 1 })
}
onChange={(e) => updateRange(i, { from: Number(e.target.value) || 1 })}
/>
</td>
<td className="px-2 py-1.5">
@@ -356,9 +345,7 @@ export function EndingsEditor() {
min={1}
max={count}
value={String(r.to)}
onChange={(e) =>
updateRange(i, { to: Number(e.target.value) || 1 })
}
onChange={(e) => updateRange(i, { to: Number(e.target.value) || 1 })}
/>
</td>
</tr>
@@ -367,7 +354,7 @@ export function EndingsEditor() {
</table>
</div>
{rangeWarnings.length > 0 && (
<ul className="flex flex-col gap-1 rounded border border-warning/40 bg-warning/10 p-2 text-xs text-warning">
<ul className="border-warning/40 bg-warning/10 text-warning flex flex-col gap-1 rounded border p-2 text-xs">
{rangeWarnings.map((w, i) => (
<li key={i} className="flex items-start gap-1.5">
<AlertTriangle className="mt-0.5 h-3.5 w-3.5 shrink-0" />
@@ -394,9 +381,7 @@ export function EndingsEditor() {
value={String(Math.min(endingVideoIndex, endingVideoCount))}
onChange={(v) => set("endingVideoIndex", Number(v) || 1)}
/>
<p className="text-xs text-text-muted">
{t("editor.endings.videoIndexHint")}
</p>
<p className="text-text-muted text-xs">{t("editor.endings.videoIndexHint")}</p>
</>
)}
</div>
+22 -26
View File
@@ -10,6 +10,7 @@ import {
type GachaQuestType,
} from "@config/gacha-quest-types";
import { useEditorStore } from "@store/editor-store";
import { FIELD_LIMITS } from "@config/field-limits";
const ANNIVERSARY_YEARS = Array.from({ length: 20 }, (_, i) => i + 1);
@@ -32,9 +33,7 @@ export function ExtraFieldsInput() {
const visibility = GACHA_QUEST_FIELD_VISIBILITY[questType];
const placeholders = GACHA_QUEST_PLACEHOLDERS[questType];
const placeholderFor = (
field: "chapterName" | "questName" | "partNumber",
): string => {
const placeholderFor = (field: "chapterName" | "questName" | "partNumber"): string => {
const key = `editor.placeholders.questType.${questType}.${field}`;
const localised = t(key);
if (localised && localised !== key) return localised;
@@ -57,25 +56,17 @@ export function ExtraFieldsInput() {
<div className="flex flex-col gap-3">
{extraFields.includes("gachaQuestType") && (
<div className="flex flex-col gap-1">
<label
htmlFor="gacha-quest-type"
className="text-sm font-medium text-text-secondary"
>
<label htmlFor="gacha-quest-type" className="text-text-secondary text-sm font-medium">
{t("editor.gachaQuestType")}
</label>
<select
id="gacha-quest-type"
value={store.gachaQuestType ?? "main_story"}
onChange={(e) =>
store.set("gachaQuestType", e.target.value as GachaQuestType)
}
className="rounded-lg border border-border bg-surface-1 px-3 py-2 text-sm text-text-primary transition-colors focus:border-accent focus:outline-none focus:ring-2 focus:ring-accent/50"
onChange={(e) => store.set("gachaQuestType", e.target.value as GachaQuestType)}
className="focus:ring-accent/50 border-border bg-surface-1 text-text-primary focus:border-accent rounded-lg border px-3 py-2 text-sm transition-colors focus:ring-2 focus:outline-none"
>
{GACHA_QUEST_TYPE_GROUPS.map((g) => (
<optgroup
key={g.group}
label={t(`editor.gachaQuestTypeGroups.${g.group}`)}
>
<optgroup key={g.group} label={t(`editor.gachaQuestTypeGroups.${g.group}`)}>
{g.members.map((m) => (
<option key={m} value={m}>
{t(`editor.gachaQuestTypeOptions.${m}`)}
@@ -89,6 +80,7 @@ export function ExtraFieldsInput() {
{isGacha && visibility.characterName && (
<Input
label={t("editor.characterName")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("editor.characterNamePlaceholder")}
value={store.characterName ?? ""}
onChange={(e) => store.set("characterName", e.target.value)}
@@ -96,22 +88,16 @@ export function ExtraFieldsInput() {
)}
{isGacha && visibility.anniversaryYear && (
<div className="flex flex-col gap-1">
<label
htmlFor="anniversary-year"
className="text-sm font-medium text-text-secondary"
>
<label htmlFor="anniversary-year" className="text-text-secondary text-sm font-medium">
{t("editor.anniversaryYear")}
</label>
<select
id="anniversary-year"
value={store.anniversaryYear ?? ""}
onChange={(e) =>
store.set(
"anniversaryYear",
e.target.value === "" ? null : Number(e.target.value),
)
store.set("anniversaryYear", e.target.value === "" ? null : Number(e.target.value))
}
className="rounded-lg border border-border bg-surface-1 px-3 py-2 text-sm text-text-primary transition-colors focus:border-accent focus:outline-none focus:ring-2 focus:ring-accent/50"
className="focus:ring-accent/50 border-border bg-surface-1 text-text-primary focus:border-accent rounded-lg border px-3 py-2 text-sm transition-colors focus:ring-2 focus:outline-none"
>
<option value="">—</option>
{ANNIVERSARY_YEARS.map((y) => (
@@ -125,6 +111,7 @@ export function ExtraFieldsInput() {
{showField("chapterName") && (
<Input
label={t("editor.chapterName")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={isGacha ? placeholderFor("chapterName") : t("editor.chapterNamePlaceholder")}
value={store.chapterName ?? ""}
onChange={(e) => store.set("chapterName", e.target.value)}
@@ -133,6 +120,7 @@ export function ExtraFieldsInput() {
{showField("questName") && (
<Input
label={t("editor.questName")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={isGacha ? placeholderFor("questName") : t("editor.questNamePlaceholder")}
value={store.questName ?? ""}
onChange={(e) => store.set("questName", e.target.value)}
@@ -141,6 +129,7 @@ export function ExtraFieldsInput() {
{showField("partNumber") && (
<Input
label={t("editor.partNumber")}
maxLength={FIELD_LIMITS.NUMERIC}
placeholder={isGacha ? placeholderFor("partNumber") : t("editor.partNumberPlaceholder")}
value={store.partNumber ?? ""}
onChange={(e) => store.set("partNumber", e.target.value)}
@@ -149,6 +138,7 @@ export function ExtraFieldsInput() {
{isGacha && (
<Input
label={t("editor.gachaVersion")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("editor.gachaVersionPlaceholder")}
value={store.gachaVersion ?? ""}
onChange={(e) => store.set("gachaVersion", e.target.value)}
@@ -157,6 +147,7 @@ export function ExtraFieldsInput() {
{extraFields.includes("bossName") && (
<Input
label={t("editor.bossName")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("editor.bossNamePlaceholder")}
value={store.bossName ?? ""}
onChange={(e) => store.set("bossName", e.target.value)}
@@ -165,6 +156,7 @@ export function ExtraFieldsInput() {
{extraFields.includes("dlcName") && (
<Input
label={t("editor.dlcName")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("editor.dlcNamePlaceholder")}
value={store.dlcName ?? ""}
onChange={(e) => store.set("dlcName", e.target.value)}
@@ -173,6 +165,7 @@ export function ExtraFieldsInput() {
{extraFields.includes("challengeName") && (
<Input
label={t("editor.challengeName")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("editor.challengeNamePlaceholder")}
value={store.challengeName ?? ""}
onChange={(e) => store.set("challengeName", e.target.value)}
@@ -182,12 +175,14 @@ export function ExtraFieldsInput() {
<>
<Input
label={t("editor.modName")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("editor.modNamePlaceholder")}
value={store.modName ?? ""}
onChange={(e) => store.set("modName", e.target.value)}
/>
<Textarea
label={t("editor.modList")}
maxLength={FIELD_LIMITS.LONG_TEXT}
placeholder={t("editor.modListPlaceholder")}
value={store.modList ?? ""}
onChange={(e) => store.set("modList", e.target.value)}
@@ -198,6 +193,7 @@ export function ExtraFieldsInput() {
{extraFields.includes("liveUrl") && (
<Input
label={t("editor.liveUrl")}
maxLength={FIELD_LIMITS.URL}
placeholder={t("editor.liveUrlPlaceholder")}
value={store.liveUrl ?? ""}
onChange={(e) => store.set("liveUrl", e.target.value)}
@@ -205,14 +201,14 @@ export function ExtraFieldsInput() {
)}
{extraFields.includes("scheduledTime") && (
<div className="flex flex-col gap-1">
<label className="text-sm font-medium text-text-secondary">
<label className="text-text-secondary text-sm font-medium">
{t("editor.scheduledTime")}
</label>
<input
type="datetime-local"
value={store.scheduledTime ?? ""}
onChange={(e) => store.set("scheduledTime", e.target.value)}
className="rounded-lg border border-border bg-surface-1 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted transition-colors focus:border-accent focus:outline-none focus:ring-2 focus:ring-accent/50"
className="focus:ring-accent/50 border-border bg-surface-1 text-text-primary placeholder:text-text-muted focus:border-accent rounded-lg border px-3 py-2 text-sm transition-colors focus:ring-2 focus:outline-none"
/>
</div>
)}
+4
View File
@@ -3,6 +3,7 @@ import { Input } from "@components/ui/Input";
import { Select } from "@components/ui/Select";
import { PLATFORMS } from "@config/platforms";
import { useEditorStore } from "@store/editor-store";
import { FIELD_LIMITS } from "@config/field-limits";
/**
* Core identity fields for the video (game name, channel, platform).
@@ -19,6 +20,7 @@ export function GameInfoForm() {
<div className="flex flex-col gap-3">
<Input
label={t("editor.gameName")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("editor.gameNamePlaceholder")}
value={store.gameName}
onChange={(e) => store.set("gameName", e.target.value)}
@@ -27,6 +29,7 @@ export function GameInfoForm() {
/>
<Input
label={t("editor.channelName")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("editor.channelNamePlaceholder")}
value={store.channelName}
onChange={(e) => store.set("channelName", e.target.value)}
@@ -49,6 +52,7 @@ export function GameInfoForm() {
*/}
<Input
label={t("editor.pubDevName")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("editor.pubDevNamePlaceholder")}
value={store.pubDevName ?? ""}
onChange={(e) => store.set("pubDevName", e.target.value)}
+9 -18
View File
@@ -1,12 +1,7 @@
import { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { ChipGroup } from "@components/ui/ChipGroup";
import {
GENRES,
GENRE_GROUPS,
GENRE_GROUP_IDS,
type GenreGroupId,
} from "@config/genres";
import { GENRES, GENRE_GROUPS, GENRE_GROUP_IDS, type GenreGroupId } from "@config/genres";
import { GENRES_WITHOUT_GRAPHICS_SETTINGS } from "@config/graphics-settings";
import { useEditorStore } from "@store/editor-store";
import { MAX_GENRES, type Genre } from "@engine/types";
@@ -55,10 +50,8 @@ export function GenreSelector() {
return (
<div className="flex flex-col gap-2">
<div className="flex flex-wrap items-center justify-between gap-2">
<span className="text-sm font-medium text-text-secondary">
{t("editor.genre")}
</span>
<span className="text-xs text-text-muted">
<span className="text-text-secondary text-sm font-medium">{t("editor.genre")}</span>
<span className="text-text-muted text-xs">
{genres.length}/{MAX_GENRES}
</span>
</div>
@@ -68,7 +61,7 @@ export function GenreSelector() {
key={groupId}
type="button"
onClick={() => applyGroup(groupId)}
className="rounded-lg border border-border bg-surface-1 px-2.5 py-1 text-xs font-medium text-text-secondary transition-colors hover:border-accent hover:text-text-primary"
className="border-border bg-surface-1 text-text-secondary hover:border-accent hover:text-text-primary rounded-lg border px-2.5 py-1 text-xs font-medium transition-colors"
>
{t(`editor.genreGroups.${groupId}`)}
</button>
@@ -79,12 +72,10 @@ export function GenreSelector() {
value={filter}
onChange={(e) => setFilter(e.target.value)}
placeholder={t("editor.genreSearchPlaceholder")}
className="rounded-lg border border-border bg-surface-1 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted transition-colors focus:border-accent focus:outline-none focus:ring-2 focus:ring-accent/50"
className="focus:ring-accent/50 border-border bg-surface-1 text-text-primary placeholder:text-text-muted focus:border-accent rounded-lg border px-3 py-2 text-sm transition-colors focus:ring-2 focus:outline-none"
/>
{visibleOptions.length === 0 ? (
<p className="py-2 text-sm text-text-muted">
{t("editor.genreSearchNoResults")}
</p>
<p className="text-text-muted py-2 text-sm">{t("editor.genreSearchNoResults")}</p>
) : (
<ChipGroup
multiple
@@ -95,12 +86,12 @@ export function GenreSelector() {
/>
)}
{showHint && (
<div className="flex items-center justify-between gap-3 rounded-lg border border-accent/40 bg-accent/5 px-3 py-2 text-xs text-text-secondary">
<div className="border-accent/40 bg-accent/5 text-text-secondary flex items-center justify-between gap-3 rounded-lg border px-3 py-2 text-xs">
<span>{t("editor.skipGraphicsHintLabel")}</span>
<div className="flex shrink-0 gap-2">
<button
type="button"
className="rounded bg-accent px-2 py-1 font-medium text-white"
className="bg-accent rounded px-2 py-1 font-medium text-white"
onClick={() => {
set("skipGraphicsSettings", true);
setHintDismissed(true);
@@ -110,7 +101,7 @@ export function GenreSelector() {
</button>
<button
type="button"
className="rounded px-2 py-1 font-medium text-text-secondary hover:bg-surface-2"
className="text-text-secondary hover:bg-surface-2 rounded px-2 py-1 font-medium"
onClick={() => setHintDismissed(true)}
>
{t("editor.skipGraphicsHintKeep")}
@@ -1,6 +1,7 @@
import { useTranslation } from "react-i18next";
import { Textarea } from "@components/ui/Textarea";
import { useEditorStore } from "@store/editor-store";
import { FIELD_LIMITS } from "@config/field-limits";
/**
* Music / sound attribution credit. When non-empty, the engine adds a
@@ -14,6 +15,7 @@ export function MusicAttributionEditor() {
return (
<Textarea
label={t("editor.musicAttribution")}
maxLength={FIELD_LIMITS.LONG_TEXT}
placeholder={t("editor.musicAttributionPlaceholder")}
value={musicAttribution ?? ""}
onChange={(e) => set("musicAttribution", e.target.value)}
@@ -1,6 +1,7 @@
import { useTranslation } from "react-i18next";
import { Textarea } from "@components/ui/Textarea";
import { useEditorStore } from "@store/editor-store";
import { FIELD_LIMITS } from "@config/field-limits";
/**
* Template for the pinned comment a creator posts under their own
@@ -15,6 +16,7 @@ export function PinnedCommentEditor() {
return (
<Textarea
label={t("editor.pinnedComment")}
maxLength={FIELD_LIMITS.LONG_TEXT}
placeholder={t("editor.pinnedCommentPlaceholder")}
value={pinnedComment ?? ""}
onChange={(e) => set("pinnedComment", e.target.value)}
+15 -15
View File
@@ -4,15 +4,9 @@ import { ValidatedInput } from "@components/ui/ValidatedInput";
import { Input } from "@components/ui/Input";
import { Select } from "@components/ui/Select";
import { useEditorStore } from "@store/editor-store";
import {
validateUrl,
validateUrlWithPattern,
validateIntegerInRange,
} from "@utils/validation";
import {
PLAYTEST_PLATFORMS,
maxInvitesForPlatform,
} from "@config/playtest-platforms";
import { validateUrl, validateUrlWithPattern, validateIntegerInRange } from "@utils/validation";
import { PLAYTEST_PLATFORMS, maxInvitesForPlatform } from "@config/playtest-platforms";
import { FIELD_LIMITS } from "@config/field-limits";
/**
* Playtest section (v0.30.0). One signup link + the platform it lives on +
@@ -49,11 +43,14 @@ export function PlaytestEditor() {
// (platform clamp, profile / preset load, draft reset). Only fires on a
// real store change, so it never clobbers an in-progress invalid edit.
useEffect(() => {
const current = invitesText.trim() === "" ? 0 : Number(invitesText);
if (current !== playtestInvites) {
setInvitesText(playtestInvites > 0 ? String(playtestInvites) : "");
}
// eslint-disable-next-line react-hooks/exhaustive-deps
const next = playtestInvites > 0 ? String(playtestInvites) : "";
// Functional form so the comparison happens against the *current* text
// without depending on it, and so an unchanged value returns the same
// reference instead of scheduling a render (react-hooks/set-state-in-effect).
setInvitesText((prev) => {
const current = prev.trim() === "" ? 0 : Number(prev);
return current === playtestInvites ? prev : next;
});
}, [playtestInvites]);
const handlePlatformChange = (id: string) => {
@@ -83,12 +80,15 @@ export function PlaytestEditor() {
return (
<div className="flex flex-col gap-3">
<span className="text-sm font-medium text-text-secondary">
<span className="text-text-secondary text-sm font-medium">
{t("editor.playtest.heading")}
</span>
<ValidatedInput
fieldId="playtestLink"
labelKey="editor.playtest.linkLabel"
label={t("editor.playtest.linkLabel")}
maxLength={FIELD_LIMITS.URL}
placeholder={platform?.urlPrefix ?? "https://"}
value={playtestLink}
onChange={(v) => setField("playtestLink", v)}
@@ -3,6 +3,7 @@ import { Select } from "@components/ui/Select";
import { Input } from "@components/ui/Input";
import { useEditorStore } from "@store/editor-store";
import { EndingsEditor } from "./EndingsEditor";
import { FIELD_LIMITS } from "@config/field-limits";
import {
PLAYTHROUGH_STATUSES,
DIFFICULTY_LEVELS,
@@ -62,7 +63,7 @@ export function PlaythroughNotesForm() {
return (
<div className="flex flex-col gap-3">
<div className="flex items-baseline justify-between">
<span className="text-sm font-medium text-text-secondary">
<span className="text-text-secondary text-sm font-medium">
{t("editor.playthroughNotes.title")}
</span>
</div>
@@ -83,6 +84,7 @@ export function PlaythroughNotesForm() {
{store.difficulty === "custom" && (
<Input
label={t("editor.difficultyCustomLabel")}
maxLength={FIELD_LIMITS.LABEL}
placeholder={t("editor.difficultyCustomPlaceholder")}
value={store.difficultyCustomLabel}
onChange={(e) => store.set("difficultyCustomLabel", e.target.value)}
@@ -105,6 +107,7 @@ export function PlaythroughNotesForm() {
{languagePatchHasCustomSlot(store.languagePatch) && (
<Input
label={t("editor.playthroughNotes.languagePatchCustomLabel")}
maxLength={FIELD_LIMITS.LABEL}
placeholder={t("editor.playthroughNotes.languagePatchCustomPlaceholder")}
value={store.languagePatchCustom}
onChange={(e) => store.set("languagePatchCustom", e.target.value)}
@@ -120,6 +123,7 @@ export function PlaythroughNotesForm() {
{gameVersionHasCustomSlot(store.gameVersion) && (
<Input
label={t("editor.playthroughNotes.gameVersionCustomLabel")}
maxLength={FIELD_LIMITS.LABEL}
placeholder={t("editor.playthroughNotes.gameVersionCustomPlaceholder")}
value={store.gameVersionCustom}
onChange={(e) => store.set("gameVersionCustom", e.target.value)}
+8 -14
View File
@@ -6,35 +6,29 @@ export function QuickPreview() {
const output = useGeneratedOutput();
return (
<div className="flex flex-col gap-3 rounded-lg border border-border bg-surface-1 p-4">
<span className="text-sm font-medium text-text-secondary">{t("editor.quickPreview")}</span>
<div className="border-border bg-surface-1 flex flex-col gap-3 rounded-lg border p-4">
<span className="text-text-secondary text-sm font-medium">{t("editor.quickPreview")}</span>
<div className="flex flex-col gap-2">
<div>
<span className="text-xs font-medium uppercase text-text-muted">
{t("output.title")}
</span>
<p className="mt-1 text-sm font-medium text-text-primary">
{output.title || "..."}
</p>
<span className="text-text-muted text-xs font-medium uppercase">{t("output.title")}</span>
<p className="text-text-primary mt-1 text-sm font-medium">{output.title || "..."}</p>
</div>
<div>
<span className="text-xs font-medium uppercase text-text-muted">
<span className="text-text-muted text-xs font-medium uppercase">
{t("output.description")}
</span>
<p className="mt-1 line-clamp-3 whitespace-pre-wrap text-xs text-text-secondary">
<p className="text-text-secondary mt-1 line-clamp-3 text-xs whitespace-pre-wrap">
{output.description || "..."}
</p>
</div>
<div>
<span className="text-xs font-medium uppercase text-text-muted">
<span className="text-text-muted text-xs font-medium uppercase">
{t("output.tags")} ({output.tags.length})
</span>
<p className="mt-1 line-clamp-2 text-xs text-text-muted">
{output.tagString || "..."}
</p>
<p className="text-text-muted mt-1 line-clamp-2 text-xs">{output.tagString || "..."}</p>
</div>
</div>
</div>
+14 -22
View File
@@ -13,6 +13,7 @@ import {
} from "@config/rig-fields";
import { GPU_CUSTOM_BRAND_ID, findGpuBrand } from "@config/gpu-catalog";
import { useEditorStore } from "@store/editor-store";
import { FIELD_LIMITS } from "@config/field-limits";
import {
validateGpuValue,
validateCompositeField,
@@ -39,7 +40,7 @@ export function RigEditor() {
const renderValidationBadge = (issue: RigValidationIssue | null) => {
if (!issue) return null;
return (
<div className="flex items-center gap-1 text-xs text-warning">
<div className="text-warning flex items-center gap-1 text-xs">
<AlertTriangle className="h-3 w-3" />
<span>{t(issue.messageKey)}</span>
</div>
@@ -66,10 +67,7 @@ export function RigEditor() {
: [{ value: "", label: "—" }];
const currentSeries = currentBrand?.series.find((s) => s.id === series);
const modelOptions = currentSeries
? [
{ value: "", label: "—" },
...currentSeries.models.map((m) => ({ value: m, label: m })),
]
? [{ value: "", label: "—" }, ...currentSeries.models.map((m) => ({ value: m, label: m }))]
: [{ value: "", label: "—" }];
const setBrand = (next: string) => {
@@ -84,16 +82,12 @@ export function RigEditor() {
setNested("rig", field.id, joinCascading(brand, series, next));
};
const setCustomText = (text: string) => {
setNested(
"rig",
field.id,
text ? joinCascading(GPU_CUSTOM_BRAND_ID, "", text) : "",
);
setNested("rig", field.id, text ? joinCascading(GPU_CUSTOM_BRAND_ID, "", text) : "");
};
return (
<div key={field.id} className="col-span-2 flex flex-col gap-2">
<span className="text-sm font-medium text-text-secondary">{t(field.labelKey)}</span>
<span className="text-text-secondary text-sm font-medium">{t(field.labelKey)}</span>
<div className="grid grid-cols-3 gap-2">
<Select
label={t("editor.gpu_brand")}
@@ -105,6 +99,7 @@ export function RigEditor() {
<div className="col-span-2">
<Input
label={t("editor.gpu_custom")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder="e.g. RTX 4090 (custom OC)"
value={model}
onChange={(e) => setCustomText(e.target.value)}
@@ -141,9 +136,7 @@ export function RigEditor() {
// Validate per field — only RAM has size/DDR semantics. Running the
// RAM validator on the OS composite mis-fired "Pick a DDR generation."
const issue = validateCompositeField(field.id, raw);
const partValues = field.composite.parts.map(
(_p, i) => storedParts[i] ?? "",
);
const partValues = field.composite.parts.map((_p, i) => storedParts[i] ?? "");
// v0.23.0: setting a part also resets all downstream parts to "" so
// a cascading parent change can't leave the form with a stale child
@@ -180,10 +173,8 @@ export function RigEditor() {
return (
<div key={field.id} className="col-span-2 flex flex-col gap-2">
<span className="text-sm font-medium text-text-secondary">{t(field.labelKey)}</span>
<div className="grid grid-cols-2 gap-2">
{renderedParts}
</div>
<span className="text-text-secondary text-sm font-medium">{t(field.labelKey)}</span>
<div className="grid grid-cols-2 gap-2">{renderedParts}</div>
{renderValidationBadge(issue)}
</div>
);
@@ -232,7 +223,7 @@ export function RigEditor() {
onChange={(e) => onCustomChange(e.target.value)}
/>
{part.customSuffix && (
<span className="text-sm text-text-muted">{part.customSuffix.trim()}</span>
<span className="text-text-muted text-sm">{part.customSuffix.trim()}</span>
)}
</div>
)}
@@ -247,8 +238,7 @@ export function RigEditor() {
const commit = (nextValue: string, nextVersion: string) => {
// Keep the stored form compact: drop the pipe when empty.
const next =
!nextValue && !nextVersion ? "" : `${nextValue}|${nextVersion}`;
const next = !nextValue && !nextVersion ? "" : `${nextValue}|${nextVersion}`;
setNested("rig", field.id, next);
};
@@ -262,6 +252,7 @@ export function RigEditor() {
/>
<Input
label={t("editor.version")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={field.versionPlaceholder}
value={version}
onChange={(e) => commit(value, e.target.value)}
@@ -272,7 +263,7 @@ export function RigEditor() {
return (
<div className="flex flex-col gap-3">
<span className="text-sm font-medium text-text-secondary">{t("editor.rig")}</span>
<span className="text-text-secondary text-sm font-medium">{t("editor.rig")}</span>
<div className="grid grid-cols-2 gap-2">
{RIG_FIELDS.map((field) => {
if (field.type === "cascading_dropdown") return renderCascading(field);
@@ -282,6 +273,7 @@ export function RigEditor() {
<Input
key={field.id}
label={t(field.labelKey)}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={field.placeholder}
value={rig[field.id] ?? ""}
onChange={(e) => setNested("rig", field.id, e.target.value)}
+10 -3
View File
@@ -3,6 +3,7 @@ import { ValidatedInput } from "@components/ui/ValidatedInput";
import { SOCIAL_FIELDS } from "@config/social-fields";
import { useEditorStore } from "@store/editor-store";
import { validateUrl, validateUrlWithPrefix } from "@utils/validation";
import { FIELD_LIMITS } from "@config/field-limits";
export function SocialEditor() {
const { t } = useTranslation("ui");
@@ -14,15 +15,18 @@ export function SocialEditor() {
return (
<div className="flex flex-col gap-4">
<span className="text-sm font-medium text-text-secondary">{t("editor.social")}</span>
<span className="text-text-secondary text-sm font-medium">{t("editor.social")}</span>
<div className="flex flex-col gap-2">
<span className="text-xs font-medium uppercase text-text-muted">Donate</span>
<span className="text-text-muted text-xs font-medium uppercase">Donate</span>
{donateFields.map((field) => (
<ValidatedInput
key={field.id}
fieldId={`social.${field.id}`}
labelKey={field.labelKey}
label={t(field.labelKey)}
placeholder={field.urlPrefix || "URL"}
maxLength={FIELD_LIMITS.URL}
value={social[field.id] ?? ""}
onChange={(v) => setNested("social", field.id, v)}
validate={(v) =>
@@ -33,12 +37,15 @@ export function SocialEditor() {
</div>
<div className="flex flex-col gap-2">
<span className="text-xs font-medium uppercase text-text-muted">Social</span>
<span className="text-text-muted text-xs font-medium uppercase">Social</span>
{socialFields.map((field) => (
<ValidatedInput
key={field.id}
fieldId={`social.${field.id}`}
labelKey={field.labelKey}
label={t(field.labelKey)}
placeholder={field.urlPrefix || "URL"}
maxLength={FIELD_LIMITS.URL}
value={social[field.id] ?? ""}
onChange={(v) => setNested("social", field.id, v)}
validate={(v) =>
@@ -1,6 +1,7 @@
import { useTranslation } from "react-i18next";
import { Input } from "@components/ui/Input";
import { useEditorStore } from "@store/editor-store";
import { FIELD_LIMITS } from "@config/field-limits";
/**
* Publisher/developer + platform pair for the "🎁 Thanks to …" credit
@@ -17,12 +18,14 @@ export function SponsorCreditEditor() {
<div className="flex flex-col gap-2">
<Input
label={t("editor.sponsorName")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("editor.sponsorNamePlaceholder")}
value={sponsorName ?? ""}
onChange={(e) => set("sponsorName", e.target.value)}
/>
<Input
label={t("editor.sponsorPlatform")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("editor.sponsorPlatformPlaceholder")}
value={sponsorPlatform ?? ""}
onChange={(e) => set("sponsorPlatform", e.target.value)}
+14 -17
View File
@@ -7,11 +7,9 @@ import { Select } from "@components/ui/Select";
import { PLATFORMS } from "@config/platforms";
import { useEditorStore } from "@store/editor-store";
import { validateUrlWithPattern } from "@utils/validation";
import {
extractGameNameFromUrl,
isLinkNameMismatch,
} from "@utils/url-extractors";
import { extractGameNameFromUrl, isLinkNameMismatch } from "@utils/url-extractors";
import type { StoreLinkType } from "@engine/types";
import { FIELD_LIMITS } from "@config/field-limits";
const STORE_LINK_TYPE_VALUES: readonly StoreLinkType[] = ["paid", "free", "demo"];
@@ -30,9 +28,9 @@ export function StoreLinkEditor() {
const setNested = useEditorStore((s) => s.setNested);
const setStoreLinkType = useEditorStore((s) => s.setStoreLinkType);
const [dismissedFingerprints, setDismissedFingerprints] = useState<
ReadonlySet<string>
>(new Set());
const [dismissedFingerprints, setDismissedFingerprints] = useState<ReadonlySet<string>>(
new Set(),
);
const typeOptions = STORE_LINK_TYPE_VALUES.map((value) => ({
value,
@@ -79,11 +77,11 @@ export function StoreLinkEditor() {
setField("gameName", extracted);
toast.custom(
(item) => (
<div className="flex items-center gap-3 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary shadow">
<div className="border-border bg-surface-2 text-text-primary flex items-center gap-3 rounded-lg border px-3 py-2 text-sm shadow">
<span>{t("editor.toast.urlAutoFilled", { name: extracted })}</span>
<button
type="button"
className="rounded px-2 py-0.5 text-xs font-medium text-accent hover:bg-surface-1"
className="text-accent hover:bg-surface-1 rounded px-2 py-0.5 text-xs font-medium"
onClick={() => {
setField("gameName", "");
toast.dismiss(item.id);
@@ -99,10 +97,10 @@ export function StoreLinkEditor() {
return (
<div className="flex flex-col gap-3">
<span className="text-sm font-medium text-text-secondary">{t("editor.storeLinks")}</span>
<span className="text-text-secondary text-sm font-medium">{t("editor.storeLinks")}</span>
{mismatch && (
<div className="flex items-start gap-2 rounded-lg border border-warning bg-surface-2 px-3 py-2 text-sm">
<span className="flex-1 text-text-primary">
<div className="border-warning bg-surface-2 flex items-start gap-2 rounded-lg border px-3 py-2 text-sm">
<span className="text-text-primary flex-1">
{t("editor.warning.linkNameMismatch", {
host: mismatch.host,
suggestedName: mismatch.suggestedName,
@@ -112,7 +110,7 @@ export function StoreLinkEditor() {
<button
type="button"
aria-label={t("common.dismiss")}
className="shrink-0 rounded px-2 py-0.5 text-base leading-none text-text-secondary hover:bg-surface-1"
className="text-text-secondary hover:bg-surface-1 shrink-0 rounded px-2 py-0.5 text-base leading-none"
onClick={() =>
setDismissedFingerprints((prev) => {
const next = new Set(prev);
@@ -135,13 +133,12 @@ export function StoreLinkEditor() {
// the optional game-copyright description line independently
// of whether the publisher URL is filled.
return (
<div
key={platform.id}
className="grid grid-cols-[1fr_9rem] items-end gap-2"
>
<div key={platform.id} className="grid grid-cols-[1fr_9rem] items-end gap-2">
<ValidatedInput
fieldId={`storeLinks.${platform.id}`}
label={platform.label}
placeholder={platform.urlPrefix}
maxLength={FIELD_LIMITS.URL}
value={url}
onChange={(v) => {
const final = v && platform.normalize ? platform.normalize(v) : v;
+13 -24
View File
@@ -3,10 +3,7 @@ import { useTranslation } from "react-i18next";
import { ChevronDown, ChevronRight, Search, X } from "lucide-react";
import clsx from "clsx";
import { useEditorStore } from "@store/editor-store";
import {
TECH_NOTE_GROUPS,
type TechNoteGroup,
} from "@config/tech-note-groups";
import { TECH_NOTE_GROUPS, type TechNoteGroup } from "@config/tech-note-groups";
import type { TechNote } from "@engine/types";
/**
@@ -70,30 +67,26 @@ export function TechNotesChecklist() {
return (
<div className="flex flex-col gap-2">
<div className="flex items-baseline justify-between">
<span className="text-sm font-medium text-text-secondary">
{t("editor.techNotes")}
</span>
<span className="text-text-secondary text-sm font-medium">{t("editor.techNotes")}</span>
{selected.length > 0 && (
<span className="text-xs text-text-muted">
{selected.length} selected
</span>
<span className="text-text-muted text-xs">{selected.length} selected</span>
)}
</div>
<div className="relative">
<Search className="pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-text-muted" />
<Search className="text-text-muted pointer-events-none absolute top-1/2 left-2.5 h-3.5 w-3.5 -translate-y-1/2" />
<input
type="text"
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder={t("editor.techNoteSearchPlaceholder")}
className="w-full rounded-md border border-border bg-surface-1 py-1.5 pl-8 pr-7 text-sm text-text-primary placeholder:text-text-muted focus:border-accent focus:outline-none"
className="border-border bg-surface-1 text-text-primary placeholder:text-text-muted focus:border-accent w-full rounded-md border py-1.5 pr-7 pl-8 text-sm focus:outline-none"
/>
{query && (
<button
type="button"
onClick={() => setQuery("")}
className="absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-primary"
className="text-text-muted hover:text-text-primary absolute top-1/2 right-2 -translate-y-1/2"
aria-label="Clear search"
>
<X className="h-3.5 w-3.5" />
@@ -102,25 +95,21 @@ export function TechNotesChecklist() {
</div>
{isFiltering && totalMatching === 0 ? (
<p className="py-2 text-center text-xs text-text-muted">
{t("editor.techNoteEmpty")}
</p>
<p className="text-text-muted py-2 text-center text-xs">{t("editor.techNoteEmpty")}</p>
) : (
<div className="flex flex-col gap-1">
{filteredGroups.map((group) => {
const isOpen = isFiltering || openGroups[group.id];
const groupSelectedCount = group.items.filter((id) =>
selected.includes(id),
).length;
const groupSelectedCount = group.items.filter((id) => selected.includes(id)).length;
return (
<div
key={group.id}
className="overflow-hidden rounded-md border border-border bg-surface-1"
className="border-border bg-surface-1 overflow-hidden rounded-md border"
>
<button
type="button"
onClick={() => toggleGroup(group.id)}
className="flex w-full items-center justify-between px-3 py-2 text-left text-xs font-medium text-text-secondary hover:bg-surface-2"
className="text-text-secondary hover:bg-surface-2 flex w-full items-center justify-between px-3 py-2 text-left text-xs font-medium"
aria-expanded={isOpen}
>
<span className="flex items-center gap-1.5">
@@ -132,13 +121,13 @@ export function TechNotesChecklist() {
{t(group.labelKey)}
</span>
{groupSelectedCount > 0 && (
<span className="rounded-full bg-accent/15 px-2 py-0.5 text-[10px] font-medium text-accent">
<span className="bg-accent/15 text-accent rounded-full px-2 py-0.5 text-[10px] font-medium">
{groupSelectedCount}
</span>
)}
</button>
{isOpen && (
<div className="grid grid-cols-1 gap-x-3 gap-y-1 border-t border-border bg-surface-1 px-3 py-2 sm:grid-cols-2">
<div className="border-border bg-surface-1 grid grid-cols-1 gap-x-3 gap-y-1 border-t px-3 py-2 sm:grid-cols-2">
{group.items.map((id) => {
const checked = selected.includes(id);
return (
@@ -155,7 +144,7 @@ export function TechNotesChecklist() {
type="checkbox"
checked={checked}
onChange={() => toggleItem(id)}
className="h-3.5 w-3.5 shrink-0 cursor-pointer rounded border-border text-accent focus:ring-1 focus:ring-accent/40"
className="focus:ring-accent/40 border-border text-accent h-3.5 w-3.5 shrink-0 cursor-pointer rounded focus:ring-1"
/>
<span>{t(`editor.techNoteOptions.${id}`)}</span>
</label>
@@ -1,6 +1,7 @@
import { useTranslation } from "react-i18next";
import { Textarea } from "@components/ui/Textarea";
import { useEditorStore } from "@store/editor-store";
import { FIELD_LIMITS } from "@config/field-limits";
/**
* Free-form draft for the thumbnail text overlay. Never lands in the
@@ -15,6 +16,7 @@ export function ThumbnailHelper() {
return (
<Textarea
label={t("editor.thumbnailText")}
maxLength={FIELD_LIMITS.LONG_TEXT}
placeholder={t("editor.thumbnailTextPlaceholder")}
value={thumbnailText ?? ""}
onChange={(e) => set("thumbnailText", e.target.value)}
@@ -1,6 +1,7 @@
import { useTranslation } from "react-i18next";
import { Textarea } from "@components/ui/Textarea";
import { useEditorStore } from "@store/editor-store";
import { FIELD_LIMITS } from "@config/field-limits";
export function TimestampEditor() {
const { t } = useTranslation("ui");
@@ -10,6 +11,7 @@ export function TimestampEditor() {
return (
<Textarea
label={t("editor.timestamps")}
maxLength={FIELD_LIMITS.TIMESTAMPS}
placeholder={t("editor.timestampsPlaceholder")}
value={timestamps ?? ""}
onChange={(e) => set("timestamps", e.target.value)}
+6 -3
View File
@@ -23,6 +23,7 @@ import {
coerceFrameGenMultiplier,
} from "@engine/graphics-vendor";
import { VIDEO_STYLE_ERA_IDS, type VideoStyleEra } from "@config/video-styles";
import { FIELD_LIMITS } from "@config/field-limits";
const RESOLUTION_OPTIONS = [
{ value: "720p", label: "720p" },
@@ -111,7 +112,7 @@ export function VideoSettingsForm() {
return (
<div className="flex flex-col gap-3">
<span className="text-sm font-medium text-text-secondary">{t("editor.videoSettings")}</span>
<span className="text-text-secondary text-sm font-medium">{t("editor.videoSettings")}</span>
<div className="grid grid-cols-1 gap-3 sm:grid-cols-3">
<Select
@@ -137,6 +138,7 @@ export function VideoSettingsForm() {
{store.graphicsPreset === "custom" && (
<Input
label={t("editor.graphicsPresetCustom")}
maxLength={FIELD_LIMITS.LABEL}
placeholder={t("editor.graphicsPresetCustomPlaceholder")}
value={store.graphicsPresetCustom}
onChange={(e) => store.set("graphicsPresetCustom", e.target.value)}
@@ -149,14 +151,14 @@ export function VideoSettingsForm() {
value={store.videoStyleEra}
onChange={(v) => store.set("videoStyleEra", v as VideoStyleEra)}
/>
<p className="-mt-1 text-xs text-text-muted">{t("editor.videoStyleHelp")}</p>
<p className="text-text-muted -mt-1 text-xs">{t("editor.videoStyleHelp")}</p>
<Toggle
label={t("editor.skipGraphicsSettings")}
checked={store.skipGraphicsSettings}
onChange={(v) => store.set("skipGraphicsSettings", v)}
/>
<p className="-mt-1 text-xs text-text-muted">{t("editor.skipGraphicsSettingsHelp")}</p>
<p className="text-text-muted -mt-1 text-xs">{t("editor.skipGraphicsSettingsHelp")}</p>
{!store.skipGraphicsSettings && (
<>
@@ -200,6 +202,7 @@ export function VideoSettingsForm() {
<Input
label={t("editor.versionInfo")}
maxLength={FIELD_LIMITS.LABEL}
placeholder={t("editor.versionInfoPlaceholder")}
value={store.versionInfo}
onChange={(e) => store.set("versionInfo", e.target.value)}
@@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next";
import { Input } from "@components/ui/Input";
import { Select } from "@components/ui/Select";
import { useEditorStore } from "@store/editor-store";
import { FIELD_LIMITS } from "@config/field-limits";
import {
VIETNAMESE_BANKS,
VIETNAMESE_BANK_OTHER,
@@ -48,11 +49,8 @@ export function VietnameseDonateEditor() {
() => isVi && isCustomVietnameseBank(vnBankName ?? ""),
);
const customMode =
isVi && (otherSticky || isCustomVietnameseBank(vnBankName ?? ""));
const selectValue = customMode
? VIETNAMESE_BANK_OTHER
: (vnBankName ?? "");
const customMode = isVi && (otherSticky || isCustomVietnameseBank(vnBankName ?? ""));
const selectValue = customMode ? VIETNAMESE_BANK_OTHER : (vnBankName ?? "");
const bankOptions = [
{ value: "", label: t("editor.vnBankNameSelectPlaceholder") },
@@ -63,10 +61,8 @@ export function VietnameseDonateEditor() {
return (
<div className="flex flex-col gap-3">
<div className="flex flex-col gap-1">
<span className="text-sm font-medium text-text-secondary">
{t("editor.vnDonate")}
</span>
<p className="text-xs text-text-muted">{t("editor.vnDonateHelp")}</p>
<span className="text-text-secondary text-sm font-medium">{t("editor.vnDonate")}</span>
<p className="text-text-muted text-xs">{t("editor.vnDonateHelp")}</p>
</div>
<div className="grid grid-cols-2 gap-3">
@@ -98,6 +94,7 @@ export function VietnameseDonateEditor() {
) : (
<Input
label={t("editor.vnBankName")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("editor.vnBankNamePlaceholder")}
value={vnBankName ?? ""}
onChange={(e) => store.set("vnBankName", e.target.value)}
@@ -105,6 +102,7 @@ export function VietnameseDonateEditor() {
)}
<Input
label={t("editor.vnBankAccount")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("editor.vnBankAccountPlaceholder")}
value={store.vnBankAccount ?? ""}
onChange={(e) => store.set("vnBankAccount", e.target.value)}
@@ -113,6 +111,7 @@ export function VietnameseDonateEditor() {
<Input
label={t("editor.vnBankHolder")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("editor.vnBankHolderPlaceholder")}
value={store.vnBankHolder ?? ""}
onChange={(e) => store.set("vnBankHolder", e.target.value)}
@@ -121,12 +120,14 @@ export function VietnameseDonateEditor() {
<div className="grid grid-cols-2 gap-3">
<Input
label={t("editor.vnMomo")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("editor.vnMomoPlaceholder")}
value={store.vnMomo ?? ""}
onChange={(e) => store.set("vnMomo", e.target.value)}
/>
<Input
label={t("editor.vnZalopay")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("editor.vnZalopayPlaceholder")}
value={store.vnZalopay ?? ""}
onChange={(e) => store.set("vnZalopay", e.target.value)}
+8 -8
View File
@@ -52,16 +52,16 @@ function FullscreenError({ kind }: ErrorPageProps) {
useDocumentTitle(title);
return (
<div className="flex min-h-screen flex-col items-center justify-center gap-6 bg-surface-0 px-6 py-12 text-center">
<div className="bg-surface-0 flex min-h-screen flex-col items-center justify-center gap-6 px-6 py-12 text-center">
<Icon className={clsx("h-16 w-16", colour)} aria-hidden />
{meta.code !== null && (
<p className={clsx("font-mono text-6xl font-bold leading-none tabular-nums", colour)}>
<p className={clsx("font-mono text-6xl leading-none font-bold tabular-nums", colour)}>
{meta.code}
</p>
)}
<div className="max-w-md space-y-2">
<h1 className="text-2xl font-semibold text-text-primary">{title}</h1>
<p className="text-sm text-text-secondary">{description}</p>
<h1 className="text-text-primary text-2xl font-semibold">{title}</h1>
<p className="text-text-secondary text-sm">{description}</p>
</div>
<div className="flex flex-wrap items-center justify-center gap-3">
<Button
@@ -99,14 +99,14 @@ function ContainedError({ kind, onReset, detail }: ErrorPageProps) {
return (
<div className="flex min-h-[200px] items-center justify-center p-6">
<div className="w-full max-w-md rounded-lg border border-danger/40 bg-surface-2 p-5 shadow-md shadow-black/10">
<div className="border-danger/40 bg-surface-2 w-full max-w-md rounded-lg border p-5 shadow-md shadow-black/10">
<div className={clsx("mb-3 flex items-center gap-2", colour)}>
<Icon className="h-4 w-4" />
<h2 className="text-sm font-semibold">{title}</h2>
</div>
<p className="mb-3 text-xs text-text-secondary">{description}</p>
<p className="text-text-secondary mb-3 text-xs">{description}</p>
{detail && (
<pre className="mb-4 max-h-32 overflow-auto whitespace-pre-wrap rounded bg-surface-3 p-2 text-[11px] text-text-muted">
<pre className="bg-surface-3 text-text-muted mb-4 max-h-32 overflow-auto rounded p-2 text-[11px] whitespace-pre-wrap">
{detail}
</pre>
)}
@@ -140,7 +140,7 @@ function ReportBugLink({ size = "md" }: { size?: "sm" | "md" }) {
target="_blank"
rel="noopener noreferrer"
className={clsx(
"inline-flex items-center justify-center gap-2 rounded-lg font-medium text-text-secondary transition-colors hover:bg-surface-2 hover:text-text-primary focus:outline-none focus:ring-2 focus:ring-accent/50",
"focus:ring-accent/50 text-text-secondary hover:bg-surface-2 hover:text-text-primary inline-flex items-center justify-center gap-2 rounded-lg font-medium transition-colors focus:ring-2 focus:outline-none",
sizeClass,
)}
>
+4 -4
View File
@@ -35,18 +35,18 @@ export function OfflineBanner() {
return (
<div
role="status"
className="fixed inset-x-0 bottom-0 z-50 flex items-center justify-center gap-3 border-t border-warning/40 bg-surface-2 px-4 py-2 text-sm text-text-primary shadow-md shadow-black/20"
className="border-warning/40 bg-surface-2 text-text-primary fixed inset-x-0 bottom-0 z-50 flex items-center justify-center gap-3 border-t px-4 py-2 text-sm shadow-md shadow-black/20"
>
<WifiOff className="h-4 w-4 shrink-0 text-warning" aria-hidden />
<WifiOff className="text-warning h-4 w-4 shrink-0" aria-hidden />
<span>{t("errorPages.offlineBanner.message")}</span>
<Link to="/offline" className="font-medium text-accent hover:text-accent-hover">
<Link to="/offline" className="text-accent hover:text-accent-hover font-medium">
{t("errorPages.offlineBanner.details")}
</Link>
<button
type="button"
onClick={() => setDismissed(true)}
aria-label={t("common.dismiss")}
className="ml-1 rounded p-1 text-text-muted transition-colors hover:bg-surface-3 hover:text-text-primary"
className="text-text-muted hover:bg-surface-3 hover:text-text-primary ml-1 rounded p-1 transition-colors"
>
<X className="h-4 w-4" />
</button>
+8 -8
View File
@@ -19,7 +19,7 @@ export function HistoryCard({ entry }: HistoryCardProps) {
const date = new Date(entry.createdAt).toLocaleDateString();
return (
<div className="rounded-lg border border-border-strong bg-surface-2 shadow-md shadow-black/10 transition-colors hover:border-accent/30">
<div className="hover:border-accent/30 border-border-strong bg-surface-2 rounded-lg border shadow-md shadow-black/10 transition-colors">
<div
className="flex cursor-pointer items-center justify-between p-3"
onClick={() => setExpanded(!expanded)}
@@ -27,9 +27,9 @@ export function HistoryCard({ entry }: HistoryCardProps) {
<div className="flex-1">
<div className="flex items-center gap-2">
{videoType && <span>{videoType.icon}</span>}
<span className="text-sm font-medium text-text-primary">{entry.title}</span>
<span className="text-text-primary text-sm font-medium">{entry.title}</span>
</div>
<div className="mt-1 flex gap-2 text-xs text-text-muted">
<div className="text-text-muted mt-1 flex gap-2 text-xs">
<span>{entry.gameName}</span>
<span>{entry.language.toUpperCase()}</span>
<span>{date}</span>
@@ -44,24 +44,24 @@ export function HistoryCard({ entry }: HistoryCardProps) {
deleteEntry(entry.id);
}}
>
<Trash2 className="h-3.5 w-3.5 text-danger" />
<Trash2 className="text-danger h-3.5 w-3.5" />
</Button>
{expanded ? (
<ChevronUp className="h-4 w-4 text-text-muted" />
<ChevronUp className="text-text-muted h-4 w-4" />
) : (
<ChevronDown className="h-4 w-4 text-text-muted" />
<ChevronDown className="text-text-muted h-4 w-4" />
)}
</div>
</div>
{expanded && (
<div className="border-t border-border p-3">
<div className="border-border border-t p-3">
<div className="mb-2 flex gap-2">
<CopyButton text={entry.title} label={t("output.copyTitle")} />
<CopyButton text={entry.description} label={t("output.copyDescription")} />
<CopyButton text={entry.tags} label={t("output.copyTags")} />
</div>
<pre className="max-h-48 overflow-y-auto whitespace-pre-wrap rounded bg-surface-2 p-2 font-sans text-xs text-text-secondary">
<pre className="bg-surface-2 text-text-secondary max-h-48 overflow-y-auto rounded p-2 font-sans text-xs whitespace-pre-wrap">
{entry.description}
</pre>
</div>
+1 -1
View File
@@ -23,7 +23,7 @@ export function AppShell() {
useGlobalErrorHandler();
return (
<div className="flex h-screen overflow-hidden bg-surface-0">
<div className="bg-surface-0 flex h-screen overflow-hidden">
<Sidebar />
<div className="flex min-w-0 flex-1 flex-col">
<Header onOpenMobileNav={() => setMobileNavOpen(true)} />
+11 -19
View File
@@ -37,27 +37,23 @@ export function Header({ onOpenMobileNav }: HeaderProps) {
};
return (
<header
className="flex items-center justify-between gap-2 border-b border-border bg-surface-1 px-3 py-3 pt-[max(0.75rem,env(safe-area-inset-top))] sm:px-6"
>
<header className="border-border bg-surface-1 flex items-center justify-between gap-2 border-b px-3 py-3 pt-[max(0.75rem,env(safe-area-inset-top))] sm:px-6">
<div className="flex min-w-0 items-center gap-2">
{onOpenMobileNav && (
<button
type="button"
onClick={onOpenMobileNav}
aria-label="Open navigation menu"
className="-ml-1 rounded-lg p-2 text-text-secondary transition-colors hover:bg-surface-2 hover:text-text-primary md:hidden"
className="text-text-secondary hover:bg-surface-2 hover:text-text-primary -ml-1 rounded-lg p-2 transition-colors md:hidden"
>
<Menu className="h-5 w-5" />
</button>
)}
<div className="min-w-0">
<h1 className="truncate text-base font-bold text-text-primary sm:text-lg">
<h1 className="text-text-primary truncate text-base font-bold sm:text-lg">
{t("app.title")}
</h1>
<p className="hidden truncate text-xs text-text-muted sm:block">
{t("app.subtitle")}
</p>
<p className="text-text-muted hidden truncate text-xs sm:block">{t("app.subtitle")}</p>
</div>
</div>
<div className="flex shrink-0 items-center gap-2">
@@ -75,35 +71,31 @@ export function Header({ onOpenMobileNav }: HeaderProps) {
<button
type="button"
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
className="rounded-lg p-2 text-text-secondary transition-colors hover:bg-surface-2 hover:text-text-primary"
className="text-text-secondary hover:bg-surface-2 hover:text-text-primary rounded-lg p-2 transition-colors"
title={t("header.toggleTheme")}
aria-label={t("header.toggleTheme")}
>
{theme === "dark" ? (
<Moon className="h-4 w-4" />
) : (
<Sun className="h-4 w-4" />
)}
{theme === "dark" ? <Moon className="h-4 w-4" /> : <Sun className="h-4 w-4" />}
</button>
<div className="relative" ref={dropdownRef}>
<button
onClick={() => setOpen(!open)}
className="flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-sm transition-colors hover:bg-surface-2 sm:px-3"
className="hover:bg-surface-2 flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-sm transition-colors sm:px-3"
aria-haspopup="listbox"
aria-expanded={open}
>
<span>{current?.flag}</span>
<span className="hidden text-text-primary sm:inline">{current?.nativeName}</span>
<ChevronDown className="h-3.5 w-3.5 text-text-muted" />
<span className="text-text-primary hidden sm:inline">{current?.nativeName}</span>
<ChevronDown className="text-text-muted h-3.5 w-3.5" />
</button>
{open && (
<div className="absolute right-0 top-full z-50 mt-1 max-w-[calc(100vw-2rem)] min-w-[200px] rounded-lg border border-border bg-surface-1 py-1 shadow-xl">
<div className="border-border bg-surface-1 absolute top-full right-0 z-50 mt-1 max-w-[calc(100vw-2rem)] min-w-[200px] rounded-lg border py-1 shadow-xl">
{SUPPORTED_LANGUAGES.map((lang) => (
<button
key={lang.id}
onClick={() => handleSwitch(lang.id as SupportedLanguage)}
className={clsx(
"flex w-full items-center gap-2 px-3 py-2 text-sm transition-colors hover:bg-surface-2",
"hover:bg-surface-2 flex w-full items-center gap-2 px-3 py-2 text-sm transition-colors",
lang.id === appLanguage ? "bg-accent-muted text-accent" : "text-text-primary",
)}
>
+12 -8
View File
@@ -6,7 +6,13 @@ import clsx from "clsx";
interface ScrollToTopButtonProps {
/** The scrollable container to watch and scroll back to the top. */
scrollRef: RefObject<HTMLElement>;
/**
* React 19 types `useRef<T>(null)` as `RefObject<T | null>` rather than
* `RefObject<T>` — the ref genuinely is null before the element mounts, and
* the old type quietly lied about it. Matching that here rather than casting
* at the call site keeps the null-check below honest.
*/
scrollRef: RefObject<HTMLElement | null>;
}
/** Scroll distance (px) past which the button fades in. */
@@ -50,9 +56,7 @@ export function ScrollToTopButton({ scrollRef }: ScrollToTopButtonProps) {
function scrollToTop() {
const el = scrollRef.current;
if (!el) return;
const reduceMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)",
).matches;
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
el.scrollTo({ top: 0, behavior: reduceMotion ? "auto" : "smooth" });
}
@@ -64,10 +68,10 @@ export function ScrollToTopButton({ scrollRef }: ScrollToTopButtonProps) {
aria-hidden={!visible}
tabIndex={visible ? 0 : -1}
className={clsx(
"fixed bottom-6 right-6 z-40 flex h-touch w-touch items-center justify-center",
"rounded-full border border-border bg-surface-1 text-text-primary shadow-lg",
"transition-opacity duration-200 hover:bg-surface-2",
"focus:outline-none focus-visible:ring-2 focus-visible:ring-accent",
"h-touch w-touch fixed right-6 bottom-6 z-40 flex items-center justify-center",
"border-border bg-surface-1 text-text-primary rounded-full border shadow-lg",
"hover:bg-surface-2 transition-opacity duration-200",
"focus-visible:ring-accent focus:outline-none focus-visible:ring-2",
visible ? "opacity-100" : "pointer-events-none opacity-0",
)}
>
+3 -7
View File
@@ -110,7 +110,7 @@ export function Sidebar() {
return (
<aside
className={clsx(
"hidden shrink-0 flex-col border-r border-border bg-surface-1 transition-[width] duration-200 md:flex",
"border-border bg-surface-1 hidden shrink-0 flex-col border-r transition-[width] duration-200 md:flex",
collapsed ? "w-14" : "w-56",
)}
>
@@ -119,13 +119,9 @@ export function Sidebar() {
onClick={toggle}
aria-label={t(collapsed ? "sidebar.expand" : "sidebar.collapse")}
title={t(collapsed ? "sidebar.expand" : "sidebar.collapse")}
className="flex h-12 items-center justify-center border-b border-border text-text-muted transition-colors hover:bg-surface-2 hover:text-text-primary"
className="border-border text-text-muted hover:bg-surface-2 hover:text-text-primary flex h-12 items-center justify-center border-b transition-colors"
>
{collapsed ? (
<PanelLeftOpen className="h-5 w-5" />
) : (
<PanelLeftClose className="h-5 w-5" />
)}
{collapsed ? <PanelLeftOpen className="h-5 w-5" /> : <PanelLeftClose className="h-5 w-5" />}
</button>
<SidebarNavList collapsed={collapsed} />
</aside>
+11 -11
View File
@@ -33,7 +33,7 @@ export function LogEntryCard({ entry }: LogEntryProps) {
return (
<div
className={clsx(
"rounded-lg border bg-surface-2 transition-colors",
"bg-surface-2 rounded-lg border transition-colors",
entry.level === "error" ? "border-red-500/30" : "border-border",
)}
>
@@ -49,39 +49,39 @@ export function LogEntryCard({ entry }: LogEntryProps) {
>
{entry.level}
</span>
<span className="shrink-0 rounded bg-surface-3 px-1.5 py-0.5 text-[10px] text-text-muted">
<span className="bg-surface-3 text-text-muted shrink-0 rounded px-1.5 py-0.5 text-[10px]">
{entry.source}
</span>
<span className="min-w-0 flex-1 truncate text-xs text-text-primary">{entry.message}</span>
<span className="shrink-0 text-[10px] text-text-muted">{time}</span>
<span className="text-text-primary min-w-0 flex-1 truncate text-xs">{entry.message}</span>
<span className="text-text-muted shrink-0 text-[10px]">{time}</span>
<div className="flex shrink-0 items-center gap-0.5">
<button
onClick={handleCopy}
className="rounded p-1 text-text-muted hover:bg-surface-3 hover:text-text-primary"
className="text-text-muted hover:bg-surface-3 hover:text-text-primary rounded p-1"
>
{copied ? <Check className="h-3 w-3 text-success" /> : <Copy className="h-3 w-3" />}
{copied ? <Check className="text-success h-3 w-3" /> : <Copy className="h-3 w-3" />}
</button>
<button
onClick={(e) => {
e.stopPropagation();
deleteEntry(entry.id);
}}
className="rounded p-1 text-text-muted hover:bg-surface-3 hover:text-danger"
className="text-text-muted hover:bg-surface-3 hover:text-danger rounded p-1"
>
<Trash2 className="h-3 w-3" />
</button>
{entry.details &&
(expanded ? (
<ChevronUp className="h-3.5 w-3.5 text-text-muted" />
<ChevronUp className="text-text-muted h-3.5 w-3.5" />
) : (
<ChevronDown className="h-3.5 w-3.5 text-text-muted" />
<ChevronDown className="text-text-muted h-3.5 w-3.5" />
))}
</div>
</div>
{expanded && entry.details && (
<div className="border-t border-border px-3 py-2">
<pre className="max-h-40 overflow-auto whitespace-pre-wrap font-mono text-[11px] text-text-secondary">
<div className="border-border border-t px-3 py-2">
<pre className="text-text-secondary max-h-40 overflow-auto font-mono text-[11px] whitespace-pre-wrap">
{entry.details}
</pre>
</div>
+1 -1
View File
@@ -19,7 +19,7 @@ export function CharCounter({ text, limit }: CharCounterProps) {
return (
<span
className={clsx(
"text-xs font-mono font-semibold transition-colors",
"font-mono text-xs font-semibold transition-colors",
isOver && "text-danger",
isWarning && "text-warning",
!isOver && !isWarning && "text-text-muted font-normal",
+33 -46
View File
@@ -1,61 +1,48 @@
import { useTranslation } from "react-i18next";
import toast from "react-hot-toast";
import { ClipboardCopy } from "lucide-react";
import { Button } from "@components/ui/Button";
import { useGeneratedOutput } from "@hooks/use-generated-output";
import { useClipboard } from "@hooks/use-clipboard";
import { YT_LIMITS } from "@engine/types";
import { LimitBlockBanner } from "./LimitBlockBanner";
import type { OutputLimitStatus } from "@engine/limits";
interface CopyAllBarProps {
extraText?: string;
/** Exactly what gets copied — the caller decides single vs multi-language. */
text: string;
/**
* Over-limit status of every output contributing to `text`. The bar copies a
* concatenation, so one offending language blocks the blob.
*/
status: OutputLimitStatus;
}
export function CopyAllBar({ extraText }: CopyAllBarProps) {
/**
* Sticky "copy everything" bar.
*
* Before v0.35.0 this owned its own over-limit check — which skipped tags, and
* more importantly bailed out entirely when an `extraText` prop was present.
* That prop was set by exactly one caller: OutputPage, whenever more than one
* language was selected. So selecting a second language silently turned off
* every limit check on the primary copy path. The bar no longer decides
* anything; it renders the status the page computes.
*/
export function CopyAllBar({ text, status }: CopyAllBarProps) {
const { t } = useTranslation("ui");
const output = useGeneratedOutput();
const { copy } = useClipboard();
const handleCopyAll = () => {
if (extraText) {
copy(extraText);
return;
}
const overflows: string[] = [];
if (output.title.length > YT_LIMITS.TITLE_MAX) {
overflows.push(
t("output.copy.overLimit", {
field: t("output.title"),
count: output.title.length,
limit: YT_LIMITS.TITLE_MAX,
}),
);
}
if (output.description.length > YT_LIMITS.DESCRIPTION_MAX) {
overflows.push(
t("output.copy.overLimit", {
field: t("output.description"),
count: output.description.length,
limit: YT_LIMITS.DESCRIPTION_MAX,
}),
);
}
if (overflows.length > 0) {
toast.error(overflows.join("\n"));
return;
}
copy(`${output.title}\n\n${output.description}`);
};
return (
<div className="sticky bottom-0 flex items-center justify-end border-t border-border bg-surface-0 px-3 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] sm:px-4">
<Button
onClick={handleCopyAll}
size="lg"
className="text-sm sm:text-base"
>
<ClipboardCopy className="h-4 w-4" />
{t("output.copyAll")}
</Button>
<div className="border-border bg-surface-0 sticky bottom-0 flex flex-col gap-2 border-t px-3 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] sm:px-4">
<LimitBlockBanner status={status} />
<div className="flex items-center justify-end">
<Button
onClick={() => void copy(text)}
disabled={status.blocked || !text}
size="lg"
className="text-sm sm:text-base"
>
<ClipboardCopy className="h-4 w-4" />
{t("output.copyAll")}
</Button>
</div>
</div>
);
}
+24 -7
View File
@@ -1,4 +1,5 @@
import { Copy, Check, AlertTriangle } from "lucide-react";
import { useTranslation } from "react-i18next";
import clsx from "clsx";
import { Button } from "@components/ui/Button";
import { useClipboard } from "@hooks/use-clipboard";
@@ -8,29 +9,45 @@ interface CopyButtonProps {
label: string;
limit?: number;
fieldLabel?: string;
/**
* Disable the button because *some* field in this output is over its limit —
* not necessarily this one.
*
* The rule is all-or-nothing per output: if the description is 200 characters
* too long, copying the title is blocked too. Copying two of three fields and
* silently leaving the third behind is how a half-populated video description
* gets published.
*/
blocked?: boolean;
}
export function CopyButton({ text, label, limit, fieldLabel }: CopyButtonProps) {
export function CopyButton({ text, label, limit, fieldLabel, blocked }: CopyButtonProps) {
const { t } = useTranslation("ui");
const { copy, copied } = useClipboard();
const isOver = limit !== undefined && text.length > limit;
const disabled = !text || blocked;
return (
<Button
variant="ghost"
size="sm"
onClick={() => copy(text, { limit, fieldLabel })}
disabled={!text}
className={clsx(isOver && "text-danger hover:bg-surface-2 hover:text-danger")}
title={isOver ? `${text.length}/${limit}` : undefined}
// `useClipboard` still re-checks `limit` as a backstop, for any call site
// that passes a limit without wiring `blocked`.
onClick={() => void copy(text, { limit, fieldLabel })}
disabled={disabled}
className={clsx((isOver || blocked) && "text-danger hover:bg-surface-2 hover:text-danger")}
title={
blocked ? t("output.limits.copyBlocked") : isOver ? `${text.length}/${limit}` : undefined
}
>
{isOver ? (
{isOver || blocked ? (
<AlertTriangle className="h-4 w-4" />
) : copied ? (
<Check className="h-4 w-4" />
) : (
<Copy className="h-4 w-4" />
)}
{copied ? "Copied!" : label}
{copied ? t("output.copied") : label}
</Button>
);
}
@@ -0,0 +1,45 @@
import { AlertTriangle } from "lucide-react";
import { useTranslation } from "react-i18next";
import type { OutputLimitStatus } from "@engine/limits";
interface LimitBlockBannerProps {
status: OutputLimitStatus;
/** Optional override for the heading — Batch uses a Copy-All-specific one. */
titleKey?: string;
}
/**
* Explains why copying is disabled, naming each offending field with its count.
*
* Without this, a disabled Copy button is just a dead control. The counts come
* from the engine's warnings rather than `CharLimitWarning.message`, which is a
* hardcoded English string.
*/
export function LimitBlockBanner({ status, titleKey }: LimitBlockBannerProps) {
const { t } = useTranslation("ui");
if (!status.blocked) return null;
return (
<div
role="alert"
className="border-danger/40 bg-danger/10 text-danger flex flex-col gap-1 rounded-lg border px-3 py-2 text-xs"
>
<span className="flex items-center gap-1.5 font-semibold">
<AlertTriangle className="h-3.5 w-3.5 shrink-0" />
{t(titleKey ?? "output.limits.bannerTitle")}
</span>
<ul className="flex flex-col gap-0.5 pl-5">
{status.overflows.map((o) => (
<li key={o.field}>
{t("output.limits.fieldLine", {
field: t(`output.${o.field}`),
count: o.current,
limit: o.limit,
})}
</li>
))}
</ul>
<span className="text-text-muted">{t("output.limits.bannerHint")}</span>
</div>
);
}
+10 -16
View File
@@ -27,9 +27,7 @@ export function OutputExtras() {
const pinnedComment = useEditorStore((s) => s.pinnedComment);
const showPinnedCommentTemplate = useSettingsStore((s) => s.showPinnedCommentTemplate);
const includeAskNextGame = useSettingsStore((s) => s.pinnedCommentIncludeAskNextGame);
const includeGenrePlaylist = useSettingsStore(
(s) => s.pinnedCommentIncludeGenrePlaylist,
);
const includeGenrePlaylist = useSettingsStore((s) => s.pinnedCommentIncludeGenrePlaylist);
const genrePlaylists = useSettingsStore((s) => s.genrePlaylists);
const input = useCurrentGeneratorInput();
@@ -75,13 +73,11 @@ export function OutputExtras() {
{hasThumbnail && (
<section className="flex flex-col gap-2">
<div className="flex items-center justify-between">
<h3 className="text-sm font-semibold text-text-primary">
{t("output.thumbnailText")}
</h3>
<h3 className="text-text-primary text-sm font-semibold">{t("output.thumbnailText")}</h3>
<CopyButton text={thumbnailText} label={t("output.copyThumbnailText")} />
</div>
<div className="rounded-lg border border-border bg-surface-1 p-3">
<pre className="whitespace-pre-wrap font-sans text-sm text-text-secondary">
<div className="border-border bg-surface-1 rounded-lg border p-3">
<pre className="text-text-secondary font-sans text-sm whitespace-pre-wrap">
{thumbnailText}
</pre>
</div>
@@ -91,13 +87,11 @@ export function OutputExtras() {
{hasPinned && (
<section className="flex flex-col gap-2">
<div className="flex items-center justify-between">
<h3 className="text-sm font-semibold text-text-primary">
{t("output.pinnedComment")}
</h3>
<h3 className="text-text-primary text-sm font-semibold">{t("output.pinnedComment")}</h3>
<CopyButton text={pinnedComment} label={t("output.copyPinnedComment")} />
</div>
<div className="rounded-lg border border-border bg-surface-1 p-3">
<pre className="whitespace-pre-wrap font-sans text-sm text-text-secondary">
<div className="border-border bg-surface-1 rounded-lg border p-3">
<pre className="text-text-secondary font-sans text-sm whitespace-pre-wrap">
{pinnedComment}
</pre>
</div>
@@ -107,13 +101,13 @@ export function OutputExtras() {
{hasTemplate && (
<section className="flex flex-col gap-2">
<div className="flex items-center justify-between">
<h3 className="text-sm font-semibold text-text-primary">
<h3 className="text-text-primary text-sm font-semibold">
{t("output.pinnedCommentTemplate")}
</h3>
<CopyButton text={templateText} label={t("output.copyPinnedCommentTemplate")} />
</div>
<div className="rounded-lg border border-border bg-surface-1 p-3">
<pre className="whitespace-pre-wrap font-sans text-sm text-text-secondary">
<div className="border-border bg-surface-1 rounded-lg border p-3">
<pre className="text-text-secondary font-sans text-sm whitespace-pre-wrap">
{templateText}
</pre>
</div>
+24 -12
View File
@@ -5,12 +5,19 @@ import { CopyButton } from "./CopyButton";
import { CharCounter } from "./CharCounter";
import { YT_LIMITS } from "@engine/types";
import type { GeneratorOutput } from "@engine/types";
import type { OutputLimitStatus } from "@engine/limits";
interface OutputPreviewProps {
output?: GeneratorOutput;
/**
* Over-limit status of the output actually shown. All three copy buttons are
* gated on it together — see `CopyButton.blocked` for why it is
* all-or-nothing rather than per field.
*/
status: OutputLimitStatus;
}
export function OutputPreview({ output: outputProp }: OutputPreviewProps) {
export function OutputPreview({ output: outputProp, status }: OutputPreviewProps) {
const { t } = useTranslation("ui");
const defaultOutput = useGeneratedOutput();
const { showCharCount, compactTagDisplay } = useSettingsStore();
@@ -21,7 +28,7 @@ export function OutputPreview({ output: outputProp }: OutputPreviewProps) {
{/* Title */}
<section className="flex flex-col gap-2">
<div className="flex items-center justify-between">
<h3 className="text-sm font-semibold text-text-primary">{t("output.title")}</h3>
<h3 className="text-text-primary text-sm font-semibold">{t("output.title")}</h3>
<div className="flex items-center gap-3">
{showCharCount && <CharCounter text={output.title} limit={YT_LIMITS.TITLE_MAX} />}
<CopyButton
@@ -29,30 +36,34 @@ export function OutputPreview({ output: outputProp }: OutputPreviewProps) {
label={t("output.copyTitle")}
limit={YT_LIMITS.TITLE_MAX}
fieldLabel={t("output.title")}
blocked={status.blocked}
/>
</div>
</div>
<div className="rounded-lg border border-border bg-surface-1 p-3">
<p className="text-sm font-medium text-text-primary">{output.title}</p>
<div className="border-border bg-surface-1 rounded-lg border p-3">
<p className="text-text-primary text-sm font-medium">{output.title}</p>
</div>
</section>
{/* Description */}
<section className="flex flex-col gap-2">
<div className="flex items-center justify-between">
<h3 className="text-sm font-semibold text-text-primary">{t("output.description")}</h3>
<h3 className="text-text-primary text-sm font-semibold">{t("output.description")}</h3>
<div className="flex items-center gap-3">
{showCharCount && <CharCounter text={output.description} limit={YT_LIMITS.DESCRIPTION_MAX} />}
{showCharCount && (
<CharCounter text={output.description} limit={YT_LIMITS.DESCRIPTION_MAX} />
)}
<CopyButton
text={output.description}
label={t("output.copyDescription")}
limit={YT_LIMITS.DESCRIPTION_MAX}
fieldLabel={t("output.description")}
blocked={status.blocked}
/>
</div>
</div>
<div className="max-h-[60vh] overflow-y-auto rounded-lg border border-border bg-surface-1 p-3 sm:max-h-[400px]">
<pre className="whitespace-pre-wrap font-sans text-sm text-text-secondary">
<div className="border-border bg-surface-1 max-h-[60vh] overflow-y-auto rounded-lg border p-3 sm:max-h-[400px]">
<pre className="text-text-secondary font-sans text-sm whitespace-pre-wrap">
{output.description}
</pre>
</div>
@@ -61,7 +72,7 @@ export function OutputPreview({ output: outputProp }: OutputPreviewProps) {
{/* Tags */}
<section className="flex flex-col gap-2">
<div className="flex items-center justify-between">
<h3 className="text-sm font-semibold text-text-primary">
<h3 className="text-text-primary text-sm font-semibold">
{t("output.tags")} ({output.tags.length})
</h3>
<div className="flex items-center gap-3">
@@ -71,18 +82,19 @@ export function OutputPreview({ output: outputProp }: OutputPreviewProps) {
label={t("output.copyTags")}
limit={YT_LIMITS.TAGS_MAX}
fieldLabel={t("output.tags")}
blocked={status.blocked}
/>
</div>
</div>
<div className="rounded-lg border border-border bg-surface-1 p-3">
<div className="border-border bg-surface-1 rounded-lg border p-3">
{compactTagDisplay ? (
<p className="text-xs text-text-secondary">{output.tagString}</p>
<p className="text-text-secondary text-xs">{output.tagString}</p>
) : (
<div className="flex flex-wrap gap-1.5">
{output.tags.map((tag, i) => (
<span
key={i}
className="rounded-md bg-surface-2 px-2 py-0.5 text-xs text-text-secondary"
className="bg-surface-2 text-text-secondary rounded-md px-2 py-0.5 text-xs"
>
{tag}
</span>
+9 -4
View File
@@ -82,12 +82,17 @@ export function VariantPicker({ open, onClose }: VariantPickerProps) {
]);
return (
<Modal open={open} onClose={onClose} title={t("output.generateAlternatives")} className="max-w-2xl">
<Modal
open={open}
onClose={onClose}
title={t("output.generateAlternatives")}
className="max-w-2xl"
>
<div className="flex flex-col gap-4">
{variants.map((variant) => (
<section key={variant.id} className="flex flex-col gap-2">
<div className="flex items-center justify-between">
<h3 className="text-xs font-semibold uppercase tracking-wide text-text-muted">
<h3 className="text-text-muted text-xs font-semibold tracking-wide uppercase">
{t(variant.labelKey)}
</h3>
<div className="flex items-center gap-3">
@@ -95,8 +100,8 @@ export function VariantPicker({ open, onClose }: VariantPickerProps) {
<CopyButton text={variant.title} label={t("output.copyTitle")} />
</div>
</div>
<div className="rounded-lg border border-border bg-surface-1 p-3">
<p className="text-sm font-medium text-text-primary">{variant.title}</p>
<div className="border-border bg-surface-1 rounded-lg border p-3">
<p className="text-text-primary text-sm font-medium">{variant.title}</p>
</div>
</section>
))}
+6 -10
View File
@@ -46,12 +46,12 @@ export function PresetCard({ preset }: PresetCardProps) {
return (
<>
<div className="flex flex-col gap-3 rounded-lg border border-border-strong bg-surface-2 p-4 shadow-md shadow-black/10 transition-colors hover:border-accent/30 sm:flex-row sm:items-center sm:justify-between">
<div className="hover:border-accent/30 border-border-strong bg-surface-2 flex flex-col gap-3 rounded-lg border p-4 shadow-md shadow-black/10 transition-colors sm:flex-row sm:items-center sm:justify-between">
<div className="min-w-0 flex-1">
<h3 className="text-sm font-semibold text-text-primary">{preset.gameName}</h3>
<div className="mt-1.5 flex flex-wrap items-center gap-1.5 text-xs text-text-muted">
<h3 className="text-text-primary text-sm font-semibold">{preset.gameName}</h3>
<div className="text-text-muted mt-1.5 flex flex-wrap items-center gap-1.5 text-xs">
{genreDefs.map((g) => (
<span key={g.id} className="rounded bg-surface-2 px-1.5 py-0.5">
<span key={g.id} className="bg-surface-2 rounded px-1.5 py-0.5">
{g.icon} {t(g.labelKey)}
</span>
))}
@@ -67,7 +67,7 @@ export function PresetCard({ preset }: PresetCardProps) {
<Pencil className="h-3.5 w-3.5" />
</Button>
<Button variant="ghost" size="sm" onClick={() => setShowDelete(true)}>
<Trash2 className="h-3.5 w-3.5 text-danger" />
<Trash2 className="text-danger h-3.5 w-3.5" />
</Button>
</div>
</div>
@@ -85,11 +85,7 @@ export function PresetCard({ preset }: PresetCardProps) {
variant="danger"
/>
<PresetSaveForm
open={showEdit}
onClose={() => setShowEdit(false)}
editPreset={preset}
/>
<PresetSaveForm open={showEdit} onClose={() => setShowEdit(false)} editPreset={preset} />
</>
);
}
+2 -2
View File
@@ -14,7 +14,7 @@ export function PresetList() {
return (
<div className="flex flex-col gap-4">
<div className="flex items-center justify-between">
<h2 className="text-base font-semibold text-text-primary">{t("presets.title")}</h2>
<h2 className="text-text-primary text-base font-semibold">{t("presets.title")}</h2>
<Button size="sm" onClick={() => setShowCreate(true)}>
<Plus className="h-4 w-4" />
{t("presets.createNew")}
@@ -22,7 +22,7 @@ export function PresetList() {
</div>
{presets.length === 0 ? (
<p className="rounded-lg border border-dashed border-border py-8 text-center text-sm text-text-muted">
<p className="border-border text-text-muted rounded-lg border border-dashed py-8 text-center text-sm">
{t("presets.emptyState")}
</p>
) : (
+3 -1
View File
@@ -6,6 +6,7 @@ import { Input } from "@components/ui/Input";
import { useEditorStore } from "@store/editor-store";
import { useSettingsStore } from "@store/settings-store";
import { usePresetStore, type GamePreset } from "@store/preset-store";
import { FIELD_LIMITS } from "@config/field-limits";
interface PresetSaveFormProps {
open: boolean;
@@ -59,12 +60,13 @@ export function PresetSaveForm({ open, onClose, editPreset }: PresetSaveFormProp
<div className="flex flex-col gap-3">
<Input
label={t("editor.gameName")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("editor.gameNamePlaceholder")}
value={gameName}
onChange={(e) => setGameName(e.target.value)}
autoFocus
/>
<p className="text-xs text-text-muted">
<p className="text-text-muted text-xs">
{editPreset
? "Update the game name. Other fields are saved from the editor."
: "Preset will save your current game name, genre, platform, store links, and warning settings."}
+3 -1
View File
@@ -40,5 +40,7 @@ export function PresetSelector() {
}
};
return <Select label={t("presets.selectPreset")} options={options} value="" onChange={handleSelect} />;
return (
<Select label={t("presets.selectPreset")} options={options} value="" onChange={handleSelect} />
);
}
+8 -10
View File
@@ -45,11 +45,13 @@ export function ProfileCard({ profile }: ProfileCardProps) {
return (
<>
<div className="flex flex-col gap-3 rounded-lg border border-border-strong bg-surface-2 p-4 shadow-md shadow-black/10 transition-colors hover:border-accent/30 sm:flex-row sm:items-center sm:justify-between">
<div className="hover:border-accent/30 border-border-strong bg-surface-2 flex flex-col gap-3 rounded-lg border p-4 shadow-md shadow-black/10 transition-colors sm:flex-row sm:items-center sm:justify-between">
<div className="min-w-0 flex-1">
<h3 className="text-sm font-semibold text-text-primary">{profile.name}</h3>
<p className="mt-0.5 text-xs text-text-secondary">{profile.channelName || "No channel"}</p>
<div className="mt-1.5 flex flex-wrap gap-3 text-xs text-text-muted">
<h3 className="text-text-primary text-sm font-semibold">{profile.name}</h3>
<p className="text-text-secondary mt-0.5 text-xs">
{profile.channelName || "No channel"}
</p>
<div className="text-text-muted mt-1.5 flex flex-wrap gap-3 text-xs">
{socialCount > 0 && <span>{socialCount} social links</span>}
{rigCount > 0 && <span>{rigCount} rig fields</span>}
</div>
@@ -63,7 +65,7 @@ export function ProfileCard({ profile }: ProfileCardProps) {
<Pencil className="h-3.5 w-3.5" />
</Button>
<Button variant="ghost" size="sm" onClick={() => setShowDelete(true)}>
<Trash2 className="h-3.5 w-3.5 text-danger" />
<Trash2 className="text-danger h-3.5 w-3.5" />
</Button>
</div>
</div>
@@ -81,11 +83,7 @@ export function ProfileCard({ profile }: ProfileCardProps) {
variant="danger"
/>
<ProfileSaveForm
open={showEdit}
onClose={() => setShowEdit(false)}
editProfile={profile}
/>
<ProfileSaveForm open={showEdit} onClose={() => setShowEdit(false)} editProfile={profile} />
</>
);
}
+2 -2
View File
@@ -14,7 +14,7 @@ export function ProfileList() {
return (
<div className="flex flex-col gap-4">
<div className="flex items-center justify-between">
<h2 className="text-base font-semibold text-text-primary">{t("profiles.title")}</h2>
<h2 className="text-text-primary text-base font-semibold">{t("profiles.title")}</h2>
<Button size="sm" onClick={() => setShowCreate(true)}>
<Plus className="h-4 w-4" />
{t("profiles.createNew")}
@@ -22,7 +22,7 @@ export function ProfileList() {
</div>
{profiles.length === 0 ? (
<p className="rounded-lg border border-dashed border-border py-8 text-center text-sm text-text-muted">
<p className="border-border text-text-muted rounded-lg border border-dashed py-8 text-center text-sm">
{t("profiles.emptyState")}
</p>
) : (
+5 -2
View File
@@ -6,6 +6,7 @@ import { Input } from "@components/ui/Input";
import { Textarea } from "@components/ui/Textarea";
import { useEditorStore } from "@store/editor-store";
import { useProfileStore, type Profile } from "@store/profile-store";
import { FIELD_LIMITS } from "@config/field-limits";
interface ProfileSaveFormProps {
open: boolean;
@@ -69,6 +70,7 @@ export function ProfileSaveForm({ open, onClose, editProfile }: ProfileSaveFormP
<div className="flex flex-col gap-3">
<Input
label={t("profiles.profileName")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("profiles.profileNamePlaceholder")}
value={name}
onChange={(e) => setName(e.target.value)}
@@ -76,13 +78,14 @@ export function ProfileSaveForm({ open, onClose, editProfile }: ProfileSaveFormP
/>
<Textarea
label={t("profiles.thirdPartyAdText")}
maxLength={FIELD_LIMITS.LONG_TEXT}
placeholder={t("profiles.thirdPartyAdTextPlaceholder")}
value={adText}
onChange={(e) => setAdText(e.target.value)}
rows={4}
/>
<p className="text-xs text-text-muted">{t("profiles.thirdPartyAdTextHelp")}</p>
<p className="text-xs text-text-muted">
<p className="text-text-muted text-xs">{t("profiles.thirdPartyAdTextHelp")}</p>
<p className="text-text-muted text-xs">
{editProfile
? "Update this profile's name and ad copy. Other fields are saved from the editor."
: "Profile will save your current channel name, social links, rig info, and video settings."}
+7 -5
View File
@@ -24,7 +24,9 @@ export function TemplateCard({ template }: TemplateCardProps) {
// patch via `normalizeEditorPatch`, but checking here lets us
// surface a clearer toast and skip the no-op success message.
if (!template.snapshot || typeof template.snapshot !== "object") {
toast.error(t("templates.applyFailed", { defaultValue: "Template is corrupt — cannot apply" }));
toast.error(
t("templates.applyFailed", { defaultValue: "Template is corrupt — cannot apply" }),
);
return;
}
loadProfile(template.snapshot);
@@ -35,10 +37,10 @@ export function TemplateCard({ template }: TemplateCardProps) {
return (
<>
<div className="flex flex-col gap-3 rounded-lg border border-border-strong bg-surface-2 p-4 shadow-md shadow-black/10 transition-colors hover:border-accent/30 sm:flex-row sm:items-center sm:justify-between">
<div className="hover:border-accent/30 border-border-strong bg-surface-2 flex flex-col gap-3 rounded-lg border p-4 shadow-md shadow-black/10 transition-colors sm:flex-row sm:items-center sm:justify-between">
<div className="min-w-0 flex-1">
<h3 className="text-sm font-semibold text-text-primary">{template.name}</h3>
<div className="mt-1.5 flex flex-wrap items-center gap-2 text-xs text-text-muted">
<h3 className="text-text-primary text-sm font-semibold">{template.name}</h3>
<div className="text-text-muted mt-1.5 flex flex-wrap items-center gap-2 text-xs">
<span>{template.snapshot.gameName || "—"}</span>
<span>·</span>
<span>{date}</span>
@@ -50,7 +52,7 @@ export function TemplateCard({ template }: TemplateCardProps) {
{t("templates.loadTemplate")}
</Button>
<Button variant="ghost" size="sm" onClick={() => setShowDelete(true)}>
<Trash2 className="h-3.5 w-3.5 text-danger" />
<Trash2 className="text-danger h-3.5 w-3.5" />
</Button>
</div>
</div>
+1 -1
View File
@@ -8,7 +8,7 @@ export function TemplateList() {
if (templates.length === 0) {
return (
<p className="rounded-lg border border-dashed border-border py-8 text-center text-sm text-text-muted">
<p className="border-border text-text-muted rounded-lg border border-dashed py-8 text-center text-sm">
{t("templates.emptyState")}
</p>
);
@@ -6,6 +6,7 @@ import { Input } from "@components/ui/Input";
import { useEditorStore } from "@store/editor-store";
import { useTemplateStore, type TemplateSnapshot } from "@store/template-store";
import toast from "react-hot-toast";
import { FIELD_LIMITS } from "@config/field-limits";
interface TemplateSaveFormProps {
open: boolean;
@@ -111,12 +112,13 @@ export function TemplateSaveForm({ open, onClose }: TemplateSaveFormProps) {
<div className="flex flex-col gap-3">
<Input
label={t("templates.templateName")}
maxLength={FIELD_LIMITS.SHORT_NAME}
placeholder={t("templates.templateNamePlaceholder")}
value={name}
onChange={(e) => setName(e.target.value)}
autoFocus
/>
<p className="text-xs text-text-muted">{t("templates.saveHint")}</p>
<p className="text-text-muted text-xs">{t("templates.saveHint")}</p>
</div>
</Modal>
);
+6 -16
View File
@@ -23,34 +23,26 @@ interface AccordionProps {
* sections are open and persists that choice. Height animates via a
* grid-rows trick so content can be any height without measurement.
*/
export function Accordion({
id,
title,
icon,
badge,
open,
onToggle,
children,
}: AccordionProps) {
export function Accordion({ id, title, icon, badge, open, onToggle, children }: AccordionProps) {
return (
<section
data-accordion-id={id}
className="overflow-hidden rounded-lg border border-border bg-surface-1"
className="border-border bg-surface-1 overflow-hidden rounded-lg border"
>
<button
type="button"
onClick={onToggle}
aria-expanded={open}
className="flex w-full items-center justify-between gap-3 px-4 py-3 text-left transition-colors hover:bg-surface-2"
className="hover:bg-surface-2 flex w-full items-center justify-between gap-3 px-4 py-3 text-left transition-colors"
>
<div className="flex items-center gap-2">
{icon && <span className="text-base leading-none">{icon}</span>}
<span className="text-sm font-semibold text-text-primary">{title}</span>
<span className="text-text-primary text-sm font-semibold">{title}</span>
{badge}
</div>
<ChevronDown
className={clsx(
"h-4 w-4 text-text-muted transition-transform duration-200",
"text-text-muted h-4 w-4 transition-transform duration-200",
open && "rotate-180",
)}
/>
@@ -62,9 +54,7 @@ export function Accordion({
)}
>
<div className="overflow-hidden">
<div className="flex flex-col gap-3 border-t border-border px-4 py-4">
{children}
</div>
<div className="border-border flex flex-col gap-3 border-t px-4 py-4">{children}</div>
</div>
</div>
</section>
+1 -1
View File
@@ -23,7 +23,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
<button
ref={ref}
className={clsx(
"inline-flex items-center justify-center gap-2 rounded-lg font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-accent/50 disabled:cursor-not-allowed disabled:opacity-50",
"focus:ring-accent/50 inline-flex items-center justify-center gap-2 rounded-lg font-medium transition-colors focus:ring-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",
variantClasses[variant],
sizeClasses[size],
className,
+7 -4
View File
@@ -25,7 +25,10 @@ export function Checkbox({ checked, onChange, label, className, id }: CheckboxPr
return (
<label
htmlFor={inputId}
className={clsx("group flex min-h-touch cursor-pointer items-start gap-3 text-left", className)}
className={clsx(
"group min-h-touch flex cursor-pointer items-start gap-3 text-left",
className,
)}
>
<input
id={inputId}
@@ -38,15 +41,15 @@ export function Checkbox({ checked, onChange, label, className, id }: CheckboxPr
aria-hidden
className={clsx(
"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded border transition-colors",
"peer-focus-visible:ring-2 peer-focus-visible:ring-accent/50",
"peer-focus-visible:ring-accent/50 peer-focus-visible:ring-2",
checked
? "border-accent bg-accent text-white"
: "border-border bg-surface-1 text-transparent group-hover:border-border-strong",
: "border-border bg-surface-1 group-hover:border-border-strong text-transparent",
)}
>
<Check className="h-3.5 w-3.5" strokeWidth={3} />
</span>
<span className="text-sm leading-snug text-text-primary">{label}</span>
<span className="text-text-primary text-sm leading-snug">{label}</span>
</label>
);
}
+4 -5
View File
@@ -52,15 +52,14 @@ export function ChipGroup(props: ChipGroupProps) {
}
};
const counter =
props.multiple && props.max != null ? `${props.value.length}/${props.max}` : null;
const counter = props.multiple && props.max != null ? `${props.value.length}/${props.max}` : null;
return (
<div className={clsx("flex flex-col gap-2", className)}>
{(label || counter) && (
<div className="flex items-center justify-between">
{label && <span className="text-sm font-medium text-text-secondary">{label}</span>}
{counter && <span className="text-xs text-text-muted">{counter}</span>}
{label && <span className="text-text-secondary text-sm font-medium">{label}</span>}
{counter && <span className="text-text-muted text-xs">{counter}</span>}
</div>
)}
<div className="flex flex-wrap gap-2">
@@ -78,7 +77,7 @@ export function ChipGroup(props: ChipGroupProps) {
selected
? "bg-accent text-white"
: disabled
? "cursor-not-allowed bg-surface-2 text-text-muted opacity-40"
? "bg-surface-2 text-text-muted cursor-not-allowed opacity-40"
: "bg-surface-2 text-text-secondary hover:bg-surface-3 hover:text-text-primary",
)}
>
+2 -2
View File
@@ -36,14 +36,14 @@ export function ConfirmDialog({
<Button
variant="primary"
onClick={onConfirm}
className={variant === "danger" ? "bg-danger hover:bg-danger/80" : ""}
className={variant === "danger" ? "hover:bg-danger/80 bg-danger" : ""}
>
{confirmLabel ?? t("common.confirm")}
</Button>
</>
}
>
<p className="text-sm text-text-secondary">{message}</p>
<p className="text-text-secondary text-sm">{message}</p>
</Modal>
);
}
+7 -15
View File
@@ -43,23 +43,15 @@ export function Drawer({
)}
aria-hidden={!open}
>
<div
className="absolute inset-0 bg-black/60"
onClick={onClose}
aria-hidden="true"
/>
<div className="absolute inset-0 bg-black/60" onClick={onClose} aria-hidden="true" />
<div
role="dialog"
aria-modal="true"
aria-label={ariaLabel ?? title}
className={clsx(
"absolute bottom-0 top-0 flex w-64 max-w-[85vw] flex-col bg-surface-1 shadow-2xl transition-transform duration-200",
side === "left" ? "left-0 border-r border-border" : "right-0 border-l border-border",
open
? "translate-x-0"
: side === "left"
? "-translate-x-full"
: "translate-x-full",
"bg-surface-1 absolute top-0 bottom-0 flex w-64 max-w-[85vw] flex-col shadow-2xl transition-transform duration-200",
side === "left" ? "border-border left-0 border-r" : "border-border right-0 border-l",
open ? "translate-x-0" : side === "left" ? "-translate-x-full" : "translate-x-full",
className,
)}
style={{
@@ -68,12 +60,12 @@ export function Drawer({
}}
>
{title && (
<div className="flex items-center justify-between border-b border-border px-4 py-3">
<h2 className="text-base font-semibold text-text-primary">{title}</h2>
<div className="border-border flex items-center justify-between border-b px-4 py-3">
<h2 className="text-text-primary text-base font-semibold">{title}</h2>
<button
type="button"
onClick={onClose}
className="rounded-lg p-2 text-text-muted hover:bg-surface-2 hover:text-text-primary"
className="text-text-muted hover:bg-surface-2 hover:text-text-primary rounded-lg p-2"
aria-label="Close"
>
<X className="h-4 w-4" />
+4 -4
View File
@@ -18,7 +18,7 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
return (
<div className="flex flex-col gap-1">
{label && (
<label htmlFor={inputId} className="text-sm font-medium text-text-secondary">
<label htmlFor={inputId} className="text-text-secondary text-sm font-medium">
{label}
</label>
)}
@@ -27,14 +27,14 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
id={inputId}
aria-invalid={isError || undefined}
className={clsx(
"min-h-touch rounded-lg border bg-surface-1 px-3 py-2.5 text-base text-text-primary placeholder:text-text-muted transition-colors focus:outline-none focus:ring-2 focus:ring-accent/50 sm:text-sm",
"focus:ring-accent/50 min-h-touch bg-surface-1 text-text-primary placeholder:text-text-muted rounded-lg border px-3 py-2.5 text-base transition-colors focus:ring-2 focus:outline-none sm:text-sm",
isError ? "border-danger" : "border-border focus:border-accent",
className,
)}
{...props}
/>
{errorText && <p className="text-xs text-danger">{errorText}</p>}
{helpText && !errorText && <p className="text-xs text-text-muted">{helpText}</p>}
{errorText && <p className="text-danger text-xs">{errorText}</p>}
{helpText && !errorText && <p className="text-text-muted text-xs">{helpText}</p>}
</div>
);
},
+5 -5
View File
@@ -35,16 +35,16 @@ export function Modal({ open, onClose, title, children, footer, className }: Mod
>
<div
className={clsx(
"mx-4 flex max-h-[85vh] w-[calc(100%-2rem)] max-w-lg flex-col rounded-xl border border-border bg-surface-1 shadow-2xl",
"border-border bg-surface-1 mx-4 flex max-h-[85vh] w-[calc(100%-2rem)] max-w-lg flex-col rounded-xl border shadow-2xl",
className,
)}
>
{title && (
<div className="flex items-center justify-between border-b border-border px-5 py-4">
<h2 className="text-base font-semibold text-text-primary">{title}</h2>
<div className="border-border flex items-center justify-between border-b px-5 py-4">
<h2 className="text-text-primary text-base font-semibold">{title}</h2>
<button
onClick={onClose}
className="rounded-lg p-1 text-text-muted hover:bg-surface-2 hover:text-text-primary"
className="text-text-muted hover:bg-surface-2 hover:text-text-primary rounded-lg p-1"
>
<X className="h-4 w-4" />
</button>
@@ -52,7 +52,7 @@ export function Modal({ open, onClose, title, children, footer, className }: Mod
)}
<div className="flex-1 overflow-y-auto px-5 py-4">{children}</div>
{footer && (
<div className="flex justify-end gap-2 border-t border-border px-5 py-3">{footer}</div>
<div className="border-border flex justify-end gap-2 border-t px-5 py-3">{footer}</div>
)}
</div>
</div>
+2 -2
View File
@@ -19,7 +19,7 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
return (
<div className="flex flex-col gap-1">
{label && (
<label htmlFor={selectId} className="text-sm font-medium text-text-secondary">
<label htmlFor={selectId} className="text-text-secondary text-sm font-medium">
{label}
</label>
)}
@@ -29,7 +29,7 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
value={value}
onChange={(e) => onChange(e.target.value)}
className={clsx(
"rounded-lg border border-border bg-surface-1 px-3 py-2 text-sm text-text-primary transition-colors focus:outline-none focus:ring-2 focus:ring-accent/50 focus:border-accent",
"focus:ring-accent/50 border-border bg-surface-1 text-text-primary focus:border-accent rounded-lg border px-3 py-2 text-sm transition-colors focus:ring-2 focus:outline-none",
className,
)}
{...props}
+12 -17
View File
@@ -1,4 +1,4 @@
import { useEffect, useMemo, useState } from "react";
import { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { Modal } from "./Modal";
@@ -22,36 +22,33 @@ export function ShortcutHelpModal({ open, onClose }: ShortcutHelpModalProps) {
const { t } = useTranslation("ui");
const [query, setQuery] = useState("");
// Reset the filter every time the modal closes so a re-open starts
// fresh — otherwise the previous filter persists invisibly.
useEffect(() => {
if (!open) setQuery("");
}, [open]);
// A closed modal has no filter. Deriving this rather than resetting `query`
// in an effect means a re-open always starts fresh without an extra render
// pass on every parent update while the modal is closed.
const activeQuery = open ? query : "";
const filtered = useMemo(() => {
const trimmed = query.trim().toLowerCase();
const trimmed = activeQuery.trim().toLowerCase();
if (!trimmed) return SHORTCUTS;
return SHORTCUTS.filter((s) => {
const label = t(s.labelKey).toLowerCase();
return label.includes(trimmed) || s.keys.toLowerCase().includes(trimmed);
});
}, [query, t]);
}, [activeQuery, t]);
return (
<Modal open={open} onClose={onClose} title={t("shortcuts.title")}>
<div className="flex flex-col gap-3">
<input
type="text"
value={query}
value={activeQuery}
onChange={(e) => setQuery(e.target.value)}
placeholder={t("shortcuts.searchPlaceholder")}
className="rounded-lg border border-border bg-surface-1 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted transition-colors focus:border-accent focus:outline-none focus:ring-2 focus:ring-accent/50"
className="focus:ring-accent/50 border-border bg-surface-1 text-text-primary placeholder:text-text-muted focus:border-accent rounded-lg border px-3 py-2 text-sm transition-colors focus:ring-2 focus:outline-none"
autoFocus
/>
{filtered.length === 0 ? (
<p className="py-2 text-sm text-text-muted">
{t("shortcuts.noResults")}
</p>
<p className="text-text-muted py-2 text-sm">{t("shortcuts.noResults")}</p>
) : (
<div className="flex flex-col gap-2">
{filtered.map((s) => (
@@ -59,10 +56,8 @@ export function ShortcutHelpModal({ open, onClose }: ShortcutHelpModalProps) {
key={`${s.keys}-${s.labelKey}`}
className="flex items-center justify-between py-1"
>
<span className="text-sm text-text-secondary">
{t(s.labelKey)}
</span>
<kbd className="rounded bg-surface-2 px-2 py-0.5 font-mono text-xs text-text-primary">
<span className="text-text-secondary text-sm">{t(s.labelKey)}</span>
<kbd className="bg-surface-2 text-text-primary rounded px-2 py-0.5 font-mono text-xs">
{s.keys}
</kbd>
</div>
+42
View File
@@ -0,0 +1,42 @@
import { ShieldAlert } from "lucide-react";
import { useTranslation } from "react-i18next";
import { useSettingsStore } from "@store/settings-store";
import { useEditorIssues } from "@hooks/use-strict-block";
/**
* Lists the fields Strict Mode is blocking on.
*
* A disabled Generate button with no explanation is worse than no gate at all,
* so this always names the offending field and its error. Renders nothing when
* Strict Mode is off or nothing is wrong.
*/
export function StrictModeBanner() {
const { t } = useTranslation("ui");
const strictMode = useSettingsStore((s) => s.strictMode);
const issues = useEditorIssues();
const errors = issues.filter((i) => i.severity === "error");
if (!strictMode || errors.length === 0) return null;
return (
<div
role="alert"
className="border-danger/40 bg-danger/10 text-danger flex flex-col gap-1 rounded-lg border px-3 py-2 text-xs"
>
<span className="flex items-center gap-1.5 font-semibold">
<ShieldAlert className="h-3.5 w-3.5 shrink-0" />
{t("strict.blockedTitle", { count: errors.length })}
</span>
<ul className="flex flex-col gap-0.5 pl-5">
{errors.map((issue) => (
<li key={issue.id}>
<span className="font-medium">{t(issue.labelKey)}</span>
{" — "}
{t(issue.messageKey, issue.params as Record<string, string>)}
</li>
))}
</ul>
<span className="text-text-muted">{t("strict.fixHint")}</span>
</div>
);
}
+2 -2
View File
@@ -13,7 +13,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
return (
<div className="flex flex-col gap-1">
{label && (
<label htmlFor={inputId} className="text-sm font-medium text-text-secondary">
<label htmlFor={inputId} className="text-text-secondary text-sm font-medium">
{label}
</label>
)}
@@ -21,7 +21,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
ref={ref}
id={inputId}
className={clsx(
"min-h-[96px] rounded-lg border bg-surface-1 px-3 py-2.5 text-base text-text-primary placeholder:text-text-muted transition-colors focus:outline-none focus:ring-2 focus:ring-accent/50 resize-y sm:text-sm",
"focus:ring-accent/50 bg-surface-1 text-text-primary placeholder:text-text-muted min-h-[96px] resize-y rounded-lg border px-3 py-2.5 text-base transition-colors focus:ring-2 focus:outline-none sm:text-sm",
error ? "border-danger" : "border-border focus:border-accent",
className,
)}
+2 -2
View File
@@ -16,7 +16,7 @@ export function Toggle({ label, checked, onChange, className }: ToggleProps) {
aria-checked={checked}
onClick={() => onChange(!checked)}
className={clsx(
"relative inline-flex h-6 w-11 shrink-0 rounded-full border-2 border-transparent transition-colors focus:outline-none focus:ring-2 focus:ring-accent/50",
"focus:ring-accent/50 relative inline-flex h-6 w-11 shrink-0 rounded-full border-2 border-transparent transition-colors focus:ring-2 focus:outline-none",
checked ? "bg-accent" : "bg-surface-3",
)}
>
@@ -27,7 +27,7 @@ export function Toggle({ label, checked, onChange, className }: ToggleProps) {
)}
/>
</button>
<span className="text-sm text-text-primary">{label}</span>
<span className="text-text-primary text-sm">{label}</span>
</label>
);
}
+116 -16
View File
@@ -1,10 +1,20 @@
import { useState, useCallback, type ClipboardEvent } from "react";
import { useState, useCallback, useEffect, useRef, type ClipboardEvent } from "react";
import { useTranslation } from "react-i18next";
import type { ValidationResult } from "@utils/validation";
import { usePendingInvalidStore } from "@store/pending-invalid-store";
import clsx from "clsx";
interface ValidatedInputProps {
label: string;
/**
* Stable id matching the one `collectEditorIssues` uses for the same field
* (`storeLinks.steam`, `contactEmail`). Supplying it lets Strict Mode see
* text that is invalid *and therefore never committed to the editor store* —
* without it, such a field is invisible to every gate outside this page.
*/
fieldId?: string;
/** i18n key naming the field in the Strict Mode banner. */
labelKey?: string;
value: string;
onChange: (value: string) => void;
validate: (value: string) => ValidationResult;
@@ -13,6 +23,24 @@ interface ValidatedInputProps {
inputMode?: "text" | "email" | "url" | "numeric" | "tel" | "search" | "decimal";
autoComplete?: string;
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send";
/**
* Hard cap on typed/pasted length — see `src/config/field-limits.ts`. This
* component does not spread props onto the input, so unlike `Input` it needs
* the prop declared explicitly.
*/
maxLength?: number;
/**
* Veto or rewrite a change before it is validated or committed. Return the
* (possibly adjusted) next value to accept it, or `null` to reject the
* keystroke outright, leaving the field exactly as it was.
*
* Used for constraints a validator cannot express without destroying data —
* the three-address email cap, where rejecting the 4th address must not
* disturb the three already typed.
*/
beforeChange?: (next: string, prev: string) => string | null;
/** Shown instead of `helpText` when `beforeChange` rejects a change. */
blockedMessage?: string;
/**
* Forwarded to the inner `<input>`. Used by StoreLinkEditor to sniff a
* pasted URL and auto-fill the Game Name field — see
@@ -24,6 +52,8 @@ interface ValidatedInputProps {
export function ValidatedInput({
label,
fieldId,
labelKey,
value,
onChange,
validate,
@@ -32,41 +62,109 @@ export function ValidatedInput({
inputMode,
autoComplete,
enterKeyHint,
maxLength,
beforeChange,
blockedMessage,
onPaste,
}: ValidatedInputProps) {
const { t } = useTranslation("ui");
const [displayValue, setDisplayValue] = useState(value);
const [error, setError] = useState<string | null>(null);
const [touched, setTouched] = useState(false);
const [blocked, setBlocked] = useState(false);
// Re-sync when the value changes underneath us — applying a profile, preset
// or template, or resetting the editor. Without this the box kept showing
// whatever was typed first and silently disagreed with the store, because
// `useState(value)` only reads the prop on mount.
//
// Guarded on `displayValue` so it never fights the user's own typing: while
// they type, `value` and `displayValue` already agree (or `value` is the last
// valid one, in which case an external change is what we want to adopt).
const lastExternalValue = useRef(value);
useEffect(() => {
if (value !== lastExternalValue.current) {
lastExternalValue.current = value;
setDisplayValue(value);
setError(null);
setBlocked(false);
}
}, [value]);
const handleChange = useCallback(
(newValue: string) => {
setDisplayValue(newValue);
const result = validate(newValue);
(rawValue: string) => {
const next = beforeChange ? beforeChange(rawValue, displayValue) : rawValue;
if (next === null) {
// Rejected outright — leave both the display and the committed value
// untouched so nothing already entered is lost.
setBlocked(true);
setTouched(true);
return;
}
setBlocked(false);
setDisplayValue(next);
lastExternalValue.current = next;
const result = validate(next);
if (result.valid && !result.error) {
// Fully valid: commit the value to the store.
setError(null);
onChange(newValue);
onChange(next);
} else if (result.valid && result.error) {
// Warning (e.g. prefix mismatch from validateUrlWithPrefix).
// Surface the warning but still commit so the user can decide.
setError(t(result.error, result.errorParams as Record<string, string>));
onChange(newValue);
onChange(next);
} else {
// Invalid: show the error and CLEAR the committed value so the
// bad input never reaches the generated description/tags. The
// local displayValue is preserved so the user can keep editing.
// Invalid: surface the error and DON'T commit, so the bad input never
// reaches the generated description/tags.
//
// Before v0.35.0 this branch called `onChange("")`, which wiped the
// stored value while the box still showed the user's text — so
// backspacing one character out of a complete URL silently emptied the
// field, and autosave/profile-save then persisted the empty value with
// no visible signal. Leaving the last valid value in place keeps bad
// input out just as effectively without destroying good input.
setError(t(result.error ?? "", result.errorParams as Record<string, string>));
onChange("");
}
setTouched(true);
},
[validate, onChange, t],
[validate, onChange, t, beforeChange, displayValue],
);
const message = blocked ? (blockedMessage ?? error) : error;
// Publish "this field currently holds text that will not be saved" so gates
// on other pages can see it. Keyed on the raw validation result rather than
// the rendered message, which is already translated and would re-publish on
// every UI-language change.
const liveResult = validate(displayValue);
const isInvalid = blocked || (!liveResult.valid && displayValue.trim() !== "");
const invalidKey = blocked ? "validation.emailMaxReached" : (liveResult.error ?? "");
const invalidParams = JSON.stringify(liveResult.errorParams ?? null);
useEffect(() => {
if (!fieldId) return;
const { markInvalid, clearInvalid } = usePendingInvalidStore.getState();
if (isInvalid) {
const parsed = JSON.parse(invalidParams) as Record<string, string | number> | null;
markInvalid({
id: fieldId,
labelKey: labelKey ?? label,
messageKey: invalidKey,
...(parsed ? { params: parsed } : {}),
});
} else {
clearInvalid(fieldId);
}
// Deliberately NO cleanup on unmount — see the store's doc comment. An
// entry lives until the field is valid again, so navigating to Batch does
// not silently clear the very thing Strict Mode is supposed to catch.
}, [fieldId, labelKey, label, isInvalid, invalidKey, invalidParams]);
return (
<div className="flex flex-col gap-1">
<label className="text-sm font-medium text-text-secondary">{label}</label>
<label className="text-text-secondary text-sm font-medium">{label}</label>
<input
type="text"
value={displayValue}
@@ -77,13 +175,15 @@ export function ValidatedInput({
inputMode={inputMode}
autoComplete={autoComplete}
enterKeyHint={enterKeyHint}
maxLength={maxLength}
aria-invalid={touched && Boolean(message) ? true : undefined}
className={clsx(
"min-h-touch rounded-lg border bg-surface-1 px-3 py-2.5 text-base text-text-primary placeholder:text-text-muted transition-colors focus:outline-none focus:ring-2 focus:ring-accent/50 sm:text-sm",
touched && error ? "border-danger" : "border-border focus:border-accent",
"focus:ring-accent/50 min-h-touch bg-surface-1 text-text-primary placeholder:text-text-muted rounded-lg border px-3 py-2.5 text-base transition-colors focus:ring-2 focus:outline-none sm:text-sm",
touched && message ? "border-danger" : "border-border focus:border-accent",
)}
/>
{touched && error && <p className="text-xs text-danger">{error}</p>}
{helpText && !error && <p className="text-xs text-text-muted">{helpText}</p>}
{touched && message && <p className="text-danger text-xs">{message}</p>}
{helpText && !message && <p className="text-text-muted text-xs">{helpText}</p>}
</div>
);
}
+1 -6
View File
@@ -21,12 +21,7 @@ import {
* - `runtime` — a render crash caught by ErrorBoundary
*/
export type ErrorKind =
| "notFound"
| "forbidden"
| "expired"
| "serverError"
| "offline"
| "runtime";
"notFound" | "forbidden" | "expired" | "serverError" | "offline" | "runtime";
type ErrorSeverity = "accent" | "danger" | "warning";
+74
View File
@@ -0,0 +1,74 @@
import { YT_LIMITS } from "@engine/types";
/**
* Maximum length of every free-text field in the editor.
*
* Until v0.35.0 no input in the app had a cap at all: `maxLength` appeared
* nowhere in the codebase. A pasted novel in the game-name field produced a
* title YouTube would reject, and a 4 KB "URL" silently rode along into the
* description.
*
* Caps are grouped by the *kind* of thing a field holds, not per field, so a
* new input inherits a sensible limit by picking the closest category instead
* of inventing a number. All values are UTF-16 code units, matching the DOM
* `maxLength` attribute — an emoji costs 2 and a flag emoji 4. That is a
* deliberate simplification: grapheme counting would be more "correct" but
* cannot be enforced by the browser, and these are generous ceilings meant to
* stop absurd input, not to budget characters precisely.
*/
export const FIELD_LIMITS = {
/**
* Store pages, social profiles, playlists, community invites. The longest
* realistic value in the app's own inventory is a Signal group invite
* (`https://signal.group/#<base64>`) at roughly 120 characters.
*/
URL: 200,
/**
* Up to three comma-separated addresses. RFC 5321 caps a single address at
* 254, so 200 would be too tight for even one worst-case address; 320 fits
* three ordinary ones with room to spare while still rejecting a paste of
* an entire contact list.
*/
EMAIL_FIELD: 320,
/**
* Game names, channel names, boss / chapter / DLC names, sponsor names,
* hardware model strings, profile and preset names. The longest real game
* titles run to roughly 50 characters.
*/
SHORT_NAME: 100,
/** Custom labels and version strings — a phrase, not a sentence. */
LABEL: 300,
/**
* Music attribution, mod lists, pinned comments, thumbnail text, sponsor
* blurbs, playlist notes. Long enough for a real credits block, short
* enough that no single field can consume the whole description budget.
*/
LONG_TEXT: 2000,
/**
* The timestamps field is the one input that legitimately holds a whole
* chapter list. Capped at the YouTube description limit because a longer
* value could only ever produce a description that is already over budget
* and blocked from copying.
*/
TIMESTAMPS: YT_LIMITS.DESCRIPTION_MAX,
/** Part numbers, years, counts. Ten digits is already absurd for these. */
NUMERIC: 10,
} as const;
/**
* Truncate a value to `max`.
*
* The DOM `maxLength` attribute only constrains *typing and pasting*. Values
* arriving programmatically — a profile / preset / template import, a
* store-link paste that auto-fills the game name, a hand-edited settings JSON
* — bypass it entirely. Run those through here, or the cap is decorative.
*/
export function clampField(value: string, max: number): string {
return value.length > max ? value.slice(0, max) : value;
}
+2 -9
View File
@@ -42,11 +42,7 @@ export type GachaQuestType = (typeof GACHA_QUEST_TYPES)[number];
export const DEFAULT_GACHA_QUEST_TYPE: GachaQuestType = "main_story";
export type GachaQuestTypeGroup =
| "story"
| "events"
| "tutorial_trial"
| "endgame_multiplayer"
| "showcase";
"story" | "events" | "tutorial_trial" | "endgame_multiplayer" | "showcase";
/**
* Display-order grouping for the quest-type dropdown. Each group
@@ -140,10 +136,7 @@ const DEFAULT_FIELD_VISIBILITY: GachaQuestFieldVisibility = {
anniversaryYear: false,
};
export const GACHA_QUEST_FIELD_VISIBILITY: Record<
GachaQuestType,
GachaQuestFieldVisibility
> = {
export const GACHA_QUEST_FIELD_VISIBILITY: Record<GachaQuestType, GachaQuestFieldVisibility> = {
main_story: { ...DEFAULT_FIELD_VISIBILITY, questName: false },
world_quest: { ...DEFAULT_FIELD_VISIBILITY, chapterName: false, partNumber: false },
side_quest: { ...DEFAULT_FIELD_VISIBILITY, chapterName: false, partNumber: false },
+32 -4
View File
@@ -44,7 +44,15 @@ const NVIDIA_SERIES: readonly GpuSeries[] = [
{
id: "rtx_50",
label: "RTX 50 Series",
models: ["RTX 5050", "RTX 5060", "RTX 5060 Ti", "RTX 5070", "RTX 5070 Ti", "RTX 5080", "RTX 5090"],
models: [
"RTX 5050",
"RTX 5060",
"RTX 5060 Ti",
"RTX 5070",
"RTX 5070 Ti",
"RTX 5080",
"RTX 5090",
],
},
{
id: "rtx_40",
@@ -185,12 +193,32 @@ const AMD_SERIES: readonly GpuSeries[] = [
{
id: "r9_300",
label: "Radeon R7/R9 300",
models: ["R7 360", "R7 370", "R9 380", "R9 380X", "R9 390", "R9 390X", "R9 Fury", "R9 Fury X", "R9 Nano"],
models: [
"R7 360",
"R7 370",
"R9 380",
"R9 380X",
"R9 390",
"R9 390X",
"R9 Fury",
"R9 Fury X",
"R9 Nano",
],
},
{
id: "r9_200",
label: "Radeon R7/R9 200",
models: ["R7 250", "R7 260", "R7 260X", "R9 270", "R9 270X", "R9 280", "R9 280X", "R9 290", "R9 290X"],
models: [
"R7 250",
"R7 260",
"R7 260X",
"R9 270",
"R9 270X",
"R9 280",
"R9 280X",
"R9 290",
"R9 290X",
],
},
{
id: "hd_7000",
@@ -253,4 +281,4 @@ export const GPU_CUSTOM_BRAND_ID = "custom";
*/
export function findGpuBrand(brandId: string): GpuBrand | undefined {
return GPU_CATALOG.find((b) => b.id === brandId);
}
}
+1 -6
View File
@@ -26,12 +26,7 @@ export type GraphicsPreset = (typeof GRAPHICS_PRESETS)[number];
* of these layered (e.g. Path Tracing + Ray Reconstruction + Frame
* Generation). Empty array → no RT clause in the description.
*/
export const RT_MODES = [
"ray_tracing",
"full_rt",
"path_tracing",
"ray_reconstruction",
] as const;
export const RT_MODES = ["ray_tracing", "full_rt", "path_tracing", "ray_reconstruction"] as const;
export type RTMode = (typeof RT_MODES)[number];
/**
+2 -5
View File
@@ -21,9 +21,7 @@ export interface PlatformConfig {
* numeric id, yielding the canonical `.../app/<id>` form.
*/
function normalizeSteamUrl(url: string): string {
const match = url.match(
/^(https:\/\/store\.steampowered\.com\/app\/\d+)(?:\/.*)?$/i,
);
const match = url.match(/^(https:\/\/store\.steampowered\.com\/app\/\d+)(?:\/.*)?$/i);
return match?.[1] ?? url;
}
@@ -72,8 +70,7 @@ export const PLATFORMS: readonly PlatformConfig[] = [
urlPrefix: "https://<dev>.itch.io/<game>",
// itch.io games live at https://<dev>.itch.io/<game>, where <dev>
// is a user subdomain. Reject the bare https://itch.io/... host.
urlPattern:
/^https:\/\/[a-z0-9][a-z0-9-]*\.itch\.io\/[a-z0-9][a-z0-9_-]*\/?$/i,
urlPattern: /^https:\/\/[a-z0-9][a-z0-9-]*\.itch\.io\/[a-z0-9][a-z0-9_-]*\/?$/i,
},
{
id: "humble",
+1 -2
View File
@@ -50,8 +50,7 @@ export const PLAYTEST_PLATFORMS: readonly PlaytestPlatformConfig[] = [
id: "itchio",
label: "itch.io",
urlPrefix: "https://<dev>.itch.io/<game>",
urlPattern:
/^https:\/\/[a-z0-9][a-z0-9-]*\.itch\.io\/[a-z0-9][a-z0-9_-]*\/?$/i,
urlPattern: /^https:\/\/[a-z0-9][a-z0-9-]*\.itch\.io\/[a-z0-9][a-z0-9_-]*\/?$/i,
maxInvites: 50,
},
{
+22 -17
View File
@@ -1,9 +1,4 @@
import {
GPU_CATALOG,
GPU_CUSTOM_BRAND_ID,
findGpuBrand,
type GpuCatalog,
} from "./gpu-catalog";
import { GPU_CATALOG, GPU_CUSTOM_BRAND_ID, findGpuBrand, type GpuCatalog } from "./gpu-catalog";
/**
* Supported rig field input types.
@@ -25,11 +20,7 @@ import {
* may opt into a free-text "Custom" override; the stored format is
* pipe-delimited in the order parts are declared.
*/
type RigFieldType =
| "text"
| "dropdown_with_version"
| "cascading_dropdown"
| "composite_dropdown";
type RigFieldType = "text" | "dropdown_with_version" | "cascading_dropdown" | "composite_dropdown";
interface RigFieldOption {
readonly value: string;
@@ -45,8 +36,7 @@ interface RigFieldOption {
* both). Existing static-array call sites continue to work unchanged.
*/
type RigFieldOptionResolver =
| readonly RigFieldOption[]
| ((previousParts: readonly string[]) => readonly RigFieldOption[]);
readonly RigFieldOption[] | ((previousParts: readonly string[]) => readonly RigFieldOption[]);
export interface CompositePart {
/** Stable id, used to assemble the storage tuple in declaration order. */
@@ -344,7 +334,12 @@ const OS_COMPOSITE: CompositeFieldSpec = {
export const RIG_FIELDS: readonly RigField[] = [
{ id: "os", labelKey: "rig.os", type: "composite_dropdown", composite: OS_COMPOSITE },
{ id: "cpu", labelKey: "rig.cpu", type: "text", placeholder: "Intel i9-14900K / AMD Ryzen 9 7950X" },
{
id: "cpu",
labelKey: "rig.cpu",
type: "text",
placeholder: "Intel i9-14900K / AMD Ryzen 9 7950X",
},
{
id: "gpu",
labelKey: "rig.gpu",
@@ -358,10 +353,20 @@ export const RIG_FIELDS: readonly RigField[] = [
composite: RAM_COMPOSITE,
},
{ id: "storage", labelKey: "rig.storage", type: "text", placeholder: "2TB Samsung 990 PRO NVMe" },
{ id: "monitor", labelKey: "rig.monitor", type: "text", placeholder: "LG 27GP950 27\" 4K 144Hz" },
{ id: "monitor", labelKey: "rig.monitor", type: "text", placeholder: 'LG 27GP950 27" 4K 144Hz' },
{ id: "capture", labelKey: "rig.capture", type: "text", placeholder: "OBS Studio 30.x" },
{ id: "motherboard", labelKey: "rig.motherboard", type: "text", placeholder: "ASUS ROG Maximus Z790 Hero" },
{ id: "controller", labelKey: "rig.controller", type: "text", placeholder: "DualSense / Xbox Elite Series 2" },
{
id: "motherboard",
labelKey: "rig.motherboard",
type: "text",
placeholder: "ASUS ROG Maximus Z790 Hero",
},
{
id: "controller",
labelKey: "rig.controller",
type: "text",
placeholder: "DualSense / Xbox Elite Series 2",
},
{
id: "video_editor",
labelKey: "rig.video_editor",
+119 -17
View File
@@ -1,23 +1,125 @@
export const SOCIAL_FIELDS = [
// Donate
{ id: "kofi", label: "Ko-fi", labelKey: "social.kofi", urlPrefix: "https://ko-fi.com/", category: "donate" },
{ id: "patreon", label: "Patreon", labelKey: "social.patreon", urlPrefix: "https://patreon.com/", category: "donate" },
{ id: "buymeacoffee", label: "Buy Me a Coffee", labelKey: "social.buymeacoffee", urlPrefix: "https://buymeacoffee.com/", category: "donate" },
{ id: "paypal", label: "PayPal", labelKey: "social.paypal", urlPrefix: "https://paypal.me/", category: "donate" },
{ id: "streamlabs", label: "Streamlabs", labelKey: "social.streamlabs", urlPrefix: "https://streamlabs.com/", category: "donate" },
{
id: "kofi",
label: "Ko-fi",
labelKey: "social.kofi",
urlPrefix: "https://ko-fi.com/",
category: "donate",
},
{
id: "patreon",
label: "Patreon",
labelKey: "social.patreon",
urlPrefix: "https://patreon.com/",
category: "donate",
},
{
id: "buymeacoffee",
label: "Buy Me a Coffee",
labelKey: "social.buymeacoffee",
urlPrefix: "https://buymeacoffee.com/",
category: "donate",
},
{
id: "paypal",
label: "PayPal",
labelKey: "social.paypal",
urlPrefix: "https://paypal.me/",
category: "donate",
},
{
id: "streamlabs",
label: "Streamlabs",
labelKey: "social.streamlabs",
urlPrefix: "https://streamlabs.com/",
category: "donate",
},
// Social
{ id: "github", label: "GitHub", labelKey: "social.github", urlPrefix: "https://github.com/", category: "social" },
{ id: "twitter", label: "Twitter / X", labelKey: "social.twitter", urlPrefix: "https://x.com/", category: "social" },
{ id: "discord", label: "Discord", labelKey: "social.discord", urlPrefix: "https://discord.gg/", category: "social" },
{ id: "twitch", label: "Twitch", labelKey: "social.twitch", urlPrefix: "https://twitch.tv/", category: "social" },
{ id: "tiktok", label: "TikTok", labelKey: "social.tiktok", urlPrefix: "https://tiktok.com/@", category: "social" },
{ id: "instagram", label: "Instagram", labelKey: "social.instagram", urlPrefix: "https://instagram.com/", category: "social" },
{ id: "bluesky", label: "Bluesky", labelKey: "social.bluesky", urlPrefix: "https://bsky.app/profile/", category: "social" },
{ id: "mastodon", label: "Mastodon", labelKey: "social.mastodon", urlPrefix: "", category: "social" },
{ id: "facebook", label: "Facebook", labelKey: "social.facebook", urlPrefix: "https://facebook.com/", category: "social" },
{ id: "fb_page", label: "Facebook Page", labelKey: "social.fb_page", urlPrefix: "https://facebook.com/", category: "social" },
{
id: "github",
label: "GitHub",
labelKey: "social.github",
urlPrefix: "https://github.com/",
category: "social",
},
{
id: "twitter",
label: "Twitter / X",
labelKey: "social.twitter",
urlPrefix: "https://x.com/",
category: "social",
},
{
id: "discord",
label: "Discord",
labelKey: "social.discord",
urlPrefix: "https://discord.gg/",
category: "social",
},
{
id: "twitch",
label: "Twitch",
labelKey: "social.twitch",
urlPrefix: "https://twitch.tv/",
category: "social",
},
{
id: "tiktok",
label: "TikTok",
labelKey: "social.tiktok",
urlPrefix: "https://tiktok.com/@",
category: "social",
},
{
id: "instagram",
label: "Instagram",
labelKey: "social.instagram",
urlPrefix: "https://instagram.com/",
category: "social",
},
{
id: "bluesky",
label: "Bluesky",
labelKey: "social.bluesky",
urlPrefix: "https://bsky.app/profile/",
category: "social",
},
{
id: "mastodon",
label: "Mastodon",
labelKey: "social.mastodon",
urlPrefix: "",
category: "social",
},
{
id: "facebook",
label: "Facebook",
labelKey: "social.facebook",
urlPrefix: "https://facebook.com/",
category: "social",
},
{
id: "fb_page",
label: "Facebook Page",
labelKey: "social.fb_page",
urlPrefix: "https://facebook.com/",
category: "social",
},
// Facebook Group moved to the Community section in v0.33.0 — it's now a
// dedicated `facebookGroupLink` editor field (see CommunityEditor).
{ id: "telegram", label: "Telegram", labelKey: "social.telegram", urlPrefix: "https://t.me/", category: "social" },
{ id: "website", label: "Website", labelKey: "social.website", urlPrefix: "", category: "social" },
{
id: "telegram",
label: "Telegram",
labelKey: "social.telegram",
urlPrefix: "https://t.me/",
category: "social",
},
{
id: "website",
label: "Website",
labelKey: "social.website",
urlPrefix: "",
category: "social",
},
] as const;
Loaded 100 of 195 files, more files were not shown because too many files have changed in this diff. Show more