Batch 1 (Tina 反馈 P0): Copy 按钮兜底 + 任务模板中英本地化#2
Merged
Conversation
Vector897
commented
Jul 15, 2026
Owner
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]>
There was a problem hiding this comment.
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 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 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.