fix(limits): lower the session ceiling to 462 so the layout budget holds

An owner's tab layout holds at most MAX_TAB_REFS (512) refs, counting saved web
tabs (up to MAX_WEBVIEWS, 50 by default) as well as sessions. With a ceiling of
500, session creation could still fail with HTTP 500 on the layout limit before
the capacity message. 512 - 50 = 462; a test pins the ceiling plus MAX_WEBVIEWS
inside MAX_TAB_REFS so the two limits cannot drift apart again.

Co-Authored-By: Christian Haberl <116439789+christianhaberl@users.noreply.github.com>
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
committed 2026-10-21 08:59:29 +02:00
1 parent b073035bdc
commit e58c1a2f19
9 files changed
+28 -19

No files matched your search

+12 -4
View File
@@ -52,11 +52,19 @@ describe('global session cap (CODEMAN_MAX_SESSIONS)', () => {
expect(sessionCapacityState(sessionsOf(3)).atGlobalCap).toBe(true);
});
it.each(['1000', '501', '99999999999999999999'])('clamps %j to the ceiling of 500', async (value) => {
it.each(['1000', '500', '463', '99999999999999999999'])('clamps %j to the ceiling of 462', async (value) => {
const { sessionCapacityState, sessionCapacityMessage } = await loadWithEnv({ CODEMAN_MAX_SESSIONS: value });
expect(sessionCapacityState(sessionsOf(499)).atGlobalCap).toBe(false);
expect(sessionCapacityState(sessionsOf(500)).atGlobalCap).toBe(true);
expect(sessionCapacityMessage(sessionsOf(500))).toContain('(500)');
expect(sessionCapacityState(sessionsOf(461)).atGlobalCap).toBe(false);
expect(sessionCapacityState(sessionsOf(462)).atGlobalCap).toBe(true);
expect(sessionCapacityMessage(sessionsOf(462))).toContain('(462)');
});
it('keeps the ceiling inside the tab-layout budget next to the saved web tabs', async () => {
vi.resetModules();
const { MAX_CONCURRENT_SESSIONS_CEILING } = await import('../../src/config/map-limits.js');
const { MAX_WEBVIEWS } = await import('../../src/config/webview-limits.js');
const { MAX_TAB_REFS } = await import('../../src/tab-layout.js');
expect(MAX_CONCURRENT_SESSIONS_CEILING + MAX_WEBVIEWS).toBeLessThanOrEqual(MAX_TAB_REFS);
});
it.each(['', '0', '-5', '2.5', 'abc', '1e3'])('falls back to 50 for an unusable value %j', async (value) => {