Repository navigation
feat: system application to chat #7926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
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
apiQueryThe optional chaining stops at
.find(...), but then.propertiesis accessed without?., and.api_input_field_list.map(...)also lacks?.. If the node isn't found, orproperties/api_input_field_listare undefined, this throws. Fix:2. Values not URL-encoded
default_value(andvariable) may contain spaces,&,=,#, etc., corrupting the query string. UseencodeURIComponent:`${encodeURIComponent(f.variable)}=${encodeURIComponent(f.default_value ?? '')}`3. Double slash in the URL when no query params
`${origin}${chatBasePath}/${token}/${apiQuery(application)}`apiQueryreturns''when empty, so you get.../{token}/with a trailing slash (or/{token}/?a=b). Compare the concatenation carefully — you likely want.../${token}and appendapiQuerydirectly (since it already includes the leading?), or strip the trailing/.4.
window.openwith an empty URLWhen
access_tokenis falsy,accessUrlis''andwindow.open('', '_blank')opens a blank tab. Guard against it or show an error message:5. Unused parameter / typing
ApplicationDetailis imported as a type, good. Butf: anyweakens typing — define an interface for the api field list if available.6. Naming
apiQueryreturns a query string (with leading?); consider renaming tobuildApiQuery/getApiQueryStringfor clarity.7. Error handling in
toChatThe
.thenchain has no.catch; a failed token request produces an unhandled rejection. Add.catch(or useasync/awaitwith 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.
authfrom 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 blockwindow.openif called after an async call (browser loses the "user gesture" context). Callingwindow.opensynchronously and settinglocationafterwards is safer: