fix(tui): avoid leaking footer when resuming a missing session - #202
Merged
Conversation
启动期间 footer 在构造时就被挂入渲染树,而 init() 早期的 setAppState 会排出一次渲染,在 await 时真正执行(pi-tui 的 stopped 默认为 false, 未 start 也会 doRender),把 footer 画到终端。resume 不存在的 session 时,init() 随后抛错,这次过早渲染就残留在错误信息上方。 将 footer 改为就绪态 chrome:从 buildLayout 移除挂载,改在 initMainTui 中 init() 成功之后再 mountFooter。致命启动错误会在挂载前抛出,footer 不进渲染树,过早渲染只画空树,错误信息落在干净的行上。
🦋 Changeset detectedLatest commit: 24c0c36 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
No issue — problem described below.
Problem
Resuming a non-existent session correctly errors out, but the footer (including the
context: …statusline below it) is painted to the terminal before the error, leaving stray chrome stranded above the error message.Root cause: the footer is mounted into the render tree at construction. Early in
init(),refreshAvailableModels()callssetAppState()→ui.requestRender(), which schedules a render that flushes during a laterawait. pi-tui'sTUI.stoppeddefaults tofalse, sodoRender()runs even thoughui.start()was never called, painting the footer.init()then throwsSession "..." not found, so the stray render is left above the error. On a successful startup this premature render is overwritten by the full UI, so it only shows on failure. The footer is the only content-bearing chrome during startup (transcript/editor are still empty), which is why only it leaks.What changed
Treat the footer as ready-state chrome: remove it from
buildLayout()and mount it viamountFooter()ininitMainTui()only afterinit()succeeds. A fatal startup error throws before mounting, so the footer never enters the render tree and the premature render paints an empty tree, leaving the error on a clean line. The migration / picker / OAuth-login / normal startup paths all still reachmountFooter(), so behavior is unchanged.Added regression tests: footer is not mounted when a missing-session resume fails, and is mounted once startup reaches the main TUI.
Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.