Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(infra): note env pins on the storage path and engine launch fields

Yudhi Armyndharis2669ba506363
diff --git a/dashboard/src/pages/Infrastructure.test.ts b/dashboard/src/pages/Infrastructure.test.ts
index ba9be4449..9a74cf868 100644
--- a/dashboard/src/pages/Infrastructure.test.ts
+++ b/dashboard/src/pages/Infrastructure.test.ts
@@ -556,6 +556,48 @@ test('the pending-restart note survives a successful save', async () => {
assert.ok(screen.queryByText(PENDING_RESTART_NOTE), 'the pending-restart note must not vanish once a save succeeds');
});
+/** The pin note rendered inside a text field's form group, or null. */
+function fieldPinNote(container: HTMLElement, labelText: string): string | null {
+ return fieldInput(container, labelText).closest('.form-group')?.querySelector('.env-pin-note')?.textContent ?? null;
+}
+
+test('fields the Quick Start stack pins show the env-pin note naming their variable', async () => {
+ const { screen, waitFor } = rtl;
+ resetFetchCalls();
+ overrides = { status: { ...INFRA_STATUS, envPinned: ['SESSION_DATA_PATH', 'STORAGE_LOCAL_PATH'] } };
+ const { container } = renderInfrastructure();
+
+ await screen.findByText('Database Configuration');
+ await awaitConfigHydrated(container);
+ await waitFor(() => {
+ assert.match(fieldPinNote(container, 'Session Data Path') ?? '', /SESSION_DATA_PATH/);
+ assert.match(fieldPinNote(container, 'Storage Path') ?? '', /STORAGE_LOCAL_PATH/);
+ });
+ assert.equal(fieldPinNote(container, 'Browser Arguments'), null, 'an unpinned field must carry no note');
+ const notes = Array.from(container.querySelectorAll('.env-pin-note')).map(note => note.textContent ?? '');
+ assert.ok(!notes.some(note => note.includes('PUPPETEER_ARGS') || note.includes('PUPPETEER_HEADLESS')));
+});
+
+test('without a reported pin those fields show no note, even when running and saved values differ', async () => {
+ const { screen } = rtl;
+ resetFetchCalls();
+ // The stock fixtures disagree on headless (running true, saved false): a pin-only note must not
+ // read that as a pin or as a pending restart.
+ overrides = { status: { ...INFRA_STATUS, envPinned: [] } };
+ const { container } = renderInfrastructure();
+
+ await screen.findByText('Database Configuration');
+ await awaitConfigHydrated(container);
+ for (const label of ['Session Data Path', 'Browser Arguments', 'Storage Path']) {
+ assert.equal(fieldPinNote(container, label), null, `unexpected note under ${label}`);
+ }
+ const headlessRow = toggleInput(container, 'Headless Mode').closest('.toggle-row');
+ assert.ok(
+ !headlessRow?.nextElementSibling?.classList.contains('env-pin-note'),
+ 'unexpected note under Headless Mode',
+ );
+});
+
test('the engine radio seeds from the effective engine when ENGINE_TYPE is pinned', async () => {
const { screen, waitFor } = rtl;
resetFetchCalls();
diff --git a/dashboard/src/pages/Infrastructure.tsx b/dashboard/src/pages/Infrastructure.tsx
index d0305c3ec..ec0b68997 100644
--- a/dashboard/src/pages/Infrastructure.tsx
+++ b/dashboard/src/pages/Infrastructure.tsx
@@ -177,14 +177,17 @@ export function Infrastructure() {
// - the value WAS saved and the server has not been restarted yet — a restart applies it.
// Both look identical as "running differs from saved", which is why drift alone used to be reported
// as an environment pin even on a stock stack with no variable set anywhere (#1082).
+ // Pin-only: PUPPETEER_ARGS cannot go through settingNote, because the running list is re-tokenized and
+ // gains the pinned `--lang` flag, so it never string-compares equal to the saved value. The headless
+ // flag and the two paths do have a running and a saved value, but show only a reported pin as well.
+ const pinNote = (envKey: string) =>
+ infraStatus?.envPinned?.includes(envKey) ? (
+ <p className="env-pin-note">
+ <AlertTriangle size={14} /> {t('infrastructure.envPinNote', { name: envKey })}
+ </p>
+ ) : null;
const settingNote = (envKey: string, running: unknown, saved: unknown) => {
- if (infraStatus?.envPinned?.includes(envKey)) {
- return (
- <p className="env-pin-note">
- <AlertTriangle size={14} /> {t('infrastructure.envPinNote', { name: envKey })}
- </p>
- );
- }
+ if (infraStatus?.envPinned?.includes(envKey)) return pinNote(envKey);
// Suppressed only while the request is actually in flight. `saving` is that flag; `savePending` is
// a latch set once a save SUCCEEDS and cleared only by a restart's page reload, so gating on it
// hid this note for the whole life of the page from the first successful save — which is exactly
@@ -466,6 +469,7 @@ export function Infrastructure() {
<span className="toggle-slider"></span>
</label>
</div>
+ {pinNote('PUPPETEER_HEADLESS')}
<div className="form-group">
<label htmlFor="infra-8">{t('infrastructure.engine.sessionDataPath')}</label>
<input
@@ -474,6 +478,7 @@ export function Infrastructure() {
value={configForm.engineConfig.sessionDataPath}
onChange={e => configForm.updateEngineConfig('sessionDataPath', e.target.value)}
/>
+ {pinNote('SESSION_DATA_PATH')}
</div>
<div className="form-group">
<label htmlFor="infra-9">{t('infrastructure.engine.browserArgs')}</label>
@@ -484,6 +489,7 @@ export function Infrastructure() {
onChange={e => configForm.updateEngineConfig('browserArgs', e.target.value)}
placeholder="--no-sandbox --disable-gpu"
/>
+ {pinNote('PUPPETEER_ARGS')}
</div>
</div>
) : (
@@ -727,6 +733,7 @@ export function Infrastructure() {
value={configForm.storageConfig.localPath}
onChange={e => configForm.updateStorageConfig('localPath', e.target.value)}
/>
+ {pinNote('STORAGE_LOCAL_PATH')}
</div>
)}
diff --git a/src/modules/infra/dto/infra-response.dto.ts b/src/modules/infra/dto/infra-response.dto.ts
index d2b1914f3..3709ef631 100644
--- a/src/modules/infra/dto/infra-response.dto.ts
+++ b/src/modules/infra/dto/infra-response.dto.ts
@@ -135,7 +135,7 @@ export class InfraStatusResponseDto {
@ApiProperty({
type: [String],
description:
- 'Which of the four settings the dashboard can edit are supplied by a layer ABOVE ' +
+ 'Which dashboard-editable settings are supplied by a layer ABOVE ' +
'`data/.env.generated` — the container environment or a project `.env` — and so cannot be ' +
'changed from the dashboard until that layer is. Reported, not inferred from a running-vs-saved ' +
'mismatch: a save that has not been restarted yet looks identical and needs the opposite advice.',
diff --git a/src/modules/infra/infra-status.controller.spec.ts b/src/modules/infra/infra-status.controller.spec.ts
index 2be1f9d80..866e90e95 100644
--- a/src/modules/infra/infra-status.controller.spec.ts
+++ b/src/modules/infra/infra-status.controller.spec.ts
@@ -236,6 +236,26 @@ describe('InfraStatusController.getStatus envPinned', () => {
expect(status.envPinned).not.toContain('PATH');
});
+ it('reports the storage path and engine launch options the Quick Start stack pins', async () => {
+ // docker-compose.dev.yml forwards these four with non-empty defaults, so a dashboard edit reverts.
+ recordPinnedEnvKeys({
+ SESSION_DATA_PATH: '/app/data/sessions',
+ PUPPETEER_HEADLESS: 'true',
+ PUPPETEER_ARGS: '--no-sandbox',
+ STORAGE_LOCAL_PATH: '/app/data/media',
+ PATH: '/usr/bin',
+ });
+
+ const status = await buildController().getStatus();
+
+ expect(status.envPinned).toEqual([
+ 'STORAGE_LOCAL_PATH',
+ 'PUPPETEER_HEADLESS',
+ 'SESSION_DATA_PATH',
+ 'PUPPETEER_ARGS',
+ ]);
+ });
+
it('reports an empty list when nothing above data/.env.generated supplies a selection key', async () => {
recordPinnedEnvKeys({});
diff --git a/src/modules/infra/infra-status.controller.ts b/src/modules/infra/infra-status.controller.ts
index 759a33ef3..1e564bbf1 100644
--- a/src/modules/infra/infra-status.controller.ts
+++ b/src/modules/infra/infra-status.controller.ts
@@ -55,10 +55,21 @@ interface InfraStatus {
}
/**
- * The keys behind the Infrastructure page's four editable selections, in card order. Only these are
- * reported: the page has no control for anything else, so naming other variables would be noise.
+ * The keys behind the Infrastructure page's editable controls that a shipped compose file or an
+ * operator variable is known to pin. docker-compose.dev.yml pins the local storage path and the three
+ * whatsapp-web.js launch options with non-empty defaults. Only page controls are reported: naming
+ * variables the page cannot edit would be noise.
*/
-const DASHBOARD_SELECTION_ENV_KEYS = ['DATABASE_TYPE', 'REDIS_ENABLED', 'STORAGE_TYPE', 'ENGINE_TYPE'];
+const DASHBOARD_PINNABLE_ENV_KEYS = [
+ 'DATABASE_TYPE',
+ 'REDIS_ENABLED',
+ 'STORAGE_TYPE',
+ 'STORAGE_LOCAL_PATH',
+ 'ENGINE_TYPE',
+ 'PUPPETEER_HEADLESS',
+ 'SESSION_DATA_PATH',
+ 'PUPPETEER_ARGS',
+];
@ApiTags('infrastructure')
@Controller('infra')
@@ -225,7 +236,7 @@ export class InfraStatusController {
browserArgs,
...(engineType === 'whatsapp-web.js' ? { webVersion, webVersionSource } : {}),
},
- envPinned: DASHBOARD_SELECTION_ENV_KEYS.filter(isEnvPinned),
+ envPinned: DASHBOARD_PINNABLE_ENV_KEYS.filter(isEnvPinned),
};
}