feat(core): implement V2 session.shell (#35183)

This commit is contained in:
James Long 2026-07-03 12:19:09 -04:00 committed by GitHub
commit bd8d858bf7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 412 additions and 150 deletions

View file

@ -1101,13 +1101,8 @@ export function Prompt(props: PromptProps) {
if (store.mode === "shell") {
move.startSubmit()
void sdk.client.session.shell({
void sdk.client.v2.session.shell({
sessionID,
agent: agent.id,
model: {
providerID: selectedModel.providerID,
modelID: selectedModel.modelID,
},
command: inputText,
})
setStore("mode", "normal")

View file

@ -1068,9 +1068,7 @@ function SessionMessageView(props: { message: SessionMessage }) {
<UserMessage message={props.message as SessionMessageUser} />
</Match>
<Match when={props.message.type === "shell"}>
<box paddingLeft={3}>
<text>{props.message.type === "shell" ? `$ ${props.message.command}\n${props.message.output}` : ""}</text>
</box>
<ShellMessage message={props.message as Extract<SessionMessage, { type: "shell" }>} />
</Match>
<Match when={props.message.type === "agent-switched" || props.message.type === "model-switched"}>
<SessionSwitchMessageV2 message={props.message} />
@ -1346,6 +1344,29 @@ function RevertMessage(props: {
)
}
function ShellMessage(props: { message: Extract<SessionMessage, { type: "shell" }> }) {
const { theme } = useTheme()
const output = createMemo(() => stripAnsi(props.message.output.trim()))
return (
<box
border={["left"]}
paddingTop={1}
paddingBottom={1}
paddingLeft={2}
gap={1}
backgroundColor={theme.backgroundPanel}
customBorderChars={SplitBorder.customBorderChars}
borderColor={theme.background}
>
<text fg={theme.text}>$ {props.message.command}</text>
<Show when={output()}>
<text fg={theme.textMuted}>{output()}</text>
</Show>
</box>
)
}
function UserMessage(props: { message: SessionMessageUser }) {
const ctx = use()
const data = useData()