Skip to content

Commit b3fc00f

Browse files
byapparovclaude
andcommitted
fix(run): accept --no-share and report removed share import on stderr (#189)
- `run --share` is rejected only when sharing is requested; `--no-share` asks for what is now the only behaviour and runs normally. - `import <url>` reports the removal through UI.error (stderr), keeping stdout free of error text. - The json-migration test now also feeds a malformed legacy share file, which used to be reported as a migration error. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 4e3ba7e commit b3fc00f

5 files changed

Lines changed: 22 additions & 5 deletions

File tree

‎packages/cli/src/cli/cmd/import.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { SessionTable, MessageTable, PartTable } from "../../session/session.sql
88
import { Instance } from "../../project/instance"
99
import { EOL } from "os"
1010
import { Filesystem } from "../../util/filesystem"
11+
import { UI } from "../ui"
1112

1213
export const ImportCommand = cmd({
1314
command: "import <file>",
@@ -22,8 +23,7 @@ export const ImportCommand = cmd({
2223
handler: async (args) => {
2324
// Importing from a share URL was removed with session sharing (#189).
2425
if (args.file.startsWith("http://") || args.file.startsWith("https://")) {
25-
process.stdout.write(`Importing from a share URL was removed: session sharing is no longer supported`)
26-
process.stdout.write(EOL)
26+
UI.error("Importing from a share URL was removed: session sharing is no longer supported")
2727
process.exitCode = 1
2828
return
2929
}

‎packages/cli/src/cli/cmd/run.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ export const RunCommand = cmd({
432432
process.exit(exit)
433433
}
434434

435-
if (args.share !== undefined) {
435+
if (args.share === true) {
436436
await fail("--share was removed: session sharing is no longer supported", "INVOCATION_INVALID_ARGUMENTS")
437437
}
438438

‎packages/cli/test/cli/import.test.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,15 @@ test("importing from a share URL fails with a removed error and makes no request
2929
stdout: "pipe",
3030
stderr: "pipe",
3131
})
32-
const [stdout, exit] = await Promise.all([new Response(proc.stdout).text(), proc.exited])
32+
const [stdout, stderr, exit] = await Promise.all([
33+
new Response(proc.stdout).text(),
34+
new Response(proc.stderr).text(),
35+
proc.exited,
36+
])
3337

3438
expect(exit).toBe(1)
35-
expect(stdout).toContain("Importing from a share URL was removed: session sharing is no longer supported")
39+
expect(stderr).toContain("Importing from a share URL was removed: session sharing is no longer supported")
40+
expect(stdout).toBe("")
3641
expect(requests).toEqual([])
3742
} finally {
3843
share.stop(true)

‎packages/cli/test/cli/run-share-removed.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ describe("session sharing removed (#189)", () => {
158158
})
159159
}, 20000)
160160

161+
test("`run --no-share` still runs, since it asks for what is now the only behaviour", async () => {
162+
await fixture(async (input) => {
163+
const result = await run(input, ["--no-share", "Say done."])
164+
165+
expect(result.exit, result.output).toBe(0)
166+
expect(result.events.filter((event) => event.type === "session_complete"), result.output).toHaveLength(1)
167+
expect(input.shareRequests).toEqual([])
168+
})
169+
}, 20000)
170+
161171
test("config `share`, `autoshare` and `enterprise` load as no-ops with one warning and send nothing", async () => {
162172
await fixture(async (input) => {
163173
await addShareConfig(input)

‎packages/cli/test/storage/json-migration.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,8 @@ describe("JSON to SQLite migration", () => {
596596
url: "https://share.example.com/ses_test456def",
597597
}),
598598
)
599+
// Unreadable share files were reported as migration errors before #189.
600+
await Bun.write(path.join(storageDir, "session_share", "ses_broken.json"), "{ nope")
599601

600602
const stats = await JsonMigration.run(sqlite)
601603

0 commit comments

Comments
 (0)