mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-08-31 00:03:01 +03:00
fix(tui): dismiss runtime pickers on outside click
This commit is contained in:
@@ -736,6 +736,27 @@ describe("NanobotTui layout", () => {
|
|||||||
access_mode: "full",
|
access_mode: "full",
|
||||||
restrict_to_workspace: false,
|
restrict_to_workspace: false,
|
||||||
}])
|
}])
|
||||||
|
|
||||||
|
await setup.mockMouse.click(
|
||||||
|
ui.runtimeControls.modelText.x + 2,
|
||||||
|
ui.runtimeControls.modelText.y,
|
||||||
|
)
|
||||||
|
await waitUntil(() => ui.runtimeControls.visible)
|
||||||
|
ui.composer.blur()
|
||||||
|
await setup.mockMouse.click(ui.status.x, ui.status.y)
|
||||||
|
expect(ui.runtimeControls.visible).toBe(false)
|
||||||
|
expect(ui.composer.focused).toBe(true)
|
||||||
|
|
||||||
|
await setup.mockMouse.click(
|
||||||
|
ui.runtimeControls.accessText.x + 2,
|
||||||
|
ui.runtimeControls.accessText.y,
|
||||||
|
)
|
||||||
|
await waitUntil(() => ui.runtimeControls.visible)
|
||||||
|
ui.composer.blur()
|
||||||
|
await setup.mockMouse.click(ui.status.x, ui.status.y)
|
||||||
|
expect(ui.runtimeControls.visible).toBe(false)
|
||||||
|
expect(ui.composer.focused).toBe(true)
|
||||||
|
|
||||||
expect((app as unknown as { activeTurn: boolean }).activeTurn).toBe(true)
|
expect((app as unknown as { activeTurn: boolean }).activeTurn).toBe(true)
|
||||||
app.accept({ event: "goal_status", chat_id: "chat", status: "idle" })
|
app.accept({ event: "goal_status", chat_id: "chat", status: "idle" })
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
+10
-1
@@ -487,10 +487,15 @@ export class NanobotTui {
|
|||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
backgroundColor: RGBA.defaultBackground(),
|
backgroundColor: RGBA.defaultBackground(),
|
||||||
onMouseDown: (event) => {
|
onMouseDown: (event) => {
|
||||||
|
if (event.button !== 0) return
|
||||||
|
// Runtime pickers are transient popovers. A primary click anywhere
|
||||||
|
// outside their trigger or body dismisses them; hide() restores the
|
||||||
|
// composer focus through the shared visibility callback.
|
||||||
|
this.dismissRuntimeControls()
|
||||||
// Selection belongs to transcript/input content, never to empty chrome.
|
// Selection belongs to transcript/input content, never to empty chrome.
|
||||||
// Clearing it here prevents default-background cells from lingering as
|
// Clearing it here prevents default-background cells from lingering as
|
||||||
// opaque blocks in terminals with differential repainting.
|
// opaque blocks in terminals with differential repainting.
|
||||||
if (event.button === 0 && event.target && !event.target.selectable) {
|
if (event.target && !event.target.selectable) {
|
||||||
this.renderer.clearSelection()
|
this.renderer.clearSelection()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1732,6 +1737,10 @@ export class NanobotTui {
|
|||||||
this.activeMentionQuery = null
|
this.activeMentionQuery = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private dismissRuntimeControls(): void {
|
||||||
|
if (this.runtimeControls.visible) this.runtimeControls.hide()
|
||||||
|
}
|
||||||
|
|
||||||
private applyWorkspaceScope(scope: WorkspaceScopePayload): void {
|
private applyWorkspaceScope(scope: WorkspaceScopePayload): void {
|
||||||
if (scope.project_path) {
|
if (scope.project_path) {
|
||||||
this.hostWorkspace = scope.project_path
|
this.hostWorkspace = scope.project_path
|
||||||
|
|||||||
Reference in New Issue
Block a user