Repository navigation
fix(webui): clicking the selected session's rail link returns to the conversation - #12
Conversation
|
The dependency check rejected the first version of this: That rule is right and the fix belongs where the other document listeners already are — the platform's DOM capability. The second commit adds (The shell could also take the click as a prop from the rail row instead of listening for it, which would put the decision in the rail rather than in the shell. That is a larger change to the rail's props and to the memo comparisons around it, so this keeps the change to the surface that owns the bug.) |
ca4550d to
cb77871
Compare
…conversation A rail session row is a plain `#session=<id>` anchor, so the selection runs through the hash subscription rather than through a setter the shell holds. Clicking the link of the session that is already selected changes nothing that subscription can observe -- the hash is the same, so no `hashchange` fires and the effect that puts the conversation back does not run again. The shell stayed on the 远程 page although the user asked for the conversation. The click is the one signal left, so the shell listens for it on the rail's session links in the capture phase and puts the conversation back.
The shell may not touch the document: `document`, `localStorage` and `sessionStorage` are the restricted ambient members, and the dependency check says so. The listener belongs to the platform's DOM capability, which already carries the document's listeners, so `listenForClick` joins them and the shell subscribes to the capability it already holds. The behaviour is the same document listener in the capture phase.
cb77871 to
415e4bb
Compare
The bug
Open the 远程 page from the rail, then click the session you are already in. The page stays put — the conversation never comes back, and the only way out is to pick a different session or reload the page.
Why
A rail session row is a plain
#session=<id>anchor, so the selection runs through the hash subscription insideuseSelectedSessionId(client/shell/use-selected-session.ts) rather than through a setter the shell holds.The shell puts the conversation back in an effect keyed on the resolved session id:
Clicking the link of the session that is already selected changes nothing that subscription can observe: the hash is the same, so no
hashchangefires, the id does not change, and the effect does not run again. The shell keeps the surface it was showing (shellSurfacestays{kind: "remote"}), so the click is swallowed.Clicking a different session works, because that one does change the hash.
The fix
The click is the one signal left, so the shell listens for it on the rail's session links (
data-webui-session-link) in the capture phase and puts the conversation back. The listener acts only on the link of the currently selected session: a click on any other link changes the hash and is already handled by the effect above.The test
packages/webui/test/browser/rail-session-navigation.spec.mjsdrives the built client: it selects a session, leaves for the 远程 page, clicks the same session's rail link and asserts that the conversation is back and the remote page is gone.The link is clicked by dispatching the event rather than by moving the pointer: the rail row carries its own action buttons (置顶, 归档, 更多) on the right, and they intercept the pointer at the link's centre.
The behaviour was verified against the packaged 0.1.8 client before this was upstreamed — with the patched bundle the click returns to the conversation, with the original bundle the 远程 page stays, which is the bug.