Repository navigation
fix: Execution details and display sources on the debug conversation page should remain visible at all times. #7810
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -214,6 +214,15 @@ def list(self): | |
| queryset = self.get_queryset() | ||
| return [ChatRecordSerializerModel(r).data for r in queryset] | ||
|
|
||
| def debug_page(self, current_page, page_size): | ||
| self.is_valid(raise_exception=True) | ||
| application_access_token = ( | ||
| QuerySet(ApplicationAccessToken).filter(application_id=self.data.get("application_id")).first() | ||
| ) | ||
| return ApplicationChatRecordQuerySerializers( | ||
| data={"application_id": self.data.get("application_id"), "chat_id": self.data.get("chat_id")} | ||
| ).page(current_page, page_size, show_source=True, show_exec=True) | ||
|
|
||
| def page(self, current_page, page_size): | ||
| self.is_valid(raise_exception=True) | ||
| application_access_token = ( | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is an analysis of the added 🚨 Critical Issues
💡 Optimization & Style Suggestions
✅ Recommended Refactored Code def debug_page(self, current_page, page_size):
self.is_valid(raise_exception=True)
app_id = self.data.get("application_id")
chat_id = self.data.get("chat_id")
# Option A: Remove if token check isn't enforced here
# Option B: Add check if token is required:
# if not ApplicationAccessToken.objects.filter(application_id=app_id).exists():
# raise PermissionError("Invalid application")
return ApplicationChatRecordQuerySerializers(
data={"application_id": app_id, "chat_id": chat_id}
).page(current_page, page_size, show_source=True, show_exec=True)🔐 Security ReminderEnsure the route exposing |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,11 +28,17 @@ const tokenPercentage = computed(() => { | |
| const userPwdDialogRef = useTemplateRef<InstanceType<typeof UserPwdDialog>>('userPwdDialogRef') | ||
| const apiKeyDialogRef = useTemplateRef<InstanceType<typeof ApiKeyDialog>>('apiKeyDialogRef') | ||
|
|
||
| // 退出对话账号后重新导航,由守卫处理后续认证。 | ||
| // 退出对话账号后回到当前场景首页,不停留在上一用户的对话;由守卫决定匿名认证或跳转登录页。 | ||
| const handleLogout = () => { | ||
| return auth | ||
| .logout() | ||
| .then(() => router.replace({ path: router.currentRoute.value.fullPath, force: true })) | ||
| .then(() => | ||
| router.replace( | ||
| route.meta.portal | ||
| ? { name: 'portal-application-list', force: true } | ||
| : { name: 'chat-home', params: { accessToken: route.params.accessToken }, force: true }, | ||
| ), | ||
| ) | ||
| .catch(() => {}) | ||
| } | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is a code review for the provided snippet. Critical Issues
Optimization & Suggestions
Refactored Exampleconst handleLogout = async () => {
try {
await auth.logout();
// Determine target route based on current context
const targetRoute = route.meta.portal
? { name: 'portal-application-list', force: true }
: {
name: 'chat-home',
params: { accessToken: route.params.accessToken },
force: true
};
await router.replace(targetRoute);
} catch (error) {
console.error('Logout failed:', error);
}
};Summary of Changes
|
||
|
|
||
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.
Changing method names from
pagetodebug_pageintroduces several risks and poor practices:serializer.page()was part of the public or internal contract, renaming it todebug_page()breaks any other code or tests relying on the original method name on this serializer.Recommendation:
Revert to
result.success(serializer.page(current_page, page_size)).If you intentionally need debug-only behavior (e.g., returning raw data or extra fields), implement it via a configuration flag or separate endpoint, not by altering the core pagination method's name in production code paths.