Skip to content

Clear on new session - #253

Merged
jgindin merged 4 commits into
mainfrom
clear-on-new-session
Oct 6, 2026
Merged

jgindin merged 4 commits into
mainfrom
clear-on-new-session

Conversation

@jgindin

@jgindin jgindin commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

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

  • I signed the [CLA].
  • I read the [Contributors Guide].
  • I read the [Style Guide].
  • I have added updates to the [CHANGELOG].
  • I updated/added relevant documentation.
  • My code changes (if any) have tests.
  • If my branch is on fork, I have verified that scripts/e2e_test.sh passes.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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).
@jgindin
jgindin force-pushed the clear-on-new-session branch from 595b770 to c7681df Compare October 6, 2026 01:29
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

⚡ A2UI Composer PR Preview

Your automated preview is successfully live (commit fad334b):
👉 Launch PR Preview

Note: This environment will be wiped automatically when the PR is merged or closed.

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.
@jgindin
jgindin requested a review from jonsharkey October 6, 2026 14:13
@jgindin
jgindin merged commit 5b10985 into main Oct 6, 2026
15 checks passed
@jgindin
jgindin deleted the clear-on-new-session branch October 6, 2026 16:03
jerelvelarde added a commit to jerelvelarde/a2ui-composer that referenced this pull request Oct 6, 2026
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".
jerelvelarde added a commit to jerelvelarde/a2ui-composer that referenced this pull request Oct 9, 2026
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".
jerelvelarde added a commit to jerelvelarde/a2ui-composer that referenced this pull request Oct 15, 2026
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".
jerelvelarde added a commit to jerelvelarde/a2ui-composer that referenced this pull request Oct 16, 2026
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".
jerelvelarde added a commit to jerelvelarde/a2ui-composer that referenced this pull request Oct 19, 2026
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".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants