Repository navigation
fix(cli): show a failed line window and stop frame polling - #2061
Conversation
A line whose first history window cannot be read is no longer treated as still loading: the line draws the failure with the reopen-to-retry wording and the view returns to the idle poll instead of waking at frame rate. The initial window failure is kept apart from later inventory and earlier-page errors, so those leave the loaded transcript in place, and selecting the line again in /lines or reopening /tasks reads it again. main keeps the existing visible open failure on daemons that offer report.prepare: it now fails the Session regardless of report availability, refuses submission and keeps the draft. Refs #2046
A branch whose creation fails no longer keeps the first window's read failure on its line: the creation failure settles the line and clears the stale failure with the rest of the read state, so the line cannot show a failure the tasks panel no longer lists. The unit tests cover the transport-failure exit that feeds the same failed-window state, and the reporting-daemon flow asserts that a fatal main history failure is not offered as a report. Refs #2046
eric8810
left a comment
There was a problem hiding this comment.
The first-window error is now visible without throwing away a transcript on an older-page error. Two transitions still leave the TUI and worker out of sync:
- [P2] Re-arm first-window setup when retrying the shown line.
arm_windowclearsawaiting_windowon failure before it runs the successful window setup. Reopening/tasksclears the error and queues a read, but the focus can stay the same. A same-focus snapshot does not re-arm the TUI, so the retry does not enter loading and a successful page skips window-floor and earlier-history setup. Add a TUI test covering failure → reopen on the same line → loading → successful window with older history. - [P2] Treat branch creation failure as terminal for the transcript. The worker clears the error, leaves the window incomplete, and cancels its reads. If this is the shown line, the TUI is left with exactly the state it treats as loading, but no request can resolve it. Either move focus to a surviving line or carry a terminal no-transcript state that does not frame-poll. Cover failure before the initial read settles.
A failed line window retried from the tasks panel publishes the same focus as loading, so the TUI test reopens the panel and checks that the retry arms the window, that the page lays out its window floor and that the older history stays behind the load-more row. A branch whose creation fails before its first window settles has no read that could end it; the task-history test covers the surviving focus, the cancelled read and the refusal to show the terminal line again. Refs #2046
Reopening the tasks panel on a line whose first window failed publishes the same focus as loading, which no switch announces; the view now arms that window again when the failure clears, so the retry enters loading and the page that lands is laid out over its newest window with the older history behind the load-more row. A creation that fails while the shown line's first window loads leaves no read that could end its wait. The line's creation is terminal, so the Session attachment shows the line it was cut from, main when the directory does not know it, and refuses a lines-panel selection of the failed line instead of leaving the view loading forever. Design: docs/design/timeline-ui.md §5 and docs/zh/design/timeline-ui.md §5 record the creation-failure transition. Refs #2046
The focus fallback after a failed line creation was only exercised with `main` as the parent, so the parent lookup and its window reset had no test when the directory knows the line the failed one was cut from. The new test cuts a line from another line, fails its creation while the first window is in flight, and checks that the focus returns to that line, that its window starts over and is read again, and that `/lines` refuses the failed line.
The directory learns that a branch creation failed when the fact arrives, but a line whose parent window is still loading keeps the fact in the parent's live queue: the existing refusal only sees the failure once that window replays the queue, and a window that fails to read never replays it. Cover both moments: the failed line is refused while the parent's first window is reading and after that read fails.
…ives A line whose creation failed stayed selectable until the window that recorded the fact replayed it: the fact sits in the parent's live queue while that window loads, and a window whose read fails never replays it. Record the line's terminal state in the session directory when the failure arrives, so the existing refusal sees it immediately and the transcript still replays the queue once the window loads.
|
Fixed in fed6ce7. A same-focus retry of a failed line window now arms the view again when the failure clears, so the retry enters loading and the page that lands is laid out over its newest window with the older history behind the load-more row. The TUI test A creation that fails while the shown line's first window loads is terminal for that line. The interface now shows the line it was cut from, The refusal tests fail without the fix: on |
eric8810
left a comment
There was a problem hiding this comment.
The same-focus retry now re-arms the TUI, and a creation failure moves focus away when the directory already knows the child. One ordering still lets /lines reopen a branch whose creation has already failed.
[P2] Remember the terminal fact before the child exists in the projected directory. While a parent's first window is in flight, task_event buffers its live events. The early projection.apply at tasks.rs:203–205 only sets CreationFailed if the child row already exists (projection.rs:170–177). If the parent window contains branch/create but cuts off before the already-received live branch/create-failed, replay creates a Waiting row and immediately publishes it (tasks.rs:646–681), before inventory completes and finish_window drains the buffered failure. Slow or failed inventory leaves that stale row selectable: focus_line checks only the projected row, and line_projection can reset the failed child's done state and queue a read for it.
Please retain creation failure as separate terminal state, use it for focus admission and when projecting a row later, and cover the ordering with a test that delivers the live failure before the parent page projects branch/create. Gate the follow-up inventory so the test can assert that the child stays refused in that gap. The existing new tests exercise a directory row that already exists when the failure arrives.
Non-blocking integration note: the new t("Branch history failed; reopen to retry") key has no locale entries in this patch and will need them with the literal-key checker in #2069.
The live failure can reach the worker before the parent's page projects the child's branch/create, and the parent's inventory can stay in flight after that. The test delivers the failure first, replays a page that only holds branch/create, and gates the follow-up inventory read: the child row must be terminal, /lines must refuse it, and nothing may reset or queue it, before and after the parent's window finishes. It also pins the failure notice at one per failure and checks that a re-attached Session projection holds neither the row nor the failure.
A live branch/create-failed can reach the worker before the parent's page projects the child's branch/create, and the row created from that page was published as waiting until the parent's window finished and replayed the failure. Focus admission read only the projected row, so the child could be opened, its done state reset and a read queued for it. The Session projection now records the failed branch when the fact arrives, whether or not its row exists. A row projected later carries the failure, focus admission asks the fact instead of the row, and opening a line leaves a failed creation's state alone. The record lives with the line directory, so switching or re-attaching a Session starts without it, and the notice that announces the failure still comes from the live fact alone.
A parent page can hold both the child's branch/create and the branch/create-failed that ends it. The replay folds the pair before the reply publishes, so no frame or command sees the child waiting; this test asserts the projected state, the refusal, the intact done flag and the empty queue, then fails the parent's inventory and reopens /tasks to show that only the parent is retried.
|
Fixed in 384381b. A creation failure is now a fact about the branch, recorded when the event arrives and before the line exists in the projected directory. The Session projection keeps the failed branch ids, a
The record lives with the line directory, so switching or re-attaching a Session starts without it; the last step of the first test re-attaches and asserts the new projection holds no line and the old failure does not cross over. The locale key |
eric8810
left a comment
There was a problem hiding this comment.
Reviewed at head e2e7e77.
The user-visible bug is the interesting half: a line whose first window failed used to stay blank and keep the interface waking at frame rate, with the failure visible only in /tasks. Both symptoms have the same cause — the view had no way to say "this window will not arrive", so it kept treating the read as pending. Adding a third state and letting poll_interval() fall back to the idle poll when no frame is due fixes the wake and the blank transcript together, which is the right coupling rather than two patches.
The distinctions the change keeps are the ones that would otherwise erode: the initial window failure is held apart from a later inventory or /earlier error, so those leave the loaded transcript in place; a creation that fails while the shown line's first window loads is terminal for that line, with /lines keeping creation failed and the interface showing the line it was cut from; and nothing retries in the background — selecting the line or reopening /tasks is what reads again. A transport failure recording the same failed state closes the last gap where a blank window could survive.
Blocking: none.
Checks are green at this head. I read the view.rs addition, the poll_interval/error-drawing and retry hunks in tui.rs, the new CLI flow test's name, and the PR body; I did not read the 1054 lines of tasks.rs changes or the doc changes, and ran nothing.
Non-blocking:
crates/dim-cli/src/model/view.rs—window_error: Option<String>needs a doc comment that enumerates three meanings forNone(still loading, loaded, and only a later read failed). That enumeration is the tell that the field is carrying more than one state. If the line's load state already distinguishes loading from loaded elsewhere, the field would read better as a state the compiler checks; if it does not, thenNoneis doing that work too and the comment is the only thing holding the three apart.
zerob13
left a comment
There was a problem hiding this comment.
The failed-ID tracking fixes the earlier ordering case: a terminal failure received before the directory row now survives projection and prevents focus admission. The exact CI run passed. One remaining path leaves the displayed directory out of sync with that terminal state.
[P2] Publish branch creation failure even when another line is focused. In tasks.rs:203–260, the handler updates the directory immediately but schedules a snapshot only if the child is focused. If the parent's first page has already published a Waiting child and inventory then fails, a subsequent live branch/create-failed is buffered on the unfinished parent and does not schedule a snapshot. /lines opens from the cached snapshot, so it can keep showing Waiting until unrelated activity even though Enter now refuses the line. Please schedule publication when the terminal directory state first changes, independently of focus. This path was identified by static review; no runtime reproduction was run.
A child published as waiting by its parent's first page, whose creation fails after the parent's inventory failed with the parent focused, must publish the terminal directory state on its own; a repeated failure event must not schedule another snapshot.
A live branch/create-failed that first makes the directory row terminal now schedules a snapshot even when another line is focused, so `/lines` cannot keep showing the line as waiting until unrelated activity. The terminal fact decides the first change, so a repeated failure event schedules nothing.
The `window_error` doc comment now says `history_complete` separates a window that is still loading from one that loaded, whether or not a later read failed.
|
Both notes are addressed at c45fa4e. The publication gap is fixed in 2f4237a. In the
On |
eric8810
left a comment
There was a problem hiding this comment.
The terminal fact is now both durable in the in-memory directory and published to the TUI when focus stays on another line. Replayed duplicate failures do not schedule another snapshot. The new test exercises the key case: the parent inventory has failed, the child is still shown as waiting in the last snapshot, and the live failure updates the directory without moving focus.
At c45fa4e4, the new publishing test, both early/replayed failure cases, and the same-focus retry test passed in Linux CI; required ci-ok passed. The error text already has the locale key in the tables, so my earlier integration concern does not apply.
…failed # Conflicts: # crates/dim-cli/src/session_host/tasks.rs
|
Merged current The only conflict was The appended unit tests from both changes are kept side by side unchanged: the line-window and creation-failure tests with their helpers, and the cut-counting tests with their helpers. No existing test was modified. Verification on 06af96c: Reverting the failure branch to its pre-merge form fails |
eric8810
left a comment
There was a problem hiding this comment.
Reviewed at head 06af96c.
Approving, citing my review at e2e7e774. The delta since then is small and in the direction of what that review judged: 2f4237ac adds four lines to tasks.rs so that a line whose first creation fails calls self.changed() — /lines draws its directory from published snapshots, so without that poke the refusal the PR describes would only appear on the next unrelated change — and c45fa4e4 adds the doc sentence saying history_complete separates a window that is still loading from one that loaded, whether or not a later read failed. The rest of the head is a merge of origin/main.
The design I read at e2e7e774 stands: the window's three states (loading, complete, failed), the failure drawing Branch history failed; reopen to retry: <reason> in place of the transcript and returning the view to the idle poll instead of waking at frame rate, no background retry, a retry on the same focus re-entering loading and laying out as a first window, and the initial-window failure kept apart from later inventory and /earlier errors so a loaded transcript survives them. The failed-creation paragraph in the body — terminal for that line, showing the line it was cut from, /lines keeping creation failed, the fact recorded so the refusal holds in any arrival order — is the part the four new lines serve.
Blocking: none.
Checks are green at this head. I read the two commits' diffs, the PR body and the file list; I did not re-read the 1154-line tasks.rs body or the 199 lines of tui.rs at this head, the 44 lines of new cli_flow/tasks.rs cases, or the design deltas, and ran nothing.
Non-blocking: none.
zerob13
left a comment
There was a problem hiding this comment.
The first creation failure now publishes the terminal state even while another line is focused, without changing the selection or republishing a duplicate failure. The focused regression and history-retention/retry checks passed on the exact integration, and required CI is green.
|
Merged current The only conflict was
The one test this merge touched is this branch's own Verified on 7cb3cb4: With |
eric8810
left a comment
There was a problem hiding this comment.
Reviewed at head 7cb3cb4.
Approving, citing my review at 06af96c3. This head is a merge of origin/main: the PR's own file list is the same eight files, and the only numeric difference is tasks.rs at 1152/18 instead of 1154/20 — two lines of main's owned region counted against the same branch content. No commit since 06af96c3 belongs to this branch; the ones in the comparison are other pull requests arriving through main.
What that review judged stands: the window's three states (loading, complete, failed); a failed first read drawing Branch history failed; reopen to retry: <reason> in place of the transcript and returning the view to the idle poll instead of waking at frame rate; no background retry, with a retry on the same focus re-entering loading and laying out as a first window; the initial-window failure kept apart from later inventory and /earlier errors; and the failed creation calling self.changed() so /lines draws its creation failed row from the published snapshot.
Blocking: none. Checks are green at this head.
Verification: not run; this rests on the reading recorded at 06af96c3 and e2e7e774, the confirmation that the PR's own files and their sizes are unchanged, and the current green checks.
zerob13
left a comment
There was a problem hiding this comment.
Re-reviewed the author's conflict resolution on the exact current main integration. The author’s merge preserves the dynamic default line and sends the earlier-content notice after its snapshot, without losing visible history failure, retry-on-reopen, or the first off-focus creation-failure publication. The exact Linux job passed the default-line restore, first-window failure, retry, and late-history coverage; macOS, Windows, and ci-ok also passed. No remaining blocking finding.
Restore the arcships#1514, arcships#2086 and arcships#2120 tests byte-for-byte from the base revision; the flattening only covers the tests arcships#2061 added. Keep the transport-failure and creation-failure-clears-window cells private, and replace the five creation-failure order tests with two compact cases that pin the failure-before-create and same-page orders plus the directory-known parent and the refusal while the parent window reads or has failed. The two flow cases now use the harness startup helpers instead of hand-written context replies.
A line whose first history window could not be read used to stay blank and kept the interface waking at frame rate, with the failure visible only in
/tasks. The window now has three states: loading, complete and failed.When the first read fails, the line draws
Branch history failed; reopen to retry: <reason>in place of its transcript and the view returns to the idle poll. Nothing retries in the background: selecting the line again in/lines, or reopening/tasks, reads it again, and a retry on the same focus re-enters loading and lays out its page as a first window. The initial window failure is kept apart from later inventory and/earliererrors, so those leave the loaded transcript in place. A request that fails on the transport records the same failed state.A creation that fails while the shown line's first window loads is terminal for that line. The interface shows the line it was cut from, which is a line the directory knows when it has one and
mainotherwise, and/lineskeeps the line ascreation failedand refuses to show it. The failure is recorded as a fact about the branch when the event arrives, so the refusal holds in any arrival order: before the parent's page projectsbranch/create, while the parent's window is still loading, after the parent's window fails, and while its inventory is still reading. A laterbranch/createprojects the line as failed, and opening it neither resets its settled state nor queues a read. A creation failure on a line that already failed its first read clears the stale read failure. When the fact first makes the line terminal, a snapshot is scheduled regardless of which line is focused, so/linesshows the terminal state instead of a stalewaiting; a repeated event schedules nothing.mainkeeps the existing open failure on daemons that offerreport.prepare: the failure is now visible, submission is refused and the draft is kept instead of the client waiting for a window that will not arrive, and no report invitation is offered for it.Design:
docs/design/timeline-ui.md§5 anddocs/zh/design/timeline-ui.md§5 record the states, what the line draws, the retry path and the creation-failure transition.Verification on e2e7e77:
cargo fmt --all -- --check --config error_on_line_overflow=true,cargo clippy -p dim-cli --all-targets --locked -- -D warnings,cargo test -p dim-cli --lib --locked session_host::tasks(15 tests, including the newsession_host::tasks::tests::{a_create_failure_before_its_create_is_projected_is_terminal, a_page_that_records_a_create_and_its_failure_leaves_the_line_terminal}), the two TUI window testsui::tui::tests::{reopening_a_failed_line_rearms_its_window, a_failed_line_window_shows_its_error_and_returns_the_idle_poll}run with the same lib command,cargo test -p dimcode --test cli_session_flow --locked tasks::tui_task_inventory_restores_branch_pages_and_retries_only_on_reopenandcargo run --locked -p xtask -- checkpass. The ordering test fails on e6d06de, a test-only commit on fed6ce7, at the assertion that the projected child iscreation failed(left: Waiting, right: CreationFailed), and passes on 384381b. The two refusal tests added earlier in this branch,session_host::tasks::tests::{a_create_failure_is_refused_before_the_parent_window_loads, a_create_failure_is_still_refused_after_the_parent_window_fails}, fail on f354436, a test-only commit on fd6c5bb, at the assertion that the failed line is not focused.Verification on c45fa4e, after the publication change:
cargo fmt --all -- --check --config error_on_line_overflow=true,cargo clippy -p dim-cli --all-targets --locked -- -D warnings,cargo test -p dim-cli --lib --locked session_host::tasks(16 tests, includingsession_host::tasks::tests::a_live_create_failure_publishes_the_terminal_directory_without_focus) andcargo run --locked -p xtask -- checkpass. The new test fails on d1916a1, a test-only commit on e2e7e77, atthe terminal directory state schedules a snapshot without focus, and passes on 2f4237a. The checks in the paragraph above ran at e2e7e77; this change adds the snapshot scheduling to the creation-failure handler and a doc-comment clause.Fixes #2046