Merge "idle" into "waiting"
"Idle" was set by SessionStart and by nothing else, and there was no path back into it. So it never meant "sitting unused" -- it meant "opened and never asked anything yet", a state a few seconds long that you would almost never catch. Meanwhile a session that finished an hour ago and was forgotten showed as waiting, which is correct but leaves the fourth state with nothing to describe. A session that has just opened is waiting for your first prompt exactly as one that finished a turn is waiting for your next. They are the same thing, and now they are the same state. Three glyphs instead of four, which also gives the remaining three more room to be told apart in a monochrome panel. Files written by the previous hook still say "idle", and a session open across the upgrade must not disappear, so unrecognised states now read as waiting rather than being treated as unknown. Covered by a test that feeds an "idle" file to the store and asserts it comes back as waiting, sorted by age among the others. The "hide when nothing is running" setting goes with it. Its condition was "no sessions, or all of them idle"; with idle gone the second half is unreachable and the first was already unconditional, so the switch could no longer change anything. A control that does nothing is worse than no control. The compaction test also got stronger in passing: it now checks that a mid-turn SessionStart leaves a *busy* session alone, which is the case that matters. It used to assert from waiting, where the state it was guarding against happened to be the state already stored.
This commit is contained in:
@@ -47,7 +47,9 @@ write('s-blocked', 'blocked', '/home/u/proj-blocked', 10, livePid);
|
||||
write('s-wait-new', 'waiting', '/home/u/proj-new', 60, livePid);
|
||||
write('s-wait-old', 'waiting', '/home/u/proj-old', 3600, livePid);
|
||||
write('s-dead', 'waiting', '/home/u/proj-dead', 5, deadPid);
|
||||
write('s-idle', 'idle', '/home/u/proj-idle', 5, livePid);
|
||||
// Written by the older hook, which had a fourth state. Files like this
|
||||
// survive an upgrade in a session that was already open.
|
||||
write('s-legacy', 'idle', '/home/u/proj-legacy', 5, livePid);
|
||||
GLib.file_set_contents(GLib.build_filenamev([STATE, 'notes.txt']), 'ignored');
|
||||
GLib.file_set_contents(GLib.build_filenamev([STATE, 'half.json']), '{"broken');
|
||||
|
||||
@@ -73,8 +75,12 @@ store.connect('changed', () => {
|
||||
check('longest wait precedes newer wait',
|
||||
s[1]?.sessionId === 's-wait-old' && s[2]?.sessionId === 's-wait-new',
|
||||
`${s[1]?.sessionId}, ${s[2]?.sessionId}`);
|
||||
check('busy after waiting', s[3]?.sessionId === 's-busy', s[3]?.sessionId);
|
||||
check('idle last', s[4]?.sessionId === 's-idle', s[4]?.sessionId);
|
||||
const legacy = s.find(x => x.sessionId === 's-legacy');
|
||||
check('a retired state reads as waiting, not dropped',
|
||||
legacy?.state === 'waiting', legacy?.state);
|
||||
check('and sorts by age among the waiting ones',
|
||||
s[3]?.sessionId === 's-legacy', s[3]?.sessionId);
|
||||
check('busy after waiting', s[4]?.sessionId === 's-busy', s[4]?.sessionId);
|
||||
|
||||
check('dead session file removed from disk',
|
||||
!GLib.file_test(GLib.build_filenamev([STATE, 's-dead.json']), GLib.FileTest.EXISTS));
|
||||
|
||||
Reference in New Issue
Block a user