mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-11-11 04:02:45 -10:00
fix(web-shell): render the unavailable notice and gate the pending workspace fallback
Address the two blocking review items on the #15928 managed-host follow-up: - The mount docs/README promise an unavailable notice when neither a provider nor a baseUrl is supplied, but the shell rendered an empty wrapper and the test only asserted the Java provider was not called. Render the notice via the existing managed.unavailable i18n key and strengthen the test to assert the notice text (red without the render, green with it). - The 'open the original conversation' handler fell back to the on-screen summary's workspace, which in the cross-conversation case is a foreign workspace. Gate that fallback on pending.sessionId === sessionId so the owner is never bound to the wrong workspace when its own workspace is unknown. The third review item (managed-host bundle in npm run build) is a maintainer call on build cost and is left unchanged pending that decision. ManagedAgentWebShell 18/18, ManagedSessionsPage 173/173; eslint exit 0, prettier clean.
This commit is contained in:
1 parent
95f56e9d51
commit
a61bfc04eb
3 files changed
+36
-2
No files matched your search
@@ -139,6 +139,9 @@ describe('ManagedAgentWebShell', () => {
|
||||
await act(async () => root.render(<ManagedAgentWebShell />));
|
||||
expect(createJavaManagedAgentProvider).not.toHaveBeenCalled();
|
||||
expect(container.textContent).not.toContain('managed-only');
|
||||
expect(container.querySelector('[role="status"]')?.textContent).toContain(
|
||||
'Managed Agents is unavailable',
|
||||
);
|
||||
});
|
||||
|
||||
it('wraps a host navigation slot in the portal scope and syncs theme variables', async () => {
|
||||
|
||||
@@ -21,7 +21,12 @@ import {
|
||||
import type { ManagedAgentProvider } from './components/managed/managed-agent-provider';
|
||||
import { RootErrorFallback } from './components/RootErrorFallback';
|
||||
import { WebShellCustomizationProvider } from './customization';
|
||||
import { I18nProvider, normalizeLanguage, type WebShellLanguage } from './i18n';
|
||||
import {
|
||||
I18nProvider,
|
||||
normalizeLanguage,
|
||||
useI18n,
|
||||
type WebShellLanguage,
|
||||
} from './i18n';
|
||||
import { WebShellPortalRootContext } from './portalRoot';
|
||||
import {
|
||||
ThemeProvider,
|
||||
@@ -79,6 +84,23 @@ export interface ManagedAgentWebShellProps
|
||||
style?: CSSProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shown when the shell is mounted with neither an injected provider nor a
|
||||
* baseUrl to build one from. The mount docs promise a notice in this state;
|
||||
* rendering it (rather than an empty wrapper) keeps that promise honest.
|
||||
*/
|
||||
function ManagedUnavailableNotice() {
|
||||
const { t } = useI18n();
|
||||
return (
|
||||
<p
|
||||
role="status"
|
||||
style={{ padding: '2rem', textAlign: 'center', opacity: 0.7 }}
|
||||
>
|
||||
{t('managed.unavailable')}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
/** Managed-only 产品入口,不创建 daemon workspace/session context。 */
|
||||
export function ManagedAgentWebShell(props: ManagedAgentWebShellProps) {
|
||||
const {
|
||||
@@ -304,6 +326,7 @@ export function ManagedAgentWebShell(props: ManagedAgentWebShellProps) {
|
||||
navigationSearch={navigationSearch}
|
||||
/>
|
||||
)}
|
||||
{!provider && <ManagedUnavailableNotice />}
|
||||
</div>
|
||||
</CompactModeContext.Provider>
|
||||
</TodoContextsProvider>
|
||||
|
||||
@@ -2096,8 +2096,16 @@ function ManagedSessionsContent({
|
||||
lifecycleSummaries.find(
|
||||
(session) => session.sessionId === pending.sessionId,
|
||||
)?.workspace?.workspaceId;
|
||||
// `summary` is the session currently on screen, which is the
|
||||
// pending owner only when the ids match. In the cross-
|
||||
// conversation case, falling back to its workspace would bind
|
||||
// the owner to a foreign workspace — the very misattribution
|
||||
// this flow removes — so leave the target unbound instead.
|
||||
const targetWorkspaceId =
|
||||
ownerWorkspaceId ?? summary?.workspace?.workspaceId;
|
||||
ownerWorkspaceId ??
|
||||
(pending.sessionId === sessionId
|
||||
? summary?.workspace?.workspaceId
|
||||
: undefined);
|
||||
openSession(pending.sessionId, targetWorkspaceId);
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in new issue
Block a user