diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 8d6e1bcaad..3a16e124ea 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -98,7 +98,11 @@ jobs: - name: Choose the lanes this change needs id: plan # The crate graph comes from `cargo metadata`, which needs no build. - run: python3 scripts/ci-plan.py plan --event "$GITHUB_EVENT_NAME" --draft "${{ github.event.pull_request.draft || false }}" + # TEMP evidence run (do not merge): herdr-core and the desktop e2e lane. + run: | + echo 'lanes=["rust","desktop-e2e"]' >> "$GITHUB_OUTPUT" + echo 'full=false' >> "$GITHUB_OUTPUT" + echo 'rust-packages=["herdr-core"]' >> "$GITHUB_OUTPUT" policy: name: policy checks @@ -179,7 +183,7 @@ jobs: bash scripts/verify-cargo.sh nextest --profile ci "${packages[@]}" fi - name: Report flaky tests - if: ${{ !cancelled() }} + if: ${{ false }} continue-on-error: true timeout-minutes: 5 env: @@ -515,11 +519,11 @@ jobs: HIDE_E2E_SCREENSHOT_DIR: ${{ runner.temp }}/hide-e2e run: | mkdir -p "$HIDE_E2E_SCREENSHOT_DIR" - bash scripts/verify-web.sh desktop e2e + bash scripts/verify-web.sh desktop e2e agent-tab-groups --project background --grep "edge drag splits" --repeat-each 60 --retries 0 - name: Report flaky tests # A failed test is retried once; see web-e2e.yml. id: flaky - if: ${{ !cancelled() }} + if: ${{ false }} continue-on-error: true timeout-minutes: 5 env: @@ -527,7 +531,7 @@ jobs: run: python3 scripts/ci-flaky-report.py --suite desktop --playwright desktop/e2e-report.json - name: Keep the e2e run's logs # A flaky run keeps them as a failed one does; see web-e2e.yml. - if: ${{ failure() || steps.flaky.outputs.flaky == 'true' }} + if: always() uses: actions/upload-artifact@v7 with: name: hide-desktop-e2e-logs diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 1fe7fd27bd..f2aaecd8bc 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -177,6 +177,7 @@ For tab notifications, the Herdr workspace that owns the target showing it is re A tab or pane focus is confirmed only after it has left the lane, in one of two ways: a session that shows it (its tab active in its workspace, or for a pane its layout focused on it in that tab), or Herdr's success answer when the session Hide last read already shows that tab, because the pinned Herdr publishes no event for focusing the tab it already shows; a refusal and the three-second deadline keep their rules. A session that arrives before a request leaves shows Herdr from before it, whatever it names: read as the answer, it kept a queued pane focus from ever being sent, leaving Herdr on another tab, and a queued tab focus Herdr reached on its own then left and was remembered as superseded, consuming Herdr's next real move to that tab (#629). A tab notification replaced after it was sent but before Herdr answered it stays remembered as superseded (`superseded_tab_focus`, at most 16, each for the same three seconds, dropped when Herdr definitely refuses it but kept when its result was lost, since Herdr may still have applied it): a session from before both requests can confirm the newer one, and Herdr's answer to the older one then arrives naming a tab Hide has left, so a move onto a superseded tab is consumed as that answer (`tab.focus.late_answer`) rather than followed; following it moved the keyboard to the other Agent area in the middle of typed input (#413). +A success answer can also confirm a request while an older one to the same checkout is still remembered as superseded: the session Hide last read is then from before Herdr applied the older one, and Herdr reports the newer tab again after reporting the older, so the confirmed tab is remembered as superseded too and that report is consumed as its answer; following it once moved the keyboard back to the first Agent area after a click into the second, in the middle of typed input (#660). Whether a tab focus is superseded is decided when it leaves the lane: one a newer tab focus replaced there never leaves and is not remembered, and one whose wait was replaced or settled while it waited, as a pane focus's tab wait does without taking it off the lane, is superseded as it leaves; its three-second wait starts when it is sent rather than when it was asked. Remembering only what had left by the time it was replaced let that tab focus leave unremembered, and its answer was followed as Herdr's own after a slow Herdr held the lane (#629). A pane focus in a tab Herdr is not showing moves Herdr's tab as well, and Herdr reports that tab move on its session stream after it has answered the focus, so the tab is awaited in the same tab wait: sent with its pane focus, held while that pane control runs, given its three seconds from Herdr's answer, superseded by the next move, and dropped when the focus is refused or never leaves. diff --git a/herdr-core/src/runtime/session.rs b/herdr-core/src/runtime/session.rs index 002a0aa11f..ca9de9a739 100644 --- a/herdr-core/src/runtime/session.rs +++ b/herdr-core/src/runtime/session.rs @@ -3409,6 +3409,12 @@ impl Runtime { /// Ends the wait on the tab focus for `tab_id` when Herdr has answered it /// and the session Hide last read already shows that tab, the one case /// in which no confirming event follows. + /// + /// While an earlier request to the same checkout is still unanswered, + /// that session is from before Herdr applied the earlier one: Herdr moves + /// through it and back, and reports this tab again after it. That report + /// is held as this request's late answer, so it is not followed after a + /// newer move has replaced it (#660). pub(super) fn confirm_tab_focus_already_shown(&mut self, tab_id: &str) { let confirmed = self.pending_tab_focus.as_ref().is_some_and(|pending| { pending.sent @@ -3422,6 +3428,13 @@ impl Runtime { "checkout_id": pending.scope_id, "tab_id": pending.target_id, })); + if self + .superseded_tab_focus + .iter() + .any(|held| held.scope_id == pending.scope_id && held.target_id != tab_id) + { + self.supersede_tab_focus(pending); + } } } /// Remembers a tab notification Herdr will answer after Hide has moved diff --git a/herdr-core/src/runtime/tests/session_navigation.rs b/herdr-core/src/runtime/tests/session_navigation.rs index 7f822afa15..48d4e779c8 100644 --- a/herdr-core/src/runtime/tests/session_navigation.rs +++ b/herdr-core/src/runtime/tests/session_navigation.rs @@ -1069,6 +1069,76 @@ fn view_authority_a_late_answer_to_a_superseded_switch_is_not_followed() { assert_eq!(diagnostic_count(&runtime, "tab.focus.followed"), 1); } +/// Issue #660. The same drop and click as #413, then a click back into the +/// new area, with Herdr's session stream behind its answers. The answer to +/// the click on t1 finds the session from before the drop still naming t1, +/// and the answer to the click on t2 finds the drop's late t2; each answer +/// confirms its request, but Herdr still reports each move afterwards, in +/// order. Following the late t1 moved the keyboard out of t2 in the middle +/// of typing there. +#[test] +fn view_authority_answers_confirmed_ahead_of_their_events_are_not_followed() { + let checkout_path = "/private/tmp/hide-view-authority-answer-ahead"; + let (mut runtime, checkout_id) = live_tab_order_runtime(checkout_path); + let tabs = ["w-order:t1", "w-order:t2"]; + let acknowledged = || { + Ok(RemoteControlOutcome::Acknowledged { + created_tab_id: None, + created_pane_id: None, + }) + }; + let focus = |tab_id: &str| RemoteControlAction::FocusTab { + tab_id: tab_id.to_owned(), + }; + runtime.ingest_session(Ok(tab_order_payload( + checkout_path, + &tabs, + &tabs, + "w-order:t1", + ))); + assert!(runtime.dispatch_json(&focus_tab_event(&checkout_id, "w-order:t2"))); + runtime.complete_lane_tab(focus("w-order:t2"), acknowledged(), 3); + assert!(runtime.dispatch_json(&focus_tab_event(&checkout_id, "w-order:t1"))); + runtime.complete_lane_tab(focus("w-order:t1"), acknowledged(), 3); + runtime.ingest_session(Ok(tab_order_payload( + checkout_path, + &tabs, + &tabs, + "w-order:t2", + ))); + assert!(runtime.dispatch_json(&focus_tab_event(&checkout_id, "w-order:t2"))); + runtime.complete_lane_tab(focus("w-order:t2"), acknowledged(), 3); + + // Herdr's reports of the click on t1 and then the click on t2. + for answer in ["w-order:t1", "w-order:t2"] { + runtime.ingest_session(Ok(tab_order_payload(checkout_path, &tabs, &tabs, answer))); + assert_eq!( + checkout_active_tab_id(&runtime, &checkout_id).as_deref(), + Some("w-order:t2"), + "Herdr naming {answer} does not move the tab the operator chose" + ); + assert_eq!( + runtime.snapshot().terminal.pane_id.as_deref(), + Some("w-order:t2:p"), + "the keyboard stays in the operator's pane while Herdr names {answer}" + ); + } + assert_eq!(diagnostic_count(&runtime, "tab.focus.followed"), 0); + + // Once Herdr has reported every move, one it makes on its own is followed. + runtime.ingest_session(Ok(tab_order_payload( + checkout_path, + &tabs, + &tabs, + "w-order:t1", + ))); + assert_eq!( + checkout_active_tab_id(&runtime, &checkout_id).as_deref(), + Some("w-order:t1") + ); + assert_eq!(diagnostic_count(&runtime, "tab.focus.followed"), 1); +} + /// Issue #594. Each Agent cycle commit is one pane focus, and a pane in /// another tab moves Herdr's tab too. Herdr answers the focus at once, but /// its session stream reports the tab moves afterwards, in order. Those are