Skip to content

Help50 rollout - #200

Open
rongxin-liu wants to merge 13 commits into
mainfrom
develop
Open

rongxin-liu wants to merge 13 commits into
mainfrom
develop

Conversation

@rongxin-liu

Copy link
Copy Markdown
Contributor

Checkpoint of the cs50/codespace changes for the Help50 rollout, developed and tested on canary (#196–#199), then fast-forwarded into develop. Merges 13 commits; the tree is identical to origin/canary at c31dc4b. The rebuilt codespace:canary image was verified in a fresh codespace together with the merged cs50/ddb50.vsix#25 and cs50/help50.vsix#3.

What lands on main

help50 integration (etc/profile.d/codespace.sh) — cs50/cli's /etc/profile.d/help50.sh runs after each command and calls one of three hooks; codespace.sh overrides them for codespaces:

  • _helpless (no local helper matched): prints "Click help50 above for help with that error" and shows a help50 button in the terminal title bar via command50 help50.showButton. Clicking it sends the failed command's output to cs50.ai for an explanation. The payload is a short transcript ($ <command line> then the output) when cs50/cli passes the command line (Keep the end of long output, and pass the command line to _helpless cli#246), the output alone otherwise. Whitespace-only output hides any pending button instead, so grep with no match, false, or a program exiting 1 stay quiet.
  • _helpful (a helper had advice, e.g. 1s -> "Did you mean ls?"): prints the advice inline as before and hides any pending button. No button, since the advice already answers the question.
  • _helped (command succeeded): hides the button if one is showing.

Every completed command therefore either replaces the button or clears it, so it always refers to the last command. command50 runs detached with output discarded, so the prompt is never delayed and a missing extension server degrades silently.

Supporting changes

  • Dockerfile: builds cs50/help50.vsix into /opt/cs50/extensions; devcontainer.json installs it alongside the other CS50 extensions.
  • codespace.sh sources /opt/cs50/lib/cli when present (tolerates a cs50/cli base image without help50) and exports WORKDIR=/workspaces/$RepositoryName so help50's "Did you mean to cd first?" suggestions fire in codespaces (cs50/cli defaults it to $HOME).
  • devcontainer.json: adds a Sysadmins terminal profile (sudo bash) for a root shell, which cs50/cli's profile skips entirely, so no help50.
  • tests/smoke.sh: runs the built image under timeouts and asserts non-interactive login shells exit, the hooks are the codespace overrides and behave (including the _helpless payload shape), help50.vsix and command50 are present, and root shells have no help50.
  • .github/workflows/main.yml: runs tests/smoke.sh against the built image after each build and before any push, on main and on feature branches.

Dependencies

Already on their default branches: cs50/cli#210, cs50/cli#245, cs50/cli#246 (via cs50/cli:canary -> latest), cs50/help50.vsix#1 and #3, cs50/ddb50.vsix#23–#25, cs50/cs50.vsix.

Merging

Squash-merge. Do not delete develop afterward; it is the long-lived integration branch.

- codespace.sh: override help50's _helpful/_helpless/_helped hooks to relay to
  the help50 extension via command50, which shows a button in the terminal
  title bar that hands the message to the CS50 Duck; skip _helpless when the
  failed command produced no output (e.g., grep with no match)
- codespace.sh: set WORKDIR to the workspace so help50's helpers can find
  misplaced files (cs50/cli defaults it to $HOME)
- Dockerfile, devcontainer.json: build and install help50.vsix
- devcontainer.json: add a Sysadmins terminal profile (sudo bash), which
  gets a root shell without help50
tests/smoke.sh runs the built image under timeouts: non-interactive login
shells exit (help50 must not start without a terminal), the help50 hooks
are the codespace overrides and behave, help50.vsix and command50 are
present, and root shells have no help50. Run in CI after each build and
before any push.
Branch builds use cs50/cli:amd64 (main), which doesn't have help50 yet, so
codespace.sh errored on every login shell sourcing /opt/cs50/lib/cli. Guard
the source, and have the smoke test skip the help50 checks (visibly) when the
base image lacks them, while still asserting that login shells start cleanly.
Only a successful command hid the button, so a later failure with no output
(e.g., grep with no match) left a button about an earlier command. Now any
completed command either replaces the button or clears it.
Hide a stale help50 button after a quiet failure
The advice is already on screen, so the button only added a click. Reserve
it for failures no helper recognized, where the duck can ask cs50.ai. A
recognized failure now clears any stale button like other outcomes do.
Don't show the help50 button when a helper already gave advice
cs50/cli#246 passes the failed command's line to _helpless as a second
argument. Include it, as a transcript ($ cmd, then output), so cs50.ai can
see what the student ran, not just what came back.
_help50_button hands the payload to command50 with output discarded, so no
check could see it. Stub it and assert both forms: with a command line,
"$ cmd" then the output; without one, the output alone. Whitespace-only
output still hides the button even when a command line is supplied.
Send the command line along with the output to the duck
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.

1 participant