Repository navigation
Clear on new session - #253
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements in-place session resets ('New Session') across the application without reloading the page or clearing persisted caches. It introduces a sessionResetNonce to coordinate resetting the draft to a blank surface, cancelling active streams, clearing conversation history, and resetting UI states (such as Monaco editor undo history, unread badges, and unsent prompts). Feedback on the changes suggests using optional chaining to safely cancel the response stream in ChatCoordinator and removing a redundant signal write in DataModel.clearLogs() since dataModelJson is a linked signal.
Replace the full browser reload and storage flush in ComposerShell.resetSession() with an in-memory session reset that preserves user settings, custom instructions, and persisted caches: - Add sessionResetNonce and resetToBlankDraft() on StateSync to cancel pending draft debounce timers and sync a blank createSurface draft. - Add startNewSession() and activePromptId guards on ChatCoordinator to cancel in-flight streams and clear chat and raw LLM histories. - Clear unsent prompt text, attachments, screenshot toggle, and in-flight file/screenshot reads in ChatPanelBase on reset. - Add MonacoEditor.resetEditor() and call it from RawFrame on reset to flush undo/redo history and cancel pending diagnostic timers. - Reset dynamicHeight and the growth circuit breaker in RenderedFrame on sessionResetNonce updates. - Clear debug drawer logs (including DataModel) and unread tab badges in ComposerWorkspace and ComposerDockview on reset. - Clear shared payload/error state, clean shared URL parameters via StartupResolution.cleanSharedA2uiUrl(), and clear HostCommunication and ErrorLogger histories in ComposerShell.resetSession(). - Remove unused SESSION_STATE and EDITOR_CACHE LocalStorageKey entries.
Replace the sessionResetNonce effect, untracked block, and lastHandledResetNonce field in ChatPanelBase with linkedSignal declarations for includeScreenshot, isReadingFiles, userPrompt, and attachedFiles. Remove redundant outer sessionResetNonce checks in submitPrompt and onFilesSelected.
Use optional chaining responseStream?.cancel?.() when cancelling
streams in ChatCoordinator. Document why DataModel.clearLogs()
explicitly calls dataModelJson.set('') alongside
latestModelValue.set(null).
595b770 to
c7681df
Compare
⚡ A2UI Composer PR PreviewYour automated preview is successfully live (commit
|
When a surface is created without a 'root' component (such as after clicking New Session), @a2ui/lit's <a2ui-surface> renders its default 'Loading surface...' slot fallback and @a2ui/react's <A2uiSurface> renders '[Loading root...]' via DeferredChild. - Slot an empty <span slot="loading"></span> inside <a2ui-surface> in A2uiSandboxRoot (bridge/src/lit/lit-bridge.ts). - Expose hasRoot on UseA2uiSandboxResult in useA2uiSandbox (bridge/src/react/react-bridge.ts) by subscribing to surface.componentsModel.onCreated and onDeleted. - Guard <A2uiSurface> with hasRoot in samples/react-basic-catalog and INTEGRATION_MANUAL.md so blank surfaces render an empty canvas.
a2ui-project#232 put the JSON editor and the preview in one tab group, and a2ui-project#253's New Session opens with an empty canvas snapshot. - replaceMonacoJson shows the editor tab to edit it and the preview tab afterwards, so tests click a visible preview. - The 360px embed checks use a 630px viewport: the preview now takes the whole group, so the old 1145px viewport made it twice as wide. The score-table check runs at that width too and polls until the table scrolls inside it. - The CopilotKit panel no longer hides an empty snapshot that opens the conversation; New Session shows it as "0 components in this canvas".
a2ui-project#232 put the JSON editor and the preview in one tab group, and a2ui-project#253's New Session opens with an empty canvas snapshot. - replaceMonacoJson shows the editor tab to edit it and the preview tab afterwards, so tests click a visible preview. - The 360px embed checks use a 630px viewport: the preview now takes the whole group, so the old 1145px viewport made it twice as wide. The score-table check runs at that width too and polls until the table scrolls inside it. - The CopilotKit panel no longer hides an empty snapshot that opens the conversation; New Session shows it as "0 components in this canvas".
a2ui-project#232 put the JSON editor and the preview in one tab group, and a2ui-project#253's New Session opens with an empty canvas snapshot. - replaceMonacoJson shows the editor tab to edit it and the preview tab afterwards, so tests click a visible preview. - The 360px embed checks use a 630px viewport: the preview now takes the whole group, so the old 1145px viewport made it twice as wide. The score-table check runs at that width too and polls until the table scrolls inside it. - The CopilotKit panel no longer hides an empty snapshot that opens the conversation; New Session shows it as "0 components in this canvas".
a2ui-project#232 put the JSON editor and the preview in one tab group, and a2ui-project#253's New Session opens with an empty canvas snapshot. - replaceMonacoJson shows the editor tab to edit it and the preview tab afterwards, so tests click a visible preview. - The 360px embed checks use a 630px viewport: the preview now takes the whole group, so the old 1145px viewport made it twice as wide. The score-table check runs at that width too and polls until the table scrolls inside it. - The CopilotKit panel no longer hides an empty snapshot that opens the conversation; New Session shows it as "0 components in this canvas".
a2ui-project#232 put the JSON editor and the preview in one tab group, and a2ui-project#253's New Session opens with an empty canvas snapshot. - replaceMonacoJson shows the editor tab to edit it and the preview tab afterwards, so tests click a visible preview. - The 360px embed checks use a 630px viewport: the preview now takes the whole group, so the old 1145px viewport made it twice as wide. The score-table check runs at that width too and polls until the table scrolls inside it. - The CopilotKit panel no longer hides an empty snapshot that opens the conversation; New Session shows it as "0 components in this canvas".
Description
Instead of a full reload, reset the UI when a New Session is started. For these new sessions, don't start with the sample (Book a Car); just start with an empty canvas.
NOTE: If you run the PR Preview, you will see that the React and Lit renderers show messages after clicking the New Session button; this is because the PR Preview isn't running the renderers that are built with this PR, they're running the "production" renderers.
Pre-launch Checklist