Skip to content

fix: skip canvas SSE fetch in chat shared page to eliminate spurious 103 error#14190

Merged
yuzhichang merged 8 commits intoinfiniflow:mainfrom
euvre:skip-some-hint-in-shared-chat
Apr 27, 2026
Merged

fix: skip canvas SSE fetch in chat shared page to eliminate spurious 103 error#14190
yuzhichang merged 8 commits intoinfiniflow:mainfrom
euvre:skip-some-hint-in-shared-chat

Conversation

@euvre
Copy link
Copy Markdown
Contributor

@euvre euvre commented Apr 17, 2026

What does this PR do?

Fixes the hint : 103 Only owner of canvas authorized for this operation error that appears when opening a Chat shared link (/chats/share?shared_id=...&from=chat).

Root Cause

The Chat shared page (web/src/pages/next-chats/share/index.tsx) unconditionally calls useFetchFlowSSE(), which requests /api/canvas/getsse/{sharedId}. This is an Agent Canvas endpoint that validates canvas ownership. When sharing a Chat dialog (not an Agent):

  1. sharedId is a dialog_id, not a canvas_id
  2. The API token's tenant_id doesn't match any canvas owner
  3. The backend returns code: 103, message: "Only owner of canvas authorized for this operation."
  4. The global error interceptor in request.ts displays it as a notification: hint : 103 Only owner of canvas authorized for this operation.

Changes

  • web/src/hooks/use-agent-request.ts: Added an enabled parameter to useFetchFlowSSE so callers can conditionally skip the query.
  • web/src/pages/next-chats/share/index.tsx: Only enable useFetchFlowSSE when from === SharedFrom.Agent. For Chat shares, the hook is disabled, avoiding the unnecessary canvas API call entirely.

Related Issue

Closes #14115

Type of change

  • Bug Fix (non-breaking change which fixes an issue)

Signed-off-by: noob <[email protected]>
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Apr 17, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 17, 2026

📝 Walkthrough

Walkthrough

The changes add conditional gating to the SSE flow fetching hook by introducing an enabled parameter that prevents unnecessary API calls. The hook consumer in the share page now conditionally enables flow data fetching based on whether the shared link originated from an agent source.

Changes

Cohort / File(s) Summary
Hook Enhancement
web/src/hooks/use-agent-request.ts
Modified useFetchFlowSSE to accept an optional enabled boolean parameter and gated the React Query with enabled: enabled && !!sharedId to prevent SSE queries from executing unless both the caller enables it and a sharedId exists.
Hook Consumer Update
web/src/pages/next-chats/share/index.tsx
Introduced isAgent derived value to conditionally pass agent flow state to useFetchFlowSSE, preventing the hook from fetching flow data when the shared link source is not an agent.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit's whiskers twitch with delight,
For agents now fetch with guarded might,
No needless calls to interrupt the day,
Just enable when needed—the proper way! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR description states it 'Closes #14115' but the linked issue (#14115) describes knowledge base search failures in shared chat links, which is different from the spurious 103 error this PR fixes. The two issues appear to be distinct problems. Verify that #14115 is indeed the correct linked issue. If #14115 is about knowledge base search failures, clarify whether this PR's 103 error fix is a prerequisite or whether the issues should be decoupled.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: skipping canvas SSE fetch for chat shared pages to fix the 103 error.
Out of Scope Changes check ✅ Passed All changes directly address the stated objective of conditionally disabling the canvas SSE fetch for chat shares. The modifications are tightly scoped to the hook signature and its consumer in the shared chat page.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description is comprehensive and well-structured, covering the problem, root cause analysis, specific changes, and related issue reference.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
web/src/pages/next-chats/share/index.tsx (1)

47-47: Rename constant to follow project naming rule.

Please rename isAgent to PascalCase to match the repository convention for constants.

Suggested rename
-  const isAgent = from === SharedFrom.Agent;
-  const { data: flowData } = useFetchFlowSSE(isAgent);
+  const IsAgent = from === SharedFrom.Agent;
+  const { data: flowData } = useFetchFlowSSE(IsAgent);

-  const avatarDialogSrc =
-    isAgent ? flowData?.avatar : chatInfo.avatar;
+  const avatarDialogSrc =
+    IsAgent ? flowData?.avatar : chatInfo.avatar;

As per coding guidelines, web/**/*.{ts,tsx,js,jsx}: Use PascalCase for constants and component names in TypeScript/JavaScript.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/pages/next-chats/share/index.tsx` at line 47, Rename the constant
`isAgent` to PascalCase (e.g., `IsAgent`) in this module: change the declaration
const isAgent = from === SharedFrom.Agent to const IsAgent = from ===
SharedFrom.Agent and update all references/usages in the file to `IsAgent` so
imports/consumers still work; ensure any nearby JSX or logic that relies on
`isAgent` is updated to the new identifier to avoid lint/type errors.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@web/src/pages/next-chats/share/index.tsx`:
- Line 47: Rename the constant `isAgent` to PascalCase (e.g., `IsAgent`) in this
module: change the declaration const isAgent = from === SharedFrom.Agent to
const IsAgent = from === SharedFrom.Agent and update all references/usages in
the file to `IsAgent` so imports/consumers still work; ensure any nearby JSX or
logic that relies on `isAgent` is updated to the new identifier to avoid
lint/type errors.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dc36935b-d31d-4447-a18b-3c65df8695b3

📥 Commits

Reviewing files that changed from the base of the PR and between 28d8b1c and d27ed58.

📒 Files selected for processing (2)
  • web/src/hooks/use-agent-request.ts
  • web/src/pages/next-chats/share/index.tsx

@xugangqiang xugangqiang self-assigned this Apr 17, 2026
@xugangqiang
Copy link
Copy Markdown
Contributor

@euvre
Could you please conduct regression tests and upload testing evidence?
Thanks.

@yuzhichang yuzhichang added the ci Continue Integration label Apr 17, 2026
@euvre euvre marked this pull request as draft April 17, 2026 11:32
@euvre euvre marked this pull request as draft April 17, 2026 11:32
@euvre euvre marked this pull request as draft April 17, 2026 11:32
@euvre euvre marked this pull request as ready for review April 17, 2026 11:32
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.30%. Comparing base (3ad3241) to head (ca9ee54).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14190   +/-   ##
=======================================
  Coverage   95.30%   95.30%           
=======================================
  Files          10       10           
  Lines         703      703           
  Branches      112      112           
=======================================
  Hits          670      670           
  Misses         16       16           
  Partials       17       17           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JinHai-CN JinHai-CN requested a review from cike8899 April 20, 2026 02:38
Comment thread web/src/pages/next-chats/share/index.tsx Outdated
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Apr 27, 2026
@yuzhichang yuzhichang merged commit 33bb464 into infiniflow:main Apr 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

4 participants