Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,16 @@ async function initialise(state: DriftState, home: DriftHomeView): Promise<void>

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<boolean>('ui.openOnStartup', false)) {
await home.reveal().then(undefined, () => {});
}

if (!vscode.workspace.getConfiguration('drift').get<boolean>('analysis.runOnStartup', true)) {
return;
}
Expand Down
12 changes: 12 additions & 0 deletions extension/test/package-contributions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
36 changes: 36 additions & 0 deletions site/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -100,6 +101,17 @@ export default function Home() {
>
Install the VS Code extension
</a>
{/*
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.
*/}
<a
href="#try"
className="rounded-full border border-border bg-surface px-5 py-2.5 text-sm font-medium text-foreground transition-colors hover:bg-surface-hover"
>
Try it in your browser
</a>
<a
href="#demo"
className="rounded-full border border-border bg-surface px-5 py-2.5 text-sm font-medium text-foreground transition-colors hover:bg-surface-hover"
Expand Down Expand Up @@ -329,6 +341,30 @@ export default function Home() {
</div>
</section>

{/* ── 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.
*/}
<section id="try" className="scroll-mt-8 pt-14 sm:pt-20">
<div className="flex flex-col gap-1">
<p className="font-mono text-[11px] uppercase tracking-[0.2em] text-muted">Run it yourself</p>
<h2 className={`${instrumentSerif.className} mt-2 text-2xl text-landing sm:text-3xl`}>
Try Drift in your browser, on your ecosystem.
</h2>
<p className="mt-3 max-w-2xl text-[13px] leading-relaxed text-muted">
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.
</p>
</div>

<div className="mt-6">
<BrowserDemo />
</div>
</section>

<Pipeline />

{/* ── Coverage + trust ────────────────────────────────────────── */}
Expand Down
69 changes: 69 additions & 0 deletions site/src/components/browser-demo.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div>
<ul className="grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3">
{DEMOS.map((demo) => (
<li key={demo.ecosystem}>
<a
href={codespaceUrl(demo.ecosystem)}
target="_blank"
rel="noreferrer"
className="group flex h-full flex-col rounded-lg border border-border bg-surface/75 px-4 py-3 transition-colors hover:bg-surface-hover"
>
<span className="flex items-baseline justify-between gap-2">
<span className="text-[13px] font-medium text-foreground">{labelFor(demo.ecosystem)}</span>
<span className="shrink-0 font-mono text-[11px] text-faint">{demo.ecosystem}</span>
</span>
{/*
The upgrade, not a tagline: the package and the two versions are
what tell a reader whether this is a toy or a real break.
*/}
<span className="mt-1.5 break-words font-mono text-[11px] leading-snug text-muted">
{upgradeLabel(demo)}
</span>
<span className="mt-2.5 text-[11px] uppercase tracking-[0.14em] text-faint group-hover:text-brand-text">
Open in a Codespace →
</span>
</a>
</li>
))}
</ul>

{/*
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.
*/}
<p className="mt-5 text-[11px] leading-relaxed text-faint">
Opens a GitHub Codespace on your own account — nothing to install, and the free tier covers it. The
extension and the <code className="font-mono">drift</code> CLI are both already set up: the panel analyses
the change as the editor opens, and the terminal runs{" "}
<code className="font-mono">drift analyze</code> next to it.
</p>
</div>
);
}
49 changes: 49 additions & 0 deletions site/src/lib/demos.test.ts
Original file line number Diff line number Diff line change
@@ -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");
});
});
79 changes: 79 additions & 0 deletions site/src/lib/demos.ts
Original file line number Diff line number Diff line change
@@ -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/<ecosystem>/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)}`;
}
Loading