Skip to content

Offer Change keys in the desktop app's server - #702

Merged
jserv merged 3 commits into
sysprog21:mainfrom
Patriciaath999:desktop-change-keys-687
Nov 15, 2026
Merged

jserv merged 3 commits into
sysprog21:mainfrom
Patriciaath999:desktop-change-keys-687

Conversation

@Patriciaath999

@Patriciaath999 Patriciaath999 commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

The desktop app's server offered no Change keys: #528 asks for a code printed only to the terminal that started the server, and the desktop app's child has none. This is part 1 of #564, scoped on #687.

The app makes a 32-hex-digit code from the OS generator on every launch and hands it to its child in CODETRIAL_CHANGE_KEYS_CODE. run_web reads it through codetrial::handed_change_keys_code, beside exit_when_stdin_closes, where it decides the server is a child, and carries it in LaunchedBy::Parent, so finish builds SetupContext from it and never prints it; a value shorter than 24 letters and digits counts as absent, so a careless launcher gets no Change keys instead of a weak code. A launch from a terminal still makes and prints its own code, and the loopback and trusted_proxy_hops == 0 conditions are unchanged.

The code reaches the person in the app's own window and never in a URL:

Which page gets the code is decided by navigation::change_keys_code_for, built on judge:

  • With the interview in the window, the app fills the code into the server's /setup page when it finishes loading. The page enables the field itself once /api/setup answers and keeps the value, so the field appears filled.
  • With the interview in the default browser, which happens when the webview has no WebRTC, the app cannot fill a field there. The start page it leaves in its window then shows the code, as a terminal would, and the person enters it on the browser's Setup page. This settles the open question on Offer Change keys in the desktop app's server #687.

A save takes effect at the next launch; restarting the server on it is #688. docs/desktop.md lists the new variable with the other launcher options, the README's configuration table has a row for it, and the Setup page's hint under the code field now names the desktop app as well as the terminal.

The two launcher-environment parsers moved to tests/config/launcher.rs: tests/config.rs was at its 1500-line ceiling.

Validation:

  • scripts/test.sh rust in WSL, the lane CI runs as gates (rust), passed at 90af116: lib 2115, web 227, cli 67, desktop 12 (Unix-only tests included), config 58. Among them: which loaded URLs get the code in desktop/tests/unit/navigation.rs; finish with and without a handed code in tests/unit/bin.rs; the binary started as the desktop app starts it refusing a wrong code, saving with the handed one and never printing it; binary_web_reads_deployment_keys_from_the_config_file finding no std::env::var in run_web; and a code of exactly 24 letters and digits accepted, which fails if the bound is raised. Not run there: 3 browser tests (no Playwright locally) and cargo-deny.
  • On Windows: cargo test --bins --test '*', desktop cargo test, cargo fmt --check for both crates, clippy and scripts/check-rust-style.py.
  • /codetrial-review on 90af116 against 2021548 reported no P0 to P2 finding. Two P3 notes stay as they are: after a save the Setup page still says to restart the server, which the restart in Restart the desktop server after Change keys saves #688 replaces; and the app now refuses to start if the OS random generator fails.
  • Not run: the desktop app itself, so neither the filled field nor the code on the start page has been seen in a window.

Overlaps: #561 adds a module next to the one added in tests/config.rs, and #584 edits src/launch.rs near finish and tests/unit/web/setup_edit.rs near the same test helper; whichever merges second rebases, with no shared lines changed.

Close #687

cubic-dev-ai[bot]

This comment was marked as resolved.

jserv

This comment was marked as resolved.

@Patriciaath999
Patriciaath999 force-pushed the desktop-change-keys-687 branch from 6224b01 to 3a43676 Compare November 14, 2026 11:54
jserv

This comment was marked as resolved.

@Patriciaath999
Patriciaath999 force-pushed the desktop-change-keys-687 branch from 3a43676 to 6dffd7a Compare November 14, 2026 13:07
cubic-dev-ai[bot]

This comment was marked as resolved.

jserv

This comment was marked as resolved.

jserv

This comment was marked as outdated.

jserv

This comment was marked as resolved.

@Patriciaath999
Patriciaath999 force-pushed the desktop-change-keys-687 branch from 6dffd7a to 12b1242 Compare November 15, 2026 08:50
jserv

This comment was marked as outdated.

jserv

This comment was marked as resolved.

jserv

This comment was marked as resolved.

@Patriciaath999
Patriciaath999 force-pushed the desktop-change-keys-687 branch from 12b1242 to 5b8d1f7 Compare November 15, 2026 09:26
@Patriciaath999

Copy link
Copy Markdown
Collaborator Author

@jserv The two run_web threads are addressed at 5b8d1f7: codetrial::handed_change_keys_code() in src/lib.rs reads the variable, and gates (rust), mutants (0) and mutants (1) pass there.

The one red lane is gates (browser 2/3): a java start neither waits for nor depends on a pending judge in tests/browser/start-language.test.js failed with page.waitForRequest: Timeout 4000ms exceeded. That test loads interview.html, and this branch touches nothing under web/. The same lane passed on the four earlier runs of this PR, and the only change since the last of them (12b1242, same base) moves one environment read from src/main.rs to src/lib.rs. Could you re-run that lane and re-review?

Comment thread tests/config/launcher.rs Resolved
A server the desktop app starts as its child gets no Change keys: the
code it asks for is made in run_web and printed to a terminal the
desktop user never sees, so SetupContext is left out for a child.

A child now takes its code from CODETRIAL_CHANGE_KEYS_CODE, ignoring
one shorter than 24 letters and digits, and does not print it. A launch
from a terminal still makes and prints its own code, and a child given
none still gets no Change keys. The desktop side of sysprog21#687 follows.

Change-Id: I1044d348f980a97067c591b093d56fae42984e55
The desktop app starts the server as its child and hands it the Change
keys code in the environment. Nothing ran that path: the unit tests
pass the code into finish, and no CLI test started a child with one.

The test starts the binary as the desktop app does, with
CODETRIAL_EXIT_WITH_STDIN and the code set, checks that a wrong code is
refused and the handed one rewrites the config, and that the code never
reaches stdout, which the app writes to a log file.

Change-Id: Iea6ba45fe95672c2ebcbca63ca268793b316d288
Keys entered at the desktop app's first Setup could not be changed
afterwards without editing the config file by hand, because its server
had no Change keys code anyone could read.

The app now makes a code on every launch and hands it to the server in
CODETRIAL_CHANGE_KEYS_CODE. With the interview in its window, it fills
the code into the server's own /setup page; with the interview in the
default browser, where it cannot fill a field, its start page shows the
code instead. The code never travels in a URL. A save takes effect at
the next launch; restarting the server on it is sysprog21#688.

Close sysprog21#687

Change-Id: If3fc34eae7782ba7a867489f52fdca74f7ee7e34
@jserv

jserv commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Some review comments on this pull request are not settled yet. Please refine the change per the review comments listed below, reply on each thread with what you changed or why you did not, and mark each thread resolved yourself once it is settled (Resolve conversation, at the bottom of the thread). The pull request stays blocked while review threads are open.

Not addressed at the current head:

Checked at 5b8d1f7.

@Patriciaath999
Patriciaath999 force-pushed the desktop-change-keys-687 branch from 5b8d1f7 to 90af116 Compare November 15, 2026 13:57
Comment thread desktop/src/main.rs Resolved
Comment thread src/lib.rs Resolved
@jserv
jserv added this pull request to the merge queue Nov 15, 2026
@jserv

jserv commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Thank @Patriciaath999 for contributing!

Merged via the queue into sysprog21:main with commit 228234f Nov 15, 2026
22 of 23 checks passed
@Patriciaath999
Patriciaath999 deleted the desktop-change-keys-687 branch November 16, 2026 06:47
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.

Offer Change keys in the desktop app's server

2 participants