Skip to content

Let the candidate restore the starter code - #398

Merged
jserv merged 1 commit into
sysprog21:mainfrom
RWong04:restore-starter-code
Oct 23, 2026
Merged

jserv merged 1 commit into
sysprog21:mainfrom
RWong04:restore-starter-code

Conversation

@RWong04

@RWong04 RWong04 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Adds a restore control beside the language picker that puts the current language's starter back, as accepted in #348.

The starter goes in through insertText over just the span that differs, so one Ctrl+Z restores the previous buffer. A browser without that command, or one that refuses it, would have to assign the buffer and leave nothing to undo; there the first press leaves the code alone and only arms the control, and a second press confirms. Chromium redoes a replaced selection that ends in a newline wrongly, so for the restore only, that newline is removed by a forward delete in the same undo step. Undo does not survive a language switch, which holds for any edit and is #365's subject. The control is disabled while paused and in the behavioral round, and does nothing once coding is closed.

The reset is an ordinary code_update, so no message type, recording kind or contract version changes. A Test credit already recorded survives it: reconcile_received_test (src/agent.rs:2776) appends a Test row only while test_recordable (src/agent.rs:2171) holds, and nothing removes a recorded row, since evict_one_observation (src/agent.rs:1515) never takes a phase's only one. A reset before the run is recorded stops it, so the candidate must write and run again.

Screenshots, from a page with no interview running: an edited buffer, the code after one press, after Ctrl+Z, the control dimmed while paused, a 390 px wide screen, and the prompt shown by a browser without insertText
1-edited-code
2-after-one-press
3-after-ctrl-z
4-toolbar-paused-disabled
5-narrow-390px-after-one-press
6-fallback-first-press-armed-simulated

Validation: restore-starter.test.js adds 52 tests, and each deliberate breakage I tried fails at least one. ./scripts/test.sh passes with 1599 browser and 1886 Rust tests; skipped locally are commentflow, actionlint and the Linux-only Clang fetch. I also restored the starter in every offered language of all 151 problems (747 cases): one press restores, and undo and redo are exact. A live LiveKit and Gemini session was run on an earlier revision, where the first press armed, and not repeated.

Limits: the toolbar wraps to a second row at 590 to 620 px, and the icon-only control relies on its tooltip and aria-label. In Playwright's WebKit a restore joins the typing before it, so one Cmd+Z undoes both. Safari's click-without-focus behaviour is modelled in a test, not tried in real Safari. Firefox could not be launched here, so it is unchecked whether it records the insert and the forward delete as one undo step.

Closes #348


Summary by cubic

Adds a Restore starter button to the editor toolbar so a candidate can put the current language's starter code back and start over. The reset goes through the browser's editing command over just the differing span, so one Ctrl+Z (Cmd+Z on Mac) restores the previous buffer; a trailing newline is handled separately to avoid a Chromium redo bug. In browsers without a working editing command, the first press only arms the control and a second press confirms, both in the toolbar. Only the current language's buffer changes, the reset sends as a normal code_update, and the button is inert while paused, in the behavioral round, or after coding closes. Closes #348.

Written for commit 07c4e56. Summary will update on new commits.

View guided diff

cubic-dev-ai[bot]

This comment was marked as resolved.

Comment thread web/interview.js Outdated
Comment thread web/interview.js Outdated
@jserv
jserv requested review from ColtenOuO and alanhc October 21, 2026 03:20
cubic-dev-ai[bot]

This comment was marked as resolved.

cubic-dev-ai[bot]

This comment was marked as resolved.

Comment thread tests/browser/restore-starter.test.js Outdated

@jserv jserv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please fold the six commits into one when you address these; the folded message should drop the sentence from f3a0673 saying a browser that refuses the command asks before assigning value, since eae3bf3 reversed it.

web/interview.html:210: This comment still says the toolbar stays one row, but the PR body notes it now wraps at 750 to 780 px and 1130 to 1160 px, and the restore button sits in the display-settings group although it edits code. Either move the button next to the language tabs or update the comment.

Comment thread web/interview.js Outdated
Comment thread web/interview.js Outdated
Comment thread web/interview.html Outdated
Comment thread tests/browser/restore-starter.test.js Outdated
Comment thread tests/browser/restore-starter.test.js Outdated
@RWong04
RWong04 force-pushed the restore-starter-code branch from 628f0dc to e52ffae Compare October 22, 2026 05:09
cubic-dev-ai[bot]

This comment was marked as resolved.

@RWong04
RWong04 force-pushed the restore-starter-code branch from e52ffae to a5c9b40 Compare October 22, 2026 05:19
Comment thread web/interview.js
Comment thread web/interview.js Outdated
@RWong04
RWong04 force-pushed the restore-starter-code branch from a5c9b40 to 38fc029 Compare October 22, 2026 07:16
Comment thread web/interview.js Outdated
Comment thread tests/browser/restore-starter.test.js Outdated
@RWong04
RWong04 force-pushed the restore-starter-code branch from 38fc029 to 972847b Compare October 22, 2026 13:14
Comment thread web/interview.js
Comment thread web/interview.js Outdated
@RWong04
RWong04 force-pushed the restore-starter-code branch 2 times, most recently from 37d0400 to cc9500d Compare October 22, 2026 13:51
Comment thread web/interview.js
@RWong04
RWong04 force-pushed the restore-starter-code branch from cc9500d to 05e84c8 Compare October 22, 2026 14:34
@jserv
jserv requested a review from ColtenOuO October 22, 2026 14:38
cubic-dev-ai[bot]

This comment was marked as resolved.

@RWong04
RWong04 force-pushed the restore-starter-code branch from 05e84c8 to b9c61be Compare October 22, 2026 14:58
Comment thread web/interview.js Outdated
@RWong04
RWong04 force-pushed the restore-starter-code branch from b9c61be to d5ba25a Compare October 23, 2026 09:00
Comment thread web/interview.js Outdated

@jserv jserv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rebase latest main branch and resolve conflicts.

Comment thread web/interview.js
Comment thread web/interview.js Outdated
@RWong04
RWong04 force-pushed the restore-starter-code branch from d5ba25a to 9b8f2b8 Compare October 23, 2026 11:11
Comment thread web/interview.js Outdated
Add a control beside the language picker that puts the current
language's starter back through insertText, so one Ctrl+Z returns the
code. A browser without that command, or one that refuses it, would
drop undo, so there the first press leaves the code alone and only
arms the control, and a second one confirms. The restore keeps a
trailing newline out of the replaced span, because Chromium redoes
that wrongly. The control is disabled while paused and once coding is
closed.
@RWong04
RWong04 force-pushed the restore-starter-code branch from 9b8f2b8 to 07c4e56 Compare October 23, 2026 11:35
@jserv
jserv requested a review from ColtenOuO October 23, 2026 11:49
@jserv
jserv merged commit 14fb305 into sysprog21:main Oct 23, 2026
10 checks passed
@jserv

jserv commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Thank @RWong04 for contributing!

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.

Let the candidate restore the starter code

3 participants