Skip to content

feat: system application to chat - #7926

Merged
fit2cloudwxx merged 1 commit into
v3from
pr@v3@feat_sysApplicationToChat
Nov 16, 2026
Merged

fit2cloudwxx merged 1 commit into
v3from
pr@v3@feat_sysApplicationToChat

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

feat: system application to chat

@fit2cloudwxx
fit2cloudwxx merged commit 9c21e2c into v3 Nov 16, 2026
3 of 4 checks passed
@fit2cloudwxx
fit2cloudwxx deleted the pr@v3@feat_sysApplicationToChat branch November 16, 2026 01:55
<el-button text type="primary" @click="toChat(row)">
<MkIcon name="icon_new-chat_outlined" />
</el-button>
</MkTooltip>

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:

1. Potential runtime crash in apiQuery

application?.work_flow?.nodes?.find(...)?.properties?.api_input_field_list.map(...)

The optional chaining stops at .find(...), but then .properties is accessed without ?., and .api_input_field_list.map(...) also lacks ?.. If the node isn't found, or properties / api_input_field_list are undefined, this throws. Fix:

const query = application?.work_flow?.nodes
  ?.find(n => n.id === 'base-node')
  ?.properties?.api_input_field_list
  ?.map((f: any) => `${f.variable}=${f.default_value}`)
  .join('&')

2. Values not URL-encoded
default_value (and variable) may contain spaces, &, =, #, etc., corrupting the query string. Use encodeURIComponent:

`${encodeURIComponent(f.variable)}=${encodeURIComponent(f.default_value ?? '')}`

3. Double slash in the URL when no query params

`${origin}${chatBasePath}/${token}/${apiQuery(application)}`

apiQuery returns '' when empty, so you get .../{token}/ with a trailing slash (or /{token}/?a=b). Compare the concatenation carefully — you likely want .../${token} and append apiQuery directly (since it already includes the leading ?), or strip the trailing /.

4. window.open with an empty URL
When access_token is falsy, accessUrl is '' and window.open('', '_blank') opens a blank tab. Guard against it or show an error message:

if (!ok.access_token) { /* show toast */ return }

5. Unused parameter / typing
ApplicationDetail is imported as a type, good. But f: any weakens typing — define an interface for the api field list if available.

6. Naming
apiQuery returns a query string (with leading ?); consider renaming to buildApiQuery / getApiQueryString for clarity.

7. Error handling in toChat
The .then chain has no .catch; a failed token request produces an unhandled rejection. Add .catch (or use async/await with try/catch).

8. Re-entrancy on button click
No loading state preventing multiple rapid clicks → multiple tabs. Consider disabling/spinner while the request is in-flight.

9. auth from store appears unused in this snippet — unrelated to this diff but verify it's still needed after the import changes.

10. Global state mutation via window.open — popup blockers may block window.open if called after an async call (browser loses the "user gesture" context). Calling window.open synchronously and setting location afterwards is safer:

const win = window.open('', '_blank')
// ...after await...
win.location.href = accessUrl

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