refactor(tiles): Ctrl+Tab and Alt+[ / ] cycle tiles through one helper

nextSession and prevSession each carried the same grid branch (cycleTile
from the active session, a human selection, skip the tab walk). It is now
_cycleTileFocus(delta) in tile-grid.js, next to the other focus moves;
both call it optionally, so a page or harness without tile-grid.js walks
the tabs as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer
2026-10-07 09:37:03 +02:00
parent be7328c8eb
commit 6cbaf3f7b6
2 changed files with 16 additions and 11 deletions
+3 -11
View File
@@ -9063,12 +9063,8 @@ class CodemanApp {
} }
nextSession() { nextSession() {
// With the tile grid open, Ctrl+Tab and Alt+] cycle through the tiles. // With the tile grid open, Ctrl+Tab and Alt+[ / Alt+] cycle through the tiles.
if (this._tileGrid?.open) { if (this._cycleTileFocus?.(1)) return;
const id = window.CodemanTileGrid.cycleTile(this._tileGrid.ids, this.activeSessionId, 1);
if (id) this.selectSession(id);
return;
}
if (this.sessionOrder.length <= 1) return; if (this.sessionOrder.length <= 1) return;
const currentIndex = this.sessionOrder.indexOf(this.activeSessionId); const currentIndex = this.sessionOrder.indexOf(this.activeSessionId);
@@ -9077,11 +9073,7 @@ class CodemanApp {
} }
prevSession() { prevSession() {
if (this._tileGrid?.open) { if (this._cycleTileFocus?.(-1)) return;
const id = window.CodemanTileGrid.cycleTile(this._tileGrid.ids, this.activeSessionId, -1);
if (id) this.selectSession(id);
return;
}
if (this.sessionOrder.length <= 1) return; if (this.sessionOrder.length <= 1) return;
const currentIndex = this.sessionOrder.indexOf(this.activeSessionId); const currentIndex = this.sessionOrder.indexOf(this.activeSessionId);
+13
View File
@@ -608,6 +608,19 @@ Object.assign(CodemanApp.prototype, {
if (id) this.selectSession(id); if (id) this.selectSession(id);
}, },
/**
* Ctrl+Tab / Alt+] (delta 1) and Alt+[ (delta -1) while the grid is open: a
* human selection of the next tile in reading order, wrapping. Returns
* whether the grid took the chord (it is open), so the tab walk is skipped.
*/
_cycleTileFocus(delta) {
const grid = this._tileGrid;
if (!grid?.open) return false;
const id = window.CodemanTileGrid.cycleTile(grid.ids, this.activeSessionId, delta);
if (id) this.selectSession(id);
return true;
},
/** Removes the focused tile (the session keeps running); a neighbour takes focus. */ /** Removes the focused tile (the session keeps running); a neighbour takes focus. */
removeFocusedTile() { removeFocusedTile() {
const grid = this._tileGrid; const grid = this._tileGrid;