Skip to content

Commit 3925003

Browse files
committed
fix(web): #106 review — the layout switch never moves a file instead of the chat, fills the window in both layouts, and works where a workspace sets it
Review comment 4274117959 (the moves act on whatever is active): whenChatActive resolved on its timeout as well, so the move commands ran whether or not the chat was the active editor and could move the file beside it; and in split the second levelcode.ai.focus, after README.md was opened (and became the editor on show), was followed by the move with no wait at all. Each command that acts on the active editor (the two moves, and the join below) now goes through one guard: the tab model is read immediately before it, after waiting up to 1.5 s for the reveal to land; one that cannot be confirmed is skipped, as is every later one in that arrangement, and so is one overtaken by a newer layout request while it waited. whenChatActive resolves true/false. The wait for the chat to come to the front before the window is read at all stays: when the layout is changed by saving the setting from a settings editor opened in front of the chat, that editor's group is in the tab model until the chat is focused, and read at once the window looks like two groups already, so nothing is docked (found in a browser run of this change before it was committed; pinned by a unit case). If that wait times out, nothing is moved. Tests: chatFirst with the chat never active does not move; split waits after the README until the chat is active again and does not move if it never is (also on the reload path); a split waiting to move is dropped when chatFirst is chosen meanwhile. Review comment 4274118020 (chatFirst left file groups visible): only empty groups were closed, so a group with files (a split file editor, files put on the right) kept part of the window. Such groups are now joined into the chat's group with workbench.action.joinAllGroups, which merges into the active group and moves the editors in inactive, so no document is closed and the chat stays on show. The remaining group is then unlocked: a group the chat was docked in is auto-locked, and a lone locked group sends the next file into a new split. The usual split -> chatFirst switch (the chat alone on the right) is unchanged. Test: three arrangements with files outside the chat's group are joined and unlocked; no join when the chat is not active. Review comment 4274118061 (split in a folder without README.md): with the chat as the only tab nothing kept the first group, so the move closed it and left one group, auto-locked. An empty untitled document is opened in column one first (preserveFocus, not a preview) when there is no README and no other tab; if even that cannot be opened the chat is not moved. The existing test that pinned the old sequence for this case is changed to the new one. Review comment 4274118118 (the switch wrote only the user setting): with levelcode.web.layout in .vscode/settings.json the workspace value wins, so the status item and the commands did nothing. writeLayout() inspects the setting and updates the workspace value when there is one, the user's otherwise. A folder-level value is not a third target: the setting is window-scoped, which VS Code does not read from a multi-root folder (FOLDER_SCOPES), and in a single-folder window the folder's settings are the workspace's. Tests drive activate() and the registered commands. The vscode stand-in now always has activeTabGroup: a file shown by showTextDocument is on show until the chat's reveal lands (a test can hold the reveal back), otherwise the chat is; plus openTextDocument, inspect() and a workspace layer of settings. On the previous extension.js the 8 new or changed cases fail and the other 32 pass.
1 parent 53c1039 commit 3925003

3 files changed

Lines changed: 280 additions & 39 deletions

File tree

‎docs/WEB.md‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,16 @@ extension, a stylesheet or a build-time edit of the browser build's own copy of
114114
**Layouts.** `levelcode.web.layout` is `chatFirst` (the chat alone, side bars closed, conversations on its
115115
left — the way a chat app is used) or `split` (Explorer, files on the left, the chat docked on the right — the
116116
way an editor is used). The status bar item at the left and **LevelCode: Layout: Switch** change the setting
117-
(there is no default key binding: `Cmd+Alt+L` is Find in Selection on macOS); one listener applies it, so Settings
118-
does the same. The first start in a workspace is `chatFirst`. The chat panel is not restored by a reload, so a
117+
(there is no default key binding: `Cmd+Alt+L` is Find in Selection on macOS) where it takes effect — the workspace's
118+
value when `.vscode/settings.json` has one, since that outranks the user's, the user's otherwise; one listener
119+
applies it, so Settings does the same. The first start in a workspace is `chatFirst`. The chat panel is not restored by a reload, so a
119120
`split` layout docks the chat again at start — without revealing the Explorer or moving the focus (that is done
120121
once per workspace, `workspaceState`), so an Explorer the visitor closed stays closed. The start-up and a switch wait
121122
for the chat's tab to exist (`onDidChangeTabs`, 2.5 s) rather than reading the tab model at a guessed time. Only
122123
existing workbench commands are used, so what the visitor then arranges by hand is an ordinary layout. Files that are
123-
open when going back to `chatFirst` stay as tabs beside the chat.
124+
open when going back to `chatFirst` stay open as tabs behind the chat: a group that still has files (a split file
125+
editor, say) is joined into the chat's (`workbench.action.joinAllGroups`, which moves them in inactive), and that one
126+
group is unlocked, because a group the chat was docked in is locked and would send the next file into a new split.
124127

125128
**Widths.** The chat page decides by **its own width**, not the window's: from 1000 px it docks the
126129
conversation list as a 264 px rail; below 760 px it compacts; in between the list is the dialog it is on the
@@ -134,7 +137,15 @@ Constraints worth knowing before changing it:
134137

135138
- The chat webview's CSP has no `font-src`: the skin uses the system font stack only.
136139
- A group that is emptied by moving the chat out of it is closed, so `split` opens a file in the first group
137-
**before** it moves the chat (`applyLayout`, pinned by `workspace.test.js`).
140+
**before** it moves the chat — the README, or an empty untitled document when there is none and the chat is the
141+
group's only tab (`applyLayout`, pinned by `workspace.test.js`).
142+
- The move and join commands act on the **active editor**, and `levelcode.ai.focus` returns before the reveal has
143+
reached the tab model. The window is read only once the chat is in front (until then an editor that was in front
144+
of it, such as a settings editor in a group of its own, still counts as a group). Each move or join then runs only
145+
when the tab model says the chat is the active editor, read immediately
146+
before it (after waiting up to 1.5 s for that); otherwise it is skipped, as is every later one in that arrangement,
147+
and so is one that a newer layout request has overtaken. A skipped move leaves the window as it was; a guessed one
148+
would move the file beside the chat.
138149
- The rail asks the page for its conversations with `listSessions`; it must never call `openSessions()`,
139150
which seeds the list with sample conversations when nothing has arrived yet.
140151
- Text drawn in the theme's accent uses `textLink.foreground`, not `focusBorder` (which is translucent and a line

0 commit comments

Comments
 (0)