Compare commits

..

3 Commits

20 changed files with 8 additions and 739 deletions
@@ -1,13 +0,0 @@
# Interview AI application-context lifetime
Baseline A3 `348f4684`, isolated branch codex/interview-ai-context at E:/Storage/Projects/Active/temp docs/jobjakt-local-build/next-security-patch. Source `0f8b17a`. Uses the qualified locked Next16.4.6/follow-redirects1.16.3 installation. No live model.
Three deterministic tests failed on original runtime source: a late generation displayed application7 text under application8; a completed suggestion remained available after changing application; a late accepted write called the former board loader again after navigation. Synthetic model/API responses only. The first two are also a risk of offering the wrong application's content for explicit application8 acceptance; no real misdirected write is claimed.
The sole assistant caller now keys its instance by jobId, scoping instructions, generated-language draft, errors, busy state and suggestions to that application instance. Existing CV reader cleanup remains. A layout-lifetime ref invalidates on committed unmount; an already accepted write can finish at its original target, but cannot invoke the old board-refresh callback afterward. No write is redirected, automatically retried or newly authorised. Current-application explicit accept/reject and normal refresh still use existing paths. UI language and generated-content language remain independent within the current application.
PASSED: final55 cases/two suites (51 InterviewPrep/four daily connected route cases), non-incremental TypeScript, scoped two-file lint and source diff. Three red failures are included in55;48 skipped cases in the focused red selection are not final-suite skips. An earlier successful run used a passive cleanup; final55 was rerun after using synchronous layout cleanup and is the qualification result. Existing generation, explicit acceptance, failed-add retry, answer drafts, CV retry and follow-up cases remain passing. [Receipts](evidence/interview-ai-context/SOURCE_RECEIPTS.json) bind final source and readable/native evidence.
PASSED: final standard Next16.4.6 build on exact new source after the55-case run; compile, TypeScript and static export completed exit0. No warning bypass. This is current isolated E-drive export evidence, not the older C-drive export and not a fresh browser run.
NOT RUN: fresh full frontend/backend regression, browser, native device/AT, actual model/semantic quality, provider, security/recovery/release qualification. Parent preparation/follow-up outstanding reads, broader job/session lifetime, AI live fallback copy and other components remain separate proof-required work; this is not whole-application isolation acceptance. Existing PDF metrics/visual acceptance not reopened. No catalogue/schema/renderer/ownership/revision/provider changes, orchestrator, main merge or production action.
@@ -1,61 +0,0 @@
{
"baseline": "348f468478ed2fae1b6a52ff970471ea8ce54dd4",
"sourceCommit": "0f8b17a",
"sourceSha256Lf": {
"job-tracker-ui/src/components/InterviewPrep.tsx": "e1c12d012d0488a8cee533015fff0944028578ca6ee37dd61fe70b60363a5803",
"job-tracker-ui/src/interview-prep.test.tsx": "dfb23ea0682377a7edfe6af147f1046c90841e102ef35a2f62c6c85754058c97",
"job-tracker-ui/package.json": "8b31e44c10b77b6d1e007af04c757c0577f12972ff3f6c7079bbc4c446a0d415",
"job-tracker-ui/package-lock.json": "ac90fbdc79e2e0f23d54748814b41a03f5dcaf8fd27291b3dcb73b2603a83e72"
},
"nativeReceipts": [
{
"path": "interview-ai-context-red.json",
"lfSha256": "cd1750809c6757251f0616417b85d206db07ce6b74c3a167bb6f3537c5a10c06",
"rawSha256": "cd1750809c6757251f0616417b85d206db07ce6b74c3a167bb6f3537c5a10c06",
"gzipSha256": "bf634ffd5cebf2f84df570c339cded3cd9e4fba247ccb71662572e9e1536c783",
"nativeEncoding": "utf-8-sig"
},
{
"path": "interview-ai-context-red.txt",
"lfSha256": "a8673e1828567e5dcf97241f893c56178ba8cc09a90fbd9ed4a96e036527974c",
"rawSha256": "999d08952b06ea3dd0b9021fcc6cd8263e069e24404a18242209ca9c1bf98ad3",
"gzipSha256": "ab7bcecff278cce39f68ed4495cdbd0c827c31f5ccd515f5d12083d081ac4fd6",
"nativeEncoding": "utf-16"
},
{
"path": "interview-ai-context-final.json",
"lfSha256": "3a24bbb550d5246f9dbb3fa28c6e5570c290263ba80714f6d1ffa7597a3496a8",
"rawSha256": "3a24bbb550d5246f9dbb3fa28c6e5570c290263ba80714f6d1ffa7597a3496a8",
"gzipSha256": "8b54fbfc88a68d714250d36a4cc41af046ecceb8f3b5cc51f06c858c0f307222",
"nativeEncoding": "utf-8-sig"
},
{
"path": "interview-ai-context-final.txt",
"lfSha256": "a4b08a7b17361517ff242d01d15a2e31f974924adbab26ccf866efc45b886dd0",
"rawSha256": "89dc7976226bf01bbd22702c18ea96ea3e821161c2c6fcb65949e6c2b514b924",
"gzipSha256": "1905b14d96265a2a1fa2ab37f354e74e99569dd15401bd9dfac254fa8a969a14",
"nativeEncoding": "utf-16"
},
{
"path": "interview-ai-context-typecheck.txt",
"lfSha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"rawSha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"gzipSha256": "46b50c321b39e89a491b6727a01628c34245605a30beb3e7414c5e01cff90e6e",
"nativeEncoding": "utf-8-sig"
},
{
"path": "interview-ai-context-lint.txt",
"lfSha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"rawSha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"gzipSha256": "46b50c321b39e89a491b6727a01628c34245605a30beb3e7414c5e01cff90e6e",
"nativeEncoding": "utf-8-sig"
},
{
"path": "interview-ai-context-build.txt",
"lfSha256": "2670468cf9011247d064dbd24366eeccc367597f86992c6129b60e00a1e7f3c1",
"rawSha256": "87aa3a0631f4f36905c225ac05a5977045ff0c3735fda14eafbd5b6ffcab6b2a",
"gzipSha256": "c9ec5fd2e55767fead726932919416886763c9e5fc75573415d7d3c1b3fc174b",
"nativeEncoding": "utf-16"
}
]
}
@@ -1,23 +0,0 @@
> job-tracker-ui@0.1.0 build
> node --max-old-space-size=4096 ./node_modules/next/dist/bin/next build
▲ Next.js 16.4.6 (Turbopack)
✓ Running next.config.js took 49ms
Creating an optimized production build ...
✓ Compiled successfully in 788ms
Running TypeScript ...
Finished TypeScript in 10.6s ...
Collecting page data using 4 workers ...
Generating static pages using 4 workers (0/3) ...
✓ Generating static pages using 4 workers (3/3) in 1504ms
Finalizing page optimization ...
Route (app)
┌ ○ /
└ ○ /_not-found
○ (Static) prerendered as static content
File diff suppressed because one or more lines are too long
@@ -1,13 +0,0 @@
node :
At line:1 char:122
+ ... =$env:TEMP; node node_modules/jest/bin/jest.js --runInBand --runTests ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Test Suites: 2 passed, 2 total
Tests: 55 passed, 55 total
Snapshots: 0 total
Time: 29.011 s
Ran all test suites within paths "src/interview-prep.test.tsx", "src/daily-control-loop.test.tsx".
Test results written to: ..\..\interview-ai-context-final.json
File diff suppressed because one or more lines are too long
@@ -1,361 +0,0 @@
node : console.error
At line:1 char:122
+ ... =$env:TEMP; node node_modules/jest/bin/jest.js --runInBand --runTests ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: ( console.error:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
An update to InterviewAiAssistant inside a test was not wrapped in act(...).
When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */
This ensures that you're testing the behavior the user would see in the browser. Learn more at
https://react.dev/link/wrap-tests-with-act
233 | setCv(null); setCvLoading(true); setCvError(null);
234 | applicationAssetsApi.cv(jobId)
> 235 | .then((result) => { if (active) setCv(result); })
| ^
236 | .catch((cause) => { if (active) setCvError({ cause }); })
237 | .finally(() => { if (active) setCvLoading(false); });
238 | return () => { active = false; };
at node_modules/react-dom/cjs/react-dom-client.development.js:18758:19
at runWithFiberInDEV (node_modules/react-dom/cjs/react-dom-client.development.js:874:13)
at warnIfUpdatesNotWrappedWithActDEV (node_modules/react-dom/cjs/react-dom-client.development.js:18757:9)
at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom-client.development.js:16409:11)
at dispatchSetStateInternal (node_modules/react-dom/cjs/react-dom-client.development.js:9170:13)
at dispatchSetState (node_modules/react-dom/cjs/react-dom-client.development.js:9127:7)
at setCv (src/components/InterviewPrep.tsx:235:39)
console.error
An update to ApplicationFollowUp inside a test was not wrapped in act(...).
When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */
This ensures that you're testing the behavior the user would see in the browser. Learn more at
https://react.dev/link/wrap-tests-with-act
431 | try {
432 | const result = await interviewPrepApi.followUp(jobId);
> 433 | setData(result);
| ^
434 | setDate(result.followUpAt ? result.followUpAt.slice(0, 10) : "");
435 | setAction(result.nextAction ?? "");
436 | setError(null);
at node_modules/react-dom/cjs/react-dom-client.development.js:18758:19
at runWithFiberInDEV (node_modules/react-dom/cjs/react-dom-client.development.js:874:13)
at warnIfUpdatesNotWrappedWithActDEV (node_modules/react-dom/cjs/react-dom-client.development.js:18757:9)
at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom-client.development.js:16409:11)
at dispatchSetStateInternal (node_modules/react-dom/cjs/react-dom-client.development.js:9170:13)
at dispatchSetState (node_modules/react-dom/cjs/react-dom-client.development.js:9127:7)
at setData (src/components/InterviewPrep.tsx:433:7)
console.error
An update to ApplicationFollowUp inside a test was not wrapped in act(...).
When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */
This ensures that you're testing the behavior the user would see in the browser. Learn more at
https://react.dev/link/wrap-tests-with-act
432 | const result = await interviewPrepApi.followUp(jobId);
433 | setData(result);
> 434 | setDate(result.followUpAt ? result.followUpAt.slice(0, 10) : "");
| ^
435 | setAction(result.nextAction ?? "");
436 | setError(null);
437 | } catch (err) {
at node_modules/react-dom/cjs/react-dom-client.development.js:18758:19
at runWithFiberInDEV (node_modules/react-dom/cjs/react-dom-client.development.js:874:13)
at warnIfUpdatesNotWrappedWithActDEV (node_modules/react-dom/cjs/react-dom-client.development.js:18757:9)
at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom-client.development.js:16409:11)
at dispatchSetStateInternal (node_modules/react-dom/cjs/react-dom-client.development.js:9170:13)
at dispatchSetState (node_modules/react-dom/cjs/react-dom-client.development.js:9127:7)
at setDate (src/components/InterviewPrep.tsx:434:7)
console.error
An update to ApplicationFollowUp inside a test was not wrapped in act(...).
When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */
This ensures that you're testing the behavior the user would see in the browser. Learn more at
https://react.dev/link/wrap-tests-with-act
433 | setData(result);
434 | setDate(result.followUpAt ? result.followUpAt.slice(0, 10) : "");
> 435 | setAction(result.nextAction ?? "");
| ^
436 | setError(null);
437 | } catch (err) {
438 | setError({ cause: err, fallback: "interviewFollowUpLoadFailed" });
at node_modules/react-dom/cjs/react-dom-client.development.js:18758:19
at runWithFiberInDEV (node_modules/react-dom/cjs/react-dom-client.development.js:874:13)
at warnIfUpdatesNotWrappedWithActDEV (node_modules/react-dom/cjs/react-dom-client.development.js:18757:9)
at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom-client.development.js:16409:11)
at dispatchSetStateInternal (node_modules/react-dom/cjs/react-dom-client.development.js:9170:13)
at dispatchSetState (node_modules/react-dom/cjs/react-dom-client.development.js:9127:7)
at setAction (src/components/InterviewPrep.tsx:435:7)
console.error
An update to ApplicationFollowUp inside a test was not wrapped in act(...).
When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */
This ensures that you're testing the behavior the user would see in the browser. Learn more at
https://react.dev/link/wrap-tests-with-act
434 | setDate(result.followUpAt ? result.followUpAt.slice(0, 10) : "");
435 | setAction(result.nextAction ?? "");
> 436 | setError(null);
| ^
437 | } catch (err) {
438 | setError({ cause: err, fallback: "interviewFollowUpLoadFailed" });
439 | } finally {
at node_modules/react-dom/cjs/react-dom-client.development.js:18758:19
at runWithFiberInDEV (node_modules/react-dom/cjs/react-dom-client.development.js:874:13)
at warnIfUpdatesNotWrappedWithActDEV (node_modules/react-dom/cjs/react-dom-client.development.js:18757:9)
at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom-client.development.js:16409:11)
at dispatchSetStateInternal (node_modules/react-dom/cjs/react-dom-client.development.js:9170:13)
at dispatchSetState (node_modules/react-dom/cjs/react-dom-client.development.js:9127:7)
at setError (src/components/InterviewPrep.tsx:436:7)
console.error
An update to ApplicationFollowUp inside a test was not wrapped in act(...).
When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */
This ensures that you're testing the behavior the user would see in the browser. Learn more at
https://react.dev/link/wrap-tests-with-act
438 | setError({ cause: err, fallback: "interviewFollowUpLoadFailed" });
439 | } finally {
> 440 | setLoading(false);
| ^
441 | }
442 | }, [jobId]);
443 |
at node_modules/react-dom/cjs/react-dom-client.development.js:18758:19
at runWithFiberInDEV (node_modules/react-dom/cjs/react-dom-client.development.js:874:13)
at warnIfUpdatesNotWrappedWithActDEV (node_modules/react-dom/cjs/react-dom-client.development.js:18757:9)
at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom-client.development.js:16409:11)
at dispatchSetStateInternal (node_modules/react-dom/cjs/react-dom-client.development.js:9170:13)
at dispatchSetState (node_modules/react-dom/cjs/react-dom-client.development.js:9127:7)
at setLoading (src/components/InterviewPrep.tsx:440:7)
console.error
An update to ApplicationInterviewPrep inside a test was not wrapped in act(...).
When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */
This ensures that you're testing the behavior the user would see in the browser. Learn more at
https://react.dev/link/wrap-tests-with-act
55 | setLoading(true);
56 | try {
> 57 | setBoard(await interviewPrepApi.get(jobId));
| ^
58 | setError(null);
59 | } catch (err) {
60 | setError({ cause: err, fallback: "interviewPrepLoadFailed" });
at node_modules/react-dom/cjs/react-dom-client.development.js:18758:19
at runWithFiberInDEV (node_modules/react-dom/cjs/react-dom-client.development.js:874:13)
at warnIfUpdatesNotWrappedWithActDEV (node_modules/react-dom/cjs/react-dom-client.development.js:18757:9)
at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom-client.development.js:16409:11)
at dispatchSetStateInternal (node_modules/react-dom/cjs/react-dom-client.development.js:9170:13)
at dispatchSetState (node_modules/react-dom/cjs/react-dom-client.development.js:9127:7)
at setBoard (src/components/InterviewPrep.tsx:57:7)
console.error
An update to ApplicationInterviewPrep inside a test was not wrapped in act(...).
When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */
This ensures that you're testing the behavior the user would see in the browser. Learn more at
https://react.dev/link/wrap-tests-with-act
56 | try {
57 | setBoard(await interviewPrepApi.get(jobId));
> 58 | setError(null);
| ^
59 | } catch (err) {
60 | setError({ cause: err, fallback: "interviewPrepLoadFailed" });
61 | } finally {
at node_modules/react-dom/cjs/react-dom-client.development.js:18758:19
at runWithFiberInDEV (node_modules/react-dom/cjs/react-dom-client.development.js:874:13)
at warnIfUpdatesNotWrappedWithActDEV (node_modules/react-dom/cjs/react-dom-client.development.js:18757:9)
at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom-client.development.js:16409:11)
at dispatchSetStateInternal (node_modules/react-dom/cjs/react-dom-client.development.js:9170:13)
at dispatchSetState (node_modules/react-dom/cjs/react-dom-client.development.js:9127:7)
at setError (src/components/InterviewPrep.tsx:58:7)
console.error
An update to ApplicationInterviewPrep inside a test was not wrapped in act(...).
When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */
This ensures that you're testing the behavior the user would see in the browser. Learn more at
https://react.dev/link/wrap-tests-with-act
60 | setError({ cause: err, fallback: "interviewPrepLoadFailed" });
61 | } finally {
> 62 | setLoading(false);
| ^
63 | }
64 | }, [jobId]);
65 |
at node_modules/react-dom/cjs/react-dom-client.development.js:18758:19
at runWithFiberInDEV (node_modules/react-dom/cjs/react-dom-client.development.js:874:13)
at warnIfUpdatesNotWrappedWithActDEV (node_modules/react-dom/cjs/react-dom-client.development.js:18757:9)
at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom-client.development.js:16409:11)
at dispatchSetStateInternal (node_modules/react-dom/cjs/react-dom-client.development.js:9170:13)
at dispatchSetState (node_modules/react-dom/cjs/react-dom-client.development.js:9127:7)
at setLoading (src/components/InterviewPrep.tsx:62:7)
console.error
An update to InterviewAiAssistant inside a test was not wrapped in act(...).
When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */
This ensures that you're testing the behavior the user would see in the browser. Learn more at
https://react.dev/link/wrap-tests-with-act
235 | .then((result) => { if (active) setCv(result); })
236 | .catch((cause) => { if (active) setCvError({ cause }); })
> 237 | .finally(() => { if (active) setCvLoading(false); });
| ^
238 | return () => { active = false; };
239 | }, [jobId, cvReadAttempt]);
240 |
at node_modules/react-dom/cjs/react-dom-client.development.js:18758:19
at runWithFiberInDEV (node_modules/react-dom/cjs/react-dom-client.development.js:874:13)
at warnIfUpdatesNotWrappedWithActDEV (node_modules/react-dom/cjs/react-dom-client.development.js:18757:9)
at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom-client.development.js:16409:11)
at dispatchSetStateInternal (node_modules/react-dom/cjs/react-dom-client.development.js:9170:13)
at dispatchSetState (node_modules/react-dom/cjs/react-dom-client.development.js:9127:7)
at setCvLoading (src/components/InterviewPrep.tsx:237:36)
FAIL src/interview-prep.test.tsx (6.032 s)
● late generation cannot offer another application the previous application suggestion
expect(element).not.toBeInTheDocument()
expected document not to contain element, found <p class="MuiTypography-root MuiTypography-body2
css-1jpc1n5-MuiTypography-root">Only for application seven</p> instead
356 | await act(async () => finish({ data: { result: { text: 'Only for application seven' } } }));
357 | const assistant = within(screen.getByRole('region', { name: translations.en.interviewAiTitle }));
> 358 | expect(assistant.queryByText('Only for application seven')).not.toBeInTheDocument();
| ^
359 | expect(assistant.queryByRole('button', { name: translations.en.interviewAiAddToPrep
})).not.toBeInTheDocument();
360 | expect(assistant.getByLabelText(translations.en.coverAiAdditionalInstructions)).toHaveValue('');
361 | expect(mockedApi.post).toHaveBeenCalledTimes(1);
at Object.toBeInTheDocument (src/interview-prep.test.tsx:358:67)
● completed AI suggestion is scoped to its application instead of becoming a new application draft
expect(element).not.toBeInTheDocument()
expected document not to contain element, found <p class="MuiTypography-root MuiTypography-body2
css-1jpc1n5-MuiTypography-root">Prepared for application seven only</p> instead
371 | view.rerender(<I18nProvider><ConfirmProvider><ApplicationInterviewPrep jobId={8}
/></ConfirmProvider></I18nProvider>);
372 | const assistant = within(screen.getByRole('region', { name: translations.en.interviewAiTitle }));
> 373 | expect(assistant.queryByText('Prepared for application seven only')).not.toBeInTheDocument();
| ^
374 | expect(assistant.queryByRole('button', { name: translations.en.interviewAiAddToPrep
})).not.toBeInTheDocument();
375 | expect(mockedApi.post).not.toHaveBeenCalledWith('/jobapplications/8/interview-prep', expect.anything());
376 | });
at Object.toBeInTheDocument (src/interview-prep.test.tsx:373:76)
● late accepted suggestion does not reload the previous application board into the current application
expect(received).toHaveLength(expected)
Expected length: 1
Received length: 2
Received array: [["/jobapplications/7/interview-prep"], ["/jobapplications/7/interview-prep"]]
389 | await waitFor(() => expect(mockedApi.get).toHaveBeenCalledWith('/jobapplications/8/interview-prep'));
390 | await act(async () => finish({ data: board.groups[0].items[0] }));
> 391 | expect(mockedApi.get.mock.calls.filter(([url]) => url ===
'/jobapplications/7/interview-prep')).toHaveLength(1);
| ^
392 | expect(mockedApi.get.mock.calls.filter(([url]) => url ===
'/jobapplications/8/interview-prep')).toHaveLength(1);
393 | expect(mockedApi.post.mock.calls[1]).toEqual(['/jobapplications/7/interview-prep',
expect.objectContaining({ source: 'ai', content: 'Application seven suggestion' })]);
394 | });
at Object.toHaveLength (src/interview-prep.test.tsx:391:99)
Test Suites: 1 failed, 1 total
Tests: 3 failed, 48 skipped, 51 total
Snapshots: 0 total
Time: 7.657 s, estimated 24 s
Ran all test suites within paths "src/interview-prep.test.tsx".
Test results written to: ..\..\interview-ai-context-red.json
@@ -1,45 +0,0 @@
# Interview parent state lifetime
17 November 2026; final revalidation 18 November 2026. Development checkpoint based on A3 `eb253877`, branch `codex/interview-parent-lifetime`. Scope is the interview-preparation and follow-up parent components and their unit tests. No runtime locale expansion, model/service calls, schema changes, production work or approval changes.
## Reproduced defects and fix
On unchanged baseline, deferred reads for application 7 were completed after rendering application 8. Seven regression cases failed: previous prep content replaced the current board; previous follow-up data overwrote a current draft; stale errors appeared in either current surface; stale finalisers dismissed either current loading state; and parent drafts/data survived the application boundary, causing a failed new follow-up read to expose old editable data instead of a GET-only retry.
A second pre-fix run added three cases: an older same-application refresh replaced a newer board, and a late prep addition cleared the new application's title draft and initiated a previous-application reload (both failed); a late follow-up write already retained its original API target (positive control passed). Thus nine expected failing regressions and one passing control were observed before editing production code; overlapping reruns are not additional unique tests.
The exported prep/follow-up components now render a job-keyed private workspace, following the existing keyed interview-assistant ownership pattern. Changing job unmounts its board, drafts, error and busy state together. A per-workspace active flag and read sequence guard read success/error/finally, and prevent an unmounted workspace from starting a refresh after an existing write completes. Only the newest read can update a mounted owner. Explicit writes retain their original closure/API target; no write is cancelled, migrated to another application or retried automatically. Same-application language changes keep the same workspace and its drafts.
Two additional same-application controls exercise stale errors and stale finalisers while a newer refresh remains pending. Existing rerender tests now await remount reads inside `act`, avoiding React test warnings caused by unawaited new parent workspaces. No test suppresses console output.
## Verification
Commands from `job-tracker-ui`:
```powershell
rtk proxy node node_modules/jest/bin/jest.js --runInBand --runTestsByPath src/interview-prep.test.tsx --cacheDirectory='../.test-cache'
rtk proxy node node_modules/typescript/bin/tsc --noEmit --incremental false
rtk proxy node node_modules/eslint/bin/eslint.js src/components/InterviewPrep.tsx src/interview-prep.test.tsx --max-warnings=0
```
- Final focused jsdom suite: **63/63 passed**, no snapshots, no React warnings. This includes 12 added cases and the existing 51; prior focused runs are not added to that total.
- Native runner receipt: [jest-results.json](jest-results.json), produced with `--json --outputFile='../docs/validation/interview-parent-lifetime/jest-results.json'` added to the command above. Final revalidation passed 63/63 with zero failed/pending tests and 23.206 seconds reported by the runner. This is a repeat of the same source-bound cases, not an additional 63 distinct tests.
- Full UI TypeScript check: passed, exit 0.
- Scoped lint: passed, exit 0, zero warnings. An earlier cleanup-ref lint warning was fixed by checking the active flag on completion instead of mutating the read ref during cleanup.
- `rtk git diff --check`: passed.
- Graph-first query used the existing isolated A3 research graph before source inspection. `rtk proxy graphify update .` performed AST-only extraction in this new worktree, without API/model calls or shared graph mutation. The initial refresh created 19,835 nodes and 48,044 edges; an incremental refresh followed the final source/test edits. Generated graph output is local untracked research material, not a new runtime dependency. Graph reported missing optional PDF/SQL extraction dependencies and unsupported/no-symbol files; this is structural orientation, not full runtime or document analysis.
Existing dependencies were accessed read-only through a directory junction to `E:/Storage/Projects/Active/temp docs/jobjakt-local-build/next-security-patch/job-tracker-ui/node_modules`. No install/build/browser lane ran.
Validated working-file SHA-256:
| File | SHA-256 |
| --- | --- |
| `job-tracker-ui/src/components/InterviewPrep.tsx` | `57d208df5880d8b93c9a3acf13e7b11d2791f4a9d3fdf55da56debe68c3145ee` |
| `job-tracker-ui/src/interview-prep.test.tsx` | `82c36af6225d4fb00fb689bf7243ef2163b6abc237c91a7058f283c173d34471` |
## Limits and integration
Browser/native/device, broader repository suites, hosted CI, backend/database, live AI, provider and production checks were not run. Root owns source-bound browser qualification, integration/publication and central tracking. This checkpoint does not grant release or roadmap-stage approval.
Adjacent existing behaviour remains: ordinary same-application board refresh hides/remounts row editors through `Shell`'s loading condition; preserving row-local unsaved answers during every ordinary refresh needs a separate behavioural decision and test package. This fix prevents superseded reads from replacing the newest board/draft state; it does not redesign refresh presentation or persistence. Pending writes may still finish on the original application after navigation, as explicitly initiated by the user.
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
import React, { useCallback, useEffect, useState } from "react";
import {
Alert, Box, Button, Checkbox, Chip, IconButton, LinearProgress, MenuItem, Paper,
@@ -43,10 +43,6 @@ function Shell({ title, subtitle, loading, error, children, onRetry, keepContent
}
export function ApplicationInterviewPrep({ jobId }: { jobId: number }) {
return <InterviewPrepWorkspace key={jobId} jobId={jobId} />;
}
function InterviewPrepWorkspace({ jobId }: { jobId: number }) {
const { t } = useI18n();
const [board, setBoard] = useState<InterviewPrepBoard | null>(null);
const [error, setError] = useState<{ cause: unknown; fallback: "interviewPrepLoadFailed" | "interviewPrepUpdateFailed" | "interviewPrepAnswerSaveFailed" } | null>(null);
@@ -54,26 +50,16 @@ function InterviewPrepWorkspace({ jobId }: { jobId: number }) {
const [busy, setBusy] = useState(false);
const [title, setTitle] = useState("");
const [category, setCategory] = useState(INTERVIEW_PREP_CATEGORIES[0].key);
const active = useRef(true);
const readSequence = useRef(0);
useLayoutEffect(() => {
active.current = true;
return () => { active.current = false; };
}, []);
const load = useCallback(async () => {
if (!active.current) return;
const request = ++readSequence.current;
setLoading(true);
try {
const result = await interviewPrepApi.get(jobId);
if (!active.current || request !== readSequence.current) return;
setBoard(result);
setBoard(await interviewPrepApi.get(jobId));
setError(null);
} catch (err) {
if (active.current && request === readSequence.current) setError({ cause: err, fallback: "interviewPrepLoadFailed" });
setError({ cause: err, fallback: "interviewPrepLoadFailed" });
} finally {
if (active.current && request === readSequence.current) setLoading(false);
setLoading(false);
}
}, [jobId]);
@@ -213,7 +199,7 @@ function InterviewPrepWorkspace({ jobId }: { jobId: number }) {
</Stack>
</Shell>
<InterviewAiAssistant key={jobId} jobId={jobId} onAccepted={load} />
<InterviewAiAssistant jobId={jobId} onAccepted={load} />
<ApplicationFollowUp jobId={jobId} />
</Stack>
@@ -229,11 +215,6 @@ const INTERVIEW_AI_FOCUS = [
] as const;
function InterviewAiAssistant({ jobId, onAccepted }: { jobId: number; onAccepted: () => void }) {
const active = useRef(true);
useLayoutEffect(() => {
active.current = true;
return () => { active.current = false; };
}, []);
const { canUseAi } = useAccountPlan();
const { language: uiLanguage, t } = useI18n();
const [cv, setCv] = useState<ApplicationCv | null>(null);
@@ -291,7 +272,6 @@ function InterviewAiAssistant({ jobId, onAccepted }: { jobId: number; onAccepted
content: suggestion,
source: "ai",
});
if (!active.current) return;
setSuggestion("");
onAccepted();
} catch (err) {
@@ -438,10 +418,6 @@ function PrepRow({ jobId, item, busy, onChanged, onError }: {
}
export function ApplicationFollowUp({ jobId }: { jobId: number }) {
return <FollowUpWorkspace key={jobId} jobId={jobId} />;
}
function FollowUpWorkspace({ jobId }: { jobId: number }) {
const { t } = useI18n();
const [data, setData] = useState<FollowUp | null>(null);
const [error, setError] = useState<{ cause: unknown; fallback: "interviewFollowUpLoadFailed" | "interviewFollowUpSaveFailed" } | null>(null);
@@ -449,28 +425,19 @@ function FollowUpWorkspace({ jobId }: { jobId: number }) {
const [busy, setBusy] = useState(false);
const [date, setDate] = useState<string>("");
const [action, setAction] = useState<string>("");
const active = useRef(true);
const readSequence = useRef(0);
useLayoutEffect(() => {
active.current = true;
return () => { active.current = false; };
}, []);
const load = useCallback(async () => {
if (!active.current) return;
const request = ++readSequence.current;
setLoading(true);
try {
const result = await interviewPrepApi.followUp(jobId);
if (!active.current || request !== readSequence.current) return;
setData(result);
setDate(result.followUpAt ? result.followUpAt.slice(0, 10) : "");
setAction(result.nextAction ?? "");
setError(null);
} catch (err) {
if (active.current && request === readSequence.current) setError({ cause: err, fallback: "interviewFollowUpLoadFailed" });
setError({ cause: err, fallback: "interviewFollowUpLoadFailed" });
} finally {
if (active.current && request === readSequence.current) setLoading(false);
setLoading(false);
}
}, [jobId]);
+1 -180
View File
@@ -63,135 +63,6 @@ beforeEach(() => {
window.localStorage.setItem("uiLanguage", "en");
});
function deferredRead() {
let resolve!: (value: any) => void;
let reject!: (reason: unknown) => void;
const promise = new Promise<any>((yes, no) => { resolve = yes; reject = no; });
return { promise, resolve, reject };
}
test.each(['success', 'failure', 'pending-newer'] as const)('a newer preparation refresh wins against an older %s completion', async completion => {
mockedApi.get.mockReset(); routeGet();
const read = mockedApi.get.getMockImplementation()!;
const older = deferredRead(); const newer = deferredRead();
let reads = 0;
mockedApi.get.mockImplementation((url: string) => url.endsWith('/interview-prep') && ++reads > 1 ? (reads === 2 ? older.promise : newer.promise) : read(url));
const firstWrite = deferredRead(); const secondWrite = deferredRead();
mockedApi.patch.mockReset().mockReturnValueOnce(firstWrite.promise).mockReturnValueOnce(secondWrite.promise);
render(<ApplicationInterviewPrep jobId={7} />);
fireEvent.click(await screen.findByRole('checkbox', { name: 'Ready: Funding history' }));
fireEvent.click(screen.getByRole('checkbox', { name: 'Ready: Tell me about a conflict' }));
await act(async () => firstWrite.resolve({ data: {} }));
await act(async () => secondWrite.resolve({ data: {} }));
expect(reads).toBe(3);
if (completion === 'pending-newer') {
await act(async () => older.resolve({ data: board }));
const region = within(screen.getByRole('region', { name: translations.en.interviewPrepTitle }));
expect(region.getByRole('progressbar', { name: translations.en.loading })).toBeVisible();
expect(region.queryByLabelText(translations.en.interviewPrepAddLabel)).not.toBeInTheDocument();
}
const currentBoard = { ...board, groups: [{ ...board.groups[0], items: [{ ...board.groups[0].items[0], title: 'Newest board' }] }] };
await act(async () => newer.resolve({ data: currentBoard }));
expect(await screen.findByText('Newest board')).toBeVisible();
fireEvent.change(screen.getByLabelText(translations.en.interviewPrepAddLabel), { target: { value: 'Current draft' } });
if (completion === 'success') await act(async () => older.resolve({ data: board }));
if (completion === 'failure') await act(async () => older.reject(new Error('Older refresh failure')));
expect(screen.getByText('Newest board')).toBeVisible();
expect(screen.queryByText(translations.en.interviewPrepLoadFailed)).not.toBeInTheDocument();
expect(screen.getByLabelText(translations.en.interviewPrepAddLabel)).toHaveValue('Current draft');
});
test.each(['prep', 'follow-up'] as const)('late %s write keeps its original target and cannot clear a new application draft', async surface => {
mockedApi.get.mockReset(); routeGet();
const write = deferredRead();
mockedApi.post.mockReset().mockReturnValueOnce(write.promise);
mockedApi.put.mockReset().mockReturnValueOnce(write.promise);
const component = (id: number) => surface === 'prep' ? <ApplicationInterviewPrep jobId={id} /> : <ApplicationFollowUp jobId={id} />;
const label = surface === 'prep' ? translations.en.interviewPrepAddLabel : translations.en.workspaceNextAction;
const view = render(component(7));
fireEvent.change(await screen.findByLabelText(label), { target: { value: 'Original application write' } });
fireEvent.click(screen.getByRole('button', { name: translations.en[surface === 'prep' ? 'interviewPrepAdd' : 'save'] }));
await act(async () => view.rerender(<I18nProvider><ConfirmProvider>{component(8)}</ConfirmProvider></I18nProvider>));
fireEvent.change(await screen.findByLabelText(label), { target: { value: 'New application draft' } });
await act(async () => write.resolve({ data: surface === 'prep' ? board.groups[0].items[0] : followUp }));
expect(screen.getByLabelText(label)).toHaveValue('New application draft');
expect(surface === 'prep' ? mockedApi.post : mockedApi.put).toHaveBeenCalledTimes(1);
expect((surface === 'prep' ? mockedApi.post : mockedApi.put).mock.calls[0][0]).toBe(`/jobapplications/7/${surface === 'prep' ? 'interview-prep' : 'follow-up'}`);
expect(mockedApi.get.mock.calls.filter(([url]) => url === '/jobapplications/7/interview-prep')).toHaveLength(surface === 'prep' ? 1 : 0);
});
test.each(['prep', 'follow-up'] as const)('late %s read cannot replace the current application or its draft', async surface => {
mockedApi.get.mockReset(); routeGet();
const read = mockedApi.get.getMockImplementation()!;
const old = deferredRead();
const suffix = surface === 'prep' ? 'interview-prep' : 'follow-up';
mockedApi.get.mockImplementation((url: string) => url === `/jobapplications/7/${suffix}` ? old.promise : read(url));
const component = (id: number) => surface === 'prep' ? <ApplicationInterviewPrep jobId={id} /> : <ApplicationFollowUp jobId={id} />;
const view = render(component(7));
await act(async () => view.rerender(<I18nProvider><ConfirmProvider>{component(8)}</ConfirmProvider></I18nProvider>));
const label = surface === 'prep' ? translations.en.interviewPrepAddLabel : translations.en.workspaceNextAction;
fireEvent.change(await screen.findByLabelText(label), { target: { value: 'Current application draft' } });
const oldData = surface === 'prep'
? { ...board, groups: [{ ...board.groups[0], items: [{ ...board.groups[0].items[0], title: 'Previous application only' }] }] }
: { ...followUp, nextAction: 'Previous application only' };
await act(async () => old.resolve({ data: oldData }));
expect(screen.getByLabelText(label)).toHaveValue('Current application draft');
expect(screen.queryByText('Previous application only')).not.toBeInTheDocument();
expect(screen.queryByDisplayValue('Previous application only')).not.toBeInTheDocument();
expect(mockedApi.post).not.toHaveBeenCalled(); expect(mockedApi.put).not.toHaveBeenCalled();
});
test.each(['prep', 'follow-up'] as const)('late %s read failure cannot hide the current draft', async surface => {
mockedApi.get.mockReset(); routeGet();
const read = mockedApi.get.getMockImplementation()!;
const old = deferredRead();
const suffix = surface === 'prep' ? 'interview-prep' : 'follow-up';
mockedApi.get.mockImplementation((url: string) => url === `/jobapplications/7/${suffix}` ? old.promise : read(url));
const component = (id: number) => surface === 'prep' ? <ApplicationInterviewPrep jobId={id} /> : <ApplicationFollowUp jobId={id} />;
const view = render(component(7));
await act(async () => view.rerender(<I18nProvider><ConfirmProvider>{component(8)}</ConfirmProvider></I18nProvider>));
const label = surface === 'prep' ? translations.en.interviewPrepAddLabel : translations.en.workspaceNextAction;
fireEvent.change(await screen.findByLabelText(label), { target: { value: 'Current application draft' } });
await act(async () => old.reject(new Error('Previous application failure')));
expect(screen.queryByText(translations.en[surface === 'prep' ? 'interviewPrepLoadFailed' : 'interviewFollowUpLoadFailed'])).not.toBeInTheDocument();
expect(screen.getByLabelText(label)).toHaveValue('Current application draft');
});
test.each(['prep', 'follow-up'] as const)('late %s finally cannot dismiss the current application loading state', async surface => {
mockedApi.get.mockReset(); routeGet();
const read = mockedApi.get.getMockImplementation()!;
const old = deferredRead(); const current = deferredRead();
const suffix = surface === 'prep' ? 'interview-prep' : 'follow-up';
mockedApi.get.mockImplementation((url: string) => url.endsWith(`/${suffix}`) ? (url.includes('/7/') ? old.promise : current.promise) : read(url));
const component = (id: number) => surface === 'prep' ? <ApplicationInterviewPrep jobId={id} /> : <ApplicationFollowUp jobId={id} />;
const view = render(component(7));
await act(async () => view.rerender(<I18nProvider><ConfirmProvider>{component(8)}</ConfirmProvider></I18nProvider>));
await act(async () => old.resolve({ data: surface === 'prep' ? board : followUp }));
const region = within(screen.getByRole('region', { name: translations.en[surface === 'prep' ? 'interviewPrepTitle' : 'interviewFollowUpTitle'] }));
expect(region.getByRole('progressbar', { name: translations.en.loading })).toBeVisible();
expect(region.queryByLabelText(translations.en[surface === 'prep' ? 'interviewPrepAddLabel' : 'workspaceNextAction'])).not.toBeInTheDocument();
await act(async () => current.resolve({ data: surface === 'prep' ? board : followUp }));
expect(await region.findByLabelText(translations.en[surface === 'prep' ? 'interviewPrepAddLabel' : 'workspaceNextAction'])).toBeVisible();
});
test('changing application resets parent drafts and a failed follow-up read retains a GET-only retry', async () => {
mockedApi.get.mockReset(); routeGet();
const read = mockedApi.get.getMockImplementation()!;
mockedApi.get.mockImplementation((url: string) => url === '/jobapplications/8/follow-up' ? Promise.reject(new Error('Current read failure')) : read(url));
const view = render(<ApplicationInterviewPrep jobId={7} />);
fireEvent.change(await screen.findByLabelText(translations.en.interviewPrepAddLabel), { target: { value: 'Application seven draft' } });
await screen.findByDisplayValue(followUp.nextAction);
await act(async () => view.rerender(<I18nProvider><ConfirmProvider><ApplicationInterviewPrep jobId={8} /></ConfirmProvider></I18nProvider>));
expect(await screen.findByLabelText(translations.en.interviewPrepAddLabel)).toHaveValue('');
expect(await screen.findByText(translations.en.interviewFollowUpLoadFailed)).toBeVisible();
const region = within(screen.getByRole('region', { name: translations.en.interviewFollowUpTitle }));
expect(region.queryByLabelText(translations.en.workspaceNextAction)).not.toBeInTheDocument();
mockedApi.get.mockImplementation(read);
fireEvent.click(region.getByRole('button', { name: translations.en.retry }));
expect(await region.findByLabelText(translations.en.workspaceNextAction)).toHaveValue(followUp.nextAction);
expect(mockedApi.put).not.toHaveBeenCalled();
});
test.each(['en', 'nb'] as const)('pending preparation deletion follows %s without a preparation reload or answer loss', async from => {
localStorage.setItem('uiLanguage', from);
const to = from === 'en' ? 'nb' : 'en';
@@ -472,56 +343,6 @@ test("AI preparation uses the linked CV and only saves after explicit acceptance
));
});
test('late generation cannot offer another application the previous application suggestion', async () => {
mockedApi.get.mockReset(); routeGet();
let finish!: (value: any) => void;
mockedApi.post.mockReset().mockReturnValueOnce(new Promise(resolve => { finish = resolve; }) as any);
const view = render(<ApplicationInterviewPrep jobId={7} />);
await screen.findByText('Backend CV');
fireEvent.change(screen.getByLabelText(translations.en.coverAiAdditionalInstructions), { target: { value: 'Private instructions for application seven' } });
fireEvent.click(screen.getByRole('button', { name: translations.en.interviewAiGenerate }));
await waitFor(() => expect(mockedApi.post).toHaveBeenCalledTimes(1));
await act(async () => view.rerender(<I18nProvider><ConfirmProvider><ApplicationInterviewPrep jobId={8} /></ConfirmProvider></I18nProvider>));
await act(async () => finish({ data: { result: { text: 'Only for application seven' } } }));
const assistant = within(screen.getByRole('region', { name: translations.en.interviewAiTitle }));
expect(assistant.queryByText('Only for application seven')).not.toBeInTheDocument();
expect(assistant.queryByRole('button', { name: translations.en.interviewAiAddToPrep })).not.toBeInTheDocument();
expect(assistant.getByLabelText(translations.en.coverAiAdditionalInstructions)).toHaveValue('');
expect(mockedApi.post).toHaveBeenCalledTimes(1);
});
test('completed AI suggestion is scoped to its application instead of becoming a new application draft', async () => {
mockedApi.get.mockReset(); routeGet();
mockedApi.post.mockReset().mockResolvedValue({ data: { result: { text: 'Prepared for application seven only' } } } as any);
const view = render(<ApplicationInterviewPrep jobId={7} />);
await screen.findByText('Backend CV');
fireEvent.click(screen.getByRole('button', { name: translations.en.interviewAiGenerate }));
expect(await screen.findByText('Prepared for application seven only')).toBeVisible();
await act(async () => view.rerender(<I18nProvider><ConfirmProvider><ApplicationInterviewPrep jobId={8} /></ConfirmProvider></I18nProvider>));
const assistant = within(screen.getByRole('region', { name: translations.en.interviewAiTitle }));
expect(assistant.queryByText('Prepared for application seven only')).not.toBeInTheDocument();
expect(assistant.queryByRole('button', { name: translations.en.interviewAiAddToPrep })).not.toBeInTheDocument();
expect(mockedApi.post).not.toHaveBeenCalledWith('/jobapplications/8/interview-prep', expect.anything());
});
test('late accepted suggestion does not reload the previous application board into the current application', async () => {
mockedApi.get.mockReset(); routeGet();
let finish!: (value: any) => void;
mockedApi.post.mockReset().mockResolvedValueOnce({ data: { result: { text: 'Application seven suggestion' } } } as any).mockReturnValueOnce(new Promise(resolve => { finish = resolve; }) as any);
const view = render(<ApplicationInterviewPrep jobId={7} />);
await screen.findByText('Backend CV');
fireEvent.click(screen.getByRole('button', { name: translations.en.interviewAiGenerate }));
await screen.findByText('Application seven suggestion');
fireEvent.click(screen.getByRole('button', { name: translations.en.interviewAiAddToPrep }));
await waitFor(() => expect(mockedApi.post).toHaveBeenCalledTimes(2));
await act(async () => view.rerender(<I18nProvider><ConfirmProvider><ApplicationInterviewPrep jobId={8} /></ConfirmProvider></I18nProvider>));
await waitFor(() => expect(mockedApi.get).toHaveBeenCalledWith('/jobapplications/8/interview-prep'));
await act(async () => finish({ data: board.groups[0].items[0] }));
expect(mockedApi.get.mock.calls.filter(([url]) => url === '/jobapplications/7/interview-prep')).toHaveLength(1);
expect(mockedApi.get.mock.calls.filter(([url]) => url === '/jobapplications/8/interview-prep')).toHaveLength(1);
expect(mockedApi.post.mock.calls[1]).toEqual(['/jobapplications/7/interview-prep', expect.objectContaining({ source: 'ai', content: 'Application seven suggestion' })]);
});
test.each(['en', 'nb'] as const)('pending linked CV is loading, not an empty selection (%s)', async language => {
localStorage.setItem('uiLanguage', language);
mockedApi.get.mockReset(); routeGet();
@@ -573,7 +394,7 @@ test.each(['en', 'nb'] as const)('changing application hides the previous linked
mockedApi.get.mockImplementation((url: string) => url === '/jobapplications/8/cv' ? pending as any : read(url));
const view = render(<ApplicationInterviewPrep jobId={7} />);
await screen.findByText('Backend CV');
await act(async () => view.rerender(<I18nProvider><ConfirmProvider><ApplicationInterviewPrep jobId={8} /></ConfirmProvider></I18nProvider>));
view.rerender(<I18nProvider><ConfirmProvider><ApplicationInterviewPrep jobId={8} /></ConfirmProvider></I18nProvider>);
const assistant = within(screen.getByRole('region', { name: translations[language].interviewAiTitle }));
expect(assistant.queryByText('Backend CV')).not.toBeInTheDocument();
expect(assistant.getByRole('progressbar', { name: translations[language].loading })).toBeVisible();