|
|
@@ -23,7 +23,11 @@ const sessions = {
|
|
|
|
|
|
const shells = [shell("sh-a", "bun test"), shell("sh-b", "bun dev")]
|
|
|
|
|
|
-async function renderComposer(defaultTab: "subagents" | "shell", keybinds: Partial<TuiKeybind.Keybinds>) {
|
|
|
+async function renderComposer(
|
|
|
+ defaultTab: "subagents" | "shell",
|
|
|
+ keybinds: Partial<TuiKeybind.Keybinds>,
|
|
|
+ focusedTextarea = false,
|
|
|
+) {
|
|
|
const events = createEventStream()
|
|
|
const interrupted: string[] = []
|
|
|
const removed: string[] = []
|
|
|
@@ -69,7 +73,21 @@ async function renderComposer(defaultTab: "subagents" | "shell", keybinds: Parti
|
|
|
.then(() => wait(() => data.session.status("child-a") === "running"))
|
|
|
.then(() => ready.resolve(), ready.reject)
|
|
|
})
|
|
|
- return <Composer sessionID="parent" open={true} defaultTab={defaultTab} onClose={() => closed++} />
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ {focusedTextarea && <textarea focused={true} initialValue="draft" />}
|
|
|
+ <Composer sessionID="parent" open={true} defaultTab={defaultTab} onClose={() => closed++} />
|
|
|
+ </>
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ function AppExit() {
|
|
|
+ Keymap.createLayer(() => ({
|
|
|
+ mode: "global",
|
|
|
+ commands: [{ id: "app.exit", title: "Exit", group: "System", run: () => {} }],
|
|
|
+ }))
|
|
|
+ Keymap.createLayer(() => ({ bindings: ["app.exit"] }))
|
|
|
+ return null
|
|
|
}
|
|
|
|
|
|
const app = await testRender(
|
|
|
@@ -77,6 +95,7 @@ async function renderComposer(defaultTab: "subagents" | "shell", keybinds: Parti
|
|
|
<TestTuiContexts directory={directory}>
|
|
|
<ConfigProvider config={createTuiResolvedConfig({ keybinds })}>
|
|
|
<Keymap.Provider>
|
|
|
+ <AppExit />
|
|
|
<ClientProvider api={createApi(calls.fetch)}>
|
|
|
<DataProvider>
|
|
|
<LocationProvider>
|
|
|
@@ -154,6 +173,18 @@ test("disabled shell bindings have no component fallbacks", async () => {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+test("shell kill binding overrides app exit", async () => {
|
|
|
+ const composer = await renderComposer("shell", {}, true)
|
|
|
+ try {
|
|
|
+ expect(composer.app.captureCharFrame()).toContain("bun test")
|
|
|
+ composer.app.mockInput.pressKey("d", { ctrl: true })
|
|
|
+ await wait(() => composer.removed.length === 1)
|
|
|
+ expect(composer.removed).toEqual(["sh-a"])
|
|
|
+ } finally {
|
|
|
+ composer.app.renderer.destroy()
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
function session(id: string, title: string, parentID?: string) {
|
|
|
return {
|
|
|
id,
|