Repository navigation
feat: tailor AI generation examples to workflow types - #8191
Conversation
| :suggested-requirements="suggestedRequirements" | ||
| :default-model-settings="defaultModelSettings" | ||
| :workflow-mode="WorkflowMode.Knowledge" | ||
| /> |
There was a problem hiding this comment.
Here's my review of the diff:
Potential Issues
-
computedvs static array:suggestedRequirementsis acomputed, which is fine if the i18n locale can change at runtime (so it re-translates). However, if you want this behavior, ensure downstream components actually react to prop changes. If locale never changes after mount, a plainconstwitht(...)would suffice — butcomputedis safer overall. -
useI18n({ useScope: 'global' }): Confirmed intentional for global scope. Just verify this component isn't expected to inherit local/component-scoped translations from a parent — otherwise translations may resolve differently than expected. -
Prop typing for
suggested-requirements: The new propsuggestedRequirementsis passed toAiGeneratePanel, but the diff doesn't show it being added to that component'sdefineProps. ConfirmAiGeneratePanel.vuewas updated to accept it (otherwise Vue will warn about an unknown attribute and it'll fall through to the root element instead of being used). -
Reactive identity churn: Because it's a
computed, the array reference only changes when its dependencies change. That's good — but ifAiGeneratePaneluses a deep watcher on this prop, it won't be triggered by reference-stable recomputations (it won't recompute unless deps change anyway). Just something to be aware of. -
Comment accuracy: The comment was changed from "AI 生成智能体工作流" (intelligent agent workflow) to "AI 生成知识库工作流" (knowledge base workflow). Ensure this reflects the actual purpose — the button now targets
WorkflowMode.Knowledge. Looks consistent. ✔ -
Missing trailing comma in emit type:
defineEmits<{ open: [] }>()lacks a trailing comma (open: [],). Minor style nit — align with your ESLint/prettier config.
Optimization Suggestions
-
Static keys → dynamic iteration: You could derive suggestions via a key list to avoid repetition:
const suggestionKeys = [ 'workflow.aiGeneration.knowledgeExamples.documentParsing', 'workflow.aiGeneration.knowledgeExamples.segmentQuestions', 'workflow.aiGeneration.knowledgeExamples.documentTags', ] as const const suggestedRequirements = computed(() => suggestionKeys.map((k) => t(k)))
This keeps translation keys centralized and easier to extend or i18n-lint.
-
Type safety for i18n keys: If
vue-i18nis configured with typed schema ($ttyping /strictMessage), consider using typed message keys so invalid keys are caught at compile time rather than silently falling back. -
useTemplateRefgeneric: Already correctly typed viaInstanceType<typeof AiGeneratePanel>. Good. -
Consider
computeddeprecation of redundant calls:tfrom global scope is stable; no issue. But if translation functions return reactive refs in some setups,.valuehandling might be needed — verify your vue-i18n version semantics (v9+ fine).
Summary
The diff looks correct overall. The main actionable item is verifying AiGeneratePanel declares the new suggestedRequirements prop, plus optionally centralizing the translation keys into an array for maintainability.
| :suggested-requirements="suggestedRequirements" | ||
| :default-model-settings="defaultModelSettings" | ||
| :workflow-mode="WorkflowMode.Tool" | ||
| /> |
There was a problem hiding this comment.
Here are the issues and suggestions I found:
1. useI18n scope mismatch (likely bug)
const { t } = useI18n({ useScope: 'global' })- If the project relies on local (component-scoped) translations for these keys, using
globalscope will fail to resolve them and fall back to the raw key string. - Conversely, if you genuinely want global scope, that's fine — but verify consistency with how other components in this repo call
useI18n. Mixing scopes is a common source of "missing translation" bugs. - Suggestion: Confirm which scope the
workflow.aiGeneration.toolExamples.*keys are registered under.
2. computed for static i18n strings – check reactivity correctness
const suggestedRequirements = computed(() => [ t(...), t(...), t(...) ])- This correctly re-evaluates when the locale changes, which is good.
- However,
tfromuseI18nis reactive in Vue-i18n v9+, so this works. Just ensurevue-i18nversion is ≥9; in older versions reactive locale switching behavior differs. - Minor: The computed returns a new array each time. If passed as a prop that triggers watchers/
v-fordiffing downstream, consider whetherAiGeneratePanelneeds a stable reference (usually fine).
3. Comment change may be misleading
- <!-- AI 生成智能体工作流 -->
+ <!-- AI 生成工具工作流 -->- Ensure this reflects the actual
WorkflowMode.Toolbehavior. It matchesworkflow-mode="WorkflowMode.Tool", so likely a correct terminology fix. Good catch — but double-check no leftover references to "智能体" elsewhere.
4. Prop ordering / style nit
:suggested-requirementswas inserted between:get-logic-flowand:default-model-settings. No functional issue, just keep attribute ordering consistent with lint rules (some teams sort alphabetically).
5. suggestedRequirements as a required vs optional prop
- Verify
AiGeneratePaneldefinessuggestedRequirementsas a prop. If it doesn't yet exist in that component, this will silently pass an undeclared attr (falls through to$attrs). Make sure the child component declares it.
6. Import ordering
import { compute, ... }— new imports placed with type imports interleaved; ensure ESLintimport/orderis satisfied (value imports generally before type-only imports, or as configured).
7. disabled variable
:disabled="disabled"— confirmdisabledis defined (either viawithDefaults/destructure or inherited). Not shown in the diff, so assuming it pre-exists.
8. Performance — negligible, but note three t() calls run on every locale change only (good). No concern.
Summary of action items:
- ✅ Verify
useI18nscope matches where translation keys live (most important). - ✅ Confirm all three translation keys exist in both languages.
- ✅ Ensure
AiGeneratePaneldeclares the newsuggested-requirementsprop. ⚠️ Check import ordering against lint config.- ℹ️ The comment/terminology update looks correct.
| :suggested-requirements="suggestedRequirements" | ||
| :default-model-settings="defaultModelSettings" | ||
| :workflow-mode="WorkflowMode.Application" | ||
| /> |
There was a problem hiding this comment.
Here's my review:
Issues & Observations
-
useI18nscope mismatch risk: UsinguseScope: 'global'is fine, but ensure the parent app actually initializes a global i18n instance (viacreateI18n). If the component is rendered in isolation or in tests without a global instance, this will throw. Consider whetheruseScope: 'local'with a localmessagesdefinition would be more appropriate for testability. -
computedrecomputation:suggestedRequirementsis a computed returning an array of translated strings. This correctly re-evaluates when locale changes — good. However, since it produces a new array reference on every locale change, verify that the childAiGeneratePaneldoesn't use this prop as awatchsource without guarding against unnecessary churn (it likely won't recompute per render becausecomputedcaches until deps change — so this is fine). -
Missing
keystability: IfAiGeneratePanelrenders these suggestions viav-forwithout keys, translated strings are used as content but not identity. Not visible here, but confirm keys are stable (e.g., index or a fixed ID) rather than the translated text itself. -
i18n key coverage: Ensure the three keys exist in all locale files:
workflow.aiGeneration.applicationExamples.productSupportworkflow.aiGeneration.applicationExamples.pricingworkflow.aiGeneration.applicationExamples.humanSupport
A missing key causes a visible fallback warning. Consider adding a type-augmentation for i18n keys (
vue-i18nsupports typed keys) to catch this at compile time. -
Import ordering / style: New imports were added but
import { computed, useTemplateRef } from 'vue'now mixes a macro-adjacent import with reactivity imports. Fine, but consistent alphabetical grouping may help if linting enforces it. -
No
readonly/ type annotation: The computed's inferred type isComputedRef<string[]>. That's acceptable; explicit typing isn't required. -
Performance: Negligible — three
t()calls inside a computed. No issue. -
Naming:
suggestedRequirementsmatches the prop name in the child (:suggested-requirements), good kebab-case binding.
Suggestions
- Add typed i18n keys (via
defineI18nMessagePathor the schema augmentation) to prevent silent missing translations. - Consider moving the example list to a constant of keys (rather than calling
t()inline) if you want to reuse them elsewhere:This also improves readability and easier unit testing.const EXAMPLE_KEYS = [ 'workflow.aiGeneration.applicationExamples.productSupport', ... ] as const const suggestedRequirements = computed(() => EXAMPLE_KEYS.map(k => t(k)))
- If the component is tested independently, mock
useI18nor wrap in a global i18n plugin fixture.
Overall the change is small and correct; the main thing to verify is global i18n availability and translation key coverage.
feat: tailor AI generation examples to workflow types