| index d198f5b..aa14410 100644 |
| --- a/web/static/apps/chat.js |
| +++ b/web/static/apps/chat.js |
| @@ -582,6 +582,11 @@ export const app = defineApp({ |
| if (!root) { |
| root = buildSkeleton(el, ctx); |
| } |
| + // Stamp the mount with its thread so a stray refresh can tell whether the |
| + // pane still belongs to it (see doRefresh). #app-pane is shared across |
| + // threads, so an async welcome/tour step firing after you've navigated |
| + // away would otherwise re-render its thread into whatever's on screen now. |
| + root.dataset.thread = ctx.threadId; |
| // Point the single document-level hotkey listener at THIS mount. On the |
| // instant-restore path buildSkeleton is skipped, so this — not the build — |
| // is what keeps the shortcuts live after switching threads. Guard on |
| @@ -613,7 +618,17 @@ export const app = defineApp({ |
| // Let addLocalNotice re-render this pane when a command reply comes in — the |
| // reply isn't folded state, so nothing else would. Points at the live mount |
| // (like the hotkeys/native re-points above), self-removed on teardown. |
| - const doRefresh = () => renderApp(ctx.threadId, "chat", el); |
| + const doRefresh = () => { |
| + // A parked thread's refresh (a late welcome/tour notice, a scripted |
| + // typing beat) must not paint into the shared #app-pane once another |
| + // thread has taken it over — that's how Eleven's onboarding messages |
| + // leaked into the chat you'd navigated to. The notice is already stored |
| + // in localNotices and paints when this thread is next opened; skip the |
| + // live render when the pane no longer belongs to us. |
| + const cur = el.querySelector(":scope > .chatapp-root"); |
| + if (cur && cur.dataset.thread && cur.dataset.thread !== ctx.threadId) return; |
| + renderApp(ctx.threadId, "chat", el); |
| + }; |
| refreshFeed.set(ctx.threadId, doRefresh); |
| // Keep the live mount ctx so the shell can inject a private notice into this |
| // thread (e.g. the welcome DM's "Take the tour" chip starting Eleven's tour). |