Skip to content
Merged
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
12 changes: 7 additions & 5 deletions crates/daemon/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,10 @@
// prompts (codex with tool-heavy turns) don't lose any.
approvalQueue: [],
approvalShown: null,
// Logical session-list visibility. Keep this separate from the
// responsive CSS classes because narrow-screen auto-hide after
// selecting a session is intentionally not persisted to storage.
sessionListVisible: true,
};

const LARGE_TEXT_PASTE_CHARS = 16 * 1024;
Expand Down Expand Up @@ -3287,6 +3291,7 @@
}

function setSessionListVisible(visible, persist = true) {
state.sessionListVisible = !!visible;
if (isNarrowLayout()) {
sessionListEl.classList.toggle("collapsed", !visible);
} else {
Expand All @@ -3301,9 +3306,7 @@
}

function isSessionListVisible() {
return isNarrowLayout()
? !sessionListEl.classList.contains("collapsed")
: !mainEl.classList.contains("session-list-hidden");
return state.sessionListVisible;
}

function currentSessionListWidth() {
Expand Down Expand Up @@ -3353,8 +3356,7 @@

window.addEventListener("resize", () => {
setSessionListWidth(currentSessionListWidth(), false);
const storedVisible = localStorage.getItem(SESSION_LIST_VISIBLE_KEY);
setSessionListVisible(storedVisible !== "0", false);
setSessionListVisible(state.sessionListVisible, false);
});

// --- Transcript rendering -------------------------------------------------
Expand Down
53 changes: 53 additions & 0 deletions crates/e2e/tests/web_smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,59 @@ async fn web_client_loads_and_websocket_connects() {
"visible keyboard switch should preserve terminal focus: {switch_focus:?}"
);

// Mobile regression: selecting a session auto-hides the narrow session
// list without changing the stored preference. Keyboard/viewport resizes
// must preserve that current hidden state instead of re-reading the older
// stored "visible" preference and expanding the list from the top.
let list_resize: serde_json::Value = page
.evaluate(
r#"
(() => {
const saved = {
isNarrowLayout,
sessionListVisible: state.sessionListVisible,
storage: localStorage.getItem(SESSION_LIST_VISIBLE_KEY),
mode: state.mode,
};
try {
isNarrowLayout = () => true;
state.mode = 'chat';
localStorage.setItem(SESSION_LIST_VISIBLE_KEY, '1');
setSessionListVisible(false, false);
const before = {
visible: isSessionListVisible(),
collapsed: document.getElementById('sessionList').classList.contains('collapsed'),
stored: localStorage.getItem(SESSION_LIST_VISIBLE_KEY),
};
window.dispatchEvent(new Event('resize'));
const after = {
visible: isSessionListVisible(),
collapsed: document.getElementById('sessionList').classList.contains('collapsed'),
stored: localStorage.getItem(SESSION_LIST_VISIBLE_KEY),
};
return { before, after };
} finally {
isNarrowLayout = saved.isNarrowLayout;
state.sessionListVisible = saved.sessionListVisible;
state.mode = saved.mode;
if (saved.storage === null) localStorage.removeItem(SESSION_LIST_VISIBLE_KEY);
else localStorage.setItem(SESSION_LIST_VISIBLE_KEY, saved.storage);
setSessionListVisible(saved.sessionListVisible, false);
}
})()
"#,
)
.await
.expect("evaluate session list resize")
.into_value::<serde_json::Value>()
.expect("json object");
assert_eq!(list_resize["before"]["visible"], false);
assert_eq!(list_resize["before"]["collapsed"], true);
assert_eq!(list_resize["before"]["stored"], "1");
assert_eq!(list_resize["after"]["visible"], false);
assert_eq!(list_resize["after"]["collapsed"], true);
assert_eq!(list_resize["after"]["stored"], "1");

// Issue #132: the web session list exposes pin/unpin in the
// selected-session toolbar and marks pinned rows visibly.
let pin_ui: serde_json::Value = page
Expand Down
Loading