Skip to content

Batch 1 (Tina 反馈 P0): Copy 按钮兜底 + 任务模板中英本地化#2

Merged
Vector897 merged 2 commits into
mainfrom
fix/tina-batch1-copy-i18n
Jul 15, 2026
Merged

Batch 1 (Tina 反馈 P0): Copy 按钮兜底 + 任务模板中英本地化#2
Vector897 merged 2 commits into
mainfrom
fix/tina-batch1-copy-i18n

Conversation

@Vector897

Copy link
Copy Markdown
Owner

Vector897 and others added 2 commits July 15, 2026 15:06
navigator.clipboard is undefined outside secure contexts (HTTPS/localhost),
so the copy silently failed on the plain-HTTP public demo. Fall back to
document.execCommand('copy') and show a manual-copy hint if both paths fail.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Task-picker templates are backend-provided display copy but were English-only,
so the Tasks page showed English cards even with the UI switched to Chinese.
Make templates bilingual and localize them per request language via
GET /api/tasks/templates?lang=; the frontend re-fetches on language change.
Functional keys (id/task_type/field key/type/default) stay language-independent.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot AI review requested due to automatic review settings July 15, 2026 14:07

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 addresses two UX P0 items: (1) make the Deploy page “Copy” button work reliably even in non-secure (HTTP) contexts, and (2) localize task templates (names/descriptions/field labels/placeholders) between English and Chinese end-to-end via a lang query param.

Changes:

  • Refetch task templates when UI language changes so the template picker shows localized copy.
  • Add clipboard-copy fallback (execCommand) + failure hint messaging on the Deploy page.
  • Introduce bilingual template definitions on the server and a localized /api/tasks/templates?lang= response.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
web/app/tasks/page.tsx Refetch templates on lang changes so the picker follows UI language.
web/app/deploy/page.tsx Adds clipboard fallback + user-facing failure hint for blocked auto-copy environments.
server/app/core/engine/task_templates.py Converts template display strings to bilingual dicts and adds localized_templates().
server/app/api/tasks.py Updates templates endpoint to accept lang and return localized templates.

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

Comment thread web/app/tasks/page.tsx
Comment on lines +39 to +42
// Templates carry backend-provided display copy; re-fetch on language change so the picker follows the UI language.
useEffect(() => {
api(`/api/tasks/templates?lang=${lang}`).then(setTemplates).catch(() => {});
}, [lang]);
Comment thread web/app/deploy/page.tsx
Comment on lines +42 to +56
function legacyCopy() {
try {
const ta = document.createElement("textarea");
ta.value = PROMPT;
ta.setAttribute("readonly", "");
ta.style.position = "fixed";
ta.style.left = "-9999px";
document.body.appendChild(ta);
ta.select();
const ok = document.execCommand("copy");
document.body.removeChild(ta);
ok ? done() : setFailed(true);
} catch {
setFailed(true);
}
Comment on lines 136 to 141
if f["type"] == "text" and not str(val).strip():
# text fields without a default are required: an empty query makes the arXiv API error out directly and the task is bound to fail
raise ValueError(f"Field '{f['label']}' is required")
raise ValueError(f"Field '{_pick(f['label'], 'en')}' is required")
params[f["key"]] = val
title = f"{tpl['name']}: {params.get('query', '')}".strip(": ")[:60]
title = f"{_pick(tpl['name'], 'en')}: {params.get('query', '')}".strip(": ")[:60]
return tpl["task_type"], params, title
@Vector897
Vector897 merged commit 1f3150a into main Jul 15, 2026
1 check passed
@Vector897
Vector897 deleted the fix/tina-batch1-copy-i18n branch July 15, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants