mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-04 14:39:42 +02:00
refactor: drop the two store members nothing consults
`TuiModelStore.confirmSatisfied()` and `approvalFor()` had no caller outside their own tests. The first one mattered: it answered "does the typed text authorize this kill?" with an exact name match, while the rule actually consulted (`confirmAccepts()` in tui-app) also accepts the 8-character id prefix a mux name carries. Two divergent answers to one question, the stricter one unreachable and waiting to be picked up by mistake. knip cannot see class members, so the dead-code sweep never flagged either. The tests they existed for now assert observable state instead, and the approvals one got stronger on the way: it checks that a session id coming back does not inherit the dead session's dialog, which is the invariant `removeSession()` is actually keeping. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -262,28 +262,32 @@ describe('the store', () => {
|
||||
expect(flattenRows(model.groups())).toHaveLength(3);
|
||||
});
|
||||
|
||||
it('tracks the confirm-kill overlay and only accepts the exact name', () => {
|
||||
// Whether the typed text AUTHORIZES the kill is `confirmAccepts()` in
|
||||
// tui-app, tested there; the store only carries what was typed.
|
||||
it('tracks the confirm-kill overlay, keyed to the name it showed', () => {
|
||||
const model = createTuiModel();
|
||||
model.replaceSessions([session({ sessionId: 'a', name: 'w4-api' })]);
|
||||
model.beginConfirmKill(model.rows()[0]);
|
||||
expect(model.mode).toBe('confirm-kill');
|
||||
expect(model.confirmSatisfied()).toBe(false);
|
||||
expect(model.confirm).toEqual({ sessionId: 'a', name: 'w4-api', typed: '' });
|
||||
model.setConfirmInput('w4-ap');
|
||||
expect(model.confirmSatisfied()).toBe(false);
|
||||
model.setConfirmInput('w4-api');
|
||||
expect(model.confirmSatisfied()).toBe(true);
|
||||
expect(model.confirm?.typed).toBe('w4-ap');
|
||||
model.closeOverlay();
|
||||
expect(model.mode).toBe('list');
|
||||
expect(model.confirm).toBeNull();
|
||||
});
|
||||
|
||||
it('drops a session approval along with the session', () => {
|
||||
it('drops a session approval along with the session, and never resurrects it', () => {
|
||||
const model = createTuiModel();
|
||||
model.replaceSessions([session({ sessionId: 'a' })]);
|
||||
model.setApprovals([approval({ sessionId: 'a' })]);
|
||||
expect(model.approvalFor('a')).toBeDefined();
|
||||
expect(model.rows()[0].approval).toBeDefined();
|
||||
model.removeSession('a');
|
||||
expect(model.approvalFor('a')).toBeUndefined();
|
||||
expect(model.rows()).toHaveLength(0);
|
||||
// The same id coming back must not inherit the dead session's dialog.
|
||||
model.upsertSession(session({ sessionId: 'a' }));
|
||||
expect(model.rows()[0].approval).toBeUndefined();
|
||||
expect(model.rows()[0].state).toBe('idle');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user