Skip to content
1 change: 1 addition & 0 deletions .opencode/agent/translator.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ opencode serve --hostname 0.0.0.0 --port 4096
opencode serve [--port <number>] [--hostname <string>] [--cors <origin>]
opencode session [command]
opencode session list
opencode session delete <sessionID>
opencode stats
opencode uninstall
opencode upgrade
Expand Down
26 changes: 25 additions & 1 deletion packages/opencode/src/cli/cmd/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,34 @@ function pagerCmd(): string[] {
export const SessionCommand = cmd({
command: "session",
describe: "manage sessions",
builder: (yargs: Argv) => yargs.command(SessionListCommand).demandCommand(),
builder: (yargs: Argv) => yargs.command(SessionListCommand).command(SessionDeleteCommand).demandCommand(),
async handler() {},
})

export const SessionDeleteCommand = cmd({
command: "delete <sessionID>",
describe: "delete a session",
builder: (yargs: Argv) => {
return yargs.positional("sessionID", {
describe: "session ID to delete",
type: "string",
demandOption: true,
})
},
handler: async (args) => {
await bootstrap(process.cwd(), async () => {
try {
await Session.get(args.sessionID)
} catch {
console.error(`Session not found: ${args.sessionID}`)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prolly shouldnt use console here, should use UI consistent w/ other commands.

@ariane-emory ariane-emory Feb 16, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, great advice, thanks! I have updated the PR to use UI.error instead of console.error and also changed the "Session ses_whateverid deleted" message a few lines further down to use UI.println instead if console.log. Tested bit the successful case and the error case and both work properly and look pretty good onscreen to me. Hopefully it's good to go now, if not let me know and I'll keep polishing. :)

process.exit(1)
}
await Session.remove(args.sessionID)
console.log(`Session ${args.sessionID} deleted`)
})
},
})

export const SessionListCommand = cmd({
command: "list",
describe: "list sessions",
Expand Down
Loading