Skip to content

feat: tailor AI generation examples to workflow types - #8191

Merged
wangdan-fit2cloud merged 1 commit into
v3from
pr@v3@fix_aigeneration_examples
Nov 26, 2026
Merged

wangdan-fit2cloud merged 1 commit into
v3from
pr@v3@fix_aigeneration_examples

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

feat: tailor AI generation examples to workflow types

:suggested-requirements="suggestedRequirements"
:default-model-settings="defaultModelSettings"
:workflow-mode="WorkflowMode.Knowledge"
/>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here's my review of the diff:

Potential Issues

  1. computed vs static array: suggestedRequirements is a computed, 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 plain const with t(...) would suffice — but computed is safer overall.

  2. 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.

  3. Prop typing for suggested-requirements: The new prop suggestedRequirements is passed to AiGeneratePanel, but the diff doesn't show it being added to that component's defineProps. Confirm AiGeneratePanel.vue was 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).

  4. Reactive identity churn: Because it's a computed, the array reference only changes when its dependencies change. That's good — but if AiGeneratePanel uses 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.

  5. 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. ✔

  6. Missing trailing comma in emit type: defineEmits<{ open: [] }>() lacks a trailing comma (open: [],). Minor style nit — align with your ESLint/prettier config.

Optimization Suggestions

  1. 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.

  2. Type safety for i18n keys: If vue-i18n is configured with typed schema ($t typing / strictMessage), consider using typed message keys so invalid keys are caught at compile time rather than silently falling back.

  3. useTemplateRef generic: Already correctly typed via InstanceType<typeof AiGeneratePanel>. Good.

  4. Consider computed deprecation of redundant calls: t from global scope is stable; no issue. But if translation functions return reactive refs in some setups, .value handling 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.

@wangdan-fit2cloud
wangdan-fit2cloud merged commit 26116ba into v3 Nov 26, 2026
3 of 4 checks passed
@wangdan-fit2cloud
wangdan-fit2cloud deleted the pr@v3@fix_aigeneration_examples branch November 26, 2026 10:51
:suggested-requirements="suggestedRequirements"
:default-model-settings="defaultModelSettings"
:workflow-mode="WorkflowMode.Tool"
/>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 global scope 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, t from useI18n is reactive in Vue-i18n v9+, so this works. Just ensure vue-i18n version 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-for diffing downstream, consider whether AiGeneratePanel needs a stable reference (usually fine).

3. Comment change may be misleading

-  <!-- AI 生成智能体工作流 -->
+  <!-- AI 生成工具工作流 -->
  • Ensure this reflects the actual WorkflowMode.Tool behavior. It matches workflow-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-requirements was inserted between :get-logic-flow and :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 AiGeneratePanel defines suggestedRequirements as 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 ESLint import/order is satisfied (value imports generally before type-only imports, or as configured).

7. disabled variable

  • :disabled="disabled" — confirm disabled is defined (either via withDefaults/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 useI18n scope matches where translation keys live (most important).
  • ✅ Confirm all three translation keys exist in both languages.
  • ✅ Ensure AiGeneratePanel declares the new suggested-requirements prop.
  • ⚠️ Check import ordering against lint config.
  • ℹ️ The comment/terminology update looks correct.

:suggested-requirements="suggestedRequirements"
:default-model-settings="defaultModelSettings"
:workflow-mode="WorkflowMode.Application"
/>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here's my review:

Issues & Observations

  1. useI18n scope mismatch risk: Using useScope: 'global' is fine, but ensure the parent app actually initializes a global i18n instance (via createI18n). If the component is rendered in isolation or in tests without a global instance, this will throw. Consider whether useScope: 'local' with a local messages definition would be more appropriate for testability.

  2. computed recomputation: suggestedRequirements is 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 child AiGeneratePanel doesn't use this prop as a watch source without guarding against unnecessary churn (it likely won't recompute per render because computed caches until deps change — so this is fine).

  3. Missing key stability: If AiGeneratePanel renders these suggestions via v-for without 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.

  4. i18n key coverage: Ensure the three keys exist in all locale files:

    • workflow.aiGeneration.applicationExamples.productSupport
    • workflow.aiGeneration.applicationExamples.pricing
    • workflow.aiGeneration.applicationExamples.humanSupport

    A missing key causes a visible fallback warning. Consider adding a type-augmentation for i18n keys (vue-i18n supports typed keys) to catch this at compile time.

  5. 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.

  6. No readonly / type annotation: The computed's inferred type is ComputedRef<string[]>. That's acceptable; explicit typing isn't required.

  7. Performance: Negligible — three t() calls inside a computed. No issue.

  8. Naming: suggestedRequirements matches the prop name in the child (:suggested-requirements), good kebab-case binding.

Suggestions

  • Add typed i18n keys (via defineI18nMessagePath or 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:
    const EXAMPLE_KEYS = [
      'workflow.aiGeneration.applicationExamples.productSupport',
      ...
    ] as const
    const suggestedRequirements = computed(() => EXAMPLE_KEYS.map(k => t(k)))
    This also improves readability and easier unit testing.
  • If the component is tested independently, mock useI18n or 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.

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