Skip to content

feat: url upload - #7928

Merged
wangdan-fit2cloud merged 2 commits into
v3from
pr@v3@feat_url_upload
Nov 16, 2026
Merged

wangdan-fit2cloud merged 2 commits into
v3from
pr@v3@feat_url_upload

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

feat: url upload
feat: url upload

@wangdan-fit2cloud
wangdan-fit2cloud merged commit cb371ed into v3 Nov 16, 2026
3 of 4 checks passed
@wangdan-fit2cloud
wangdan-fit2cloud deleted the pr@v3@feat_url_upload branch November 16, 2026 02:41
</el-button>
</div>
</el-popover>
</template>

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.

Overall the component is structurally fine, but there are a few important risks and some minor improvements:

1. Pinia store destructuring can break reactivity

If useMessageInputStore() is a Pinia store, direct destructuring of state/getters loses reactivity:

const { canUpload, uploadEnabled, urlUploading, urlUploadTypes, disabled, streamLoading } =
  useMessageInputStore()

This is especially suspicious because the code later uses urlUploadTypes.value, disabled.value, etc. Use storeToRefs for state/getters and keep actions from the store itself:

import { storeToRefs } from 'pinia'

const store = useMessageInputStore()
const {
  canUpload,
  uploadEnabled,
  urlUploading,
  urlUploadTypes,
  disabled,
  streamLoading,
} = storeToRefs(store)
const { addUrls } = store

If this is not a Pinia store but a custom composable returning refs, then ignore this point.

2. confirm() depends on addUrls return semantics

if (urls.value.length && (await addUrls(urls.value, selectedType.value))) visible.value = false

If addUrls returns void/undefined on success, the popover will never close. Also, if addUrls rejects, the error is unhandled. Make the success contract explicit:

async function confirm() {
  if (!urls.value.length || urlUploading.value) return

  try {
    const success = await addUrls(urls.value, selectedType.value)
    if (success) visible.value = false
  } catch (error) {
    // Keep the popover open; show/handle the error via store/message
  }
}

If addUrls does not return a boolean, close the popover after a successful await instead.

3. Close the popover when canUpload becomes false

Currently only disabled and streamLoading close the popover:

watch([disabled, streamLoading], () => {
  if (disabled.value || streamLoading.value) visible.value = false
})

If canUpload becomes false while the popover is open, it can remain open. Include it:

watch(
  [canUpload, disabled, streamLoading],
  ([can, isDisabled, loading]) => {
    if (!can || isDisabled || loading) visible.value = false
  },
  { immediate: true },
)

4. Hard-coded selectedType may be invalid

const selectedType = ref<...>('document_list')

If 'document_list' is not present in urlUploadTypes, this can cause a type/value mismatch. Prefer initializing from the first available option, or make selectedType possibly undefined and disable submit until it is set. Also, when urlUploadTypes becomes empty, the old selected value remains. The submit button is disabled, but the select may show a stale value.

5. Consider deduplicating and validating URLs

urls currently allows duplicate addresses. You may want:

const urls = computed(() =>
  [...new Set(
    addresses.value
      .split(/\r?\n|\r/)
      .map((address) => address.trim())
      .filter(Boolean),
  )],
)

Also consider basic client-side URL validation for better UX, but do not rely on it for security. If the backend fetches these URLs, enforce server-side URL validation and SSRF protection.

6. cancel is still enabled during urlUploading

The cancel button can close the popover while an upload is in progress. If that is not desired, disable it while urlUploading is true, or clearly allow the upload to continue in the background.

7. Icon-only button is missing an accessible label

<el-button text :disabled="!canUpload">
  <MkIcon name="icon_attachment_outlined" :size="18" ... />
</el-button>

Add aria-label and/or a tooltip:

<el-button text :disabled="!canUpload" aria-label="Open URL/local upload">

8. Verify custom Tailwind classes

flex-between, w-15!, text-N900!, and my-4! look like custom utilities or Tailwind-version-specific important syntax. In default Tailwind, w-15 is not a standard spacing class. Verify these classes are defined/configured. Otherwise use standard utilities such as flex items-center justify-between, w-[15rem], etc.

9. Possible double padding in the popover

Element Plus popover content may already have default padding in some versions. The inner <div class="p-4"> can cause extra spacing. Verify visually; if so, remove p-4 or customize the popover padding.

10. localUpload button safety

The local upload button is disabled by urlUploading || !canUpload, but not explicitly by disabled or streamLoading. If canUpload does not already include those states, add them:

:disabled="urlUploading || !canUpload || disabled || streamLoading"

11. Minor: @after-leave only resets addresses

If you want a full reset, also reset selectedType to the first available type. If preserving the last selected type is intentional, this is fine.

12. Verify MkIcon registration

Ensure MkIcon is globally registered or imported. Otherwise the template will fail at runtime.

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