Make the panel position and the label width settings
Two things that were constants and had no business being constants. Placement: the box (left, centre, right) and the index within it. The default is unchanged -- centre, index 1, immediately right of the clock -- and an index past the end of a box lands at the end, so a large one means "last". Applied at once, no reload. Moving is done by rebuilding the indicator rather than by moving the actor. addToStatusArea is what registers it under the uuid and there is no documented call to move one between boxes; everything else reaches into Main.panel's private boxes. It costs one re-read of a few small state files and only when the setting is touched. Label width: three characters by default, settable up to ten, not down. Three is enough to keep initials apart and narrow enough not to shove the clock about; below three, distinct projects start sharing a label. A wider label takes more initials rather than a longer prefix -- a prefix collapses dev-skills and dev-conventions at any width -- so dev-skills stays "ds" however wide the setting, while claude-code-gnome-extension becomes "ccge" at four. A disambiguating digit still eats into the label instead of extending past the width, so a chip that gains one does not push the row. Sticky labels work against that setting: kept labels are kept whatever width they were cut at, so widening would leave every session on screen at its old width until it ended. The width is therefore the one thing that discards the map -- a relabelling that was asked for is not a label moving under your hand. The combo row is bound by hand: Gio.Settings.bind maps a boolean to 'active' and an int to 'value', but a string to a selected index needs bind_with_mapping, which is not introspectable. Only the write direction is wired up, and the test covers it, because a row that stores its index instead of its value looks fine until the shell reads the key. Fixed on the way, found by watching the centre box grow 2 -> 3 -> 4 -> 5 across four moves: PanelMenu.ButtonBox connects `this._onDestroy.bind(this)` in its _init, and its _onDestroy is what destroys the container -- the St.Bin the panel box actually holds. The name resolves through the prototype chain, so this extension's own _onDestroy had been silently replacing the shell's since the beginning, leaving an empty container in the panel on every teardown. Renamed to _teardown; the box now stays at two children across moves and across enable/disable cycles. Verified in a nested shell on a copy of the extension carrying temporary logging, since the shell refuses screenshots to non-portal callers: every box, indices 0, 1 and 9, and widths 3, 5, 8, 10 and back, with no JS errors and no leftover actors.
This commit is contained in:
@@ -26,6 +26,17 @@ check('camelCase counts as segments', 'om', abbreviate('outlineMcp'));
|
||||
check('digits survive', 'p2', abbreviate('proj_2'));
|
||||
check('empty name does not crash', '?', abbreviate(''));
|
||||
|
||||
// --- a wider label ---------------------------------------------------------
|
||||
// More initials, not a longer prefix: the whole point of initials is keeping
|
||||
// "dev-skills" and "dev-conventions" apart, and a prefix at any width does not.
|
||||
check('a wider label takes more initials', 'ccge',
|
||||
abbreviate('claude-code-gnome-extension', 4));
|
||||
check('and stops at the segments it has', 'ds', abbreviate('dev-skills', 6));
|
||||
check('a single word gets more of itself', 'jellyb', abbreviate('jellybit', 6));
|
||||
check('the default is still three', 'ccg', abbreviate('claude-code-gnome-extension'));
|
||||
check('a nonsense width falls back to the default', 'ccg',
|
||||
abbreviate('claude-code-gnome-extension', 'wide'));
|
||||
|
||||
// --- collisions ------------------------------------------------------------
|
||||
const two = [
|
||||
{ sessionId: 'a', since: 100, base: 'dev-skills' },
|
||||
@@ -70,6 +81,21 @@ check('every label fits in three characters', [3], lengths);
|
||||
check('twelve sessions in one project are all distinct',
|
||||
12, new Set(wide.values()).size);
|
||||
|
||||
// A digit still eats into the label instead of extending past the width, which
|
||||
// is what keeps a row of chips from rippling when one of them gains a digit.
|
||||
const wider = assignChips(many, new Map(), 5);
|
||||
check('a wider run holds its own width',
|
||||
[5], [...new Set([...wider.values()].map(l => l.length))]);
|
||||
check('and stays distinct', 12, new Set(wider.values()).size);
|
||||
check('the oldest keeps the clean label', 'umbar', wider.get('s0'));
|
||||
check('the next one gives up a character', 'umba2', wider.get('s1'));
|
||||
|
||||
// Stickiness outranks the width: labels already handed out are kept as they
|
||||
// are. The indicator drops the map when the setting changes, which is the only
|
||||
// way a label is allowed to move.
|
||||
const kept = assignChips(many, wide, 5);
|
||||
check('an existing label is not re-cut', 'umb', kept.get('s0'));
|
||||
|
||||
out(failures ? `\n${failures} failure(s)` : '\nall passed');
|
||||
if (typeof imports !== 'undefined')
|
||||
imports.system.exit(failures ? 1 : 0);
|
||||
|
||||
Reference in New Issue
Block a user