* feat(app): launch a terminal from the New workspace screen
New workspace only ever started a chat agent. Empty workspaces existed but
were reachable only by submitting an empty composer, which nothing advertised,
and terminals could not be started from this screen at all. People concluded
Paseo did not support terminals.
Adds a launch chip to the meta row, shaped from the same ComboboxTrigger as
its neighbours, that chooses between Chat and a terminal. Terminal profiles
mark where a typed prompt goes with a {{{prompt}}} sentinel in their command
or args, substituted client-side before create_terminal_request, so the daemon
learns nothing new and the protocol is untouched. A profile without the
sentinel takes no input: the composer goes read-only and shows the exact
command, so there is nothing to type wrong.
Prompt forms come from each CLI's own --help. claude, codex, and pi take a
trailing positional; opencode's positional is the project directory, so it
uses --prompt=. Profiles predating the sentinel adopt the right form on read,
keyed on the command's base name rather than the profile id, because profiles
created in settings get generated ids.
* fix(app): stop existing launchers passing the prompt sentinel literally
Adoption made every caller of resolveTerminalProfiles see sentinel-bearing
args, but only New workspace substituted them. Pinned targets and the
workspace terminal menu forwarded profile.args straight through, so launching
Claude from an existing workspace ran `claude "{{{prompt}}}"` with that text as
the prompt.
Every launcher now goes through resolveTerminalProfileLaunch. Surfaces with
nowhere to type pass an empty prompt, which drops the prompt-only arg and
gives back the bare command they had before.
Also from the same review:
- Adoption skipped when args lead with a subcommand. `opencode run` takes a
positional message rather than --prompt, and `codex login` takes no prompt at
all. Only the first arg is checked, so `pi --thinking high` still adopts.
- Settings edits the persisted list again, not the adopted view. It writes the
whole list back on any change, so resolving first baked read-time adoption
into the user's config the moment they reordered a row.
- A hidden draft no longer names a workspace. Text typed for a prompt-taking
profile stayed in state after switching to a read-only one and still seeded
the generated title and branch.
- Windows .cmd escaping now has a round-trip test: a real cmd.exe runs a real
.cmd shim that echoes its argv, covering metacharacters, an injection
attempt, and newlines. The existing tests only asserted the command line we
generate.
- Fixed an ENOTEMPTY flake in the terminal suite. kill() only signals, so the
shell was still writing into $ZDOTDIR while its directory was being removed.
Cleanup waits for exit instead.
* fix(app): keep the host and isolation accessible names stable
Wiring the new tooltips also replaced these two accessible names with the
tooltip copy, which broke `sidebar-project-grouping` at the host picker: its
selector is `getByRole("button", { name: "Host", exact: true })` and the button
had become "Choose the host". It timed out on both attempts in CI.
An accessible name identifies a control; a tooltip explains it. Conflating them
renamed a control that other surfaces address by name. The names go back to
what they were and the tooltips keep the "Choose the ..." copy.
* test(server): stop temp-dir teardown failing unrelated terminal tests
The ENOTEMPTY flake survived both earlier attempts. Waiting for the session to
exit shrank the window; retrying the remove did not close it either. The writes
come from processes zsh forks on the way out, which outlive the pty and answer
to nothing the test holds.
Teardown is now best-effort and logs what it left behind. A temp directory we
cannot remove is not a defect in the terminal code under test, and failing on it
reports the race against whichever assertion ran last, which is exactly how this
surfaced: as a flake in an unrelated zsh title test. 10 consecutive runs green.
Also replaces a cast in the Windows .cmd helper with a real narrow, so a change
to ResolvedTerminalCommand fails loudly there. Test files are excluded from
typecheck (tsconfig.server.json), so a cast in one is never checked at all.
* fix(app): keep terminal launch policy in its owning workflows
Profile adoption now parses known global option values before deciding whether argv already contains a positional. Workspace naming is derived inside the terminal workflow so hidden launch-only drafts cannot affect branch or title generation.
* fix(server): preserve cmd shim arguments through both parses
npm command shims forward %*, so metacharacters lose one escape layer before the target process receives argv. Exercise the production node-pty string command line against a forwarding shim, and only tolerate the known ENOTEMPTY teardown race.
* fix(server): stabilize Windows subprocess tests
* test(server): isolate Windows argv recorder output
* test(server): allow native watcher integration to settle
102 lines
3.6 KiB
TypeScript
102 lines
3.6 KiB
TypeScript
import { test } from "../support/fixtures";
|
|
import { gotoAppShell } from "../support/helpers/app";
|
|
import { waitForSidebarHydration } from "../support/helpers/workspace-ui";
|
|
import {
|
|
openNewWorkspaceComposer,
|
|
submitNewWorkspacePrompt,
|
|
} from "../support/helpers/new-workspace";
|
|
import { seedWorkspace, type SeededWorkspace } from "../support/helpers/seed-client";
|
|
import {
|
|
expectChatLaunchSelected,
|
|
expectTerminalLaunchSelected,
|
|
expectTerminalOutputContains,
|
|
expectWorkspaceOpensWithTerminalTab,
|
|
fillTerminalPrompt,
|
|
patchTerminalProfiles,
|
|
seedTerminalProfiles,
|
|
selectChatLaunch,
|
|
selectLaunchOption,
|
|
submitTerminalLaunch,
|
|
type TerminalProfile,
|
|
type TerminalProfileSeed,
|
|
} from "../support/helpers/new-workspace-launch";
|
|
|
|
// `sleep` keeps the terminal alive long enough for the UI to attach and
|
|
// render output before the process exits — see new-workspace-launch-terminal.spec.ts.
|
|
const PROMPT_PROFILE: TerminalProfile = {
|
|
id: "e2e-memory-profile",
|
|
name: "Memory Profile",
|
|
command: "/bin/sh",
|
|
args: ["-c", 'echo remembered: "$0"; sleep 10', "{{{prompt}}}"],
|
|
};
|
|
|
|
function hasLeftNewWorkspaceRoute(url: URL): boolean {
|
|
return !/\/new(?:\?.*)?$/.test(`${url.pathname}${url.search}`);
|
|
}
|
|
|
|
test.describe("New workspace: launch target memory", () => {
|
|
let workspace: SeededWorkspace;
|
|
let profileSeed: TerminalProfileSeed;
|
|
|
|
test.beforeEach(async () => {
|
|
workspace = await seedWorkspace({ repoPrefix: "launch-memory-" });
|
|
profileSeed = await seedTerminalProfiles([PROMPT_PROFILE]);
|
|
});
|
|
|
|
test.afterEach(async () => {
|
|
await profileSeed.restore();
|
|
await workspace?.cleanup();
|
|
});
|
|
|
|
test("remembers the launch target across visits, and a removed profile falls back to chat instead of a dead entry", async ({
|
|
page,
|
|
}) => {
|
|
test.setTimeout(90_000);
|
|
await gotoAppShell(page);
|
|
await waitForSidebarHydration(page);
|
|
|
|
const openNewWorkspace = () =>
|
|
openNewWorkspaceComposer(page, {
|
|
projectKey: workspace.projectKey,
|
|
projectDisplayName: workspace.projectDisplayName,
|
|
});
|
|
|
|
await test.step("launching a terminal profile preselects it the next time New workspace opens", async () => {
|
|
await openNewWorkspace();
|
|
await selectLaunchOption(page, PROMPT_PROFILE.id);
|
|
await fillTerminalPrompt(page, "remember me");
|
|
await submitTerminalLaunch(page);
|
|
await expectWorkspaceOpensWithTerminalTab(page);
|
|
await expectTerminalOutputContains(page, "remembered: remember me");
|
|
|
|
await openNewWorkspace();
|
|
await expectTerminalLaunchSelected(page, PROMPT_PROFILE.name);
|
|
});
|
|
|
|
await test.step("switching to Chat and submitting preselects Chat the next time", async () => {
|
|
await selectChatLaunch(page);
|
|
await expectChatLaunchSelected(page);
|
|
await submitNewWorkspacePrompt(page, "hello from chat");
|
|
// The chat handoff navigates asynchronously (draft -> created agent). Let
|
|
// it fully settle before moving on, so it can't fire a late redirect
|
|
// that races the next step's navigation.
|
|
await page.waitForURL(hasLeftNewWorkspaceRoute, { timeout: 30_000 });
|
|
|
|
await openNewWorkspace();
|
|
await expectChatLaunchSelected(page);
|
|
});
|
|
|
|
await test.step("re-selecting the terminal profile, then removing it daemon-side, falls back to Chat rather than a dead entry", async () => {
|
|
await selectLaunchOption(page, PROMPT_PROFILE.id);
|
|
await fillTerminalPrompt(page, "second run");
|
|
await submitTerminalLaunch(page);
|
|
await expectWorkspaceOpensWithTerminalTab(page);
|
|
|
|
await patchTerminalProfiles([]);
|
|
|
|
await openNewWorkspace();
|
|
await expectChatLaunchSelected(page);
|
|
});
|
|
});
|
|
});
|