mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-16 11:19:33 +01:00
feat(tabs): keep alerted tabs visible during a rail search
A session with a tab alert (red action or yellow idle, whatever tabAlerts holds, the same set a collapsed group header surfaces) now stays visible while the rail search or the sidebar filter is narrowing the list, even when its name does not match. A prompt waiting on you should never be hidden by a view filter. The pure CodemanTabSearch.filter decides it: a row passed with keep: true is never hidden. It counts toward its group, so the group stays on screen and the header number is the rows left showing, but not toward matchCount, so "No sessions match" still shows above a lone alerted row. _applyTabListFilter() flags session rows from tabAlerts; web tabs carry no alerts and are never kept. No new wiring: updateTabAlertFromHooks() and _onSessionWorking() already call renderSessionTabs(), and both render paths end in the shared filter.
This commit is contained in:
1 parent
7c3877016b
commit
d3fc07ee28
5 files changed
+117
-12
No files matched your search
+11
-3
@@ -5753,9 +5753,15 @@ class CodemanApp {
|
||||
* - Rail: the NAME only, a web tab's title included (it is a row in the same
|
||||
* list, and hiding every web tab would make a dashboard unfindable).
|
||||
*
|
||||
* A group or case box left with no match hides with its header, its count
|
||||
* shows the matches, and the grouped tree's roving stop and posinset follow
|
||||
* the visible items. A collapsed group's rows are not in the DOM at all,
|
||||
* A session row with a tab alert (red action or yellow idle, whatever
|
||||
* tabAlerts holds, the set a collapsed group header surfaces) stays visible
|
||||
* even when it does not match: a prompt waiting on you is never hidden by a
|
||||
* view filter. Alerts come and go through renderSessionTabs(), and both
|
||||
* render paths end here, so nothing else re-runs this for them.
|
||||
*
|
||||
* A group or case box left with nothing showing hides with its header, its
|
||||
* count shows the rows left showing (a kept row included), and the grouped
|
||||
* tree's roving stop and posinset follow the visible items. A collapsed group's rows are not in the DOM at all,
|
||||
* which is why the rail search also expands the projection (_projectTabGroups).
|
||||
*/
|
||||
_applyTabListFilter() {
|
||||
@@ -5771,6 +5777,8 @@ class CodemanApp {
|
||||
? this._tabRowSearchName(tab)
|
||||
: `${tab.getAttribute('aria-label') || ''} ${tab.getAttribute('title') || ''}`,
|
||||
section: tab.closest('.tab-layout-group, .tab-cluster'),
|
||||
// Web tabs carry no alerts; only a session row can be kept.
|
||||
keep: !tab.dataset.webviewId && !!tab.dataset.id && !!this.tabAlerts?.get(tab.dataset.id),
|
||||
}));
|
||||
const result = window.CodemanTabSearch?.filter(rows, query);
|
||||
if (!result) return;
|
||||
|
||||
@@ -1032,12 +1032,18 @@ function tabSearchNeedle(query) {
|
||||
* rendered and applies the result as classes, so the list itself (grouping,
|
||||
* order, Alt+N badges) is never rebuilt or reordered by a search.
|
||||
*
|
||||
* @param {Array<{key: unknown, text: string, section?: unknown}>} rows in list
|
||||
* order; `section` is the row's group or case box, null/undefined for none.
|
||||
* A row flagged `keep: true` is never hidden, matching or not (the caller keeps
|
||||
* a tab with an alert on screen: a prompt waiting on you is never hidden by a
|
||||
* view filter). It counts toward its section, so its group stays on screen with
|
||||
* it, but not toward `matchCount`.
|
||||
*
|
||||
* @param {Array<{key: unknown, text: string, section?: unknown, keep?: boolean}>} rows
|
||||
* in list order; `section` is the row's group or case box, null/undefined for none.
|
||||
* @param {unknown} query
|
||||
* @returns {{active: boolean, hidden: Set<unknown>, counts: Map<unknown, number>, matchCount: number}}
|
||||
* `counts` has every section seen, an emptied one as 0, so it can be hidden;
|
||||
* `matchCount` is the number of rows left showing.
|
||||
* `counts` is the rows left showing per section (kept rows included), every
|
||||
* section seen, an emptied one as 0, so it can be hidden; `matchCount` is the
|
||||
* number of rows whose TEXT matched, so it can be 0 above a lone kept row.
|
||||
*/
|
||||
function filterTabSearchRows(rows, query) {
|
||||
const needle = tabSearchNeedle(query);
|
||||
@@ -1048,11 +1054,12 @@ function filterTabSearchRows(rows, query) {
|
||||
const hasSection = row.section !== null && row.section !== undefined;
|
||||
if (hasSection && !counts.has(row.section)) counts.set(row.section, 0);
|
||||
const text = typeof row.text === 'string' ? row.text.toLocaleLowerCase() : '';
|
||||
if (needle && !text.includes(needle)) {
|
||||
const matches = !needle || text.includes(needle);
|
||||
if (!matches && row.keep !== true) {
|
||||
hidden.add(row.key);
|
||||
continue;
|
||||
}
|
||||
matchCount++;
|
||||
if (matches) matchCount++;
|
||||
if (hasSection) counts.set(row.section, counts.get(row.section) + 1);
|
||||
}
|
||||
return { active: needle.length > 0, hidden, counts, matchCount };
|
||||
|
||||
Reference in new issue
Block a user