Skip to content

Restore the saved language on retry - #319

Open
Corn0722 wants to merge 1 commit into
sysprog21:mainfrom
Corn0722:restore-retry-language
Open

Corn0722 wants to merge 1 commit into
sysprog21:mainfrom
Corn0722:restore-retry-language

Conversation

@Corn0722

@Corn0722 Corn0722 commented Oct 15, 2026 •

Copy link
Copy Markdown

Retrying a past coding attempt currently restores its problem, duration, loop, and mode but starts the next interview with Python regardless of the saved language.

This change carries the saved language into the interview URL and restores it only when the problem offers it. Missing, unknown, or unavailable languages retain the existing Python fallback, and a delayed C selection does not replace a language the candidate has already chosen or edited.

Tests cover retrying a JavaScript attempt, restoring an offered language, retaining Python for an unavailable language, and restoring C only after a compatible judge loads.

Closes #310


Summary by cubic

Retrying a past coding attempt now restores its saved language instead of always starting the interview in Python.

The language is only restored when the problem offers it; missing, unknown, or unavailable languages keep the Python fallback, and a delayed C judge no longer overrides a language the candidate has already selected, edited with, or run tests with.

Closes #310.

Written for commit 99a05a9. Summary will update on new commits.

View guided diff

cubic-dev-ai[bot]

This comment was marked as resolved.

Comment thread web/interview.js
Comment thread tests/browser/candidate-cases.test.js Outdated
@Corn0722
Corn0722 force-pushed the restore-retry-language branch from 032f429 to e313f61 Compare October 16, 2026 06:53
cubic-dev-ai[bot]

This comment was marked as resolved.

Retrying a coding attempt currently resets its language to Python, which
can hide the mismatch until starter code or tests appear. Preserve the
saved language only when the problem offers it, retaining Python as the
fallback.
@Corn0722
Corn0722 force-pushed the restore-retry-language branch from e313f61 to 99a05a9 Compare October 16, 2026 07:03
@jserv
jserv requested review from ColtenOuO and alanhc October 16, 2026 23:59
Comment thread web/interview.js
Comment on lines +870 to +873
button.addEventListener("click", () => {
languageChoiceCommitted = true;
setLanguage(button.dataset.language);
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing covers this languageChoiceCommitted = true. If I drop L871, every test in candidate-cases, editor-pipeline and dom-contract still passes. The case it guards: the URL asks for language=c, the candidate clicks JavaScript while C is still disabled, and the judge arriving later switches them to C anyway. The editing test covers the other half of the earlier "changing tabs or editing" request, but not this one.

Could you add a held-judge test that clicks [data-language="javascript"] before releaseJudge() and asserts JavaScript is still selected after candidateCasesReady?

Comment on lines +696 to +714
test("a requested C tab is restored after its judge loads", async (t) => {
if (!browser) return t.skip("playwright chromium unavailable");
const runtimeConfig = DEFAULT_RUNTIME_CONFIG.replace(
"ENABLED = false",
"ENABLED = true",
).replace('BASE_URL = ""', 'BASE_URL = "https://godbolt.org"');
const enabled = await startStaticServer({ runtimeConfig });
const page = await browser.newPage();
let releaseJudge = () => {};
try {
releaseJudge = await holdJudge(page);
await page.goto(
`${enabled.base}/interview.html?problem=chargeback-pair-match&language=c`,
{ waitUntil: "domcontentloaded" },
);
const c = page.locator('[data-language="c"]');
await page.waitForFunction(
() => document.querySelector('[data-language="c"]').disabled,
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The four new tests repeat the same setup: the Compiler Explorer runtime config (also used at L647), the static server, holdJudge, the language=c URL, the wait for C to be disabled, and the same finally cleanup. A helper would leave each test with just the step that differs:

async function withHeldRequestedC(body) {
  const enabled = await startStaticServer({ runtimeConfig: CE_RUNTIME_CONFIG });
  const page = await browser.newPage();
  let releaseJudge = () => {};
  try {
    releaseJudge = await holdJudge(page);
    await page.goto(
      `${enabled.base}/interview.html?problem=chargeback-pair-match&language=c`,
      { waitUntil: "domcontentloaded" },
    );
    await page.waitForFunction(
      () => document.querySelector('[data-language="c"]').disabled,
    );
    await body(page, () => releaseJudge());
  } finally {
    releaseJudge();
    await page.close();
    await new Promise((closed) => enabled.server.close(closed));
  }
}

CE_RUNTIME_CONFIG would be the DEFAULT_RUNTIME_CONFIG.replace(...) result, hoisted to module scope. The tab-click test from the other comment would then be a few lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restore the programming language when retrying an interview

3 participants