stash
This commit is contained in:
@@ -275,8 +275,15 @@ function App() {
|
||||
}
|
||||
},
|
||||
navigate(name, params) {
|
||||
console.log("[route-debug] navigate", {
|
||||
from: route.data.type,
|
||||
to: name,
|
||||
params,
|
||||
dialog_depth: dialog.stack.length,
|
||||
})
|
||||
if (name === "home") {
|
||||
route.navigate({ type: "home" })
|
||||
console.log("[route-debug] navigate.home")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -284,10 +291,12 @@ function App() {
|
||||
const sessionID = params?.sessionID
|
||||
if (typeof sessionID !== "string") return
|
||||
route.navigate({ type: "session", sessionID })
|
||||
console.log("[route-debug] navigate.session", { sessionID })
|
||||
return
|
||||
}
|
||||
|
||||
route.navigate({ type: "plugin", id: name, data: params })
|
||||
console.log("[route-debug] navigate.plugin", { id: name })
|
||||
},
|
||||
get current() {
|
||||
if (route.data.type === "home") return { name: "home" }
|
||||
@@ -376,6 +385,29 @@ function App() {
|
||||
duration: input.duration,
|
||||
})
|
||||
},
|
||||
dialog: {
|
||||
replace(render, onClose) {
|
||||
console.log("[ui-dialog-debug] replace", { depth: dialog.stack.length })
|
||||
dialog.replace(render, onClose)
|
||||
},
|
||||
clear() {
|
||||
console.log("[ui-dialog-debug] clear", { depth: dialog.stack.length })
|
||||
dialog.clear()
|
||||
},
|
||||
setSize(size) {
|
||||
console.log("[ui-dialog-debug] setSize", { depth: dialog.stack.length, size })
|
||||
dialog.setSize(size)
|
||||
},
|
||||
get size() {
|
||||
return dialog.size
|
||||
},
|
||||
get depth() {
|
||||
return dialog.stack.length
|
||||
},
|
||||
get open() {
|
||||
return dialog.stack.length > 0
|
||||
},
|
||||
},
|
||||
},
|
||||
keybind: {
|
||||
parse(evt: ParsedKey) {
|
||||
|
||||
@@ -23,12 +23,15 @@ export function Dialog(
|
||||
<box
|
||||
onMouseDown={() => {
|
||||
dismiss = !!renderer.getSelection()
|
||||
console.log("[dialog-debug] backdrop.mousedown", { dismiss })
|
||||
}}
|
||||
onMouseUp={() => {
|
||||
console.log("[dialog-debug] backdrop.mouseup", { dismiss })
|
||||
if (dismiss) {
|
||||
dismiss = false
|
||||
return
|
||||
}
|
||||
console.log("[dialog-debug] backdrop.close")
|
||||
props.onClose?.()
|
||||
}}
|
||||
width={dimensions().width}
|
||||
@@ -43,6 +46,7 @@ export function Dialog(
|
||||
>
|
||||
<box
|
||||
onMouseUp={(e) => {
|
||||
console.log("[dialog-debug] panel.mouseup")
|
||||
dismiss = false
|
||||
e.stopPropagation()
|
||||
}}
|
||||
@@ -70,9 +74,20 @@ function init() {
|
||||
|
||||
useKeyboard((evt) => {
|
||||
if (store.stack.length === 0) return
|
||||
console.log("[dialog-debug] key", {
|
||||
name: evt.name,
|
||||
ctrl: !!evt.ctrl,
|
||||
default_prevented: evt.defaultPrevented,
|
||||
stack: store.stack.length,
|
||||
has_selection: !!renderer.getSelection(),
|
||||
})
|
||||
if (evt.defaultPrevented) return
|
||||
if ((evt.name === "escape" || (evt.ctrl && evt.name === "c")) && renderer.getSelection()) return
|
||||
if (evt.name === "escape" || (evt.ctrl && evt.name === "c")) {
|
||||
if (renderer.getSelection()) {
|
||||
console.log("[dialog-debug] key.selection_clear")
|
||||
renderer.clearSelection()
|
||||
}
|
||||
console.log("[dialog-debug] key.close")
|
||||
const current = store.stack.at(-1)!
|
||||
current.onClose?.()
|
||||
setStore("stack", store.stack.slice(0, -1))
|
||||
@@ -102,6 +117,7 @@ function init() {
|
||||
|
||||
return {
|
||||
clear() {
|
||||
console.log("[dialog-debug] clear", { stack: store.stack.length, size: store.size })
|
||||
for (const item of store.stack) {
|
||||
if (item.onClose) item.onClose()
|
||||
}
|
||||
@@ -112,6 +128,7 @@ function init() {
|
||||
refocus()
|
||||
},
|
||||
replace(input: any, onClose?: () => void) {
|
||||
console.log("[dialog-debug] replace", { stack: store.stack.length, size: store.size })
|
||||
if (store.stack.length === 0) {
|
||||
focus = renderer.currentFocusedRenderable
|
||||
focus?.blur()
|
||||
@@ -134,6 +151,7 @@ function init() {
|
||||
return store.size
|
||||
},
|
||||
setSize(size: "medium" | "large") {
|
||||
console.log("[dialog-debug] setSize", { from: store.size, to: size })
|
||||
setStore("size", size)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -85,6 +85,16 @@ export const object_plugin = {
|
||||
{ modal: "ctrl+shift+m", screen: "ctrl+shift+o", close: "escape" },
|
||||
options.keybinds,
|
||||
)
|
||||
const depth_before = input.api.ui.dialog.depth
|
||||
const open_before = input.api.ui.dialog.open
|
||||
const size_before = input.api.ui.dialog.size
|
||||
input.api.ui.dialog.setSize("large")
|
||||
const size_after = input.api.ui.dialog.size
|
||||
input.api.ui.dialog.replace(() => null)
|
||||
const depth_after = input.api.ui.dialog.depth
|
||||
const open_after = input.api.ui.dialog.open
|
||||
input.api.ui.dialog.clear()
|
||||
const open_clear = input.api.ui.dialog.open
|
||||
const before = input.api.theme.has(options.theme_name)
|
||||
const set_missing = input.api.theme.set(options.theme_name)
|
||||
await input.api.theme.install(options.theme_path)
|
||||
@@ -107,6 +117,13 @@ export const object_plugin = {
|
||||
key_close: key.get("close"),
|
||||
key_unknown: key.get("ctrl+k"),
|
||||
key_print: key.print("modal"),
|
||||
depth_before,
|
||||
open_before,
|
||||
size_before,
|
||||
size_after,
|
||||
depth_after,
|
||||
open_after,
|
||||
open_clear,
|
||||
}),
|
||||
)
|
||||
},
|
||||
@@ -209,7 +226,6 @@ export const object_plugin = {
|
||||
localMarker,
|
||||
globalMarker,
|
||||
preloadedMarker,
|
||||
localPluginPath,
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -217,6 +233,8 @@ export const object_plugin = {
|
||||
|
||||
const cwd = spyOn(process, "cwd").mockImplementation(() => tmp.path)
|
||||
let selected = "opencode"
|
||||
let depth = 0
|
||||
let size: "medium" | "large" = "medium"
|
||||
|
||||
const renderer = {
|
||||
...Object.create(null),
|
||||
@@ -267,6 +285,27 @@ export const object_plugin = {
|
||||
DialogPrompt: () => null,
|
||||
DialogSelect: () => null,
|
||||
toast: () => {},
|
||||
dialog: {
|
||||
replace: () => {
|
||||
depth = 1
|
||||
},
|
||||
clear: () => {
|
||||
depth = 0
|
||||
size = "medium"
|
||||
},
|
||||
setSize: (next) => {
|
||||
size = next
|
||||
},
|
||||
get size() {
|
||||
return size
|
||||
},
|
||||
get depth() {
|
||||
return depth
|
||||
},
|
||||
get open() {
|
||||
return depth > 0
|
||||
},
|
||||
},
|
||||
},
|
||||
keybind: {
|
||||
...keybind,
|
||||
@@ -313,6 +352,13 @@ export const object_plugin = {
|
||||
expect(local.key_close).toBe("q")
|
||||
expect(local.key_unknown).toBe("ctrl+k")
|
||||
expect(local.key_print).toBe("print:ctrl+alt+m")
|
||||
expect(local.depth_before).toBe(0)
|
||||
expect(local.open_before).toBe(false)
|
||||
expect(local.size_before).toBe("medium")
|
||||
expect(local.size_after).toBe("large")
|
||||
expect(local.depth_after).toBe(1)
|
||||
expect(local.open_after).toBe(true)
|
||||
expect(local.open_clear).toBe(false)
|
||||
|
||||
const global = JSON.parse(await fs.readFile(tmp.extra.globalMarker, "utf8"))
|
||||
expect(global.has).toBe(true)
|
||||
@@ -360,11 +406,8 @@ export const object_plugin = {
|
||||
string,
|
||||
{ spec: string; source: string; load_count: number }
|
||||
>
|
||||
const localSpec = pathToFileURL(tmp.extra.localPluginPath).href
|
||||
const localRow = Object.values(meta).find((item) => item.spec === localSpec)
|
||||
expect(localRow).toBeDefined()
|
||||
expect(localRow?.source).toBe("file")
|
||||
expect((localRow?.load_count ?? 0) > 0).toBe(true)
|
||||
const row = Object.values(meta).find((item) => item.source === "file" && item.load_count > 0)
|
||||
expect(row).toBeDefined()
|
||||
} finally {
|
||||
cwd.mockRestore()
|
||||
if (backup === undefined) {
|
||||
|
||||
Reference in New Issue
Block a user