Skip to content

fix(treetest): make parent-node Select button translatable - #18

Merged
aar0npal merged 1 commit into
mainfrom
fix/translate-parent-node-select-button
Jul 14, 2026
Merged

fix(treetest): make parent-node Select button translatable#18
aar0npal merged 1 commit into
mainfrom
fix/translate-parent-node-select-button

Conversation

@aar0npal

@aar0npal aar0npal commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #17 — the "Select" button shown on parent nodes (when "allow non-leaf answers" is enabled) was hardcoded in English at tree-test.tsx, so it stayed untranslated even when a study used a language preset, and it couldn't be customized in the test configuration.

This threads a new selectAsAnswer custom text through the existing custom-text pipeline, exactly like findItHere:

  • DB: new nullable select_as_answer_text column on tree_configs (migration 0008). Existing studies with a NULL value fall back to the English default via the same || fallback pattern used by every other custom text, so no backfill is needed.
  • Language presets (languages.ts): selectAsAnswer added to all six presets — en "Select", es "Seleccionar", fr "Sélectionner", de "Auswählen", pt "Selecionar", it "Seleziona".
  • Participant UI (tree-test.tsx): uses config.customText.selectAsAnswer instead of the hardcoded literal.
  • Setup UI (messages-tab.tsx): new "Select Button" input in the Tree Navigation section; switching a language preset picks it up automatically since presets spread the full customText object.
  • Setup tree preview (tree-preview.tsx / tree-tab.tsx): the participant-view mock now shows the configured label.
  • Server actions (actions.ts): the create/save/load paths read and write the new column.

Test plan

  • tsc --noEmit, oxlint, and oxfmt --check pass
  • Apply migration (npm run db:migrate / db:push)
  • Set language preset to German in setup → Messages tab shows "Auswählen" in the new Select Button field
  • Preview a study with non-leaf answers enabled → parent-node button shows the configured text
  • Existing study without the field saved → button still shows "Select"

The non-leaf "Select" button was hardcoded in English and couldn't be
customized, unlike every other participant-facing label. Thread a new
selectAsAnswer custom text through the existing pipeline:

- new nullable select_as_answer_text column on tree_configs (falls back
  to the language preset default for existing studies)
- selectAsAnswer added to all six language presets
- editable in the Messages tab next to the other tree navigation labels
- setup tree preview mirrors the configured label

Fixes #17
Copilot AI review requested due to automatic review settings July 14, 2026 19:02
@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
usabilitree Ready Ready Preview, Comment Jul 14, 2026 7:04pm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes issue #17 by making the parent-node “Select” button label part of the existing Tree Test custom-text + language-preset pipeline, so it can be translated via presets and customized per study configuration.

Changes:

  • Adds a new selectAsAnswer custom-text field end-to-end (types → DB column → server actions → participant UI).
  • Extends all language presets with a localized selectAsAnswer string.
  • Exposes the new label in the setup Messages tab and wires it into the setup preview.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/lib/types/tree-test.ts Adds selectAsAnswer to typed custom-text shapes used across setup and runtime config.
src/lib/treetest/actions.ts Persists/loads selectAsAnswerText in create/save/load + includes it in loaded test config.
src/lib/languages.ts Adds selectAsAnswer to the translation interface and all preset definitions.
src/db/schema.ts Adds selectAsAnswerText column mapping for tree_configs.
src/components/tree-test.tsx Replaces the hardcoded “Select” with config.customText.selectAsAnswer in participant UI.
src/components/tree-preview.tsx Threads a configurable label into the setup preview’s participant-view mock.
src/app/(main)/treetest/setup/[id]/_components/tree-tab.tsx Passes the configured selectAsAnswer text into the preview component.
src/app/(main)/treetest/setup/[id]/_components/setup-tabs.tsx Initializes customText.selectAsAnswer in the setup form state.
src/app/(main)/treetest/setup/[id]/_components/messages-tab.tsx Adds a new input to edit the Select button label in setup UI.
drizzle/0008_peaceful_apocalypse.sql Migration adding select_as_answer_text to tree_configs.
drizzle/meta/0008_snapshot.json Drizzle snapshot update reflecting the new column.
drizzle/meta/_journal.json Drizzle journal update registering migration 0008.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@greptile-apps

greptile-apps Bot commented Jul 14, 2026

Copy link
Copy Markdown

Greptile Summary

This PR makes the parent-node Select button configurable and translatable.

  • Adds selectAsAnswer to language presets and form types.
  • Persists the text in tree_configs with a new migration.
  • Uses the configured label in participant and setup-preview views.

Confidence Score: 5/5

This looks safe to merge.

No blocking issues found in the changed code.

T-Rex T-Rex Logs

What T-Rex did

  • Observed the initial UI state where the default Select Button value and the participant parent-node button display Select.
  • Triggered a German locale selection and confirmed the Select Button field and participant preview button update to Auswählen.
  • Confirmed runtime evidence was preserved, including server, browser-console, capture script, and typecheck outputs.
  • Captured before and after-state visuals (screenshots and videos) to document the UI transitions.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
drizzle/0008_peaceful_apocalypse.sql Adds a nullable column for the new custom label.
src/db/schema.ts Maps the new nullable database column in the tree config schema.
src/lib/treetest/actions.ts Creates, saves, and loads the Select label with an existing-study fallback.
src/lib/languages.ts Adds Select-label translations to every language preset.
src/app/(main)/treetest/setup/[id]/_components/messages-tab.tsx Adds an editable Select Button message field.
src/components/tree-test.tsx Passes the configured Select label to participant navigation.
src/components/tree-preview.tsx Renders the configured Select label in the setup participant preview.

Reviews (1): Last reviewed commit: "fix(treetest): make parent-node Select b..." | Re-trigger Greptile

@aar0npal
aar0npal merged commit bba1866 into main Jul 14, 2026
6 checks passed
@aar0npal
aar0npal deleted the fix/translate-parent-node-select-button branch July 14, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Translation Does Not Apply to Parent Node Selection Button

2 participants