Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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=["desktop-e2e"]' >> "$GITHUB_OUTPUT"
echo 'full=false' >> "$GITHUB_OUTPUT"
echo 'rust-packages=[]' >> "$GITHUB_OUTPUT"

policy:
name: policy checks
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -515,19 +519,19 @@ 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:
GH_TOKEN: ${{ github.token }}
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
Expand Down
19 changes: 12 additions & 7 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,17 @@ Hide keeps the latest local selection at that outcome, but the pinned API suppli
Which Herdr tab move is Hide's own answer, and when one Herdr makes is followed, is read from one list (`tab_focus_requests`, `runtime/tab_focus.rs`): the tab moves that have left the lane and not been answered, in the order they left, each a tab focus, the tab of a pane focus, or a tab created with focus.
A request still waiting on the lane is not in it: the lane holds it, and nothing of it can reach Herdr until it leaves.
The order carries meaning because of two facts: the lane sends the next control only after Herdr has answered the last, so Herdr applies them in the order they were sent, and Herdr delivers events "in order within each subscription" ([Socket API](https://herdr.dev/docs/socket-api/), Event subscriptions), so their moves arrive in that order.
A tab newly active in its workspace, or a fresh focus event naming one, is a Herdr move; it answers the earliest request on that tab, and every request sent before that one leaves with it, because Herdr applied it earlier and its move arrived earlier or was folded into the same session.
A move is read in the workspace that owns the tab, whichever workspace holds Herdr's keyboard, because a checkout is keyed by path and can hold tabs from several Herdr workspaces.
A request answered where Herdr already was moves nothing, and the pinned Herdr publishes no event for focusing the tab it already shows, so that answer settles it; where Herdr was is the tab of the request before it in the same workspace, or with none left, what Hide last read from Herdr.
A session alone confirms nothing: until the moves of earlier requests have arrived it shows Herdr from before them, and taking one that still showed the first of quick clicks t2, t1, t2 as the answer to the second t2 let the later moves be followed as Herdr's own and left the screen on t1 after a last click on t2 (#653).
A refused request leaves at once; one whose answer was lost, and one Herdr never reports, wait out the three-second deadline, which for a pane focus's tab move starts at Herdr's answer to the focus and does not run while that pane control is running.
At most 16 are kept (`TAB_FOCUS_REQUEST_LIMIT`); a burst faster than the deadline evicts the oldest and logs `tab.focus.request_evicted`.
A Herdr move is one `tab_focused` event, and the event replica keeps each as it applies it (`SessionTabMoves`, `sidebar.rs`): a session folds several events into one state, and one that ends on t2 cannot say whether Herdr went t2 or t2, t3, t2.
Each session the replica publishes carries its count of moves and the latest 16, but a move alone never publishes while a workspace is held for its layout, because that publish would take back a workspace the creation worker already projected; the move rides on the next publish.
The core reads the moves it has not read yet, oldest first; each answers the earliest request on its tab, and every request sent before that one leaves with it, because Herdr applied it earlier.
A session alone answers nothing: until the moves of earlier requests have arrived it shows Herdr from before them, and taking one that still showed the first of quick clicks t2, t1, t2 as the answer to the second t2 let the later moves be followed as Herdr's own and left the screen on t1 after a last click on t2 (#653); taking a session that showed the last request's tab as the answer to all of them would have followed t3 out of t2, t3, t2 arriving one session each.
A snapshot read outside the event stream (a close's or a creation's fresh projection, the editor's status answer) has no place in Herdr's order and answers nothing.
When moves were dropped between two sessions, because more than 16 arrived or a new replica started after a reconnect, the tabs newly active since the last session and a fresh focus event stand in for them, and `tab.focus.moves_gap` is logged.
A move answers by its tab alone, whichever workspace holds Herdr's keyboard, because a checkout is keyed by path and can hold tabs from several Herdr workspaces.
A request for the tab Herdr shows moves nothing, and the pinned Herdr publishes no event for it, so its answer settles it; Herdr does publish one for any other tab, another workspace's active tab included, so which tab Herdr shows is one value, recorded on each request as it leaves: the tab of the request before it, or with none outstanding, the focused tab of the last session.
A refused request leaves at once and moved nothing, so the request after it takes over where Herdr was; one whose answer was lost, and one Herdr never reports, wait out the three-second deadline, which for a pane focus's tab move starts at Herdr's answer to the focus and does not run while that pane control is running.
A refusal is reported when nothing was asked after it, also when its request had already passed its deadline.
At most 16 requests are kept (`TAB_FOCUS_LIMIT`, the same number as the moves); a burst faster than the deadline evicts the oldest and logs `tab.focus.request_evicted`.
While any request in a checkout is outstanding, sent or waiting on the lane, Herdr is about to be moved again and its moves there are not followed; a move that answers a request Hide has since left is logged as `tab.focus.late_answer`.
The list replaced one pending slot that rules were added to a failure at a time: a superseded list for a request replaced in flight (#413), a pane focus's tab wait (#594), superseding on leaving the lane (#629), and confirming only sent requests (#635); each had followed a Herdr move that was Hide's own answer.
A pane focus is confirmed only after it has left the lane, by a session whose layout of its tab focuses it while that tab is active in its workspace: a session that arrives before it leaves shows Herdr from before it, and taken as the answer it kept a queued pane focus from ever being sent, leaving Herdr on another tab (#629).
Expand Down Expand Up @@ -508,7 +513,7 @@ The envelope `id` is request correlation, never retry identity; mutation converg
`live.rs` and `remote.rs` also use this boundary for response decoding and generated request parameters.
The boundary preserves remote protocol diagnostics before decoding the complete generated snapshot, and the isolated pinned-server probe checks the control responses.
Terminal input, scroll, resize and release messages and the parameterless snapshot request remain boundary-owned schema gaps, with tests that require migration when their parameter types appear.
Behavior the schema does not state: the pinned Herdr publishes no `tab_focused` or `pane_focused` event for a `tab.focus` on the tab it already shows (checked on a private server: a move to another tab publishes both, a repeat publishes neither), so a focus that lands there is confirmed by its answer (the control lane paragraphs above).
Behavior the schema does not state: the pinned Herdr publishes no `tab_focused` or `pane_focused` event for a `tab.focus` on the tab it already shows, the active tab of its focused workspace (checked on a private server: a move to another tab publishes both, a repeat publishes neither, and a `tab.focus` on another workspace's active tab publishes both with `workspace_focused`; a `pane.focus` in another tab, a tab created with focus and `workspace.focus` each publish `tab_focused`; a burst t1, t2, t1 publishes three in order), so a focus that lands there is confirmed by its answer (the control lane paragraphs above).


## The platform layer
Expand Down
17 changes: 11 additions & 6 deletions herdr-core/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,11 @@ const CLOSE_STAGE_TIMEOUT_MS: u64 = 5_000;
/// waiting stops.
const VIEW_FOCUS_NOTIFICATION_TIMEOUT_MS: u64 = 3_000;

/// How many sent, unanswered tab moves Hide remembers at once. Each lives at
/// most `VIEW_FOCUS_NOTIFICATION_TIMEOUT_MS`; a burst of tab switches faster
/// than that evicts the oldest and reports it.
const TAB_FOCUS_REQUEST_LIMIT: usize = 16;
// How many sent, unanswered tab moves Hide remembers at once, the same
// number of Herdr's moves the replica keeps. Each lives at most
// `VIEW_FOCUS_NOTIFICATION_TIMEOUT_MS`; a burst of tab switches faster than
// that evicts the oldest and reports it.
use crate::sidebar::TAB_FOCUS_LIMIT;

/// A pane focus Hide has already made and told Herdr about.
///
Expand Down Expand Up @@ -1354,8 +1355,11 @@ pub struct Runtime {
/// created with focus. Which Herdr move is Hide's own answer, and when a
/// move Herdr makes is followed, are read from it (`tab_focus.rs`).
tab_focus_requests: Vec<tab_focus::TabFocusRequest>,
/// The tabs active in their Herdr workspaces at the last session, so the
/// next one says which tabs Herdr has moved to since.
/// How many of the replica's tab moves have been read, and of which
/// replica, so the next session says which moves are new.
herdr_tab_moves_read: Option<(u64, u64)>,
/// The tabs active in their Herdr workspaces at the last replica session.
/// When moves were dropped, the difference from it stands in for them.
herdr_active_tabs_seen: BTreeSet<String>,
/// The tab Herdr had focused at the last session update. A follow needs
/// Herdr's focus to have moved; a focused tab that merely differs from
Expand Down Expand Up @@ -1901,6 +1905,7 @@ impl Runtime {
pending_read_record_reconciliation: HashSet::new(),
visible_tab_ids: BTreeMap::new(),
tab_focus_requests: Vec::new(),
herdr_tab_moves_read: None,
herdr_active_tabs_seen: BTreeSet::new(),
herdr_focused_tab_seen: None,
herdr_tab_focus_seen: None,
Expand Down
14 changes: 8 additions & 6 deletions herdr-core/src/runtime/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ impl Runtime {
}
}
self.report_unresolved_active_tabs(unresolved_active_tabs);
self.reconcile_visible_tabs(&mut workspaces, &herdr_tabs);
self.reconcile_visible_tabs(&mut workspaces, &herdr_tabs, payload.tab_moves.as_ref());

let previous = self.snapshot.navigator.clone();
let previous_card = self.snapshot.card.clone();
Expand Down Expand Up @@ -1223,6 +1223,7 @@ impl Runtime {
&mut self,
workspaces: &mut [WorkspaceSnapshot],
herdr: &HerdrTabView,
herdr_moves: Option<&crate::sidebar::SessionTabMoves>,
) {
let mut followed: Vec<(String, String, String)> = Vec::new();
let mut follow_pane: Option<String> = None;
Expand All @@ -1242,7 +1243,8 @@ impl Runtime {
self.herdr_focused_tab_seen = herdr.focused_tab_id.clone();
// Herdr's moves since the last session answer Hide's requests in
// the order they were sent; a focus move among them is not followed.
let answered = self.take_tab_focus_answers(herdr, herdr_focus_moved);
let answered = self.take_tab_focus_answers(herdr, herdr_moves, herdr_focus_moved);
let asks = self.tab_asks();
let focus_answered = herdr_focus_moved
&& herdr
.focused_tab_id
Expand Down Expand Up @@ -1396,7 +1398,7 @@ impl Runtime {
&& (workspace.device_id != workspace::LOCAL_DEVICE_ID
|| self.workspace_views.is_none()
|| answered.iter().any(|request| request.tab_id == *tab_id)
|| self.tab_move_asked(tab_id)
|| asks.asked(tab_id)
|| (herdr.focus_event.as_ref().is_some_and(|event| !event.creation))
|| (herdr.focus_event.is_none() && self.snapshot.navigator.workspaces.iter().any(|previous| {
previous.checkouts.iter().any(|previous| {
Expand All @@ -1408,8 +1410,8 @@ impl Runtime {
})))
})
.map(str::to_owned);
let pending_tab = self.newest_tab_ask_in(&checkout.id);
let outstanding = self.tab_moves_outstanding(&checkout.id);
let pending_tab = asks.newest_in(&checkout.id).map(str::to_owned);
let outstanding = asks.outstanding_in(&checkout.id);
// The tab holding the selected pane, when it is in this
// checkout. With no tab of its own yet, Hide shows the tab the
// keyboard is in rather than one Herdr remembers, so a restore
Expand Down Expand Up @@ -3176,7 +3178,7 @@ impl Runtime {
// that was already on its way.
let previous_focus = self.snapshot.focused.pane_id.clone();
let pending_pane = self.pending_pane_focus.clone();
let arriving_confirms_pending_tab = self.tab_move_asked(&arriving_tab_id);
let arriving_confirms_pending_tab = self.tab_asks().asked(&arriving_tab_id);
let mut adopt_focus = match pending_pane.as_ref() {
_ if self.pane_focus_in_flight.is_some() => false,
Some(pending)
Expand Down
Loading
Loading