feat(work-status): add opt-in turn statistics (#3177)

Add optional completed-turn statistics without changing the existing panel layout. Separate final text delivery speed from whole-turn throughput, preserve scope and opt-in settings, and explain each metric with localized delayed tooltips.

Validated focused telemetry, lifecycle, sync and persistence tests, all-workspace type-check and lint, web builds, the 12-locale narrow layout, and full GitHub CI.
This commit is contained in:
alvins82
2026-09-06 22:56:27 +03:00
committed by GitHub
parent b0282b2720
commit d8215ef5b3
36 changed files with 1404 additions and 31 deletions
@@ -203,6 +203,9 @@ export const createSettingsHelpers = (dependencies) => {
...new Set(candidate.workStatusHiddenSections.filter((entry) => typeof entry === 'string' && entry.length > 0)),
];
}
if (typeof candidate.workStatusHiddenSectionsExplicit === 'boolean') {
result.workStatusHiddenSectionsExplicit = candidate.workStatusHiddenSectionsExplicit;
}
if (typeof candidate.desktopLanAccessEnabled === 'boolean') {
result.desktopLanAccessEnabled = candidate.desktopLanAccessEnabled;
}
@@ -69,6 +69,19 @@ const createTestHelpersWithRealSanitizers = () => {
};
describe('settings helpers', () => {
it('round-trips telemetry opt-in with the hidden list and preserves it across unrelated writes', () => {
const helpers = createTestHelpers();
const legacy = helpers.sanitizeSettingsUpdate({ workStatusHiddenSections: [] });
expect(legacy.workStatusHiddenSectionsExplicit).toBeUndefined();
const changes = helpers.sanitizeSettingsUpdate({ workStatusHiddenSections: [], workStatusHiddenSectionsExplicit: true });
const saved = helpers.mergePersistedSettings(legacy, changes);
const reloaded = helpers.formatSettingsResponse(JSON.parse(JSON.stringify(saved)));
expect(reloaded.workStatusHiddenSections).toEqual([]);
expect(reloaded.workStatusHiddenSectionsExplicit).toBe(true);
const next = helpers.mergePersistedSettings(reloaded, helpers.sanitizeSettingsUpdate({ workStatusPanelEnabled: false }));
expect(helpers.formatSettingsResponse(next).workStatusHiddenSectionsExplicit).toBe(true);
expect(helpers.sanitizeSettingsUpdate({ workStatusHiddenSectionsExplicit: 'true' }).workStatusHiddenSectionsExplicit).toBeUndefined();
});
it('imports from the packed @openchamber/web tarball without escaping the published package', async () => {
const tempRoot = mkdtempSync(join(tmpdir(), 'settings-helpers-pack-'));
const packDir = join(tempRoot, 'pack');