mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-09 08:59:40 +02:00
refactor(tiles): the picker's Open and "Open group as tiles" share _replaceTileGrid
Both put a new set of sessions on the grid in place of the open one: choose the focus (the session in focus if the set holds it, else the first), close an open grid forgotten, drop activeSessionId so re-parking snapshots nothing, then open. They now call one _replaceTileGrid(ids), which carries the reason for the order once. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+15
-14
@@ -449,16 +449,7 @@ Object.assign(CodemanApp.prototype, {
|
||||
open.addEventListener('click', () => {
|
||||
const ids = boxes.filter((b) => b.checked).map((b) => b.value);
|
||||
this.closeTilePicker();
|
||||
if (ids.length === 0) return;
|
||||
const focus = ids.includes(this.activeSessionId) ? this.activeSessionId : ids[0];
|
||||
if (this._tilesOwnTerminal()) {
|
||||
// A new set for the open grid, as "Open group as tiles" does it: the
|
||||
// parked terminal still holds what it showed before the grid, and
|
||||
// re-parking must not snapshot it.
|
||||
this.closeTileGrid({ keepStored: false, reselect: false });
|
||||
this.activeSessionId = null;
|
||||
}
|
||||
this.openTileGrid(ids, { focusedId: focus });
|
||||
if (ids.length > 0) this._replaceTileGrid(ids);
|
||||
});
|
||||
|
||||
document.body.appendChild(menu);
|
||||
@@ -879,13 +870,23 @@ Object.assign(CodemanApp.prototype, {
|
||||
this.showToast?.('This group has no session to show as tiles', 'info');
|
||||
return false;
|
||||
}
|
||||
// Before the open grid closes (which drops activeSessionId): the session in
|
||||
// focus keeps it if the group holds it, as with the picker's Open.
|
||||
return this._replaceTileGrid(ids);
|
||||
},
|
||||
|
||||
/**
|
||||
* Opens the grid on `ids` in place of whatever it shows (the picker's Open,
|
||||
* "Open group as tiles"): the session in focus keeps focus when `ids` holds
|
||||
* it, otherwise the first one takes it. Chosen BEFORE an open grid closes,
|
||||
* because the close drops activeSessionId: as in selectSession's tile
|
||||
* branch, the parked terminal still holds what it showed before the grid,
|
||||
* and re-parking must not snapshot it.
|
||||
*
|
||||
* @returns {boolean} whether the grid is open afterwards
|
||||
*/
|
||||
_replaceTileGrid(ids) {
|
||||
const focus = ids.includes(this.activeSessionId) ? this.activeSessionId : ids[0];
|
||||
if (this._tilesOwnTerminal()) {
|
||||
this.closeTileGrid({ keepStored: false, reselect: false });
|
||||
// As selectSession's tile branch: the parked terminal still holds what it
|
||||
// showed before the grid, and re-parking must not snapshot it.
|
||||
this.activeSessionId = null;
|
||||
}
|
||||
return this.openTileGrid(ids, { focusedId: focus });
|
||||
|
||||
Reference in New Issue
Block a user