diff --git a/extension/package.json b/extension/package.json index 94758337..d9f59caf 100644 --- a/extension/package.json +++ b/extension/package.json @@ -584,11 +584,17 @@ "markdownDescription": "Flag affected lines in the editor and the Problems panel, with the upstream change that caused each one.", "order": 20 }, + "drift.ui.openOnStartup": { + "type": "boolean", + "default": false, + "markdownDescription": "Open the Drift panel automatically when a window opens, instead of waiting for the startup notification. Off by default, because a tool that seizes the sidebar on every window is a tool people disable; useful for demos, walkthroughs, and prepared environments.", + "order": 21 + }, "drift.ui.showManifestCodeLens": { "type": "boolean", "default": true, "markdownDescription": "Show Drift CodeLens prompts above dependency manifests. Turn this off when the dependency tree and report are enough.", - "order": 21 + "order": 22 }, "drift.fix.customInstructions": { "type": "string", diff --git a/extension/src/extension.ts b/extension/src/extension.ts index 67eaa1dc..239f06e4 100644 --- a/extension/src/extension.ts +++ b/extension/src/extension.ts @@ -238,6 +238,16 @@ async function initialise(state: DriftState, home: DriftHomeView): Promise state.set({ kind: 'idle' }); + // Prepared environments — demos, walkthroughs, a Codespace someone opened to + // see what this does — need the panel visible without a click. Revealing + // happens *before* the startup analysis rather than after it, so the visitor + // watches the work happen instead of arriving at a finished verdict with no + // idea what produced it. Off by default: seizing the sidebar of every window + // is how an extension gets uninstalled. + if (vscode.workspace.getConfiguration('drift').get('ui.openOnStartup', false)) { + await home.reveal().then(undefined, () => {}); + } + if (!vscode.workspace.getConfiguration('drift').get('analysis.runOnStartup', true)) { return; } diff --git a/extension/test/package-contributions.test.ts b/extension/test/package-contributions.test.ts index b4185b5d..a3acd012 100644 --- a/extension/test/package-contributions.test.ts +++ b/extension/test/package-contributions.test.ts @@ -36,6 +36,18 @@ describe('extension package contributions', () => { assert.equal(walkthrough!.steps.length, 5); }); + test('the demo/prepared-environment panel opener exists and stays off by default', () => { + // Codespaces and walkthroughs need the panel up without a click, but a + // sidebar that seizes focus in every window is a reason to uninstall. The + // default is the whole point of the setting, so it is pinned here. + const opener = pkg.contributes.configuration.properties['drift.ui.openOnStartup'] as + | { type?: string; default?: unknown } + | undefined; + assert.ok(opener, 'drift.ui.openOnStartup is contributed'); + assert.equal(opener!.type, 'boolean'); + assert.equal(opener!.default, false); + }); + test('removes the deprecated single effort setting from Settings UI', () => { assert.equal('drift.session.effort' in pkg.contributes.configuration.properties, false); assert.ok('drift.agent.efforts' in pkg.contributes.configuration.properties); diff --git a/site/src/app/page.tsx b/site/src/app/page.tsx index aff78def..548416ba 100644 --- a/site/src/app/page.tsx +++ b/site/src/app/page.tsx @@ -3,6 +3,7 @@ import { instrumentSerif } from "@/lib/fonts"; import { Backdrop } from "@/components/backdrop"; import { CopyCommand } from "@/components/copy-command"; import { Demo } from "@/components/demo"; +import { BrowserDemo } from "@/components/browser-demo"; import { EcosystemsSummary } from "@/components/ecosystems"; import { Pipeline } from "@/components/pipeline"; import { ActionSummary, ActionFlow } from "@/components/action-flow"; @@ -100,6 +101,17 @@ export default function Home() { > Install the VS Code extension + {/* + The strongest thing this page can offer a sceptic: not a recording + of Drift working, but Drift working, on their ecosystem, in a + browser tab, in about a minute. + */} + + Try it in your browser + + {/* ── Try it yourself ─────────────────────────────────────────── */} + {/* + Placed immediately after the recorded run, because that is where the + reader's scepticism peaks: they have just been shown a demo that + worked, and the next honest move is to hand them the controls. + */} +
+
+

Run it yourself

+

+ Try Drift in your browser, on your ecosystem. +

+

+ Each demo is a small project pinned to an old version of a real dependency, using an API the newer + version breaks. Opening it upgrades the manifest and leaves the code alone, so Drift analyses an + ordinary uncommitted change — and has no idea it is a demo. +

+
+ +
+ +
+
+ {/* ── Coverage + trust ────────────────────────────────────────── */} diff --git a/site/src/components/browser-demo.tsx b/site/src/components/browser-demo.tsx new file mode 100644 index 00000000..a06e4518 --- /dev/null +++ b/site/src/components/browser-demo.tsx @@ -0,0 +1,69 @@ +import { DEMOS, codespaceUrl, labelFor, upgradeLabel } from "@/lib/demos"; + +/** + * "Try it in your browser" — a Codespace for every ecosystem Drift supports. + * + * Every other proof on this page is something the reader watches: a recording, + * a benchmark number, a support matrix. This is the one they can run, on a real + * repository, against a real upgrade, in a real editor — which is the only + * answer to the reasonable suspicion that a recorded demo was chosen because it + * worked. + * + * The fixture is honest about what it is. Each demo repository is committed at + * the *old* dependency version with source that was correct for it, and + * Codespace creation edits the manifest to the new version and touches nothing + * else. So Drift is handed an ordinary uncommitted dependency change — the + * exact situation a developer is in mid-upgrade — and nothing in Drift knows it + * is a demo. `git status` in the Codespace shows one modified manifest, which + * is the claim, checkable in the demo itself. + * + * Sixteen links rather than one, because the first question a visitor has is + * "does it do *my* language", and answering it with a JavaScript demo and a + * promise about the rest is how the support table lost trust before. + */ +export function BrowserDemo() { + return ( +
+ + + {/* + Said plainly rather than in a footnote. A Codespace is created under the + visitor's own GitHub account and spends their own free allowance, and + finding that out on GitHub's create page instead of here would be a + worse experience than being told. + */} +

+ Opens a GitHub Codespace on your own account — nothing to install, and the free tier covers it. The + extension and the drift CLI are both already set up: the panel analyses + the change as the editor opens, and the terminal runs{" "} + drift analyze next to it. +

+
+ ); +} diff --git a/site/src/lib/demos.test.ts b/site/src/lib/demos.test.ts new file mode 100644 index 00000000..8e7bcc5c --- /dev/null +++ b/site/src/lib/demos.test.ts @@ -0,0 +1,49 @@ +import { test, describe } from "node:test"; +import assert from "node:assert/strict"; +import { ECOSYSTEM_CAPABILITIES } from "./capabilities.ts"; +import { DEMOS, codespaceUrl, labelFor, upgradeLabel } from "./demos.ts"; + +describe("browser demos", () => { + /* + * The claim the landing page makes is "every ecosystem Drift supports, you can + * try in a browser". That claim is only true while the two lists agree, and + * the failure mode is silent: an ecosystem added to the core would simply be + * missing from the demo grid and nobody would notice. So it fails the build. + */ + test("the demo set and the supported ecosystems are the same set", () => { + const supported = ECOSYSTEM_CAPABILITIES.map((c) => c.ecosystem).sort(); + const demoed = DEMOS.map((d) => d.ecosystem).sort(); + assert.deepEqual(demoed, supported); + }); + + test("every demo resolves a real label from the generated capability list", () => { + for (const demo of DEMOS) { + assert.notEqual(labelFor(demo.ecosystem), demo.ecosystem, `${demo.ecosystem} has a label`); + } + }); + + test("a demo actually upgrades: the two versions differ", () => { + for (const demo of DEMOS) { + assert.notEqual(demo.from, demo.to, `${demo.ecosystem} moves version`); + } + }); + + test("the Codespaces link selects that demo's own devcontainer", () => { + // The encoded path is what stops the create page asking the visitor to pick + // one of sixteen containers, so it is the part worth pinning. + const url = codespaceUrl("npm"); + assert.match(url, /^https:\/\/codespaces\.new\/trydrift\/demo\?/); + assert.match(url, /devcontainer_path=\.devcontainer%2Fnpm%2Fdevcontainer\.json/); + }); + + test("Go's pseudo-versions are shortened to something a card can show", () => { + const go = DEMOS.find((d) => d.ecosystem === "go")!; + const label = upgradeLabel(go); + assert.match(label, /golang\.org\/x\/exp 20230522 → 20231006/); + }); + + test("an ordinary version is left alone", () => { + const npm = DEMOS.find((d) => d.ecosystem === "npm")!; + assert.equal(upgradeLabel(npm), "axios 0.21.4 → 1.7.7"); + }); +}); diff --git a/site/src/lib/demos.ts b/site/src/lib/demos.ts new file mode 100644 index 00000000..0605fc27 --- /dev/null +++ b/site/src/lib/demos.ts @@ -0,0 +1,79 @@ +import { ECOSYSTEM_CAPABILITIES } from "./capabilities.ts"; + +/** + * The browser demos: every ecosystem Drift supports has a fixture here. + * + * Each entry mirrors `demos//demo.json` in `trydrift/demo`, which is + * the source of truth: that repository holds the fixture, pins the dependency + * at the *old* version, and lets Codespace creation apply the upgrade. What is + * duplicated here is only what the page has to render — the package and the two + * versions — and `demos.test.ts` pins the set of ecosystems against the core's + * own capability list, so adding an ecosystem to Drift fails this build until a + * demo for it exists. + * + * Labels are deliberately *not* repeated. They are read from + * `ECOSYSTEM_CAPABILITIES`, which is generated from the core, so an ecosystem + * renamed there renames itself here too. + */ +export interface Demo { + /** Ecosystem id, matching `EcosystemCapability.ecosystem`. */ + ecosystem: string; + /** The package the demo upgrades. */ + dependency: string; + /** The version the fixture is committed at. */ + from: string; + /** The version Codespace creation moves it to. */ + to: string; +} + +/** The demo repository that hosts the fixtures and devcontainers. */ +export const DEMO_REPO = "trydrift/demo"; + +export const DEMOS: readonly Demo[] = [ + { ecosystem: "npm", dependency: "axios", from: "0.21.4", to: "1.7.7" }, + { ecosystem: "pypi", dependency: "werkzeug", from: "2.0.3", to: "2.1.0" }, + { + ecosystem: "go", + dependency: "golang.org/x/exp", + from: "v0.0.0-20230522175609-2e198f4a06a1", + to: "v0.0.0-20231006140011-7918f672742d", + }, + { ecosystem: "cargo", dependency: "clap", from: "2.34.0", to: "4.5.4" }, + { ecosystem: "maven", dependency: "com.google.guava:guava", from: "20.0", to: "21.0" }, + { ecosystem: "rubygems", dependency: "rack", from: "3.0.0", to: "3.1.0" }, + { ecosystem: "nuget", dependency: "AutoMapper", from: "8.1.1", to: "9.0.0" }, + { ecosystem: "packagist", dependency: "monolog/monolog", from: "2.9.3", to: "3.5.0" }, + { ecosystem: "hex", dependency: "plug", from: "1.13.6", to: "1.15.0" }, + { ecosystem: "pub", dependency: "dio", from: "4.0.6", to: "5.0.0" }, + { ecosystem: "swift", dependency: "Alamofire", from: "4.9.1", to: "5.9.1" }, + { ecosystem: "cocoapods", dependency: "Alamofire", from: "4.9.1", to: "5.9.1" }, + { ecosystem: "opam", dependency: "lwt", from: "4.5.0", to: "5.7.0" }, + { ecosystem: "conan", dependency: "fmt", from: "9.1.0", to: "10.2.1" }, + { ecosystem: "vcpkg", dependency: "catch2", from: "2.13.9", to: "3.5.2" }, + { ecosystem: "arduino", dependency: "bblanchon/ArduinoJson", from: "5.13.5", to: "6.21.3" }, +]; + +/** The human label for a demo, read from the generated capability list. */ +export function labelFor(ecosystem: string): string { + return ECOSYSTEM_CAPABILITIES.find((c) => c.ecosystem === ecosystem)?.label ?? ecosystem; +} + +/** + * GitHub's Codespaces deep link for one demo's devcontainer. + * + * `devcontainer_path` is what selects the per-ecosystem container: without it + * the create page asks the visitor to choose between sixteen, which is exactly + * the decision the landing page already made for them. + */ +export function codespaceUrl(ecosystem: string): string { + const path = encodeURIComponent(`.devcontainer/${ecosystem}/devcontainer.json`); + return `https://codespaces.new/${DEMO_REPO}?quickstart=1&devcontainer_path=${path}`; +} + +/** A short "axios 0.21.4 → 1.7.7" for the card. */ +export function upgradeLabel(demo: Demo): string { + // Go pseudo-versions (v0.0.0-20230522175609-2e198f4a06a1) carry the only part + // a reader can compare — the date — buried between a zero version and a hash. + const short = (v: string) => /^v0\.0\.0-(\d{8})\d*-/.exec(v)?.[1] ?? v; + return `${demo.dependency} ${short(demo.from)} → ${short(demo.to)}`; +}