Skip to content

fix(ui): switch tasks without a footer jump or transcript flash - #5683

Merged
Astro-Han merged 4 commits into
apache:mainfrom
Astro-Han:fix/ui-session-switch-flicker
Sep 24, 2026
Merged

Astro-Han merged 4 commits into
apache:mainfrom
Astro-Han:fix/ui-session-switch-flicker

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Switching tasks in the sidebar caused two glitches, reproducible on every switch.

Composer footer jump. The permission button unmounted for 1–6 frames, so .maka-model-selection-controls moved 34px left and back. The boundary read for the new session only starts once its transcript is published. While that read is in flight, the surface fails closed (#1611), and the shell expressed that by withholding onPermissionModeChange, which unmounted the button.

  • PermissionModeSelect now accepts no mode. It keeps its place, shows a neutral shield, names no mode ("Permission mode: Unavailable") and is disabled.
  • The shell always passes the handler. Pending, unreadable, external and shared sessions now share one state instead of the button appearing and disappearing.
  • The surface's fail-closed semantics are unchanged, and so is every other gate on localInteractionAvailable (command palette, goal dialog, model picker).
  • The composer's ?? 'ask' fallback is removed. It would have announced Auto for an unknown boundary.

Transcript flash. The sequence was: blank, the new task painted from its top, blank again, then a jump to the tail. The new virtualizer mounts before it knows its viewport, and the swap's fade started at mount, so these intermediate frames were already mostly visible.

  • The transcript scroll authority now reports when a list is in place through whenInPlace: the viewport is measured and the reader is where the last command put them (tail pin or restored reading position). The wait is bounded by the existing settle budget.
  • The swap stays transparent until then, and the fade starts on that frame.
  • The swap's key={session.id} existed only to restart the animation on mount, so it is removed. The virtualizer keeps its generation key for its measurement cache.

Recovery notices. The task, workspace and session-health recovery notices render beside the transcript, outside the swap. On a switch they appeared before the new transcript, and in one direction they disappeared for two frames and came back. They now share the swap's hidden-until-placed state and its fade, through a sibling selector on the chat view root (.agents-chat-view-root:has(.maka-chat-session-swap…) ~ .maka-chat-recovery-notice). No new signal is added, and a view without a transcript list shows them as before.

Only an activation that already has Turns (a switch between tasks) waits to be in place. A conversation opened from an empty or loading state has nothing to hold back: it is placed at once, and its list arrives as it does on main. The shell's in-flight permission-mode overlay now goes through deriveDesktopExecutionBoundarySurface, which applies it only when the boundary yields a mode, so a pending change is never shown or re-editable on an unknown boundary.

Also drops a dead fallback-mode branch at the surface call site. CI's renderer-architecture ledger records the smaller app-shell.tsx.

Behavior change

  • External and shared sessions, and side chat before any companion or source session exists, now show a disabled neutral shield where the footer used to show nothing. The side-chat case used to show an enabled Auto. None of these can change the mode, before or after.
  • A newly opened transcript appears once it is in place, not at mount. The hidden interval is the same few frames that used to show blank or misplaced content.
  • Recovery notices under the transcript fade in with it on a switch between tasks. A notice that appears mid-conversation now also fades in over the same 180ms.

Verification

Every composited frame was captured with Electron frame subscription (≈30 fps), with animations on, using real mouse clicks. Left is main, right is this branch.

4× slower, two switches:

compare-4x-slow.mp4

Real time, six switches:

compare-1x.mp4

Measured frame by frame (rAF, 60 frames per switch) in the chat-prompt-rail fixture, switching between a short and a long task. The long task's scrollTop is shown as current/max:

Before (main) After
Permission button unmounted 1–2 frames per switch; model controls x 428→394→428; layout-shift on .maka-model-selection-controls stays mounted; x constant at 428; neutral disabled shield for 1–2 frames, then the real mode; no footer layout shift
Long task, tail visible frames: 0 rows (scrollTop 19522/19522 estimated) → rows 488+ at 188118/193619 → 1 row at tail → correct same intermediate frames at opacity 0; data-placed on the frame at the tail; fade 0→1 over ~180ms with no change in position
Long task, restored reading position visible jitter while restoring (one run: 0.663 layout shift, first visible Turn 436→435→438→435) intermediate frames hidden; shown at the restored Turn
  • Recovery notice opacity matches the swap on every sampled frame: 0 until data-placed, then fades in on the same frame. Its gap to the last Turn is unchanged at 16px.
  • Ablation: a per-row "measured" check (virtua -1 sizes) and a flushSync reveal were tried and removed, because neither changed the frames above.
  • @maka/ui tests: 644/644 pass. Adds unit coverage for whenInPlace (unmeasured, off-tail pin, pending restore target, settle budget) and for the mode-less PermissionModeSelect.
  • @maka/desktop typecheck (incl. storybook), the boundary read-model and recovery-notice tests, renderer architecture (--strict-base), Knip (desktop, ui), Astryx surface inventory and theme drift all pass; npm run format and npm run lint are clean.
  • E2E was not run locally; left to CI. No E2E uses screenshot comparison. Playwright visibility ignores opacity, and the settle budget caps the hidden interval.
  • Light/dark: both defects are layout and opacity timing and independent of theme, so frame data stands in for before/after images.
  • Adversarial review (Codex): the overlay-on-unknown-boundary path and a notice blink on first open from the home screen were fixed in the last two commits, with unit tests on the surface and on useChatScroll. A smooth centered search reveal fading in while it scrolls is intended motion, as on main. A load slower than the settle budget on first open behaves as on main and is out of this PR's scope.
  • Pre-existing, unchanged: on first open from the home screen, the recovery notice unmounts for about two frames when the transcript is published, on main as well.
  • Not verified: a restore whose target is confirmed unavailable, between two sessions with different start margins. The swap element now persists across sessions, so its start-margin write-back may nudge scrollTop once in that narrow path.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Claude Code: diagnosis, implementation, tests, frame measurements, and this description.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@github-actions github-actions Bot added the effort/M Under 500 readable lines label Sep 24, 2026
Switching tasks in the sidebar produced two visual glitches.

The composer's permission button unmounted for 1-6 frames, shifting the
model controls 34px left and back. The boundary read for the new session
only starts once its transcript is published, and while it is in flight the
surface fails closed (apache#1611), which the shell expressed by withholding
onPermissionModeChange. PermissionModeSelect now accepts no mode: it keeps
its place, shows a neutral shield, names no mode, and is disabled. The shell
always passes the handler, so pending, unreadable, external and shared
sessions share that one state; the surface's fail-closed semantics and the
other gates on localInteractionAvailable are unchanged. The composer's
`?? 'ask'` fallback, which would have announced Auto for an unknown
boundary, is gone.

The transcript went blank, painted the new task from its top, went blank
again, then jumped to the tail: the new virtualizer mounts before it knows
its viewport, and the swap's fade started at mount. The scroll authority
now reports when a list is in place (viewport measured and the reader where
the last command put them, bounded by the settle budget), and the swap stays
transparent until then; the fade runs from that frame. The swap's
session key existed only to restart the animation on mount and is removed;
the virtualizer keeps its generation key for its measurement cache.

Also drops a dead fallback-mode branch at the surface call site.

Generated-by: Claude Code
The task, workspace and session-health recovery notices render beside the
transcript, outside the swap, so on a task switch they appeared (or blinked
out for a couple of frames and back) while the new transcript was still
hidden. They now share the swap's hidden-until-placed state and its fade,
through a sibling selector on the chat view root: no new signal, and a view
without a transcript list shows them as before.

Generated-by: Claude Code
@Astro-Han
Astro-Han force-pushed the fix/ui-session-switch-flicker branch from 51c983b to a196c68 Compare September 24, 2026 08:16
The shell preferred a session's in-flight permission-mode overlay over the
boundary surface. Now that the composer control stays mounted and enables
itself whenever it has a mode, an overlay that outlived a switch-back or a
failed boundary read would show a mode, and accept another change, while the
boundary was unknown (apache#1611). The overlay now passes through
deriveDesktopExecutionBoundarySurface, which applies it only when the
boundary yields a mode, so that function stays the one place that decides
which mode the shell shows.

Generated-by: Claude Code
The reveal gate armed on every activation. A conversation opened from an
empty or loading state has no list yet, so its recovery notices showed with
the loading hero, were hidden when the list mounted, and faded back in; and
a load slower than the settle budget spent the budget before any list
existed. Only an activation that already has Turns (a switch between tasks)
now waits to be in place; one without a list is placed at once and its list
arrives as it did before.

Generated-by: Claude Code
@Astro-Han
Astro-Han marked this pull request as ready for review September 24, 2026 08:51

@hqhq1025 hqhq1025 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.

Reviewed exact head 6067daef6df004b884dccc8120eed42a37159b06. I found no P0-P2 issues.

The change keeps the permission control mounted while the execution boundary is unknown, but disables it and avoids presenting a fabricated mode (packages/ui/src/permission-mode-menu.tsx:87-118, apps/desktop/src/renderer/desktop-execution-boundary-surface.ts:42-51). For transcript switching, the virtualizer now exposes measured readiness, the scroll authority gates reveal on the active pin/restore position with a bounded fallback, and the session swap plus adjacent recovery notices remain transparent until that placement is reached (packages/ui/src/use-chat-scroll.ts:145-198, packages/ui/src/transcript-scroll-authority.tsx:239-245,490-496, apps/desktop/src/renderer/styles/chat-message.css:37-55).

Validation: hosted test and label succeeded; local UI 645/645 and Desktop 2696/2696 passed, as did full typecheck, lint, format, ASF headers, renderer architecture 112/112, E2E budget, production renderer build/stale checks, diff check, and a clean merge tree against current main 276faf1c91fd948dc0fda7124b2e5c5701add544. I also inspected the supplied slow-motion and real-time frame captures; the reviewed flows no longer expose the intermediate transcript positions or footer shift.

Residual scope: I did not independently run packaged Electron E2E or native macOS/Windows builds. The disclosed unavailable-restore/different-start-margin edge remains unexercised, but the inspected control flow did not establish a P0-P2 regression.

Review notice: This review was prepared by an automated review agent operated by hqhq1025 and is published at the direction of AstroHan, who has read these findings and is the human accountable for them.

@Astro-Han
Astro-Han merged commit 31b7cd6 into apache:main Sep 24, 2026
2 checks passed
@Astro-Han
Astro-Han deleted the fix/ui-session-switch-flicker branch September 24, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/M Under 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants