mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
Merge remote-tracking branch 'origin/dev' into persisted-browser
This commit is contained in:
commit
9e20e99a4f
122 changed files with 1340 additions and 572 deletions
|
|
@ -182,8 +182,8 @@ const table = sqliteTable("session", {
|
|||
|
||||
- When you open a PR, decide whether the change needs a flag: new user-visible behavior, risky core changes, and anything not ready to release get one; fixes, refactors, docs and tests do not.
|
||||
- Gate risky behavior, or behavior that lands over several PRs, with a key and a description in `packages/schema/src/config/flag.ts`, and read it with `Flag.enabled("<key>")` from `@opencode/core/flag`.
|
||||
- Flags are on in local and dev builds and off in releases; `experimental.<key>` in config and `OPENCODE_FLAGS="key,-other"` override that.
|
||||
- Say in the PR body which flag guards the change. To try every flag at once, use `OPENCODE_FLAGS=all` or `experimental.all_flags: true`; a `-<key>` opt-out or `experimental.<key>: false` still wins, and neither `all` nor `all_flags` is a flag key.
|
||||
- Flags default to on in local and dev builds and off in releases, except `optInOnly` flags (such as `full_codemode`), which require an explicit `OPENCODE_FLAGS=<key>` or `experimental.<key>: true` in every build.
|
||||
- Say in the PR body which flag guards the change. The reserved switches `OPENCODE_FLAGS=all` and `experimental.all_flags: true` skip opt-in-only flags; use `all,-<key>` or `experimental.<key>: false` to opt out within the respective source.
|
||||
- Ship a feature by deleting its flag and the checks that read it.
|
||||
|
||||
## Testing
|
||||
|
|
|
|||
|
|
@ -577,6 +577,9 @@ const lowerAssistantMessage = Effect.fnUntraced(function* (
|
|||
const opaque = reasoningOpaque(reasoning, options.providerMetadataKey)
|
||||
const reasoningText =
|
||||
reasoning.length === 0 || (opaque !== undefined && text === "") ? (requireReasoning ? "" : undefined) : text
|
||||
// A model that declares a different reasoning field reads reasoning there, so structured details and opaque values
|
||||
// from earlier turns (including another model served under the same provider metadata key) must not be replayed.
|
||||
const replaysStructured = configuredField === undefined || configuredField === "reasoning_details"
|
||||
const result = {
|
||||
role: "assistant" as const,
|
||||
content: (() => {
|
||||
|
|
@ -585,10 +588,11 @@ const lowerAssistantMessage = Effect.fnUntraced(function* (
|
|||
return content.map((part) => part.text).join("")
|
||||
})(),
|
||||
...(toolCalls.length > 0 ? { tool_calls: toolCalls } : {}),
|
||||
...(details !== undefined ? { reasoning_details: details } : {}),
|
||||
...(opaque !== undefined ? { reasoning_opaque: opaque } : {}),
|
||||
...(details !== undefined && replaysStructured ? { reasoning_details: details } : {}),
|
||||
...(opaque !== undefined && replaysStructured ? { reasoning_opaque: opaque } : {}),
|
||||
}
|
||||
if (field === undefined || reasoningText === undefined) return result
|
||||
// `reasoning_details` is the structured list itself, so scalar text must not be written over it.
|
||||
if (field === undefined || reasoningText === undefined || field === "reasoning_details") return result
|
||||
return { ...result, [field]: reasoningText }
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { describe, expect } from "bun:test"
|
||||
import { Effect } from "effect"
|
||||
import { ai, LanguageModel, LLMEvent, LLMResponse } from "../../src/effect.js"
|
||||
import { ai, LLMEvent, LLMResponse } from "../../src/effect.js"
|
||||
import * as OpenAICompatible from "../../src/providers/openai-compatible.js"
|
||||
import * as OpenRouter from "../../src/providers/openrouter.js"
|
||||
import { LLMClient } from "../../src/route.js"
|
||||
|
|
@ -11,28 +11,22 @@ import { expectWeatherToolLoop, goldenWeatherToolLoopRequest, runWeatherToolLoop
|
|||
const cases = [
|
||||
{
|
||||
name: "OpenRouter",
|
||||
model: LanguageModel.update(
|
||||
OpenRouter.configure({
|
||||
apiKey: process.env.OPENROUTER_API_KEY ?? "fixture",
|
||||
providerOptions: { reasoning: { max_tokens: 1024 } },
|
||||
}).model("anthropic/claude-sonnet-4.6"),
|
||||
{ compatibility: { reasoningField: "reasoning" } },
|
||||
),
|
||||
model: OpenRouter.configure({
|
||||
apiKey: process.env.OPENROUTER_API_KEY ?? "fixture",
|
||||
providerOptions: { reasoning: { max_tokens: 1024 } },
|
||||
}).model("anthropic/claude-sonnet-4.6"),
|
||||
requires: ["OPENROUTER_API_KEY"],
|
||||
cassette: "openrouter-reasoning",
|
||||
structured: true,
|
||||
},
|
||||
{
|
||||
name: "Vercel AI Gateway",
|
||||
model: LanguageModel.update(
|
||||
OpenAICompatible.configure({
|
||||
provider: "vercel-ai-gateway",
|
||||
baseURL: "https://ai-gateway.vercel.sh/v1",
|
||||
apiKey: process.env.AI_GATEWAY_API_KEY ?? "fixture",
|
||||
http: { body: { reasoning: { enabled: true, max_tokens: 1024 } } },
|
||||
}).model("anthropic/claude-sonnet-4.6"),
|
||||
{ compatibility: { reasoningField: "reasoning" } },
|
||||
),
|
||||
model: OpenAICompatible.configure({
|
||||
provider: "vercel-ai-gateway",
|
||||
baseURL: "https://ai-gateway.vercel.sh/v1",
|
||||
apiKey: process.env.AI_GATEWAY_API_KEY ?? "fixture",
|
||||
http: { body: { reasoning: { enabled: true, max_tokens: 1024 } } },
|
||||
}).model("anthropic/claude-sonnet-4.6"),
|
||||
requires: ["AI_GATEWAY_API_KEY"],
|
||||
cassette: "vercel-ai-gateway-reasoning",
|
||||
structured: true,
|
||||
|
|
|
|||
|
|
@ -1247,6 +1247,85 @@ describe("OpenAI Chat route", () => {
|
|||
}),
|
||||
)
|
||||
|
||||
// A mid-session model switch can keep the same provider metadata key while the new model reads reasoning from a
|
||||
// declared field of its own; details replayed from the earlier model are refused by some endpoints.
|
||||
it.effect("does not replay reasoning details when the model declares another reasoning field", () =>
|
||||
Effect.gen(function* () {
|
||||
const details = [
|
||||
{ type: "reasoning.text", text: "thinking", signature: "signed", format: "anthropic-claude-v1", index: 0 },
|
||||
]
|
||||
const replay = yield* compileRequest(
|
||||
ai.request({
|
||||
model: LanguageModel.update(model, { compatibility: { reasoningField: "reasoning_content" } }),
|
||||
messages: [
|
||||
Message.assistant([
|
||||
{
|
||||
type: "reasoning",
|
||||
text: "thinking",
|
||||
providerMetadata: { openai: { reasoningField: "reasoning", reasoningDetails: details } },
|
||||
},
|
||||
{ type: "text", text: "Hello" },
|
||||
]),
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(replay.body.messages).toEqual([{ role: "assistant", content: "Hello", reasoning_content: "thinking" }])
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("keeps replayed reasoning details when the model declares reasoning_details", () =>
|
||||
Effect.gen(function* () {
|
||||
const details = [
|
||||
{ type: "reasoning.text", text: "thinking", signature: "signed", format: "anthropic-claude-v1", index: 0 },
|
||||
]
|
||||
const replay = yield* compileRequest(
|
||||
ai.request({
|
||||
model: LanguageModel.update(model, { compatibility: { reasoningField: "reasoning_details" } }),
|
||||
messages: [
|
||||
Message.assistant([
|
||||
{
|
||||
type: "reasoning",
|
||||
text: "thinking",
|
||||
providerMetadata: { openai: { reasoningField: "reasoning", reasoningDetails: details } },
|
||||
},
|
||||
{ type: "text", text: "Hello" },
|
||||
]),
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(replay.body.messages).toEqual([{ role: "assistant", content: "Hello", reasoning_details: details }])
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("keeps replayed reasoning details when the model declares no reasoning field", () =>
|
||||
Effect.gen(function* () {
|
||||
const details = [
|
||||
{ type: "reasoning.text", text: "thinking", signature: "signed", format: "anthropic-claude-v1", index: 0 },
|
||||
]
|
||||
const replay = yield* compileRequest(
|
||||
ai.request({
|
||||
model,
|
||||
messages: [
|
||||
Message.assistant([
|
||||
{
|
||||
type: "reasoning",
|
||||
text: "thinking",
|
||||
providerMetadata: { openai: { reasoningField: "reasoning", reasoningDetails: details } },
|
||||
},
|
||||
{ type: "text", text: "Hello" },
|
||||
]),
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
expect(replay.body.messages).toEqual([
|
||||
{ role: "assistant", content: "Hello", reasoning: "thinking", reasoning_details: details },
|
||||
])
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("reports the cost the endpoint billed", () =>
|
||||
Effect.gen(function* () {
|
||||
const response = yield* LLMClient.generate(request).pipe(
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ test("Tab and Enter while suggestions load act on the typed folder, not the prev
|
|||
const input = picker.getByRole("combobox")
|
||||
|
||||
await input.fill("alp")
|
||||
await expect(picker.getByRole("option")).toHaveText(["C:\\OpenCode\\Picker\\alpha/"])
|
||||
await expect(picker.getByRole("option")).toHaveCount(1)
|
||||
await expect(picker.getByRole("option")).toHaveAttribute("data-directory-path", "C:/OpenCode/Picker/alpha")
|
||||
|
||||
const search = await holdRoute(page, /\/api\/fs\/find\?(.*&)?query=beta(&|$)/)
|
||||
await input.fill("beta")
|
||||
|
|
@ -40,7 +41,7 @@ test("Tab and Enter while suggestions load act on the typed folder, not the prev
|
|||
|
||||
await input.press("Enter")
|
||||
await expect(input).toHaveValue("C:\\OpenCode\\Picker\\beta\\")
|
||||
await expect(picker.locator(".directory-picker-selection-text")).toHaveText("C:\\…\\Picker\\beta")
|
||||
await expect(picker.getByRole("treeitem", { name: "beta", exact: true })).toHaveAttribute("aria-selected", "true")
|
||||
search.release()
|
||||
})
|
||||
|
||||
|
|
@ -103,3 +104,30 @@ test("the folder picker's tree scrolls with the mouse wheel inside the modal", a
|
|||
await page.mouse.wheel(0, 300)
|
||||
await expect.poll(scrollTop).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
test("Escape closes suggestions, then drops a typed path, before it closes the picker", async ({ page }) => {
|
||||
const picker = await openPicker(page, {
|
||||
fileList: (path) =>
|
||||
path === directory ? ["alpha", "beta"].map((name) => fileNode(directory, name, "directory")) : [],
|
||||
findFiles: (input) => ["alpha", "beta"].filter((name) => input.query.length >= 3 && name.startsWith(input.query)),
|
||||
})
|
||||
|
||||
const input = picker.getByRole("combobox")
|
||||
|
||||
await picker.getByRole("treeitem", { name: "beta", exact: true }).click()
|
||||
await expect(input).toHaveValue("C:\\OpenCode\\Picker\\beta\\")
|
||||
|
||||
await input.fill("alp")
|
||||
await expect(picker.getByRole("option")).toHaveCount(1)
|
||||
await input.press("Escape")
|
||||
await expect(picker.getByRole("option")).toHaveCount(0)
|
||||
await expect(input).toHaveValue("alp")
|
||||
|
||||
await input.press("Escape")
|
||||
await expect(picker).toBeVisible()
|
||||
await expect(input).toHaveValue("C:\\OpenCode\\Picker\\beta\\")
|
||||
await expect(picker.getByRole("treeitem", { name: "beta", exact: true })).toHaveAttribute("aria-selected", "true")
|
||||
|
||||
await input.press("Escape")
|
||||
await expect(picker).toBeHidden()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -84,13 +84,15 @@ test("creates a session in a new project and selects its model", async ({ page }
|
|||
return url.pathname === "/api/fs/list" && url.searchParams.get("path") === "C:/OpenCode"
|
||||
})
|
||||
|
||||
await picker.getByRole("button", { name: "Parent", exact: true }).click()
|
||||
await picker
|
||||
.getByRole("navigation", { name: "Folder path", exact: true })
|
||||
.getByRole("button", { name: "OpenCode", exact: true })
|
||||
.click()
|
||||
expect(new URL((await listing).url()).searchParams.get("location[directory]")).toBe(directory)
|
||||
const directoryItem = picker.getByRole("treeitem", { name: "NewProject", exact: true })
|
||||
await expect(directoryItem).toBeVisible()
|
||||
await directoryItem.click()
|
||||
await expect(directoryItem).toHaveAttribute("aria-selected", "true")
|
||||
await expect(picker.getByText("C:\\OpenCode\\NewProject", { exact: true })).toBeVisible()
|
||||
const selectFolder = picker.getByRole("button", { name: "Select folder", exact: true })
|
||||
await expect(selectFolder).toBeEnabled()
|
||||
await selectFolder.click()
|
||||
|
|
|
|||
|
|
@ -220,8 +220,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "አዲስ ቅርንጫፍ ለመፍጠር መልዕክት የለም",
|
||||
"dialog.directory.action.selectFile": "ፋይል ምረጥ",
|
||||
"dialog.directory.action.selectFolder": "አቃፊን ምረጥ",
|
||||
"dialog.directory.root": "ሥር",
|
||||
"dialog.directory.parent": "ወላጅ",
|
||||
"dialog.directory.readError": "ይህን አቃፊ ማንበብ አልተቻለም",
|
||||
"dialog.server.add.title": "አገልጋይ አክል",
|
||||
"dialog.server.add.url": "የአገልጋይ አድራሻ",
|
||||
|
|
|
|||
|
|
@ -233,8 +233,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "لا توجد رسائل للتفرع منها",
|
||||
"dialog.directory.action.selectFile": "اختيار ملف",
|
||||
"dialog.directory.action.selectFolder": "اختيار مجلد",
|
||||
"dialog.directory.root": "الجذر",
|
||||
"dialog.directory.parent": "المجلد الأصل",
|
||||
"dialog.directory.readError": "تعذرت قراءة هذا المجلد",
|
||||
"dialog.server.add.title": "إضافة خادم",
|
||||
"dialog.server.add.url": "عنوان URL للخادم",
|
||||
|
|
|
|||
|
|
@ -222,8 +222,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Yeni sessiyaya ayırmaq üçün mesaj yoxdur",
|
||||
"dialog.directory.action.selectFile": "Fayl seçin",
|
||||
"dialog.directory.action.selectFolder": "Qovluğu seçin",
|
||||
"dialog.directory.root": "Kök",
|
||||
"dialog.directory.parent": "Üst qovluq",
|
||||
"dialog.directory.readError": "Bu qovluğu oxumaq mümkün deyil",
|
||||
"dialog.server.add.title": "Server əlavə et",
|
||||
"dialog.server.add.url": "Server ünvanı",
|
||||
|
|
|
|||
|
|
@ -221,8 +221,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Няма съобщения за разклонение",
|
||||
"dialog.directory.action.selectFile": "Изберете файл",
|
||||
"dialog.directory.action.selectFolder": "Изберете папка",
|
||||
"dialog.directory.root": "корен",
|
||||
"dialog.directory.parent": "Родител",
|
||||
"dialog.directory.readError": "Тази папка не може да се прочете",
|
||||
"dialog.server.add.title": "Добавете сървър",
|
||||
"dialog.server.add.url": "Адрес на сървъра",
|
||||
|
|
|
|||
|
|
@ -225,8 +225,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "থেকে কাঁটাচামচ কোন বার্তা",
|
||||
"dialog.directory.action.selectFile": "ফাইল নির্বাচন করুন",
|
||||
"dialog.directory.action.selectFolder": "ফোল্ডার নির্বাচন করুন",
|
||||
"dialog.directory.root": "রুট",
|
||||
"dialog.directory.parent": "অভিভাবক",
|
||||
"dialog.directory.readError": "এই ফোল্ডারটি পড়তে অক্ষম৷",
|
||||
"dialog.server.add.title": "সার্ভার যোগ করুন",
|
||||
"dialog.server.add.url": "সার্ভার ঠিকানা",
|
||||
|
|
|
|||
|
|
@ -438,8 +438,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Nenhuma mensagem para bifurcar",
|
||||
"dialog.directory.action.selectFile": "Selecionar arquivo",
|
||||
"dialog.directory.action.selectFolder": "Selecionar pasta",
|
||||
"dialog.directory.root": "Raiz",
|
||||
"dialog.directory.parent": "Pasta superior",
|
||||
"dialog.directory.readError": "Não foi possível ler esta pasta",
|
||||
"dialog.server.add.title": "Adicionar um servidor",
|
||||
"dialog.server.add.url": "Endereço do servidor",
|
||||
|
|
|
|||
|
|
@ -243,8 +243,6 @@ export const dict = {
|
|||
|
||||
"dialog.directory.action.selectFile": "Odaberi datoteku",
|
||||
"dialog.directory.action.selectFolder": "Odaberi fasciklu",
|
||||
"dialog.directory.root": "Korijen",
|
||||
"dialog.directory.parent": "Nadređena fascikla",
|
||||
"dialog.directory.readError": "Nije moguće pročitati ovu fasciklu",
|
||||
|
||||
"dialog.server.add.title": "Dodaj server",
|
||||
|
|
|
|||
|
|
@ -220,8 +220,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "No hi ha missatges per bifurcar",
|
||||
"dialog.directory.action.selectFile": "Seleccioneu el fitxer",
|
||||
"dialog.directory.action.selectFolder": "Seleccioneu la carpeta",
|
||||
"dialog.directory.root": "Arrel",
|
||||
"dialog.directory.parent": "Pare",
|
||||
"dialog.directory.readError": "No es pot llegir aquesta carpeta",
|
||||
"dialog.server.add.title": "Afegeix servidor",
|
||||
"dialog.server.add.url": "Adreça del servidor",
|
||||
|
|
|
|||
|
|
@ -220,8 +220,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Žádné zprávy k rozvětvení",
|
||||
"dialog.directory.action.selectFile": "Vyberte soubor",
|
||||
"dialog.directory.action.selectFolder": "Vyberte složku",
|
||||
"dialog.directory.root": "Kořen",
|
||||
"dialog.directory.parent": "Rodič",
|
||||
"dialog.directory.readError": "Tuto složku nelze přečíst",
|
||||
"dialog.server.add.title": "Přidat server",
|
||||
"dialog.server.add.url": "Adresa serveru",
|
||||
|
|
|
|||
|
|
@ -373,8 +373,6 @@ export const dict = {
|
|||
|
||||
"dialog.directory.action.selectFile": "Vælg fil",
|
||||
"dialog.directory.action.selectFolder": "Vælg mappe",
|
||||
"dialog.directory.root": "Rod",
|
||||
"dialog.directory.parent": "Overordnet",
|
||||
"dialog.directory.readError": "Denne mappe kan ikke læses",
|
||||
|
||||
"dialog.server.add.title": "Tilføj en server",
|
||||
|
|
|
|||
|
|
@ -371,8 +371,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Keine Nachrichten zum Abzweigen vorhanden",
|
||||
"dialog.directory.action.selectFile": "Datei auswählen",
|
||||
"dialog.directory.action.selectFolder": "Ordner auswählen",
|
||||
"dialog.directory.root": "Stammverzeichnis",
|
||||
"dialog.directory.parent": "Übergeordnet",
|
||||
"dialog.directory.readError": "Dieser Ordner kann nicht gelesen werden",
|
||||
"dialog.server.add.title": "Server hinzufügen",
|
||||
"dialog.server.add.url": "Serveradresse",
|
||||
|
|
|
|||
|
|
@ -224,8 +224,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "ފޯކް ކުރާނެ މެސެޖެއް ނެތެވެ",
|
||||
"dialog.directory.action.selectFile": "ފައިލް ހޮވާށެވެ",
|
||||
"dialog.directory.action.selectFolder": "ފޯލްޑަރ ހޮވާށެވެ",
|
||||
"dialog.directory.root": "މޫ",
|
||||
"dialog.directory.parent": "ބެލެނިވެރިޔާއެވެ",
|
||||
"dialog.directory.readError": "މި ފޯލްޑަރ ކިޔަން ނުކުޅެދިއްޖެއެވެ",
|
||||
"dialog.server.add.title": "ސަރވަރ އިތުރުކުރުން",
|
||||
"dialog.server.add.url": "ސަރވަރ އެޑްރެސް",
|
||||
|
|
|
|||
|
|
@ -232,8 +232,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "ལས་ཕོརཀ་འབད་ནི་ལུ་འཕྲིན་དོན་མེད།",
|
||||
"dialog.directory.action.selectFile": "ཡིག་སྣོད་སེལ་འཐུ་འབད།",
|
||||
"dialog.directory.action.selectFolder": "སྣོད་འཛིན་སེལ་འཐུ་འབད།",
|
||||
"dialog.directory.root": "ར༌ཏོག",
|
||||
"dialog.directory.parent": "ཕ་མ།",
|
||||
"dialog.directory.readError": "སྣོད་འཛིན་འདི་ལྷག་མི་ཚུགས།",
|
||||
"dialog.server.add.title": "སར་བར་ཁ་སྐོང་འབད།",
|
||||
"dialog.server.add.url": "སར་བར་ཁ་བྱང་།",
|
||||
|
|
|
|||
|
|
@ -222,8 +222,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Δεν υπάρχουν μηνύματα για διακλάδωση",
|
||||
"dialog.directory.action.selectFile": "Επιλογή αρχείου",
|
||||
"dialog.directory.action.selectFolder": "Επιλογή φακέλου",
|
||||
"dialog.directory.root": "Ρίζα",
|
||||
"dialog.directory.parent": "Γονικός",
|
||||
"dialog.directory.readError": "Δεν είναι δυνατή η ανάγνωση αυτού του φακέλου",
|
||||
"dialog.server.add.title": "Προσθήκη διακομιστή",
|
||||
"dialog.server.add.url": "Διεύθυνση διακομιστή",
|
||||
|
|
|
|||
|
|
@ -416,12 +416,12 @@ export const dict = {
|
|||
|
||||
"dialog.directory.action.selectFile": "Select file",
|
||||
"dialog.directory.action.selectFolder": "Select folder",
|
||||
"dialog.directory.search.placeholder": "Search projects or enter ~/path…",
|
||||
"dialog.directory.breadcrumbs": "Folder path",
|
||||
"dialog.directory.search.placeholder": "Search folders or enter ~/path…",
|
||||
"dialog.directory.recent": "Recent",
|
||||
"dialog.directory.moreProjects": "More projects",
|
||||
"dialog.directory.recentProject": "{{name}} ({{path}})",
|
||||
"dialog.directory.gitRepo": "git repo",
|
||||
"dialog.directory.root": "Root",
|
||||
"dialog.directory.parent": "Parent",
|
||||
"dialog.directory.readError": "Unable to read this folder",
|
||||
|
||||
"dialog.server.add.title": "Add server",
|
||||
|
|
|
|||
|
|
@ -459,8 +459,6 @@ export const dict = {
|
|||
|
||||
"dialog.directory.action.selectFile": "Seleccionar archivo",
|
||||
"dialog.directory.action.selectFolder": "Seleccionar carpeta",
|
||||
"dialog.directory.root": "Raíz",
|
||||
"dialog.directory.parent": "Carpeta superior",
|
||||
"dialog.directory.readError": "No se puede leer esta carpeta",
|
||||
|
||||
"dialog.server.add.title": "Añadir un servidor",
|
||||
|
|
|
|||
|
|
@ -220,8 +220,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Ühtegi sõnumit pole",
|
||||
"dialog.directory.action.selectFile": "Valige fail",
|
||||
"dialog.directory.action.selectFolder": "Valige kaust",
|
||||
"dialog.directory.root": "Juur",
|
||||
"dialog.directory.parent": "Lapsevanem",
|
||||
"dialog.directory.readError": "Seda kausta ei saa lugeda",
|
||||
"dialog.server.add.title": "Lisa server",
|
||||
"dialog.server.add.url": "Serveri aadress",
|
||||
|
|
|
|||
|
|
@ -230,8 +230,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "هیچ پیامی برای فورک وجود ندارد",
|
||||
"dialog.directory.action.selectFile": "فایل را انتخاب کنید",
|
||||
"dialog.directory.action.selectFolder": "پوشه را انتخاب کنید",
|
||||
"dialog.directory.root": "ریشه",
|
||||
"dialog.directory.parent": "پدر و مادر",
|
||||
"dialog.directory.readError": "خواندن این پوشه ممکن نیست",
|
||||
"dialog.server.add.title": "سرور اضافه کنید",
|
||||
"dialog.server.add.url": "آدرس سرور",
|
||||
|
|
|
|||
|
|
@ -354,8 +354,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Ei viestejä, joista voisi haarauttaa",
|
||||
"dialog.directory.action.selectFile": "Valitse tiedosto",
|
||||
"dialog.directory.action.selectFolder": "Valitse kansio",
|
||||
"dialog.directory.root": "Juuri",
|
||||
"dialog.directory.parent": "Ylätaso",
|
||||
"dialog.directory.readError": "Tätä kansiota ei voi lukea",
|
||||
"dialog.server.add.title": "Lisää palvelin",
|
||||
"dialog.server.add.url": "Palvelimen osoite",
|
||||
|
|
|
|||
|
|
@ -220,8 +220,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Eingi boð at greina frá",
|
||||
"dialog.directory.action.selectFile": "Vel fílu",
|
||||
"dialog.directory.action.selectFolder": "Vel mappu",
|
||||
"dialog.directory.root": "Rót",
|
||||
"dialog.directory.parent": "Foreldur",
|
||||
"dialog.directory.readError": "Tað ber ikki til at lesa hesa mappuna",
|
||||
"dialog.server.add.title": "Legg ambætara til",
|
||||
"dialog.server.add.url": "Ambætaraadressa",
|
||||
|
|
|
|||
|
|
@ -442,8 +442,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Aucun message à partir duquel bifurquer",
|
||||
"dialog.directory.action.selectFile": "Sélectionner le fichier",
|
||||
"dialog.directory.action.selectFolder": "Sélectionner le dossier",
|
||||
"dialog.directory.root": "Racine",
|
||||
"dialog.directory.parent": "Parent",
|
||||
"dialog.directory.readError": "Impossible de lire ce dossier",
|
||||
"dialog.server.add.title": "Ajouter un serveur",
|
||||
"dialog.server.add.url": "URL du serveur",
|
||||
|
|
|
|||
|
|
@ -229,8 +229,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "אין הודעות שמהן אפשר ליצור הפעלה",
|
||||
"dialog.directory.action.selectFile": "בחר קובץ",
|
||||
"dialog.directory.action.selectFolder": "בחר תיקייה",
|
||||
"dialog.directory.root": "שורש",
|
||||
"dialog.directory.parent": "תיקיית אב",
|
||||
"dialog.directory.readError": "לא ניתן לקרוא את התיקייה הזו",
|
||||
"dialog.server.add.title": "הוסף שרת",
|
||||
"dialog.server.add.url": "כתובת שרת",
|
||||
|
|
|
|||
|
|
@ -226,8 +226,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "फ़ोर्क करने के लिए कोई संदेश नहीं",
|
||||
"dialog.directory.action.selectFile": "फ़ाइल का चयन करें",
|
||||
"dialog.directory.action.selectFolder": "फ़ोल्डर चुनें",
|
||||
"dialog.directory.root": "रूट",
|
||||
"dialog.directory.parent": "पैरेंट",
|
||||
"dialog.directory.readError": "इस फ़ोल्डर को पढ़ने में असमर्थ",
|
||||
"dialog.server.add.title": "सर्वर जोड़ें",
|
||||
"dialog.server.add.url": "सर्वर पता",
|
||||
|
|
|
|||
|
|
@ -233,8 +233,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Nema poruka za račvanje",
|
||||
"dialog.directory.action.selectFile": "Odaberite datoteku",
|
||||
"dialog.directory.action.selectFolder": "Odaberite mapu",
|
||||
"dialog.directory.root": "Korijen",
|
||||
"dialog.directory.parent": "Roditelj",
|
||||
"dialog.directory.readError": "Nije moguće pročitati ovu mapu",
|
||||
"dialog.server.add.title": "Dodaj poslužitelj",
|
||||
"dialog.server.add.url": "Adresa poslužitelja",
|
||||
|
|
|
|||
|
|
@ -233,8 +233,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Nincsenek üzenetek, ahonnan elágazhatna",
|
||||
"dialog.directory.action.selectFile": "Válassza ki a fájlt",
|
||||
"dialog.directory.action.selectFolder": "Válasszon mappát",
|
||||
"dialog.directory.root": "Gyökér",
|
||||
"dialog.directory.parent": "Szülő",
|
||||
"dialog.directory.readError": "Ez a mappa nem olvasható",
|
||||
"dialog.server.add.title": "Szerver hozzáadása",
|
||||
"dialog.server.add.url": "Szerver címe",
|
||||
|
|
|
|||
|
|
@ -221,8 +221,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Չկան պատառաքաղված հաղորդագրություններ",
|
||||
"dialog.directory.action.selectFile": "Ընտրել ֆայլը",
|
||||
"dialog.directory.action.selectFolder": "Ընտրել թղթապանակ",
|
||||
"dialog.directory.root": "Արմատ",
|
||||
"dialog.directory.parent": "Ծնող",
|
||||
"dialog.directory.readError": "Անհնար է կարդալ այս թղթապանակը",
|
||||
"dialog.server.add.title": "Ավելացնել սերվեր",
|
||||
"dialog.server.add.url": "Սերվերի հասցեն",
|
||||
|
|
|
|||
|
|
@ -252,8 +252,6 @@ export const dict = {
|
|||
|
||||
"dialog.directory.action.selectFile": "Pilih berkas",
|
||||
"dialog.directory.action.selectFolder": "Pilih folder",
|
||||
"dialog.directory.root": "Akar",
|
||||
"dialog.directory.parent": "Induk",
|
||||
"dialog.directory.readError": "Tidak dapat membaca folder ini",
|
||||
|
||||
"dialog.server.add.title": "Tambah server",
|
||||
|
|
|
|||
|
|
@ -233,8 +233,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Engin skilaboð til að punga frá",
|
||||
"dialog.directory.action.selectFile": "Veldu skrá",
|
||||
"dialog.directory.action.selectFolder": "Veldu möppu",
|
||||
"dialog.directory.root": "Rót",
|
||||
"dialog.directory.parent": "Foreldri",
|
||||
"dialog.directory.readError": "Get ekki lesið þessa möppu",
|
||||
"dialog.server.add.title": "Bæta við netþjóni",
|
||||
"dialog.server.add.url": "Heimilisfang netþjóns",
|
||||
|
|
|
|||
|
|
@ -375,8 +375,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Nessun messaggio da cui effettuare il fork",
|
||||
"dialog.directory.action.selectFile": "Seleziona file",
|
||||
"dialog.directory.action.selectFolder": "Seleziona la cartella",
|
||||
"dialog.directory.root": "Radice",
|
||||
"dialog.directory.parent": "Cartella superiore",
|
||||
"dialog.directory.readError": "Impossibile leggere questa cartella",
|
||||
"dialog.server.add.title": "Aggiungi server",
|
||||
"dialog.server.add.url": "Indirizzo del server",
|
||||
|
|
|
|||
|
|
@ -231,8 +231,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "フォーク元のメッセージがありません",
|
||||
"dialog.directory.action.selectFile": "ファイルを選択",
|
||||
"dialog.directory.action.selectFolder": "フォルダを選択",
|
||||
"dialog.directory.root": "ルート",
|
||||
"dialog.directory.parent": "親フォルダ",
|
||||
"dialog.directory.readError": "このフォルダを読み取れません",
|
||||
"dialog.server.add.title": "サーバーを追加",
|
||||
"dialog.server.add.url": "サーバーURL",
|
||||
|
|
|
|||
|
|
@ -220,8 +220,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "განშტოებისთვის შეტყობინებები არ არის",
|
||||
"dialog.directory.action.selectFile": "აირჩიეთ ფაილი",
|
||||
"dialog.directory.action.selectFolder": "აირჩიე საქაღალდე",
|
||||
"dialog.directory.root": "ძირეული",
|
||||
"dialog.directory.parent": "მშობელი",
|
||||
"dialog.directory.readError": "ამ საქაღალდის წაკითხვა შეუძლებელია",
|
||||
"dialog.server.add.title": "სერვერის დამატება",
|
||||
"dialog.server.add.url": "სერვერის მისამართი",
|
||||
|
|
|
|||
|
|
@ -227,8 +227,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "គ្មានសារដែលត្រូវបំបែកពី",
|
||||
"dialog.directory.action.selectFile": "ជ្រើសរើសឯកសារ",
|
||||
"dialog.directory.action.selectFolder": "ជ្រើសរើសថត",
|
||||
"dialog.directory.root": "ឫស",
|
||||
"dialog.directory.parent": "មាតាបិតា",
|
||||
"dialog.directory.readError": "មិនអាចអានថតឯកសារនេះបានទេ។",
|
||||
"dialog.server.add.title": "បន្ថែមម៉ាស៊ីនមេ",
|
||||
"dialog.server.add.url": "អាសយដ្ឋានម៉ាស៊ីនមេ",
|
||||
|
|
|
|||
|
|
@ -155,8 +155,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "분기할 메시지 없음",
|
||||
"dialog.directory.action.selectFile": "파일 선택",
|
||||
"dialog.directory.action.selectFolder": "폴더 선택",
|
||||
"dialog.directory.root": "루트",
|
||||
"dialog.directory.parent": "상위 폴더",
|
||||
"dialog.directory.readError": "이 폴더를 읽을 수 없습니다",
|
||||
"dialog.server.add.title": "서버 추가",
|
||||
"dialog.server.add.url": "서버 URL",
|
||||
|
|
|
|||
|
|
@ -227,8 +227,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "ບໍ່ມີຂໍ້ຄວາມທີ່ຈະແຍກອອກຈາກ",
|
||||
"dialog.directory.action.selectFile": "ເລືອກໄຟລ໌",
|
||||
"dialog.directory.action.selectFolder": "ເລືອກໂຟນເດີ",
|
||||
"dialog.directory.root": "ຮາກ",
|
||||
"dialog.directory.parent": "ພໍ່ແມ່",
|
||||
"dialog.directory.readError": "ບໍ່ສາມາດອ່ານໂຟນເດີນີ້ໄດ້",
|
||||
"dialog.server.add.title": "ເພີ່ມເຊີບເວີ",
|
||||
"dialog.server.add.url": "ທີ່ຢູ່ເຊີບເວີ",
|
||||
|
|
|
|||
|
|
@ -233,8 +233,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Nėra pranešimų, iš kurių būtų galima išsišakoti",
|
||||
"dialog.directory.action.selectFile": "Pasirinkite failą",
|
||||
"dialog.directory.action.selectFolder": "Pasirinkite aplanką",
|
||||
"dialog.directory.root": "Šaknis",
|
||||
"dialog.directory.parent": "Tėvas",
|
||||
"dialog.directory.readError": "Nepavyko perskaityti šio aplanko",
|
||||
"dialog.server.add.title": "Pridėti serverį",
|
||||
"dialog.server.add.url": "Serverio adresas",
|
||||
|
|
|
|||
|
|
@ -220,8 +220,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Nav ziņu, no kurām atzarot",
|
||||
"dialog.directory.action.selectFile": "Izvēlieties failu",
|
||||
"dialog.directory.action.selectFolder": "Izvēlieties mapi",
|
||||
"dialog.directory.root": "Sakne",
|
||||
"dialog.directory.parent": "Vecāks",
|
||||
"dialog.directory.readError": "Neizdevās nolasīt šo mapi",
|
||||
"dialog.server.add.title": "Pievienot serveri",
|
||||
"dialog.server.add.url": "Servera adrese",
|
||||
|
|
|
|||
|
|
@ -221,8 +221,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Нема пораки од кои може да се префрлите",
|
||||
"dialog.directory.action.selectFile": "Изберете датотека",
|
||||
"dialog.directory.action.selectFolder": "Изберете папка",
|
||||
"dialog.directory.root": "Корен",
|
||||
"dialog.directory.parent": "Родител",
|
||||
"dialog.directory.readError": "Не може да се прочита оваа папка",
|
||||
"dialog.server.add.title": "Додај сервер",
|
||||
"dialog.server.add.url": "Адреса на серверот",
|
||||
|
|
|
|||
|
|
@ -221,8 +221,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Салаалах зурвас алга",
|
||||
"dialog.directory.action.selectFile": "Файл сонгоно уу",
|
||||
"dialog.directory.action.selectFolder": "Фолдер сонгоно уу",
|
||||
"dialog.directory.root": "Үндэс",
|
||||
"dialog.directory.parent": "Эцэг эх",
|
||||
"dialog.directory.readError": "Энэ фолдерыг унших боломжгүй байна",
|
||||
"dialog.server.add.title": "Сервер нэмэх",
|
||||
"dialog.server.add.url": "Серверийн хаяг",
|
||||
|
|
|
|||
|
|
@ -228,8 +228,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Tiada mesej untuk dicabang",
|
||||
"dialog.directory.action.selectFile": "Pilih fail",
|
||||
"dialog.directory.action.selectFolder": "Pilih folder",
|
||||
"dialog.directory.root": "Akar",
|
||||
"dialog.directory.parent": "Induk",
|
||||
"dialog.directory.readError": "Tidak dapat membaca folder ini",
|
||||
"dialog.server.add.title": "Tambah pelayan",
|
||||
"dialog.server.add.url": "Alamat pelayan",
|
||||
|
|
|
|||
|
|
@ -228,8 +228,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "လမ်းခွဲရန် မက်ဆေ့ချ်များ မရှိပါ။",
|
||||
"dialog.directory.action.selectFile": "ဖိုင်ကို ရွေးပါ။",
|
||||
"dialog.directory.action.selectFolder": "ဖိုင်တွဲကို ရွေးပါ။",
|
||||
"dialog.directory.root": "အမြစ်",
|
||||
"dialog.directory.parent": "မိဘ",
|
||||
"dialog.directory.readError": "ဤဖိုင်တွဲကို ဖတ်၍မရပါ။",
|
||||
"dialog.server.add.title": "ဆာဗာထည့်ပါ။",
|
||||
"dialog.server.add.url": "ဆာဗာလိပ်စာ",
|
||||
|
|
|
|||
|
|
@ -225,8 +225,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "बाट फोर्क गर्न कुनै सन्देश छैन",
|
||||
"dialog.directory.action.selectFile": "फाइल चयन गर्नुहोस्",
|
||||
"dialog.directory.action.selectFolder": "फोल्डर चयन गर्नुहोस्",
|
||||
"dialog.directory.root": "रूट",
|
||||
"dialog.directory.parent": "अभिभावक",
|
||||
"dialog.directory.readError": "यो फोल्डर पढ्न असमर्थ",
|
||||
"dialog.server.add.title": "सर्भर थप्नुहोस्",
|
||||
"dialog.server.add.url": "सर्भर ठेगाना",
|
||||
|
|
|
|||
|
|
@ -426,8 +426,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Geen berichten om van af te splitsen",
|
||||
"dialog.directory.action.selectFile": "Selecteer bestand",
|
||||
"dialog.directory.action.selectFolder": "Selecteer map",
|
||||
"dialog.directory.root": "Hoofdmap",
|
||||
"dialog.directory.parent": "Bovenliggende map",
|
||||
"dialog.directory.readError": "Kan deze map niet lezen",
|
||||
"dialog.server.add.title": "Server toevoegen",
|
||||
"dialog.server.add.url": "Serveradres",
|
||||
|
|
|
|||
|
|
@ -433,8 +433,6 @@ export const dict = {
|
|||
|
||||
"dialog.directory.action.selectFile": "Velg fil",
|
||||
"dialog.directory.action.selectFolder": "Velg mappe",
|
||||
"dialog.directory.root": "Rot",
|
||||
"dialog.directory.parent": "Overordnet",
|
||||
"dialog.directory.readError": "Kan ikke lese denne mappen",
|
||||
|
||||
"dialog.server.add.title": "Legg til en server",
|
||||
|
|
|
|||
|
|
@ -227,8 +227,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "فورک کرن لئی کوئی پیغام نئیں",
|
||||
"dialog.directory.action.selectFile": "فائل چنو",
|
||||
"dialog.directory.action.selectFolder": "فولڈر چنو",
|
||||
"dialog.directory.root": "Root",
|
||||
"dialog.directory.parent": "اُتلا فولڈر",
|
||||
"dialog.directory.readError": "اس فولڈر نوں پڑھن توں قاصر",
|
||||
"dialog.server.add.title": "سرور شامل کرو",
|
||||
"dialog.server.add.url": "سرور دا پتہ",
|
||||
|
|
|
|||
|
|
@ -224,8 +224,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Brak wiadomości do rozwidlenia",
|
||||
"dialog.directory.action.selectFile": "Wybierz plik",
|
||||
"dialog.directory.action.selectFolder": "Wybierz folder",
|
||||
"dialog.directory.root": "Katalog główny",
|
||||
"dialog.directory.parent": "Folder nadrzędny",
|
||||
"dialog.directory.readError": "Nie można odczytać tego folderu",
|
||||
"dialog.server.add.title": "Dodaj serwer",
|
||||
"dialog.server.add.url": "Adres URL serwera",
|
||||
|
|
|
|||
|
|
@ -220,8 +220,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Niciun mesaj de bifurcat",
|
||||
"dialog.directory.action.selectFile": "Selectează fișier",
|
||||
"dialog.directory.action.selectFolder": "Selectează folder",
|
||||
"dialog.directory.root": "Rădăcină",
|
||||
"dialog.directory.parent": "Părinte",
|
||||
"dialog.directory.readError": "Nu se poate citi acest folder",
|
||||
"dialog.server.add.title": "Adaugă server",
|
||||
"dialog.server.add.url": "Adresă server",
|
||||
|
|
|
|||
|
|
@ -242,8 +242,6 @@ export const dict = {
|
|||
|
||||
"dialog.directory.action.selectFile": "Выбрать файл",
|
||||
"dialog.directory.action.selectFolder": "Выбрать папку",
|
||||
"dialog.directory.root": "Корень",
|
||||
"dialog.directory.parent": "Родительская папка",
|
||||
"dialog.directory.readError": "Не удалось прочитать эту папку",
|
||||
|
||||
"dialog.server.add.title": "Добавить сервер",
|
||||
|
|
|
|||
|
|
@ -224,8 +224,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "ෆෝක් කිරීමට පණිවිඩ නැත",
|
||||
"dialog.directory.action.selectFile": "ගොනුව තෝරන්න",
|
||||
"dialog.directory.action.selectFolder": "ෆෝල්ඩරය තෝරන්න",
|
||||
"dialog.directory.root": "මූල",
|
||||
"dialog.directory.parent": "දෙමාපිය",
|
||||
"dialog.directory.readError": "මෙම ෆෝල්ඩරය කියවීමට නොහැක",
|
||||
"dialog.server.add.title": "සේවාදායකය එක් කරන්න",
|
||||
"dialog.server.add.url": "සේවාදායක ලිපිනය",
|
||||
|
|
|
|||
|
|
@ -246,8 +246,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Žiadne správy na vytvorenie vetvy",
|
||||
"dialog.directory.action.selectFile": "Vybrať súbor",
|
||||
"dialog.directory.action.selectFolder": "Vybrať priečinok",
|
||||
"dialog.directory.root": "Koreň",
|
||||
"dialog.directory.parent": "Nadradený",
|
||||
"dialog.directory.readError": "Nepodarilo sa načítať tento priečinok",
|
||||
"dialog.server.add.title": "Pridať server",
|
||||
"dialog.server.add.url": "Adresa servera",
|
||||
|
|
|
|||
|
|
@ -246,8 +246,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Ni sporočil za odcepitev",
|
||||
"dialog.directory.action.selectFile": "Izberite datoteko",
|
||||
"dialog.directory.action.selectFolder": "Izberite mapo",
|
||||
"dialog.directory.root": "Koren",
|
||||
"dialog.directory.parent": "starš",
|
||||
"dialog.directory.readError": "Te mape ni mogoče prebrati",
|
||||
"dialog.server.add.title": "Dodaj strežnik",
|
||||
"dialog.server.add.url": "Naslov strežnika",
|
||||
|
|
|
|||
|
|
@ -221,8 +221,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Nuk ka mesazhe për të marrë nga",
|
||||
"dialog.directory.action.selectFile": "Zgjidhni skedarin",
|
||||
"dialog.directory.action.selectFolder": "Zgjidhni dosjen",
|
||||
"dialog.directory.root": "Rrënja",
|
||||
"dialog.directory.parent": "Prindi",
|
||||
"dialog.directory.readError": "Nuk mund të lexohet kjo dosje",
|
||||
"dialog.server.add.title": "Shto server",
|
||||
"dialog.server.add.url": "Adresa e serverit",
|
||||
|
|
|
|||
|
|
@ -234,8 +234,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Нема порука од којих треба да се рачвате",
|
||||
"dialog.directory.action.selectFile": "Изаберите датотеку",
|
||||
"dialog.directory.action.selectFolder": "Изаберите фасциклу",
|
||||
"dialog.directory.root": "Роот",
|
||||
"dialog.directory.parent": "Родитељ",
|
||||
"dialog.directory.readError": "Није могуће прочитати ову фасциклу",
|
||||
"dialog.server.add.title": "Додај сервер",
|
||||
"dialog.server.add.url": "Адреса сервера",
|
||||
|
|
|
|||
|
|
@ -420,8 +420,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Inga meddelanden att förgrena från",
|
||||
"dialog.directory.action.selectFile": "Välj fil",
|
||||
"dialog.directory.action.selectFolder": "Välj mapp",
|
||||
"dialog.directory.root": "Rotmapp",
|
||||
"dialog.directory.parent": "Överordnad mapp",
|
||||
"dialog.directory.readError": "Det går inte att läsa den här mappen",
|
||||
"dialog.server.add.title": "Lägg till server",
|
||||
"dialog.server.add.url": "Serveradress",
|
||||
|
|
|
|||
|
|
@ -221,8 +221,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Паёме барои сохтани шоха нест",
|
||||
"dialog.directory.action.selectFile": "Файлро интихоб кунед",
|
||||
"dialog.directory.action.selectFolder": "Папкаро интихоб кунед",
|
||||
"dialog.directory.root": "Реша",
|
||||
"dialog.directory.parent": "Падару модар",
|
||||
"dialog.directory.readError": "Ин ҷузвдонро хондан ғайриимкон аст",
|
||||
"dialog.server.add.title": "Илова кардани сервер",
|
||||
"dialog.server.add.url": "Суроғаи сервер",
|
||||
|
|
|
|||
|
|
@ -250,8 +250,6 @@ export const dict = {
|
|||
|
||||
"dialog.directory.action.selectFile": "เลือกไฟล์",
|
||||
"dialog.directory.action.selectFolder": "เลือกโฟลเดอร์",
|
||||
"dialog.directory.root": "โฟลเดอร์ราก",
|
||||
"dialog.directory.parent": "โฟลเดอร์หลัก",
|
||||
"dialog.directory.readError": "ไม่สามารถอ่านโฟลเดอร์นี้ได้",
|
||||
|
||||
"dialog.server.add.title": "เพิ่มเซิร์ฟเวอร์",
|
||||
|
|
|
|||
|
|
@ -221,8 +221,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Şahalandyrmaly habar ýok",
|
||||
"dialog.directory.action.selectFile": "Faýly saýlaň",
|
||||
"dialog.directory.action.selectFolder": "Papkany saýlaň",
|
||||
"dialog.directory.root": "Kök",
|
||||
"dialog.directory.parent": "Ene-ata",
|
||||
"dialog.directory.readError": "Bu bukjany okap bolmaýar",
|
||||
"dialog.server.add.title": "Serwer goşuň",
|
||||
"dialog.server.add.url": "Serwer salgysy",
|
||||
|
|
|
|||
|
|
@ -255,8 +255,6 @@ export const dict = {
|
|||
|
||||
"dialog.directory.action.selectFile": "Dosya seç",
|
||||
"dialog.directory.action.selectFolder": "Klasör seç",
|
||||
"dialog.directory.root": "Kök",
|
||||
"dialog.directory.parent": "Üst klasör",
|
||||
"dialog.directory.readError": "Bu klasör okunamıyor",
|
||||
|
||||
"dialog.server.add.title": "Sunucu ekle",
|
||||
|
|
|
|||
|
|
@ -271,8 +271,6 @@ export const dict = {
|
|||
|
||||
"dialog.directory.action.selectFile": "Вибрати файл",
|
||||
"dialog.directory.action.selectFolder": "Вибрати папку",
|
||||
"dialog.directory.root": "Корінь",
|
||||
"dialog.directory.parent": "Батьківська папка",
|
||||
"dialog.directory.readError": "Не вдалося прочитати цю папку",
|
||||
|
||||
"dialog.server.add.title": "Додати сервер",
|
||||
|
|
|
|||
|
|
@ -228,8 +228,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "کوئی پیغامات نہیں ہیں جن سے فورک کیا جائے۔",
|
||||
"dialog.directory.action.selectFile": "فائل منتخب کریں۔",
|
||||
"dialog.directory.action.selectFolder": "فولڈر منتخب کریں۔",
|
||||
"dialog.directory.root": "بنیادی فولڈر",
|
||||
"dialog.directory.parent": "بالائی فولڈر",
|
||||
"dialog.directory.readError": "یہ فولڈر پڑھا نہیں جا سکا",
|
||||
"dialog.server.add.title": "سرور شامل کریں۔",
|
||||
"dialog.server.add.url": "سرور کا پتہ",
|
||||
|
|
|
|||
|
|
@ -221,8 +221,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Hech qanday xabar yo'q",
|
||||
"dialog.directory.action.selectFile": "Faylni tanlang",
|
||||
"dialog.directory.action.selectFolder": "Jildni tanlang",
|
||||
"dialog.directory.root": "Ildiz",
|
||||
"dialog.directory.parent": "Ota-ona",
|
||||
"dialog.directory.readError": "Bu jildni oʻqib boʻlmadi",
|
||||
"dialog.server.add.title": "Server qo'shish",
|
||||
"dialog.server.add.url": "Server manzili",
|
||||
|
|
|
|||
|
|
@ -233,8 +233,6 @@ export const dict = {
|
|||
"dialog.fork.empty": "Không có tin nhắn nào để phân nhánh",
|
||||
"dialog.directory.action.selectFile": "Chọn tệp",
|
||||
"dialog.directory.action.selectFolder": "Chọn thư mục",
|
||||
"dialog.directory.root": "Gốc",
|
||||
"dialog.directory.parent": "Thư mục mẹ",
|
||||
"dialog.directory.readError": "Không thể đọc thư mục này",
|
||||
"dialog.server.add.title": "Thêm máy chủ",
|
||||
"dialog.server.add.url": "Địa chỉ máy chủ",
|
||||
|
|
|
|||
|
|
@ -267,8 +267,6 @@ export const dict = {
|
|||
|
||||
"dialog.directory.action.selectFile": "选择文件",
|
||||
"dialog.directory.action.selectFolder": "选择文件夹",
|
||||
"dialog.directory.root": "根目录",
|
||||
"dialog.directory.parent": "上级目录",
|
||||
"dialog.directory.readError": "无法读取此文件夹",
|
||||
|
||||
"dialog.server.add.title": "添加服务器",
|
||||
|
|
|
|||
|
|
@ -252,8 +252,6 @@ export const dict = {
|
|||
|
||||
"dialog.directory.action.selectFile": "選擇檔案",
|
||||
"dialog.directory.action.selectFolder": "選擇資料夾",
|
||||
"dialog.directory.root": "根目錄",
|
||||
"dialog.directory.parent": "上層目錄",
|
||||
"dialog.directory.readError": "無法讀取此資料夾",
|
||||
|
||||
"dialog.server.add.title": "新增伺服器",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { expect, test } from "bun:test"
|
||||
import {
|
||||
createPickerComboboxState,
|
||||
ownsPickerEscape,
|
||||
pickerComboboxView,
|
||||
transitionPickerCombobox,
|
||||
type PickerComboboxContext,
|
||||
|
|
@ -17,6 +18,7 @@ const context: PickerComboboxContext = {
|
|||
root: "/projects",
|
||||
fallback: "/home/luke",
|
||||
locationDirectory: "/projects",
|
||||
committed: "",
|
||||
}
|
||||
|
||||
const key = (name: string, options: { shiftKey?: boolean; composing?: boolean } = {}): PickerComboboxEvent => ({
|
||||
|
|
@ -74,7 +76,6 @@ test("results of an earlier search never open the list for later input", () => {
|
|||
const late = run([{ type: "search.resolved", attempt: attempt(first.state), items: [directory("/x")] }], second.state)
|
||||
|
||||
expect(second.effects).toEqual([
|
||||
{ type: "selection.clear" },
|
||||
{ type: "search.start", attempt: attempt(first.state) + 1, query: "/projects/new", timeoutMs: 10_000 },
|
||||
])
|
||||
expect(late.state).toBe(second.state)
|
||||
|
|
@ -121,18 +122,24 @@ test("arrow keys wrap through the list and reopen a closed list after a search",
|
|||
expect(pickerComboboxView(resolved.state).active).toBe(1)
|
||||
})
|
||||
|
||||
test("Escape closes an open list without reaching the dialog, and otherwise passes through", () => {
|
||||
test("Escape closes an open list, then drops the draft, without reaching the dialog, and otherwise passes through", () => {
|
||||
const state = opened("~/op", [directory("/home/luke/a")])
|
||||
const escaped = run([key("Escape")], state)
|
||||
const passed = run([key("Escape")], escaped.state)
|
||||
const reverted = run([key("Escape")], escaped.state)
|
||||
const passed = run([key("Escape")], reverted.state)
|
||||
|
||||
expect(escaped).toMatchObject({
|
||||
state: { status: "closed", input: "~/op" },
|
||||
preventDefault: true,
|
||||
stopPropagation: true,
|
||||
})
|
||||
expect(reverted).toMatchObject({
|
||||
state: { status: "closed", input: "" },
|
||||
preventDefault: true,
|
||||
stopPropagation: true,
|
||||
})
|
||||
expect(passed).toMatchObject({ preventDefault: false, stopPropagation: false })
|
||||
expect(passed.state).toBe(escaped.state)
|
||||
expect(passed.state).toBe(reverted.state)
|
||||
})
|
||||
|
||||
test("Shift+Tab and IME Enter pass through", () => {
|
||||
|
|
@ -187,7 +194,7 @@ test("input typed before the location resolves searches once the location arrive
|
|||
const located = run([{ type: "context.changed" }], typed.state)
|
||||
|
||||
expect(typed.state).toMatchObject({ status: "open", input: "~/op", items: [] })
|
||||
expect(typed.effects).toEqual([{ type: "selection.clear" }])
|
||||
expect(typed.effects).toEqual([])
|
||||
expect(located.state).toMatchObject({ status: "loading", input: "~/op" })
|
||||
expect(located.effects).toEqual([
|
||||
{ type: "search.start", attempt: attempt(typed.state) + 1, query: "~/op", timeoutMs: 10_000 },
|
||||
|
|
@ -221,5 +228,59 @@ test("input equal to the open root has nothing to suggest", () => {
|
|||
const typed = run([{ type: "input.changed", value: "/projects/" }])
|
||||
|
||||
expect(typed.state).toMatchObject({ status: "open", items: [] })
|
||||
expect(typed.effects).toEqual([{ type: "selection.clear" }])
|
||||
expect(typed.effects).toEqual([])
|
||||
})
|
||||
|
||||
const selected = { ...context, committed: "/projects/acme/" }
|
||||
|
||||
test("a draft never clears the selection, survives a selection that settles while typing, and Escape reverts it", () => {
|
||||
const synced = run([{ type: "synced" }], createPickerComboboxState(), selected)
|
||||
const edited = run([{ type: "input.changed", value: "/projects/ac" }], synced.state, selected)
|
||||
const cleared = run([{ type: "cleared" }], synced.state, selected)
|
||||
|
||||
expect(synced.state).toEqual({ status: "closed", attempt: 0, input: "/projects/acme/" })
|
||||
expect(edited.effects.map((effect) => effect.type)).toEqual(["search.start"])
|
||||
expect(cleared.effects).toEqual([])
|
||||
|
||||
for (const draft of [edited.state, cleared.state]) {
|
||||
const reverted = run([key("Escape")], draft, selected)
|
||||
|
||||
expect(reverted.state).toMatchObject({ status: "closed", input: "/projects/acme/" })
|
||||
expect(reverted.effects).toEqual(draft.status === "loading" ? [{ type: "search.cancel" }] : [])
|
||||
}
|
||||
|
||||
const moved = { ...selected, committed: "/projects/billing/" }
|
||||
|
||||
expect(run([{ type: "synced" }], edited.state, moved).state).toBe(edited.state)
|
||||
expect(run([{ type: "synced" }], cleared.state, moved).state).toMatchObject({ input: "/projects/billing/" })
|
||||
|
||||
expect(ownsPickerEscape(edited.state, selected.committed)).toBeTrue()
|
||||
expect(ownsPickerEscape(cleared.state, selected.committed)).toBeTrue()
|
||||
expect(ownsPickerEscape(synced.state, selected.committed)).toBeFalse()
|
||||
|
||||
const escaped = run([key("Escape")], synced.state, selected)
|
||||
|
||||
expect(escaped).toMatchObject({ preventDefault: false, stopPropagation: false })
|
||||
expect(escaped.state).toBe(synced.state)
|
||||
})
|
||||
|
||||
test("confirming submits the selection, or commits a draft first and submits once it is selected", () => {
|
||||
const synced = run([{ type: "synced" }], createPickerComboboxState(), selected).state
|
||||
const typed = run([{ type: "input.changed", value: "/projects/billing" }], synced, selected).state
|
||||
|
||||
const listed = run(
|
||||
[{ type: "search.resolved", attempt: attempt(typed), items: [directory("/projects/billing-service")] }],
|
||||
typed,
|
||||
selected,
|
||||
).state
|
||||
|
||||
expect(run([{ type: "submitted" }], synced, selected).effects).toEqual([{ type: "submit" }])
|
||||
expect(run([{ type: "submitted" }], createPickerComboboxState(), selected).effects).toEqual([{ type: "submit" }])
|
||||
expect(run([{ type: "submitted" }], typed, selected).effects).toEqual([
|
||||
{ type: "search.cancel" },
|
||||
{ type: "choose.directory", path: "/projects/billing", submit: true },
|
||||
])
|
||||
expect(run([{ type: "submitted" }], listed, selected).effects).toEqual([
|
||||
{ type: "choose.directory", path: "/projects/billing-service", submit: true },
|
||||
])
|
||||
})
|
||||
|
|
|
|||
|
|
@ -12,19 +12,24 @@ export const PICKER_SEARCH_TIMEOUT_MS = 10_000
|
|||
|
||||
export type PickerSuggestion = { readonly absolute: string; readonly type: "file" | "directory" }
|
||||
|
||||
/** What the input resolves and searches against. `fallback` is the base for relative input before a root opens. */
|
||||
/**
|
||||
* What the input resolves and searches against. `fallback` is the base for relative input before a root opens;
|
||||
* `committed` is the selection as the input shows it.
|
||||
*/
|
||||
export type PickerComboboxContext = {
|
||||
readonly policy: PickerPolicy
|
||||
readonly home: string
|
||||
readonly root: string
|
||||
readonly fallback: string
|
||||
readonly locationDirectory: string | undefined
|
||||
readonly committed: string
|
||||
}
|
||||
|
||||
/**
|
||||
* The path input and its suggestion list. Only `open` holds items, and only for its `input`, so a key pressed while the
|
||||
* next search runs never acts on the previous query's results. `active` is null until the user steps or hovers;
|
||||
* `step` is an arrow key pressed while the search runs.
|
||||
* The path input and its suggestion list. The input shows the committed selection; typed input is a draft that only
|
||||
* changes the selection once committed (Enter, a suggestion, or `submitted`). Only `open` holds items, and only for
|
||||
* its `input`, so a key pressed while the next search runs never acts on the previous query's results. `active` is
|
||||
* null until the user steps or hovers; `step` is an arrow key pressed while the search runs.
|
||||
*/
|
||||
export type PickerComboboxState =
|
||||
| { readonly status: "closed"; readonly attempt: number; readonly input: string }
|
||||
|
|
@ -45,6 +50,8 @@ export type PickerComboboxEvent =
|
|||
| { readonly type: "context.changed" }
|
||||
| { readonly type: "item.hovered"; readonly index: number }
|
||||
| { readonly type: "item.clicked"; readonly index: number }
|
||||
| { readonly type: "synced" }
|
||||
| { readonly type: "submitted" }
|
||||
| { readonly type: "key.down"; readonly key: string; readonly shiftKey: boolean; readonly composing: boolean }
|
||||
| { readonly type: "search.resolved"; readonly attempt: number; readonly items: readonly PickerSuggestion[] }
|
||||
| { readonly type: "search.failed"; readonly attempt: number }
|
||||
|
|
@ -54,9 +61,9 @@ export type PickerComboboxEvent =
|
|||
export type PickerComboboxEffect =
|
||||
| { readonly type: "search.start"; readonly attempt: number; readonly query: string; readonly timeoutMs: number }
|
||||
| { readonly type: "search.cancel" }
|
||||
| { readonly type: "selection.clear" }
|
||||
| { readonly type: "choose.directory"; readonly path: string }
|
||||
| { readonly type: "choose.file"; readonly absolute: string }
|
||||
| { readonly type: "choose.directory"; readonly path: string; readonly submit?: true }
|
||||
| { readonly type: "choose.file"; readonly absolute: string; readonly submit?: true }
|
||||
| { readonly type: "submit" }
|
||||
|
||||
export type PickerComboboxTransition = {
|
||||
readonly state: PickerComboboxState
|
||||
|
|
@ -86,11 +93,22 @@ export function transitionPickerCombobox(
|
|||
const input = cleanPickerInput(event.value)
|
||||
|
||||
// Trailing whitespace cleans to the same input; the running search or open list still matches it.
|
||||
if (input === state.input && (state.status !== "closed" || !input)) {
|
||||
return result(state, [{ type: "selection.clear" }])
|
||||
}
|
||||
if (input === state.input && (state.status !== "closed" || !input)) return unchanged(state)
|
||||
|
||||
return withInput(state, input, context, [{ type: "selection.clear" }])
|
||||
return withInput(state, input, context, [])
|
||||
}
|
||||
|
||||
// A selection that settles while the user types keeps the draft; picking in the tree closes the list first.
|
||||
if (event.type === "synced") {
|
||||
if (state.status !== "closed" || state.input === context.committed) return unchanged(state)
|
||||
|
||||
return result(close(state, context.committed))
|
||||
}
|
||||
|
||||
if (event.type === "submitted") {
|
||||
if (!state.input || state.input === context.committed) return result(state, [{ type: "submit" }])
|
||||
|
||||
return commit(state, context, true)
|
||||
}
|
||||
|
||||
if (event.type === "cleared") {
|
||||
|
|
@ -168,6 +186,13 @@ export function pickerComboboxView(state: PickerComboboxState) {
|
|||
}
|
||||
}
|
||||
|
||||
// Escape closes an open list or drops a draft; only then does the input keep it from the dialog.
|
||||
export function ownsPickerEscape(state: PickerComboboxState, committed: string) {
|
||||
if (state.status === "disposed") return false
|
||||
|
||||
return (state.status === "open" && state.items.length > 0) || state.input !== committed
|
||||
}
|
||||
|
||||
function key(
|
||||
state: LiveCombobox,
|
||||
event: Extract<PickerComboboxEvent, { type: "key.down" }>,
|
||||
|
|
@ -176,9 +201,13 @@ function key(
|
|||
const items = state.status === "open" ? state.items : []
|
||||
|
||||
if (event.key === "Escape") {
|
||||
if (state.status !== "open" || items.length === 0) return unchanged(state)
|
||||
if (state.status === "open" && items.length > 0) {
|
||||
return { ...result(close(state, state.input)), preventDefault: true, stopPropagation: true }
|
||||
}
|
||||
|
||||
return { ...result(close(state, state.input)), preventDefault: true, stopPropagation: true }
|
||||
if (state.input === context.committed) return unchanged(state)
|
||||
|
||||
return { ...result(close(state, context.committed), cancel(state)), preventDefault: true, stopPropagation: true }
|
||||
}
|
||||
|
||||
if (event.key === "Tab") {
|
||||
|
|
@ -207,26 +236,32 @@ function key(
|
|||
}
|
||||
|
||||
if (event.key !== "Enter" || event.composing) return unchanged(state)
|
||||
const active = effectiveActiveIndex(state)
|
||||
|
||||
if (state.status === "open" && active >= 0) return handled(choose(state, state.items[active]!, context))
|
||||
const value = state.input ? resolve(state.input, context) : undefined
|
||||
|
||||
if (!value) return handled(unchanged(state))
|
||||
|
||||
return handled(
|
||||
result(close(state, displayInputDirectory(value, context.home)), [
|
||||
...cancel(state),
|
||||
{ type: "choose.directory", path: state.input },
|
||||
]),
|
||||
)
|
||||
return handled(commit(state, context, false))
|
||||
}
|
||||
|
||||
function choose(state: LiveCombobox, item: PickerSuggestion, context: PickerComboboxContext) {
|
||||
// Enter and a confirm with a draft both choose the highlighted suggestion, or else the typed path.
|
||||
function commit(state: LiveCombobox, context: PickerComboboxContext, submit: boolean) {
|
||||
const active = effectiveActiveIndex(state)
|
||||
|
||||
if (state.status === "open" && active >= 0) return choose(state, state.items[active]!, context, submit)
|
||||
const value = state.input ? resolve(state.input, context) : undefined
|
||||
|
||||
if (!value) return unchanged(state)
|
||||
|
||||
return result(close(state, displayInputDirectory(value, context.home)), [
|
||||
...cancel(state),
|
||||
chosenDirectory(state.input, submit),
|
||||
])
|
||||
}
|
||||
|
||||
function choose(state: LiveCombobox, item: PickerSuggestion, context: PickerComboboxContext, submit = false) {
|
||||
if (item.type === "file") {
|
||||
return result(close(state, displayPickerPath(item.absolute, state.input, context.home)), [
|
||||
...cancel(state),
|
||||
{ type: "choose.file", absolute: item.absolute },
|
||||
submit
|
||||
? { type: "choose.file", absolute: item.absolute, submit }
|
||||
: { type: "choose.file", absolute: item.absolute },
|
||||
])
|
||||
}
|
||||
|
||||
|
|
@ -236,10 +271,14 @@ function choose(state: LiveCombobox, item: PickerSuggestion, context: PickerComb
|
|||
|
||||
return result(close(state, displayInputDirectory(value, context.home)), [
|
||||
...cancel(state),
|
||||
{ type: "choose.directory", path: item.absolute },
|
||||
chosenDirectory(item.absolute, submit),
|
||||
])
|
||||
}
|
||||
|
||||
function chosenDirectory(path: string, submit: boolean): PickerComboboxEffect {
|
||||
return submit ? { type: "choose.directory", path, submit } : { type: "choose.directory", path }
|
||||
}
|
||||
|
||||
function withInput(
|
||||
state: LiveCombobox,
|
||||
input: string,
|
||||
|
|
|
|||
|
|
@ -2,21 +2,49 @@
|
|||
display: flex;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.directory-picker-subtitle {
|
||||
overflow: hidden;
|
||||
color: var(--v2-text-text-muted);
|
||||
font-size: 11px;
|
||||
font-weight: 440;
|
||||
line-height: var(--line-height-tight);
|
||||
letter-spacing: 0.05px;
|
||||
text-overflow: ellipsis;
|
||||
/* Outranks the dialog's rule that grows the title, so the server chip sits beside it. */
|
||||
.directory-picker.directory-picker
|
||||
[data-slot="dialog-header"]
|
||||
.directory-picker-header
|
||||
> [data-slot="dialog-header-title"] {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
/* The 20px close button would add 2px below the 16px title row. */
|
||||
[data-component="dialog-v2"]
|
||||
[data-slot="dialog-container"]
|
||||
.directory-picker
|
||||
[data-slot="dialog-header"]
|
||||
[data-slot="dialog-close-button"] {
|
||||
margin-block: -2px;
|
||||
}
|
||||
|
||||
.directory-picker-server {
|
||||
display: inline-flex;
|
||||
min-width: 0;
|
||||
max-width: 240px;
|
||||
height: 16px;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 0 4px;
|
||||
border-radius: 4px;
|
||||
background: var(--v2-overlay-simple-overlay-hover);
|
||||
color: var(--v2-text-text-base);
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
line-height: var(--line-height-compact);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.directory-picker-server [data-component="icon"] {
|
||||
flex-shrink: 0;
|
||||
color: var(--v2-icon-icon-muted);
|
||||
}
|
||||
|
||||
.directory-picker-body {
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
|
|
@ -31,7 +59,6 @@
|
|||
z-index: 10;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.directory-picker-input {
|
||||
|
|
@ -40,72 +67,121 @@
|
|||
flex: 1 1 0%;
|
||||
}
|
||||
|
||||
.directory-picker-actions {
|
||||
display: flex;
|
||||
.directory-picker-item-name {
|
||||
flex-shrink: 0;
|
||||
gap: 2px;
|
||||
max-width: 50%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.directory-picker-item-path {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: var(--v2-text-text-faint);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.directory-picker-recent {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.directory-picker-recent-label {
|
||||
color: var(--v2-text-text-base);
|
||||
font-size: 13px;
|
||||
font-weight: 530;
|
||||
line-height: var(--line-height-compact);
|
||||
letter-spacing: -0.04px;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.directory-picker-recent-list {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
margin-top: -4px;
|
||||
}
|
||||
|
||||
.directory-picker-recent-item {
|
||||
max-width: 240px;
|
||||
max-width: 160px;
|
||||
gap: 6px;
|
||||
padding-inline: 4px 8px;
|
||||
}
|
||||
|
||||
.directory-picker-recent-menu {
|
||||
max-width: 420px;
|
||||
}
|
||||
|
||||
.directory-picker-recent + .directory-picker-folder {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.directory-picker-folder {
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
flex: 1 1 312px;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
border: 0.5px solid var(--v2-border-border-base);
|
||||
border-radius: 6px;
|
||||
background: var(--v2-background-bg-base);
|
||||
}
|
||||
|
||||
.directory-picker-folder-header {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
height: 32px;
|
||||
flex-shrink: 0;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 0 4px 0 6px;
|
||||
border-bottom: 0.5px solid var(--v2-border-border-base);
|
||||
}
|
||||
|
||||
.directory-picker-breadcrumbs {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex: 1 1 auto;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.directory-picker-breadcrumb {
|
||||
min-width: 0;
|
||||
height: 22px;
|
||||
flex-shrink: 1;
|
||||
overflow: hidden;
|
||||
padding: 0 6px;
|
||||
border-radius: 4px;
|
||||
color: var(--v2-text-text-muted);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
line-height: 22px;
|
||||
letter-spacing: -0.04px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.directory-picker-breadcrumb:hover {
|
||||
background: var(--v2-overlay-simple-overlay-hover);
|
||||
color: var(--v2-text-text-base);
|
||||
}
|
||||
|
||||
.directory-picker-breadcrumb[aria-current] {
|
||||
flex-shrink: 0;
|
||||
color: var(--v2-text-text-base);
|
||||
}
|
||||
|
||||
.directory-picker-breadcrumb-separator {
|
||||
flex-shrink: 0;
|
||||
color: var(--v2-icon-icon-faint);
|
||||
}
|
||||
|
||||
.directory-picker-suggestions {
|
||||
position: absolute;
|
||||
z-index: 20;
|
||||
top: 34px;
|
||||
top: 36px;
|
||||
right: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 4px;
|
||||
border: 1px solid var(--v2-border-border-base);
|
||||
border-radius: 6px;
|
||||
background: var(--v2-background-bg-layer-02);
|
||||
box-shadow: var(--v2-elevation-overlay);
|
||||
}
|
||||
|
||||
.directory-picker-suggestions button {
|
||||
overflow: hidden;
|
||||
padding: 6px 8px;
|
||||
border-radius: 4px;
|
||||
color: var(--v2-text-text-muted);
|
||||
font-size: 13px;
|
||||
line-height: var(--line-height-compact);
|
||||
text-align: left;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
.directory-picker-suggestions-viewport {
|
||||
max-height: 232px;
|
||||
}
|
||||
|
||||
.directory-picker-suggestions button:hover,
|
||||
.directory-picker-suggestions button[data-active] {
|
||||
color: var(--v2-text-text-base);
|
||||
background: var(--v2-overlay-simple-overlay-hover);
|
||||
.directory-picker-suggestions [data-component="menu-v2-item"] [data-component="icon"] {
|
||||
flex-shrink: 0;
|
||||
color: var(--v2-icon-icon-muted);
|
||||
}
|
||||
|
||||
.directory-picker-browser {
|
||||
|
|
@ -116,10 +192,7 @@
|
|||
min-height: 0;
|
||||
flex: 1 1 280px;
|
||||
overflow: hidden;
|
||||
padding: 6px;
|
||||
border: 0.5px solid var(--v2-border-border-base);
|
||||
border-radius: 6px;
|
||||
background: var(--v2-background-bg-base);
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.directory-picker-tree {
|
||||
|
|
@ -132,8 +205,8 @@
|
|||
--trees-bg-muted-override: transparent;
|
||||
--trees-selected-bg-override: var(--v2-overlay-simple-overlay-pressed);
|
||||
--trees-selected-fg-override: var(--v2-text-text-base);
|
||||
--trees-selected-focused-border-color-override: var(--v2-border-border-focus);
|
||||
--trees-focus-ring-color-override: var(--v2-border-border-focus);
|
||||
--trees-selected-focused-border-color-override: transparent;
|
||||
--trees-focus-ring-color-override: transparent;
|
||||
--trees-focus-ring-width-override: 1px;
|
||||
--trees-focus-ring-offset-override: -1px;
|
||||
--trees-border-color-override: var(--v2-border-border-base);
|
||||
|
|
@ -141,7 +214,8 @@
|
|||
--trees-font-size-override: 13px;
|
||||
--trees-item-height: 24px;
|
||||
--trees-border-radius-override: 4px;
|
||||
--trees-padding-inline-override: 0px;
|
||||
/* Matches the 6px scrollbar gutter, which the tree takes out of the end padding. */
|
||||
--trees-padding-inline-override: 6px;
|
||||
--trees-item-margin-x-override: 0px;
|
||||
--trees-item-padding-x-override: 8px;
|
||||
--trees-item-row-gap-override: 6px;
|
||||
|
|
@ -158,23 +232,3 @@
|
|||
line-height: var(--line-height-compact);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.directory-picker-selection {
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
min-width: 0;
|
||||
flex: 1 1 0%;
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.directory-picker-selection-text {
|
||||
overflow: hidden;
|
||||
min-width: 0;
|
||||
color: var(--v2-text-text-faint);
|
||||
font-size: 13px;
|
||||
font-weight: 440;
|
||||
line-height: var(--line-height-compact);
|
||||
letter-spacing: -0.04px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,12 @@ import { FileTree } from "@pierre/trees"
|
|||
import { Dialog, DialogBody, DialogFooter, DialogHeader, DialogTitle } from "@opencode/ui/dialog"
|
||||
import { Button } from "@opencode/ui/button"
|
||||
import { Divider } from "@opencode/ui/divider"
|
||||
import { Icon } from "@opencode/ui/icon"
|
||||
import { Menu } from "@opencode/ui/menu"
|
||||
import { MenuScroll } from "@opencode/ui/menu-scroll"
|
||||
import {
|
||||
displayName,
|
||||
getProjectAvatarGenerated,
|
||||
getProjectAvatarSource,
|
||||
getProjectAvatarVariant,
|
||||
ProjectAvatar,
|
||||
|
|
@ -26,10 +30,11 @@ import {
|
|||
pickerMode,
|
||||
createPriorityTaskQueue,
|
||||
createDirectorySearch,
|
||||
displayInputDirectory,
|
||||
displayPickerPath,
|
||||
shortenPickerRecentPath,
|
||||
pickerBreadcrumbs,
|
||||
pickerParent,
|
||||
pickerRoot,
|
||||
listPickerDirectory,
|
||||
pickerRelativePath,
|
||||
pickerAbsolutePath,
|
||||
|
|
@ -45,6 +50,7 @@ import {
|
|||
} from "./tree-machine"
|
||||
import {
|
||||
createPickerComboboxState,
|
||||
ownsPickerEscape,
|
||||
pickerComboboxView,
|
||||
transitionPickerCombobox,
|
||||
type PickerComboboxEffect,
|
||||
|
|
@ -152,23 +158,43 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
|||
|
||||
return true
|
||||
})
|
||||
.slice(0, 5)
|
||||
.slice(0, 10)
|
||||
})
|
||||
|
||||
const search = createDirectorySearch({ sdk, home, location, base: () => treeView().root || start() })
|
||||
|
||||
const fullSelectionPath = createMemo(() => {
|
||||
const value = treeView().result
|
||||
const breadcrumbs = createMemo(() => {
|
||||
const root = treeView().root
|
||||
const crumbs = root ? pickerBreadcrumbs(root, home()) : []
|
||||
// Deep paths collapse the folders between / and ~ and the last two into an ellipsis that opens the one above them.
|
||||
const lead = crumbs[1]?.label === "~" ? 2 : 1
|
||||
|
||||
return value ? displayPickerPath(value, "", home()) : ""
|
||||
if (crumbs.length <= lead + 3) return crumbs
|
||||
|
||||
return [...crumbs.slice(0, lead), { label: "…", path: crumbs[crumbs.length - 3].path }, ...crumbs.slice(-2)]
|
||||
})
|
||||
|
||||
const shortSelectionPath = createMemo(() => {
|
||||
const value = treeView().result
|
||||
const committed = createMemo(() => {
|
||||
const selected = treeView().selected
|
||||
|
||||
return value ? shortenPickerRecentPath(value, home()) : ""
|
||||
if (!selected) return ""
|
||||
|
||||
return policy.action === "file" ? displayPickerPath(selected, "", home()) : displayInputDirectory(selected, home())
|
||||
})
|
||||
|
||||
function atSelection(input: HTMLInputElement) {
|
||||
if (!input.value) return true
|
||||
|
||||
const end = input.value.length
|
||||
|
||||
return input.value === committed() && input.selectionStart === end && input.selectionEnd === end
|
||||
}
|
||||
|
||||
function choose(directory: string) {
|
||||
dispatchCombobox({ type: "dismissed" })
|
||||
dispatchTree({ type: "directory.chosen", ...navigation(directory), fromInput: false })
|
||||
}
|
||||
|
||||
function navigation(path: string) {
|
||||
return { path, home: home(), fallback: start() || home(), located: Boolean(location()) }
|
||||
}
|
||||
|
|
@ -195,6 +221,7 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
|||
root: treeView().root,
|
||||
fallback: start() || home(),
|
||||
locationDirectory: location()?.directory,
|
||||
committed: committed(),
|
||||
})
|
||||
|
||||
if (next.state !== previous) setMachines((current) => ({ ...current, combobox: next.state }))
|
||||
|
|
@ -309,6 +336,8 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
|||
return
|
||||
}
|
||||
|
||||
if (effect.type === "submit") return resolve()
|
||||
|
||||
if (effect.type === "tree.focus-initial") {
|
||||
if (!tree?.getFocusedPath()) tree?.focusNearestPath(null)
|
||||
|
||||
|
|
@ -343,13 +372,20 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
|||
|
||||
if (effect.type === "search.cancel") return stopSearch()
|
||||
|
||||
if (effect.type === "selection.clear") return dispatchTree({ type: "selection.cleared" })
|
||||
if (effect.type === "submit") return resolve()
|
||||
|
||||
if (effect.type === "choose.directory") {
|
||||
return dispatchTree({ type: "directory.chosen", ...navigation(effect.path), fromInput: true })
|
||||
return dispatchTree({
|
||||
type: "directory.chosen",
|
||||
...navigation(effect.path),
|
||||
fromInput: true,
|
||||
submit: effect.submit,
|
||||
})
|
||||
}
|
||||
|
||||
dispatchTree({ type: "file.chosen", absolute: effect.absolute, home: home() })
|
||||
|
||||
if (effect.submit) resolve()
|
||||
}
|
||||
|
||||
function stopSearch() {
|
||||
|
|
@ -457,7 +493,7 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
|||
box-shadow: none !important;
|
||||
color: var(--v2-text-text-muted) !important;
|
||||
font-size: 13px !important;
|
||||
font-weight: 440 !important;
|
||||
font-weight: 500 !important;
|
||||
letter-spacing: -0.04px !important;
|
||||
}
|
||||
button[data-type="item"]:hover {
|
||||
|
|
@ -477,12 +513,11 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
|||
background:
|
||||
linear-gradient(0deg, var(--v2-overlay-simple-overlay-pressed), var(--v2-overlay-simple-overlay-pressed)),
|
||||
var(--v2-background-bg-base) !important;
|
||||
box-shadow: inset 0 0 0 0.5px var(--v2-border-border-base) !important;
|
||||
color: var(--v2-text-text-base) !important;
|
||||
font-weight: 530 !important;
|
||||
}
|
||||
button[data-type="item"]:focus-visible {
|
||||
outline: none !important;
|
||||
box-shadow: inset 0 0 0 1px var(--v2-border-border-focus) !important;
|
||||
}
|
||||
[data-item-type="folder"] > [data-item-section="icon"] {
|
||||
width: auto !important;
|
||||
|
|
@ -519,16 +554,36 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
|||
-webkit-mask-image: ${FOLDER_OPEN_MASK};
|
||||
mask-image: ${FOLDER_OPEN_MASK};
|
||||
}
|
||||
/* The tree renders rows in its shadow root, which only takes text decorations, so this repeats Badge's neutral compact style. */
|
||||
[data-item-section="decoration"] > span {
|
||||
box-sizing: border-box;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
height: 16px;
|
||||
padding: 0 4px;
|
||||
border-radius: 2px;
|
||||
background: var(--v2-background-bg-layer-03);
|
||||
border: 0.5px solid var(--v2-border-border-base);
|
||||
background: var(--v2-background-bg-layer-02);
|
||||
color: var(--v2-text-text-muted);
|
||||
font-size: 11px;
|
||||
font-weight: 530;
|
||||
line-height: 12px;
|
||||
line-height: 1;
|
||||
letter-spacing: 0.05px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
[data-item-section="spacing"] {
|
||||
padding-inline-start: 6.5px;
|
||||
}
|
||||
[data-item-section="spacing-item"] {
|
||||
border-left: none;
|
||||
margin-right: 0;
|
||||
border-inline-start: 1px solid color-mix(in srgb, var(--v2-border-border-muted) 50%, transparent);
|
||||
margin-inline-end: calc(var(--trees-level-gap) - 1px);
|
||||
transform: none;
|
||||
}
|
||||
/* The tree always reserves a lane for git change letters. */
|
||||
[data-item-section="git"] {
|
||||
display: none;
|
||||
}
|
||||
[data-file-tree-virtualized-scroll] {
|
||||
overscroll-behavior: contain;
|
||||
|
|
@ -557,6 +612,8 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
|||
if (path) dispatchTree({ type: "navigate", ...navigation(path) })
|
||||
})
|
||||
|
||||
createEffect(on(committed, () => dispatchCombobox({ type: "synced" }), { defer: true }))
|
||||
|
||||
// Suggestions search against the root and location, so a search started before either arrived runs again.
|
||||
createEffect(
|
||||
on([() => location()?.directory, treeRoot], () => dispatchCombobox({ type: "context.changed" }), {
|
||||
|
|
@ -578,9 +635,10 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
|||
<DialogTitle>{props.title ?? language.t("command.project.open")}</DialogTitle>
|
||||
<Show when={subtitle()}>
|
||||
{(value) => (
|
||||
<div class="directory-picker-subtitle" dir="ltr">
|
||||
{value()}
|
||||
</div>
|
||||
<span class="directory-picker-server" dir="ltr">
|
||||
<Icon name="server" size="small" />
|
||||
<span class="truncate">{value()}</span>
|
||||
</span>
|
||||
)}
|
||||
</Show>
|
||||
</div>
|
||||
|
|
@ -597,6 +655,9 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
|||
showClearButton={!!comboboxView().input}
|
||||
onClearClick={() => dispatchCombobox({ type: "cleared" })}
|
||||
class="directory-picker-input"
|
||||
data-owns-escape={ownsPickerEscape(machines().combobox, committed()) ? "" : undefined}
|
||||
appearance="large"
|
||||
leadingIcon={<Icon name="magnifying-glass" size="small" />}
|
||||
onInput={(event) => dispatchCombobox({ type: "input.changed", value: event.currentTarget.value })}
|
||||
role="combobox"
|
||||
aria-label={language.t("dialog.directory.search.placeholder")}
|
||||
|
|
@ -605,6 +666,19 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
|||
aria-controls="directory-picker-suggestions"
|
||||
aria-activedescendant={comboboxView().activeDescendant}
|
||||
onKeyDown={(event) => {
|
||||
// Goes up a level from the shown selection; a held key that just cleared the text must not keep climbing.
|
||||
if (
|
||||
event.key === "Backspace" &&
|
||||
!event.repeat &&
|
||||
!event.isComposing &&
|
||||
atSelection(event.currentTarget)
|
||||
) {
|
||||
event.preventDefault()
|
||||
const selected = treeView().selected
|
||||
|
||||
return selected ? choose(pickerParent(selected)) : navigate(pickerParent(treeView().root))
|
||||
}
|
||||
|
||||
const next = dispatchCombobox({
|
||||
type: "key.down",
|
||||
key: event.key,
|
||||
|
|
@ -617,118 +691,162 @@ export function DirectoryPickerDialog(props: DirectoryPickerDialogProps) {
|
|||
if (next.stopPropagation) event.stopPropagation()
|
||||
}}
|
||||
/>
|
||||
<div class="directory-picker-actions">
|
||||
<Button size="normal" variant="ghost" onClick={() => navigate(home() || treeView().root)}>
|
||||
~
|
||||
</Button>
|
||||
<Button
|
||||
size="normal"
|
||||
variant="ghost"
|
||||
onClick={() => navigate(pickerRoot(treeView().root) || treeView().root)}
|
||||
>
|
||||
{language.t("dialog.directory.root")}
|
||||
</Button>
|
||||
<Button
|
||||
size="normal"
|
||||
variant="ghost"
|
||||
onClick={() => navigate(pickerParent(treeView().selected || treeView().root))}
|
||||
>
|
||||
{language.t("dialog.directory.parent")}
|
||||
</Button>
|
||||
</div>
|
||||
<Show when={comboboxView().listboxOpen}>
|
||||
<div id="directory-picker-suggestions" role="listbox" class="directory-picker-suggestions">
|
||||
<For each={comboboxView().items}>
|
||||
{(suggestion, index) => (
|
||||
<button
|
||||
id={`directory-picker-suggestion-${index()}`}
|
||||
data-directory-path={suggestion.absolute}
|
||||
role="option"
|
||||
aria-selected={index() === comboboxView().active}
|
||||
data-active={index() === comboboxView().active ? "" : undefined}
|
||||
onPointerMove={() => dispatchCombobox({ type: "item.hovered", index: index() })}
|
||||
onClick={() => dispatchCombobox({ type: "item.clicked", index: index() })}
|
||||
>
|
||||
{displayPickerPath(suggestion.absolute, comboboxView().input, home())}
|
||||
{suggestion.type === "directory" ? "/" : ""}
|
||||
</button>
|
||||
)}
|
||||
</For>
|
||||
<div data-component="menu-v2-content" class="directory-picker-suggestions">
|
||||
<MenuScroll viewportClass="directory-picker-suggestions-viewport">
|
||||
<div id="directory-picker-suggestions" role="listbox">
|
||||
<For each={comboboxView().items}>
|
||||
{(suggestion, index) => (
|
||||
<div
|
||||
id={`directory-picker-suggestion-${index()}`}
|
||||
data-component="menu-v2-item"
|
||||
data-directory-path={suggestion.absolute}
|
||||
role="option"
|
||||
aria-selected={index() === comboboxView().active}
|
||||
data-highlighted={index() === comboboxView().active ? "" : undefined}
|
||||
onPointerMove={() => dispatchCombobox({ type: "item.hovered", index: index() })}
|
||||
onClick={() => dispatchCombobox({ type: "item.clicked", index: index() })}
|
||||
>
|
||||
<span data-slot="menu-v2-item-content">
|
||||
<Icon name={suggestion.type === "directory" ? "folder" : "open-file"} size="small" />
|
||||
<span class="directory-picker-item-name">
|
||||
{pickerBreadcrumbs(suggestion.absolute, home()).at(-1)?.label}
|
||||
</span>
|
||||
<bdi dir="ltr" class="directory-picker-item-path">
|
||||
{shortenPickerRecentPath(pickerParent(suggestion.absolute), home())}
|
||||
</bdi>
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</For>
|
||||
</div>
|
||||
</MenuScroll>
|
||||
</div>
|
||||
</Show>
|
||||
</div>
|
||||
<Show when={recentProjects().length > 0}>
|
||||
<div class="directory-picker-recent">
|
||||
<div class="directory-picker-recent-label">{language.t("dialog.directory.recent")}</div>
|
||||
<div class="directory-picker-recent-list">
|
||||
<For each={recentProjects()}>
|
||||
{(project) => {
|
||||
const name = () => displayName(project)
|
||||
const fullPath = () => displayPickerPath(project.worktree, "", home())
|
||||
const shortPath = () => shortenPickerRecentPath(project.worktree, home())
|
||||
<div class="directory-picker-recent" aria-label={language.t("dialog.directory.recent")} role="group">
|
||||
<For each={recentProjects().slice(0, 3)}>
|
||||
{(project) => {
|
||||
const name = () => displayName(project)
|
||||
const shortPath = () => shortenPickerRecentPath(project.worktree, home())
|
||||
|
||||
return (
|
||||
<Tooltip placement="top" value={<bdi dir="ltr">{fullPath()}</bdi>}>
|
||||
<Button
|
||||
size="normal"
|
||||
variant="neutral"
|
||||
class="directory-picker-recent-item"
|
||||
aria-label={language.t("dialog.directory.recentProject", {
|
||||
name: name(),
|
||||
path: shortPath(),
|
||||
})}
|
||||
onClick={() => {
|
||||
dispatchCombobox({ type: "dismissed" })
|
||||
dispatchTree({ type: "directory.chosen", ...navigation(project.worktree), fromInput: false })
|
||||
}}
|
||||
>
|
||||
<ProjectAvatar
|
||||
class="shrink-0"
|
||||
aria-hidden="true"
|
||||
fallback={name()}
|
||||
src={getProjectAvatarSource(project.id, project.icon)}
|
||||
variant={getProjectAvatarVariant(project.icon?.color)}
|
||||
/>
|
||||
<span class="min-w-0 truncate">{name()}</span>
|
||||
</Button>
|
||||
</Tooltip>
|
||||
)
|
||||
}}
|
||||
</For>
|
||||
</div>
|
||||
return (
|
||||
<Tooltip
|
||||
placement="top"
|
||||
value={<bdi dir="ltr">{displayPickerPath(project.worktree, "", home())}</bdi>}
|
||||
>
|
||||
<Button
|
||||
size="small"
|
||||
variant="neutral"
|
||||
class="directory-picker-recent-item"
|
||||
aria-label={language.t("dialog.directory.recentProject", { name: name(), path: shortPath() })}
|
||||
onClick={() => choose(project.worktree)}
|
||||
>
|
||||
<ProjectAvatar
|
||||
class="shrink-0"
|
||||
aria-hidden="true"
|
||||
fallback={name()}
|
||||
src={getProjectAvatarSource(project.id, project.icon)}
|
||||
variant={getProjectAvatarVariant(project.icon?.color)}
|
||||
generated={getProjectAvatarGenerated(project)}
|
||||
/>
|
||||
<span class="min-w-0 truncate">{name()}</span>
|
||||
</Button>
|
||||
</Tooltip>
|
||||
)
|
||||
}}
|
||||
</For>
|
||||
<Show when={recentProjects().length > 3}>
|
||||
<Menu gutter={4} modal={false} placement="bottom-start">
|
||||
<Menu.Trigger as={Button} size="small" variant="neutral">
|
||||
{language.t("dialog.directory.moreProjects")}
|
||||
</Menu.Trigger>
|
||||
<Menu.Portal>
|
||||
<Menu.Content class="directory-picker-recent-menu">
|
||||
<For each={recentProjects().slice(3)}>
|
||||
{(project) => {
|
||||
const name = () => displayName(project)
|
||||
const shortPath = () => shortenPickerRecentPath(project.worktree, home())
|
||||
|
||||
return (
|
||||
<Menu.Item
|
||||
aria-label={language.t("dialog.directory.recentProject", {
|
||||
name: name(),
|
||||
path: shortPath(),
|
||||
})}
|
||||
onSelect={() => choose(project.worktree)}
|
||||
>
|
||||
<ProjectAvatar
|
||||
class="shrink-0"
|
||||
aria-hidden="true"
|
||||
fallback={name()}
|
||||
src={getProjectAvatarSource(project.id, project.icon)}
|
||||
variant={getProjectAvatarVariant(project.icon?.color)}
|
||||
generated={getProjectAvatarGenerated(project)}
|
||||
/>
|
||||
<span class="directory-picker-item-name">{name()}</span>
|
||||
<bdi dir="ltr" class="directory-picker-item-path">
|
||||
{shortPath()}
|
||||
</bdi>
|
||||
</Menu.Item>
|
||||
)
|
||||
}}
|
||||
</For>
|
||||
</Menu.Content>
|
||||
</Menu.Portal>
|
||||
</Menu>
|
||||
</Show>
|
||||
</div>
|
||||
</Show>
|
||||
<div
|
||||
class="directory-picker-browser"
|
||||
ref={container}
|
||||
// The modal's scroll lock sees only the shadow host, not the tree's inner scroller. Stopping the event here
|
||||
// keeps the lock from cancelling it, and the passive listener leaves the scroller to the compositor.
|
||||
on:touchmove={(event) => event.stopPropagation()}
|
||||
on:wheel={{ handleEvent: (event: WheelEvent) => event.stopPropagation(), passive: true }}
|
||||
>
|
||||
<Show when={treeView().loading}>
|
||||
<div class="directory-picker-state">{language.t("common.loading")}</div>
|
||||
</Show>
|
||||
<Show when={treeView().error}>
|
||||
<div class="directory-picker-state">{language.t("dialog.directory.readError")}</div>
|
||||
</Show>
|
||||
<div class="directory-picker-folder">
|
||||
<div class="directory-picker-folder-header">
|
||||
<nav class="directory-picker-breadcrumbs" aria-label={language.t("dialog.directory.breadcrumbs")} dir="ltr">
|
||||
<For each={breadcrumbs()}>
|
||||
{(crumb, index) => (
|
||||
<>
|
||||
<Show when={index() > 0}>
|
||||
<Icon name="chevron-right" size="small" class="directory-picker-breadcrumb-separator" />
|
||||
</Show>
|
||||
<button
|
||||
type="button"
|
||||
class="directory-picker-breadcrumb"
|
||||
aria-current={index() === breadcrumbs().length - 1 ? "location" : undefined}
|
||||
onClick={() => navigate(crumb.path)}
|
||||
>
|
||||
{crumb.label}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</For>
|
||||
</nav>
|
||||
</div>
|
||||
<div
|
||||
class="directory-picker-browser"
|
||||
ref={container}
|
||||
// The modal's scroll lock sees only the shadow host, not the tree's inner scroller. Stopping the event here
|
||||
// keeps the lock from cancelling it, and the passive listener leaves the scroller to the compositor.
|
||||
on:touchmove={(event) => event.stopPropagation()}
|
||||
on:wheel={{ handleEvent: (event: WheelEvent) => event.stopPropagation(), passive: true }}
|
||||
>
|
||||
<Show when={treeView().loading}>
|
||||
<div class="directory-picker-state">{language.t("common.loading")}</div>
|
||||
</Show>
|
||||
<Show when={treeView().error}>
|
||||
<div class="directory-picker-state">{language.t("dialog.directory.readError")}</div>
|
||||
</Show>
|
||||
</div>
|
||||
</div>
|
||||
</DialogBody>
|
||||
<DialogFooter>
|
||||
<Tooltip
|
||||
placement="top"
|
||||
disabled={!fullSelectionPath() || fullSelectionPath() === shortSelectionPath()}
|
||||
value={<bdi dir="ltr">{fullSelectionPath()}</bdi>}
|
||||
class="directory-picker-selection"
|
||||
>
|
||||
<span dir="ltr" class="directory-picker-selection-text">
|
||||
{shortSelectionPath()}
|
||||
</span>
|
||||
</Tooltip>
|
||||
<Button variant="neutral" onClick={() => dialog.close()}>
|
||||
{language.t("common.cancel")}
|
||||
</Button>
|
||||
<Button variant="contrast" disabled={!treeView().result} onClick={resolve}>
|
||||
<Button
|
||||
variant="contrast"
|
||||
disabled={!treeView().result && !comboboxView().input}
|
||||
onClick={() => dispatchCombobox({ type: "submitted" })}
|
||||
>
|
||||
{action[policy.action]}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import {
|
|||
listPickerDirectory,
|
||||
displayPickerPath,
|
||||
shortenPickerRecentPath,
|
||||
pickerBreadcrumbs,
|
||||
pickerParent,
|
||||
pickerRoot,
|
||||
pickerAbsoluteInput,
|
||||
|
|
@ -145,6 +146,41 @@ test.each([
|
|||
expect(actual).toBe(expected)
|
||||
})
|
||||
|
||||
test.each([
|
||||
[
|
||||
"a folder under home",
|
||||
pickerBreadcrumbs("/home/luke/projects/acme", "/home/luke"),
|
||||
[
|
||||
{ label: "/", path: "/" },
|
||||
{ label: "~", path: "/home/luke" },
|
||||
{ label: "projects", path: "/home/luke/projects" },
|
||||
{ label: "acme", path: "/home/luke/projects/acme" },
|
||||
],
|
||||
],
|
||||
[
|
||||
"a folder outside home",
|
||||
pickerBreadcrumbs("/srv/infra/", "/home/luke"),
|
||||
[
|
||||
{ label: "/", path: "/" },
|
||||
{ label: "srv", path: "/srv" },
|
||||
{ label: "infra", path: "/srv/infra" },
|
||||
],
|
||||
],
|
||||
["the root", pickerBreadcrumbs("/", "/home/luke"), [{ label: "/", path: "/" }]],
|
||||
[
|
||||
"a Windows drive",
|
||||
pickerBreadcrumbs("C:/Users/luke/repo", "C:/Users/luke"),
|
||||
[
|
||||
{ label: "C:", path: "C:/" },
|
||||
{ label: "Users", path: "C:/Users" },
|
||||
{ label: "luke", path: "C:/Users/luke" },
|
||||
{ label: "repo", path: "C:/Users/luke/repo" },
|
||||
],
|
||||
],
|
||||
])("breadcrumbs for %s open each ancestor", (_name, actual, expected) => {
|
||||
expect(actual).toEqual(expected)
|
||||
})
|
||||
|
||||
test("resolves directory autocomplete from the browser root without changing location", async () => {
|
||||
const calls: unknown[] = []
|
||||
const location = { directory: "/repo", workspace: "workspace_1" }
|
||||
|
|
|
|||
|
|
@ -401,6 +401,24 @@ export function shortenPickerRecentPath(path: string, home: string) {
|
|||
return display
|
||||
}
|
||||
|
||||
// The folders from the root down to `path`, with home shown as `~`.
|
||||
export function pickerBreadcrumbs(path: string, home: string) {
|
||||
const value = trimPickerPath(path)
|
||||
const root = pickerRoot(value)
|
||||
|
||||
if (!root) return []
|
||||
const tilde = pickerTilde(value, home)
|
||||
const base = tilde ? trimPickerPath(home) : root
|
||||
const names = value.slice(base.length).split("/").filter(Boolean)
|
||||
const first = [{ label: root === "/" ? "/" : trimPickerPath(root).replace(/\/$/, ""), path: root }]
|
||||
|
||||
return [
|
||||
...first,
|
||||
...(tilde && base !== root ? [{ label: "~", path: base }] : []),
|
||||
...names.map((label, index) => ({ label, path: joinPickerPath(base, names.slice(0, index + 1).join("/")) })),
|
||||
]
|
||||
}
|
||||
|
||||
export async function listPickerDirectory(
|
||||
sdk: ServerSDK,
|
||||
location: { directory: string; workspace?: string },
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ test("a newer choice wins over a reveal still waiting on its ancestors", () => {
|
|||
for (const newer of [
|
||||
choose(`${HOME}/fast-repo`),
|
||||
{ type: "tree.selected", path: "fast-repo/" } as const,
|
||||
{ type: "selection.cleared" } as const,
|
||||
{ type: "tree.selected", path: undefined } as const,
|
||||
]) {
|
||||
const chosen = run([newer], revealing.state)
|
||||
const settled = run([{ type: "dir.loaded", dir: "work", attempt: 2, nodes: [folder("slow")] }], chosen.state)
|
||||
|
|
@ -254,3 +254,40 @@ test("disposing drops queued work and ignores later results", () => {
|
|||
expect(disposed.effects).toEqual([{ type: "queue.reset" }])
|
||||
expect(run([{ type: "dir.loaded", dir: "", attempt: 1, nodes: [] }], disposed.state).state).toBe(disposed.state)
|
||||
})
|
||||
|
||||
test("a confirmed choice submits once it is selected, and never when it fails or a newer choice wins", () => {
|
||||
const state = ready(HOME, [folder("work")])
|
||||
|
||||
const submit = (path: string): PickerTreeEvent => ({
|
||||
type: "directory.chosen",
|
||||
path,
|
||||
home: HOME,
|
||||
fallback: HOME,
|
||||
located: true,
|
||||
fromInput: true,
|
||||
submit: true,
|
||||
})
|
||||
|
||||
const inside = run([submit(`${HOME}/work/repo`)], state)
|
||||
const listed = run([{ type: "dir.loaded", dir: "work", attempt: 2, nodes: [folder("repo")] }], inside.state)
|
||||
const outside = run([submit("/srv/infra")], state)
|
||||
const root = outside.state.status === "loading" ? outside.state.attempt : -1
|
||||
const opened = run([{ type: "dir.loaded", dir: "", attempt: root, nodes: [] }], outside.state)
|
||||
const failed = run([{ type: "dir.failed", dir: "", attempt: root }], outside.state)
|
||||
|
||||
const superseded = run(
|
||||
[
|
||||
{ type: "tree.selected", path: undefined },
|
||||
{ type: "dir.loaded", dir: "work", attempt: 2, nodes: [folder("repo")] },
|
||||
],
|
||||
inside.state,
|
||||
)
|
||||
|
||||
expect(inside.effects).not.toContainEqual({ type: "submit" })
|
||||
expect(listed.effects).toContainEqual({ type: "submit" })
|
||||
expect(pickerTreeView(listed.state, policy).result).toBe(`${HOME}/work/repo`)
|
||||
expect(opened.effects.at(-1)).toEqual({ type: "submit" })
|
||||
expect(pickerTreeView(opened.state, policy).result).toBe("/srv/infra")
|
||||
expect(failed.effects).not.toContainEqual({ type: "submit" })
|
||||
expect(superseded.effects).not.toContainEqual({ type: "submit" })
|
||||
})
|
||||
|
|
|
|||
|
|
@ -18,16 +18,20 @@ export type PickerDirState =
|
|||
| { readonly status: "ready" }
|
||||
| { readonly status: "failed" }
|
||||
|
||||
/** A chosen folder inside the root. Its ancestors list and expand in order from `index`, then it is selected. */
|
||||
/**
|
||||
* A chosen folder inside the root. Its ancestors list and expand in order from `index`, then it is selected, and
|
||||
* `submit` confirms it once selected.
|
||||
*/
|
||||
export type PickerReveal = {
|
||||
readonly target: string
|
||||
readonly relative: string
|
||||
readonly index: number
|
||||
readonly fromInput: boolean
|
||||
readonly submit: boolean
|
||||
}
|
||||
|
||||
/** The root to open, and the child of it to select once it lists. */
|
||||
export type PickerTarget = { readonly root: string; readonly selectChild?: string }
|
||||
/** The root to open, the child of it to select once it lists, and whether to confirm it then. */
|
||||
export type PickerTarget = { readonly root: string; readonly selectChild?: string; readonly submit?: boolean }
|
||||
|
||||
/**
|
||||
* The folder browser. `issued` numbers every location and listing request, so a result for an earlier root, reveal or
|
||||
|
|
@ -49,6 +53,7 @@ export type PickerTreeState =
|
|||
readonly attempt: number
|
||||
readonly root: string
|
||||
readonly selectChild?: string
|
||||
readonly submit?: boolean
|
||||
readonly locationDirectory?: string
|
||||
}
|
||||
| {
|
||||
|
|
@ -79,9 +84,8 @@ export type PickerTreeEvent =
|
|||
| { readonly type: "location.failed"; readonly attempt: number }
|
||||
| { readonly type: "location.timed-out"; readonly attempt: number }
|
||||
| ({ readonly type: "navigate" } & PickerNavigation)
|
||||
| ({ readonly type: "directory.chosen"; readonly fromInput: boolean } & PickerNavigation)
|
||||
| ({ readonly type: "directory.chosen"; readonly fromInput: boolean; readonly submit?: boolean } & PickerNavigation)
|
||||
| { readonly type: "file.chosen"; readonly absolute: string; readonly home: string }
|
||||
| { readonly type: "selection.cleared" }
|
||||
| { readonly type: "tree.selected"; readonly path: string | undefined }
|
||||
| { readonly type: "dir.expanded"; readonly dir: string }
|
||||
| {
|
||||
|
|
@ -113,6 +117,7 @@ export type PickerTreeEffect =
|
|||
| { readonly type: "tree.clear-selection" }
|
||||
| { readonly type: "tree.focus-initial" }
|
||||
| { readonly type: "tree.refresh-decorations" }
|
||||
| { readonly type: "submit" }
|
||||
|
||||
export type PickerTreeTransition = { readonly state: PickerTreeState; readonly effects: readonly PickerTreeEffect[] }
|
||||
|
||||
|
|
@ -172,8 +177,6 @@ export function transitionPickerTree(
|
|||
return select(state, event.path ? (policy.selection(state.root, event.path) ?? "") : "")
|
||||
}
|
||||
|
||||
if (event.type === "selection.cleared") return select(state, "")
|
||||
|
||||
return select(
|
||||
state,
|
||||
policy.selection(state.root, pickerFileSearchQuery(state.root, event.absolute, event.home)) ?? "",
|
||||
|
|
@ -225,12 +228,18 @@ function choose(
|
|||
const relative = pickerRelativePath(state.root, value)
|
||||
|
||||
if (relative === "") {
|
||||
return { state: { ...state, selected: "", reveal: undefined }, effects: [{ type: "tree.clear-selection" }] }
|
||||
return {
|
||||
state: { ...state, selected: "", reveal: undefined },
|
||||
effects: [{ type: "tree.clear-selection" }, ...submitted(event.submit)],
|
||||
}
|
||||
}
|
||||
|
||||
if (relative) {
|
||||
return advanceReveal(
|
||||
{ ...state, reveal: { target: value, relative, index: 0, fromInput: event.fromInput } },
|
||||
{
|
||||
...state,
|
||||
reveal: { target: value, relative, index: 0, fromInput: event.fromInput, submit: event.submit ?? false },
|
||||
},
|
||||
[],
|
||||
policy,
|
||||
)
|
||||
|
|
@ -240,10 +249,10 @@ function choose(
|
|||
const parent = pickerParent(value)
|
||||
|
||||
if (parent && getFilename(value) && parent !== value && parent === event.home) {
|
||||
return open(state, { root: parent, selectChild: value }, event.located)
|
||||
return open(state, { root: parent, selectChild: value, submit: event.submit }, event.located)
|
||||
}
|
||||
|
||||
return open(state, { root: value }, event.located)
|
||||
return open(state, { root: value, submit: event.submit }, event.located)
|
||||
}
|
||||
|
||||
// A new root drops every listing, queued preload and reveal of the previous one.
|
||||
|
|
@ -268,6 +277,7 @@ function open(state: LiveTree, next: PickerTarget, located: boolean): PickerTree
|
|||
attempt,
|
||||
root: next.root,
|
||||
selectChild: next.selectChild,
|
||||
submit: next.submit,
|
||||
locationDirectory: state.locationDirectory,
|
||||
},
|
||||
effects: [{ type: "queue.reset" }, { type: "tree.reset" }, list(next.root, "", attempt, "user")],
|
||||
|
|
@ -358,6 +368,7 @@ function openRoot(
|
|||
...listed.effects,
|
||||
entry ? { type: "tree.select", entry } : { type: "tree.focus-initial" },
|
||||
...children.map((name, index) => list(state.root, name, state.issued + index + 1, "background")),
|
||||
...submitted(state.submit),
|
||||
],
|
||||
}
|
||||
}
|
||||
|
|
@ -420,9 +431,12 @@ function finishReveal(
|
|||
): PickerTreeTransition {
|
||||
const entry = `${reveal.relative}/`
|
||||
|
||||
if (!state.entries[entry]) return open({ ...state, reveal: undefined }, { root: reveal.target }, true)
|
||||
if (!state.entries[entry]) {
|
||||
return open({ ...state, reveal: undefined }, { root: reveal.target, submit: reveal.submit }, true)
|
||||
}
|
||||
|
||||
const selected = { ...state, reveal: undefined, selected: policy.selection(state.root, entry) ?? "" }
|
||||
const selecting = [...effects, { type: "tree.select" as const, entry }]
|
||||
const selecting = [...effects, { type: "tree.select" as const, entry }, ...submitted(reveal.submit)]
|
||||
|
||||
if (!reveal.fromInput) return { state: selected, effects: selecting }
|
||||
|
||||
|
|
@ -483,6 +497,10 @@ function list(root: string, dir: string, attempt: number, priority: "user" | "ba
|
|||
return { type: "list", root, dir, attempt, priority, timeoutMs: PICKER_LOAD_TIMEOUT_MS }
|
||||
}
|
||||
|
||||
function submitted(submit: boolean | undefined): PickerTreeEffect[] {
|
||||
return submit ? [{ type: "submit" }] : []
|
||||
}
|
||||
|
||||
function unchanged(state: PickerTreeState): PickerTreeTransition {
|
||||
return { state, effects: [] }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ export type TurnState = {
|
|||
readonly compactions: ACPCompaction.Tracked
|
||||
readonly children: ReadonlyMap<string, Child>
|
||||
readonly openChildren: ReadonlySet<string>
|
||||
/** Background shells that will wake their session, with the inbox ID of their notice once it is queued. */
|
||||
readonly shells: ReadonlyMap<string, string | undefined>
|
||||
readonly asks: ReadonlySet<string>
|
||||
readonly finish?: SessionMessage.Assistant["finish"]
|
||||
readonly usage?: { readonly turn: TokenUsage.Info; readonly last: TokenUsage.Info }
|
||||
|
|
@ -89,6 +91,7 @@ export const initial: TurnState = {
|
|||
compactions: new Map(),
|
||||
children: new Map(),
|
||||
openChildren: new Set(),
|
||||
shells: new Map(),
|
||||
asks: new Set(),
|
||||
}
|
||||
|
||||
|
|
@ -126,16 +129,24 @@ export function fold(state: TurnState, event: OpenCodeEvent, ctx: TurnContext):
|
|||
return { state: { ...state, asks }, outputs: [{ _tag: "AskSettled", id: settledID }] }
|
||||
}
|
||||
if (!sessionID || (sessionID !== ctx.sessionID && !child)) return { state, outputs: [] }
|
||||
if (
|
||||
sessionID === ctx.sessionID &&
|
||||
event.type === "session.inbox.delivered" &&
|
||||
(!ctx.start || event.data.inboxID === ctx.start.id)
|
||||
)
|
||||
return { state: { ...state, started: true }, outputs: [] }
|
||||
if (event.type === "session.inbox.enqueued") return { state: shellNoticed(state, event), outputs: [] }
|
||||
if (event.type === "session.inbox.delivered" || event.type === "session.inbox.cancelled") {
|
||||
const settled = noticeSettled(state, event.data.inboxID)
|
||||
const started =
|
||||
sessionID === ctx.sessionID &&
|
||||
event.type === "session.inbox.delivered" &&
|
||||
(!ctx.start || event.data.inboxID === ctx.start.id)
|
||||
return { state: started ? { ...settled, started: true } : settled, outputs: [] }
|
||||
}
|
||||
if (!child && !state.started) return { state, outputs: [] }
|
||||
return child ? childEvent(state, event, ctx, child) : rootEvent(state, event, ctx)
|
||||
}
|
||||
|
||||
/** Whether work that outlives the turn, such as a background child or shell, can still wake the session. */
|
||||
export function pending(state: TurnState) {
|
||||
return state.openChildren.size > 0 || state.shells.size > 0
|
||||
}
|
||||
|
||||
export function projectChild(ctx: TurnContext, child: Child) {
|
||||
return !ctx.childUpdates && ctx.start !== undefined && child.turnID === ctx.start.id
|
||||
}
|
||||
|
|
@ -383,8 +394,17 @@ function sessionEvent(state: TurnState, event: OpenCodeEvent, ctx: TurnContext,
|
|||
case "session.tool.success": {
|
||||
const key = toolKey(event.data.sessionID, event.data.id)
|
||||
const tool = state.tools.get(key) ?? newTool(event.data.sessionID, event.data.id)
|
||||
// A shell moved to the background reports its end through a notice that wakes the session.
|
||||
const shellID = event.data.metadata?.status === "running" ? event.data.metadata.shellID : undefined
|
||||
return {
|
||||
state: { ...state, tools: without(state.tools, key) },
|
||||
state: {
|
||||
...state,
|
||||
tools: without(state.tools, key),
|
||||
// A command that exits at once can queue its notice first; keep the notice it already has.
|
||||
...(typeof shellID === "string" && !state.shells.has(shellID)
|
||||
? { shells: new Map(state.shells).set(shellID, undefined) }
|
||||
: {}),
|
||||
},
|
||||
outputs: send({
|
||||
sessionUpdate: "tool_call_update",
|
||||
...completedToolUpdate({
|
||||
|
|
@ -447,6 +467,19 @@ function childEnded(state: TurnState, ctx: TurnContext, child: ACPChild.Session,
|
|||
return { state: { ...state, openChildren }, outputs: childStatus(ctx, child, status) }
|
||||
}
|
||||
|
||||
// A background shell's notice wakes the session once delivered, so the shell stays pending until then. Only a job's
|
||||
// notice wakes it: a user's shell command queues one without a job ID that waits for the next prompt.
|
||||
function shellNoticed(state: TurnState, event: Extract<OpenCodeEvent, { type: "session.inbox.enqueued" }>) {
|
||||
const metadata = event.data.item.type === "synthetic" ? event.data.item.payload.metadata : undefined
|
||||
if (typeof metadata?.shellID !== "string" || typeof metadata.jobID !== "string") return state
|
||||
return { ...state, shells: new Map(state.shells).set(metadata.shellID, event.data.inboxID) }
|
||||
}
|
||||
|
||||
function noticeSettled(state: TurnState, inboxID: string) {
|
||||
const shells = new Map([...state.shells].filter(([, notice]) => notice !== inboxID))
|
||||
return shells.size === state.shells.size ? state : { ...state, shells }
|
||||
}
|
||||
|
||||
function recordStep(state: TurnState, tokens: TokenUsage.Info): TurnState {
|
||||
const turn = state.usage?.turn
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ export const make = Effect.fnUntraced(function* (input: {
|
|||
...ACPTranslate.initial,
|
||||
children: inherited.children,
|
||||
openChildren: inherited.openChildren,
|
||||
shells: inherited.shells,
|
||||
})
|
||||
}
|
||||
// Parented to the service scope; the session scope may already be closed.
|
||||
|
|
@ -239,10 +240,10 @@ export const make = Effect.fnUntraced(function* (input: {
|
|||
}
|
||||
})
|
||||
|
||||
const followChildren = Effect.fnUntraced(function* (turn: Turn) {
|
||||
const followBackground = Effect.fnUntraced(function* (turn: Turn) {
|
||||
while (true) {
|
||||
const folded = yield* advance(turn)
|
||||
if (folded.terminal && folded.state.openChildren.size === 0) return yield* asksSettled(turn.subscription)
|
||||
if (folded.terminal && !ACPTranslate.pending(folded.state)) return yield* asksSettled(turn.subscription)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -328,19 +329,19 @@ export const make = Effect.fnUntraced(function* (input: {
|
|||
const close = Scope.close(turn.subscription.scope, Exit.void)
|
||||
if (Exit.isFailure(exit) && !Cause.hasInterruptsOnly(exit.cause)) return yield* close
|
||||
const state = yield* Ref.get(turn.state)
|
||||
if (state.openChildren.size === 0) {
|
||||
if (!ACPTranslate.pending(state)) {
|
||||
if (state.children.size > 0) backgrounds.set(attached, { state: turn.state })
|
||||
return yield* close
|
||||
}
|
||||
const responded = yield* ACPConnection.Responded
|
||||
const nextState = yield* Ref.make({ ...state, started: false })
|
||||
const cancelled = yield* Deferred.make<void>()
|
||||
// Children outlive a cancelled turn, so their asks and report-triggered turns still reach the client.
|
||||
// Children and background shells outlive a cancelled turn, so their asks and the turns they wake reach the client.
|
||||
const background = Effect.withFiber((fiber) => {
|
||||
backgrounds.set(attached, { state: nextState, fiber })
|
||||
return Effect.exit(responded).pipe(
|
||||
Effect.andThen(
|
||||
followChildren({ ...turn, ctx: { ...turn.ctx, start: undefined }, state: nextState, cancelled }),
|
||||
followBackground({ ...turn, ctx: { ...turn.ctx, start: undefined }, state: nextState, cancelled }),
|
||||
),
|
||||
Effect.interruptible,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,75 @@
|
|||
import type { PromptResponse } from "@agentclientprotocol/sdk"
|
||||
import { expect, test } from "bun:test"
|
||||
import { Schema } from "effect"
|
||||
import path from "node:path"
|
||||
import { createAcpFixture, expectOk, initialize, newSession, toolCallStream } from "./subprocess"
|
||||
|
||||
const modelRequest = Schema.decodeUnknownSync(Schema.Struct({ messages: Schema.Array(Schema.Unknown) }))
|
||||
const sessionUpdate = Schema.decodeUnknownSync(Schema.Struct({ update: Schema.Record(Schema.String, Schema.Unknown) }))
|
||||
|
||||
const windows = process.platform === "win32"
|
||||
// Runs until the test creates `release` in the session directory, so the command ends after end_turn.
|
||||
const releasedCommand = windows
|
||||
? "while (!(Test-Path release)) { Start-Sleep -Milliseconds 50 }; 'slow shell done'"
|
||||
: "while [ ! -f release ]; do sleep 0.05; done; echo slow shell done"
|
||||
// Exits at once, so its notice can arrive before the call's result or within the turn that started it.
|
||||
const fastCommand = windows ? "'fast shell done'" : "echo fast shell done"
|
||||
|
||||
test("streams turns woken by background shells and keeps the session usable", async () => {
|
||||
const woken = Promise.withResolvers<void>()
|
||||
await using fixture = await createAcpFixture({
|
||||
respond(request) {
|
||||
const last = JSON.stringify(modelRequest(request).messages.at(-1))
|
||||
if (last.includes("<shell") && last.includes("slow shell done")) {
|
||||
woken.resolve()
|
||||
return "slow shell reaction"
|
||||
}
|
||||
if (last.includes("<shell") && last.includes("fast shell done")) return "fast shell reaction"
|
||||
if (last.includes("run the slow shell"))
|
||||
return toolCallStream("call_slow", "shell", { command: releasedCommand, description: "Slow", background: true })
|
||||
if (last.includes("run the fast shell"))
|
||||
return toolCallStream("call_fast", "shell", { command: fastCommand, description: "Fast", background: true })
|
||||
if (last.includes("follow up")) return "follow-up reply"
|
||||
return "launched"
|
||||
},
|
||||
})
|
||||
const acp = fixture.spawn()
|
||||
await initialize(acp)
|
||||
const { sessionId } = await newSession(acp, fixture.home)
|
||||
const prompt = (text: string) =>
|
||||
acp.request<PromptResponse>("session/prompt", { sessionId, prompt: [{ type: "text", text }] }).then(expectOk)
|
||||
const update = (description: string, match: (update: Record<string, unknown>) => boolean) =>
|
||||
acp
|
||||
.waitForMessage(
|
||||
(message) => message.method === "session/update" && match(sessionUpdate(message.params).update),
|
||||
description,
|
||||
)
|
||||
.then((message) => sessionUpdate(message.params).update)
|
||||
const chunk = (text: string) =>
|
||||
update(
|
||||
`the "${text}" agent_message_chunk`,
|
||||
(item) => item.sessionUpdate === "agent_message_chunk" && JSON.stringify(item).includes(text),
|
||||
)
|
||||
|
||||
// The prompt ends while its shell still runs; the shell's notice later wakes a turn the client is shown.
|
||||
expect((await prompt("run the slow shell")).stopReason).toBe("end_turn")
|
||||
const launched = await chunk("launched")
|
||||
await update(
|
||||
"the slow shell's completed call",
|
||||
(item) => item.toolCallId === "call_slow" && item.status === "completed",
|
||||
)
|
||||
await Bun.write(path.join(fixture.home, "release"), "")
|
||||
await woken.promise
|
||||
const reaction = await chunk("slow shell reaction")
|
||||
expect(reaction.messageId).not.toBe(launched.messageId)
|
||||
|
||||
// A shell that is done before its turn is: its reaction streams whether it lands in that turn or wakes another.
|
||||
expect((await prompt("run the fast shell")).stopReason).toBe("end_turn")
|
||||
await chunk("fast shell reaction")
|
||||
|
||||
expect((await prompt("follow up")).stopReason).toBe("end_turn")
|
||||
await chunk("follow-up reply")
|
||||
}, 60_000)
|
||||
|
||||
test("streams the parent's response to a subagent report after end_turn", async () => {
|
||||
const child = Promise.withResolvers<string>()
|
||||
|
|
|
|||
|
|
@ -8,12 +8,14 @@ import { ACPReplay } from "../../src/acp/replay"
|
|||
import { ACPTranslate } from "../../src/acp/translate"
|
||||
import {
|
||||
assistantMessage,
|
||||
backgroundShell,
|
||||
childCreated,
|
||||
delivered,
|
||||
durableEvent,
|
||||
ephemeralEvent,
|
||||
failed,
|
||||
reasoningDelta,
|
||||
shellNotice,
|
||||
stepEnded,
|
||||
succeeded,
|
||||
textDelta,
|
||||
|
|
@ -574,6 +576,59 @@ const rows: Row[] = [
|
|||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "keeps a background shell pending after its turn ends",
|
||||
events: live(...backgroundShell(root, "sh_bg"), succeeded(root)),
|
||||
expected: { terminal: "succeeded", pending: true },
|
||||
},
|
||||
{
|
||||
name: "keeps a background shell pending until its queued notice is delivered",
|
||||
events: live(...backgroundShell(root, "sh_bg"), shellNotice(root, "msg_notice", "sh_bg"), succeeded(root)),
|
||||
expected: { pending: true },
|
||||
},
|
||||
{
|
||||
name: "settles a background shell once its notice is delivered",
|
||||
events: live(
|
||||
...backgroundShell(root, "sh_bg"),
|
||||
shellNotice(root, "msg_notice", "sh_bg"),
|
||||
delivered(root, "msg_notice"),
|
||||
),
|
||||
expected: { pending: false },
|
||||
},
|
||||
{
|
||||
name: "settles a background shell whose notice is cancelled",
|
||||
events: live(
|
||||
...backgroundShell(root, "sh_bg"),
|
||||
shellNotice(root, "msg_notice", "sh_bg"),
|
||||
durableEvent("session.inbox.cancelled", { sessionID: root, inboxID: "msg_notice" }),
|
||||
),
|
||||
expected: { pending: false },
|
||||
},
|
||||
{
|
||||
name: "settles a shell that exits before its call's result arrives",
|
||||
events: live(
|
||||
shellNotice(root, "msg_notice", "sh_fast"),
|
||||
...backgroundShell(root, "sh_fast"),
|
||||
delivered(root, "msg_notice"),
|
||||
),
|
||||
expected: { pending: false },
|
||||
},
|
||||
{
|
||||
name: "leaves a user's shell command, whose notice waits for the next prompt, out of pending work",
|
||||
events: live(shellNotice(root, "msg_user_shell", "sh_user", { job: false }), succeeded(root)),
|
||||
expected: { pending: false },
|
||||
},
|
||||
{
|
||||
name: "keeps a finished child's background shell pending",
|
||||
events: live(
|
||||
childCreated("ses_child", root, "Explore"),
|
||||
durableEvent("session.execution.started", { sessionID: "ses_child" }),
|
||||
...backgroundShell("ses_child", "sh_child"),
|
||||
succeeded("ses_child"),
|
||||
succeeded(root),
|
||||
),
|
||||
expected: { terminal: "succeeded", pending: true },
|
||||
},
|
||||
{
|
||||
name: "replays reasoning with the same message IDs as live reasoning ordinals",
|
||||
messages: [
|
||||
|
|
@ -624,6 +679,7 @@ function translate(row: Row) {
|
|||
failure: ACPTranslate.failure(result.state)?._tag,
|
||||
context: result.state.usage?.last,
|
||||
abandoned: updates(ACPTranslate.abandon(result.state, context).outputs),
|
||||
pending: ACPTranslate.pending(result.state),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@ import { describe, expect, test } from "bun:test"
|
|||
import type { SessionNotification } from "@agentclientprotocol/sdk"
|
||||
import { ACPElicitation } from "../../src/acp/elicitation"
|
||||
import {
|
||||
backgroundShell,
|
||||
childCreated,
|
||||
delivered,
|
||||
durableEvent,
|
||||
ephemeralEvent,
|
||||
permissionAsked,
|
||||
shellNotice,
|
||||
startSession,
|
||||
succeeded,
|
||||
textDelta,
|
||||
|
|
@ -193,6 +195,40 @@ describe("acp turn events over the wire", () => {
|
|||
])
|
||||
})
|
||||
|
||||
test("streams resumed turns after background shells finish", async () => {
|
||||
await using acp = await startSession({
|
||||
onPrompt: ({ sessionID, id, text }) =>
|
||||
turn(
|
||||
sessionID,
|
||||
id,
|
||||
...backgroundShell(sessionID, `sh_${text}`),
|
||||
// The second shell finishes as its turn ends: the notice is queued in it but wakes the session afterwards.
|
||||
...(text === "second" ? [shellNotice(sessionID, "msg_notice_second", "sh_second")] : []),
|
||||
),
|
||||
})
|
||||
const sessionID = acp.sessionId
|
||||
|
||||
expect((await acp.prompt(sessionID, "first")).stopReason).toBe("end_turn")
|
||||
acp.server.send(
|
||||
shellNotice(sessionID, "msg_notice_first", "sh_first"),
|
||||
...turn(sessionID, "msg_notice_first", textDelta(sessionID, "msg_reaction_1", "first reaction")),
|
||||
)
|
||||
await acp.waitForUpdate(({ update }) => JSON.stringify(update).includes("first reaction"))
|
||||
|
||||
expect((await acp.prompt(sessionID, "second")).stopReason).toBe("end_turn")
|
||||
acp.server.send(...turn(sessionID, "msg_notice_second", textDelta(sessionID, "msg_reaction_2", "second reaction")))
|
||||
await acp.waitForUpdate(({ update }) => JSON.stringify(update).includes("second reaction"))
|
||||
|
||||
expect(
|
||||
turnUpdates(acp.updates)
|
||||
.map(({ update }) => update)
|
||||
.filter((update) => update.sessionUpdate === "agent_message_chunk"),
|
||||
).toMatchObject([
|
||||
{ messageId: "msg_reaction_1", content: { text: "first reaction" } },
|
||||
{ messageId: "msg_reaction_2", content: { text: "second reaction" } },
|
||||
])
|
||||
})
|
||||
|
||||
test("cancels unsupported session forms so execution can continue", async () => {
|
||||
await using acp = await startSession({
|
||||
onPrompt: ({ sessionID, id }) => [
|
||||
|
|
|
|||
|
|
@ -386,6 +386,31 @@ export function toolFailed(
|
|||
})
|
||||
}
|
||||
|
||||
/** The calls of a shell the model ran in the background. */
|
||||
export function backgroundShell(sessionID: string, shellID: string) {
|
||||
return [
|
||||
toolStarted(sessionID, `call_${shellID}`, "shell"),
|
||||
toolCalled(sessionID, `call_${shellID}`, { command: "build", background: true }),
|
||||
toolSucceeded(sessionID, `call_${shellID}`, { shellID, status: "running" }, "backgrounded"),
|
||||
]
|
||||
}
|
||||
|
||||
/** A finished shell's notice. A background job's carries its job ID; a user's shell command's has none. */
|
||||
export function shellNotice(sessionID: string, inboxID: string, shellID: string, options = { job: true }) {
|
||||
return durableEvent("session.inbox.enqueued", {
|
||||
sessionID,
|
||||
inboxID,
|
||||
item: {
|
||||
type: "synthetic",
|
||||
payload: {
|
||||
text: `<shell id="${shellID}" state="completed">`,
|
||||
metadata: { source: "shell", shellID, ...(options.job ? { jobID: shellID } : {}) },
|
||||
},
|
||||
delivery: "steer",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function permissionAsked(
|
||||
sessionID: string,
|
||||
id: string,
|
||||
|
|
|
|||
1
packages/client/src/promise/generated/types.ts
generated
1
packages/client/src/promise/generated/types.ts
generated
|
|
@ -2595,6 +2595,7 @@ export type ConfigEntry =
|
|||
artifacts?: boolean
|
||||
console_watches?: boolean
|
||||
mcp_events?: boolean
|
||||
full_codemode?: boolean
|
||||
part_rows?: boolean
|
||||
image_generate?: boolean | { model?: string | { providerID: string; model: string; variant?: string } }
|
||||
subagent_depth?: number
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export class Service extends Context.Service<Service, Interface>()("@opencode/Fl
|
|||
|
||||
/**
|
||||
* `OPENCODE_FLAGS`, a comma-separated list such as `schedules,-media_blob`; a leading `-` turns a flag off, and
|
||||
* `all` turns every flag on unless the same list opts one out, as in `all,-media_blob`.
|
||||
* `all` enables all flags except opt-in-only flags and any disabled in the same list, as in `all,-media_blob`.
|
||||
*/
|
||||
export const Overrides = Context.Reference<string | undefined>("@opencode/Flag/Overrides", {
|
||||
defaultValue: () => process.env.OPENCODE_FLAGS,
|
||||
|
|
@ -35,10 +35,11 @@ export const Overrides = Context.Reference<string | undefined>("@opencode/Flag/O
|
|||
const onByDefault = (channel: string) => channel === "local" || channel === "dev"
|
||||
|
||||
/**
|
||||
* Resolves every flag: `OPENCODE_FLAGS` (`-key`, then `all`), then `experimental.<key>` from the highest-priority
|
||||
* Resolves every flag: `OPENCODE_FLAGS` (`key` or `-key`, then `all`), then `experimental.<key>` from the highest-priority
|
||||
* document that sets `experimental` (the same document every other `experimental` setting reads), then `all_flags: true`
|
||||
* from the highest-priority document that sets `all_flags`, so a global switch survives a project's own `experimental`
|
||||
* block, then on for local and dev builds. `all_flags: false` falls through rather than turning flags off.
|
||||
* Opt-in-only flags skip both wildcards and default to off on every channel.
|
||||
* A remote kill switch belongs above `OPENCODE_FLAGS` here.
|
||||
*/
|
||||
export function resolve(input: {
|
||||
|
|
@ -60,14 +61,15 @@ export function resolve(input: {
|
|||
(entry): entry is Document => entry.type === "document" && entry.info.experimental?.all_flags !== undefined,
|
||||
)?.info.experimental?.all_flags === true
|
||||
return Record.map(ConfigFlag.registry, (_, key): State => {
|
||||
const override = env.get(key) ?? (all ? true : undefined)
|
||||
const configured = experimental?.[key] ?? (allFlags ? true : undefined)
|
||||
const optInOnly = ConfigFlag.optInOnly.has(key)
|
||||
const override = env.get(key) ?? (all && !optInOnly ? true : undefined)
|
||||
const configured = experimental?.[key] ?? (allFlags && !optInOnly ? true : undefined)
|
||||
const [enabled, source]: [boolean, State["source"]] =
|
||||
override !== undefined
|
||||
? [override, "env"]
|
||||
: configured !== undefined
|
||||
? [configured, "config"]
|
||||
: [onByDefault(input.channel), "default"]
|
||||
: [!optInOnly && onByDefault(input.channel), "default"]
|
||||
return { enabled, source }
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
export * as SessionStore from "./store.js"
|
||||
|
||||
import { and, asc, desc, eq, gt, isNotNull, isNull, like, lt, notInArray, or, sql, type SQL } from "drizzle-orm"
|
||||
import { and, asc, desc, eq, gt, isNotNull, isNull, lt, notInArray, or, sql, type SQL } from "drizzle-orm"
|
||||
import { Context, Effect, Layer, Schema } from "effect"
|
||||
import { Project } from "@opencode/schema/project"
|
||||
import { Workspace } from "@opencode/schema/workspace"
|
||||
|
|
@ -159,7 +159,7 @@ const layer = Layer.effect(
|
|||
if (input.workspaceID) conditions.push(eq(SessionTable.workspace_id, input.workspaceID))
|
||||
if ("project" in input) conditions.push(eq(SessionTable.project_id, input.project))
|
||||
if ("project" in input && input.subpath !== undefined) conditions.push(eq(SessionTable.path, input.subpath))
|
||||
if (input.search) conditions.push(like(SessionTable.title, `%${input.search}%`))
|
||||
if (input.search) conditions.push(sql`${SessionTable.title} GLOB ${titlePattern(input.search)}`)
|
||||
if (input.parentID !== undefined)
|
||||
conditions.push(
|
||||
input.parentID === null ? isNull(SessionTable.parent_id) : eq(SessionTable.parent_id, input.parentID),
|
||||
|
|
@ -299,3 +299,20 @@ const layer = Layer.effect(
|
|||
)
|
||||
|
||||
export const node = makeGlobalNode({ service: Service, layer, deps: [Database.node] })
|
||||
|
||||
// SQLite's LIKE folds case for ASCII only, and none of our drivers (bun, node, Durable Objects) ships ICU or lets us
|
||||
// register a lowercase function everywhere. GLOB is case-sensitive but supports character classes, so each cased
|
||||
// letter becomes a class of its single-character case forms ("т" -> "[тТ]"). The LIKE wildcards % and _ keep their
|
||||
// meaning, and GLOB metacharacters are wrapped in a class so they stay literal as they were under LIKE.
|
||||
function titlePattern(search: string) {
|
||||
const chars = Array.from(search, (char) => {
|
||||
if (char === "%") return "*"
|
||||
if (char === "_") return "?"
|
||||
const cases = new Set(
|
||||
[char, char.toLowerCase(), char.toUpperCase()].filter((form) => Array.from(form).length === 1),
|
||||
)
|
||||
if (cases.size > 1) return `[${[...cases].join("")}]`
|
||||
return "*?[".includes(char) ? `[${char}]` : char
|
||||
})
|
||||
return `*${chars.join("")}*`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ export type OpaqueReason =
|
|||
| "heredoc"
|
||||
| "invalid-redirect"
|
||||
| "invalid-structure"
|
||||
| "unsupported-escape"
|
||||
| "unterminated-escape"
|
||||
| "unterminated-quote"
|
||||
|
||||
|
|
@ -733,7 +734,7 @@ function scanBashOperatorOrSeparator(
|
|||
state.redirectWordCount = state.words.length
|
||||
}
|
||||
if (redirect === "<<" || redirect === "<<-") {
|
||||
const delimiter = bashHeredocDelimiter(input, index + redirect.length, redirect === "<<-")
|
||||
const delimiter = bashHeredocDelimiter(input, index + redirect.length, redirect === "<<-", context.dialect)
|
||||
if (!delimiter) return { kind: "opaque", reason: "invalid-redirect" }
|
||||
state.hasFileRedirect = true
|
||||
state.redirectPrefixEnd ??=
|
||||
|
|
@ -1151,8 +1152,8 @@ function scanBashUnit(
|
|||
return index + 1
|
||||
}
|
||||
if (mode === "word" && opener === "$'") {
|
||||
const quote = bashAnsiQuote(input, index + 1)
|
||||
if (!quote) return { kind: "opaque", reason: "unterminated-quote" }
|
||||
const quote = bashAnsiQuote(input, index + 1, context.dialect)
|
||||
if ("reason" in quote) return quote
|
||||
const firstQuote = input.indexOf("'", index + 2)
|
||||
// Dash does not support $'...' and closes the single-quoted span at the first `'`, even after `\`.
|
||||
if (
|
||||
|
|
@ -1166,8 +1167,8 @@ function scanBashUnit(
|
|||
return quote.end
|
||||
}
|
||||
if (mode === "arithmetic" && opener === "$'") {
|
||||
const quote = bashAnsiQuote(input, index + 1)
|
||||
if (!quote || quote.end !== input.indexOf("'", index + 2) || /[()[\];"}]/.test(quote.value))
|
||||
const quote = bashAnsiQuote(input, index + 1, context.dialect)
|
||||
if ("reason" in quote || quote.end !== input.indexOf("'", index + 2) || /[()[\];"}]/.test(quote.value))
|
||||
return { kind: "opaque", reason: "invalid-structure" }
|
||||
if (text) bashAppend(text, quote.value)
|
||||
return scanBashSpan(input, index + 2, depth, context, commands, BASH_SPANS.arithmeticQuote, allowBracket, text)
|
||||
|
|
@ -1497,8 +1498,8 @@ function scanBashParameter(
|
|||
if (!quoted && context.dialect !== "bash" && char === "(" && index > start)
|
||||
return { kind: "opaque", reason: "dynamic-execution" }
|
||||
if (quoted && char === "'" && input[index - 1] === "$") {
|
||||
const ansi = bashAnsiQuote(input, index)
|
||||
if (!ansi) return { kind: "opaque", reason: "unterminated-quote" }
|
||||
const ansi = bashAnsiQuote(input, index, context.dialect)
|
||||
if ("reason" in ansi) return ansi
|
||||
text.literal += ansi.value
|
||||
}
|
||||
const subscript = index === colon && char === "["
|
||||
|
|
@ -1677,7 +1678,12 @@ function scanBashArrayOrPattern(
|
|||
return { kind: "opaque", reason: "command-substitution" }
|
||||
}
|
||||
|
||||
function bashAnsiQuote(input: string, start: number, allowUnicode = true) {
|
||||
function bashAnsiQuote(
|
||||
input: string,
|
||||
start: number,
|
||||
dialect: Dialect,
|
||||
allowUnicode = true,
|
||||
): { value: string; end: number } | Opaque {
|
||||
let value = ""
|
||||
for (let index = start + 1; index < input.length; index++) {
|
||||
if (input[index] === "'") return { value, end: index }
|
||||
|
|
@ -1686,7 +1692,7 @@ function bashAnsiQuote(input: string, start: number, allowUnicode = true) {
|
|||
continue
|
||||
}
|
||||
const escaped = input[++index]
|
||||
if (escaped === undefined) return
|
||||
if (escaped === undefined) break
|
||||
if (escaped in BASH_ANSI_ESCAPES) {
|
||||
value += BASH_ANSI_ESCAPES[escaped]
|
||||
continue
|
||||
|
|
@ -1701,16 +1707,30 @@ function bashAnsiQuote(input: string, start: number, allowUnicode = true) {
|
|||
: /[0-7]/.test(escaped)
|
||||
? /^[0-7]{1,3}/.exec(input.slice(index, index + 3))?.[0]
|
||||
: undefined
|
||||
if (!digits) return
|
||||
const octal = /[0-7]/.test(escaped)
|
||||
const point = parseInt(digits, octal ? 8 : 16)
|
||||
if (point === 0 || point > 0x10ffff || (point >= 0xd800 && point <= 0xdfff)) return
|
||||
value += String.fromCodePoint(point)
|
||||
index += digits.length - (octal ? 1 : 0)
|
||||
if (digits) {
|
||||
const octal = /[0-7]/.test(escaped)
|
||||
const point = parseInt(digits, octal ? 8 : 16)
|
||||
if (point === 0 || point > 0x10ffff || (point >= 0xd800 && point <= 0xdfff))
|
||||
return { kind: "opaque", reason: "unsupported-escape" }
|
||||
value += String.fromCodePoint(point)
|
||||
index += digits.length - (octal ? 1 : 0)
|
||||
continue
|
||||
}
|
||||
// Bash keeps the backslash of an unknown escape and Zsh drops it, so Posix, which covers both, can't know the value.
|
||||
// Bash 3.2 and 5 decode \c control escapes differently, and \u or \U stay rejected where Unicode is. Zsh reads \C and \M as key escapes, and \x, \u or \U
|
||||
// without digits as NUL.
|
||||
if (
|
||||
dialect === "posix" ||
|
||||
(dialect === "bash" && (escaped === "c" || (!allowUnicode && /[uU]/.test(escaped)))) ||
|
||||
(dialect === "zsh" && /[CMxuU]/.test(escaped))
|
||||
)
|
||||
return { kind: "opaque", reason: "unsupported-escape" }
|
||||
value += dialect === "bash" ? `\\${escaped}` : escaped
|
||||
}
|
||||
return { kind: "opaque", reason: "unterminated-quote" }
|
||||
}
|
||||
|
||||
function bashHeredocDelimiter(input: string, start: number, tabs: boolean) {
|
||||
function bashHeredocDelimiter(input: string, start: number, tabs: boolean, dialect: Dialect) {
|
||||
let delimiter = ""
|
||||
let dashDelimiter: string | undefined
|
||||
let quoted = false
|
||||
|
|
@ -1726,8 +1746,8 @@ function bashHeredocDelimiter(input: string, start: number, tabs: boolean) {
|
|||
if (!quote && char === "$" && input.startsWith("\\\n", index + 1)) return
|
||||
// Dash retains $ in $'...' heredoc delimiters while Bash and Zsh strip $.
|
||||
if (!quote && input.startsWith("$'", index)) {
|
||||
const literal = bashAnsiQuote(input, index + 1, false)
|
||||
if (!literal || literal.end !== input.indexOf("'", index + 2)) return
|
||||
const literal = bashAnsiQuote(input, index + 1, dialect, false)
|
||||
if ("reason" in literal || literal.end !== input.indexOf("'", index + 2)) return
|
||||
dashDelimiter = `${dashDelimiter ?? delimiter}$${input.slice(index + 2, literal.end)}`
|
||||
delimiter += literal.value
|
||||
quoted = true
|
||||
|
|
|
|||
|
|
@ -617,8 +617,10 @@ describe("ConfigNormalize", () => {
|
|||
})
|
||||
|
||||
test("normalizes every registered flag as a boolean", () => {
|
||||
const result = normalized({ experimental: { todo: true, media_blob: false, schedules: "yes" } })
|
||||
expect(result.encoded.experimental).toEqual({ todo: true, media_blob: false })
|
||||
const result = normalized({
|
||||
experimental: { todo: true, media_blob: false, schedules: "yes", full_codemode: true },
|
||||
})
|
||||
expect(result.encoded.experimental).toEqual({ todo: true, media_blob: false, full_codemode: true })
|
||||
expect(result.diagnostics.map((item) => [item.kind, item.path])).toEqual([
|
||||
["invalid", ["experimental", "schedules"]],
|
||||
])
|
||||
|
|
|
|||
|
|
@ -26,26 +26,38 @@ const document = (experimental?: ConstructorParameters<typeof ConfigExperimental
|
|||
info: new Info(experimental === undefined ? {} : { experimental: new ConfigExperimental.Info(experimental) }),
|
||||
})
|
||||
|
||||
const every = (state: Flag.State) => Record.map(ConfigFlag.registry, () => state)
|
||||
const implicit = (state: Flag.State): Record<Flag.Key, Flag.State> => ({
|
||||
...Record.map(ConfigFlag.registry, () => state),
|
||||
full_codemode: { enabled: false, source: "default" },
|
||||
})
|
||||
|
||||
describe("Flag.resolve", () => {
|
||||
test("turns flags on by default only in local and dev builds", () => {
|
||||
const table = ["local", "dev", "beta", "latest", "my-branch", "unknown"].map((channel) => [
|
||||
channel,
|
||||
Flag.resolve({ entries: [], channel }).todo.enabled,
|
||||
])
|
||||
expect(Object.fromEntries(table)).toEqual({
|
||||
local: true,
|
||||
dev: true,
|
||||
beta: false,
|
||||
latest: false,
|
||||
"my-branch": false,
|
||||
unknown: false,
|
||||
})
|
||||
test.each([
|
||||
["local", true],
|
||||
["dev", true],
|
||||
["beta", false],
|
||||
["latest", false],
|
||||
["my-branch", false],
|
||||
["unknown", false],
|
||||
] as const)("applies %s build defaults and leaves full_codemode off", (channel, enabled) => {
|
||||
expect(Flag.resolve({ entries: [], channel })).toEqual(implicit({ enabled, source: "default" }))
|
||||
})
|
||||
|
||||
test("every registered flag is off in a latest release build", () => {
|
||||
expect(Flag.resolve({ entries: [], channel: "latest" })).toEqual(every({ enabled: false, source: "default" }))
|
||||
test("full_codemode can be enabled or disabled by name", () => {
|
||||
const channel = "latest"
|
||||
const entries = [document({ full_codemode: true })]
|
||||
expect(Flag.resolve({ entries: [], channel, overrides: "full_codemode" }).full_codemode).toEqual({
|
||||
enabled: true,
|
||||
source: "env",
|
||||
})
|
||||
expect(Flag.resolve({ entries, channel }).full_codemode).toEqual({ enabled: true, source: "config" })
|
||||
expect(Flag.resolve({ entries, channel, overrides: "-full_codemode" }).full_codemode).toEqual({
|
||||
enabled: false,
|
||||
source: "env",
|
||||
})
|
||||
expect(
|
||||
Flag.resolve({ entries: [document({ full_codemode: false })], channel, overrides: "all" }).full_codemode,
|
||||
).toEqual({ enabled: false, source: "config" })
|
||||
})
|
||||
|
||||
test("config overrides the default and OPENCODE_FLAGS overrides config", () => {
|
||||
|
|
@ -69,13 +81,13 @@ describe("Flag.resolve", () => {
|
|||
expect([flags.todo.enabled, flags.todo.source]).toEqual([false, "default"])
|
||||
})
|
||||
|
||||
test("OPENCODE_FLAGS=all turns every flag on, and a -key in the same list still wins", () => {
|
||||
test("OPENCODE_FLAGS=all skips opt-in-only flags, and a -key in the same list still wins", () => {
|
||||
const entries = [document({ media_blob: false })]
|
||||
expect(Flag.resolve({ entries, channel: "latest", overrides: "all" })).toEqual(
|
||||
every({ enabled: true, source: "env" }),
|
||||
implicit({ enabled: true, source: "env" }),
|
||||
)
|
||||
expect(Flag.resolve({ entries: [], channel: "latest", overrides: " -media_blob , all, " })).toEqual({
|
||||
...every({ enabled: true, source: "env" }),
|
||||
...implicit({ enabled: true, source: "env" }),
|
||||
media_blob: { enabled: false, source: "env" },
|
||||
})
|
||||
expect(Flag.resolve({ entries, channel: "latest", overrides: "-all" })).toEqual(
|
||||
|
|
@ -83,10 +95,10 @@ describe("Flag.resolve", () => {
|
|||
)
|
||||
})
|
||||
|
||||
test("experimental.all_flags turns every flag on below OPENCODE_FLAGS and below a per-flag setting", () => {
|
||||
test("experimental.all_flags skips opt-in-only flags and yields to OPENCODE_FLAGS and per-flag settings", () => {
|
||||
const entries = [document({ all_flags: true, media_blob: false })]
|
||||
expect(Flag.resolve({ entries, channel: "latest", overrides: "-artifacts" })).toEqual({
|
||||
...every({ enabled: true, source: "config" }),
|
||||
...implicit({ enabled: true, source: "config" }),
|
||||
media_blob: { enabled: false, source: "config" },
|
||||
artifacts: { enabled: false, source: "env" },
|
||||
})
|
||||
|
|
@ -94,7 +106,7 @@ describe("Flag.resolve", () => {
|
|||
|
||||
test("experimental.all_flags: false is not a kill switch, and all_flags in OPENCODE_FLAGS does nothing", () => {
|
||||
expect(Flag.resolve({ entries: [document({ all_flags: false })], channel: "dev" })).toEqual(
|
||||
every({ enabled: true, source: "default" }),
|
||||
implicit({ enabled: true, source: "default" }),
|
||||
)
|
||||
expect(Flag.resolve({ entries: [], channel: "latest", overrides: "all_flags" })).toEqual(
|
||||
Flag.resolve({ entries: [], channel: "latest" }),
|
||||
|
|
@ -105,9 +117,9 @@ describe("Flag.resolve", () => {
|
|||
const global = document({ all_flags: true })
|
||||
expect(
|
||||
Flag.resolve({ entries: [global, document({ subagent_depth: 2, todo: false })], channel: "latest" }),
|
||||
).toEqual({ ...every({ enabled: true, source: "config" }), todo: { enabled: false, source: "config" } })
|
||||
).toEqual({ ...implicit({ enabled: true, source: "config" }), todo: { enabled: false, source: "config" } })
|
||||
expect(Flag.resolve({ entries: [global, document({ all_flags: false })], channel: "latest" })).toEqual(
|
||||
every({ enabled: false, source: "default" }),
|
||||
implicit({ enabled: false, source: "default" }),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ const partRows = Config.testLayer([
|
|||
}),
|
||||
])
|
||||
|
||||
const seedSessions = (rows: { id: string; updated: number }[]) =>
|
||||
const seedSessions = (rows: { id: string; updated: number; title?: string }[]) =>
|
||||
Effect.gen(function* () {
|
||||
const database = yield* Database.Service
|
||||
const bus = yield* Bus.Service
|
||||
|
|
@ -58,7 +58,7 @@ const seedSessions = (rows: { id: string; updated: number }[]) =>
|
|||
aggregateID: sessionID,
|
||||
seq: 1,
|
||||
type: Bus.versionedType(SessionEvent.Renamed.type, 1),
|
||||
data: { sessionID, title: row.id },
|
||||
data: { sessionID, title: row.title ?? row.id },
|
||||
})
|
||||
}),
|
||||
)
|
||||
|
|
@ -166,6 +166,32 @@ describe("SessionStore", () => {
|
|||
}),
|
||||
)
|
||||
|
||||
it.effect("searches titles case-insensitively beyond ASCII and keeps LIKE wildcard semantics", () =>
|
||||
Effect.gen(function* () {
|
||||
yield* seedSessions([
|
||||
{ id: "ses_cyrillic", updated: 10, title: "Тестова сесия" },
|
||||
{ id: "ses_ascii", updated: 20, title: "OpenCode notes" },
|
||||
{ id: "ses_percent", updated: 30, title: "100% done" },
|
||||
{ id: "ses_underscore", updated: 40, title: "file_name [draft]" },
|
||||
])
|
||||
const store = yield* SessionStore.Service
|
||||
const search = (text: string) =>
|
||||
store.list({ search: text }).pipe(Effect.map((sessions) => sessions.map((session) => String(session.id))))
|
||||
|
||||
expect(yield* search("тестова")).toEqual(["ses_cyrillic"])
|
||||
expect(yield* search("ТЕСТОВА СЕСИЯ")).toEqual(["ses_cyrillic"])
|
||||
expect(yield* search("opencode")).toEqual(["ses_ascii"])
|
||||
expect(yield* search("OPENCODE")).toEqual(["ses_ascii"])
|
||||
expect(yield* search("тест%сия")).toEqual(["ses_cyrillic"])
|
||||
expect(yield* search("OP_NCODE")).toEqual(["ses_ascii"])
|
||||
expect(yield* search("100%")).toEqual(["ses_percent"])
|
||||
expect(yield* search("file_name")).toEqual(["ses_underscore"])
|
||||
expect(yield* search("[DRAFT]")).toEqual(["ses_underscore"])
|
||||
expect(yield* search("*")).toEqual([])
|
||||
expect(yield* search("?")).toEqual([])
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("pages messages by durable sequence, not timestamp or ID, and scopes cursor lookup", () =>
|
||||
Effect.gen(function* () {
|
||||
const sessionID = Session.ID.make("ses_messages")
|
||||
|
|
|
|||
|
|
@ -169,6 +169,45 @@ describe("ordinary Bash and Zsh syntax", () => {
|
|||
})
|
||||
})
|
||||
|
||||
// Expected values are what Bash 3.2 and 5.2 and Zsh 5.9 print for these words.
|
||||
test.each([
|
||||
["bash", "$'\\033\\[?1049'", "\x1b\\[?1049"],
|
||||
["bash", "$'\\q\\8\\-\\xg\\ug\\Ug'", "\\q\\8\\-\\xg\\ug\\Ug"],
|
||||
["bash", "$'a\\\nb'", "a\\\nb"],
|
||||
["zsh", "$'\\033\\[?1049'", "\x1b[?1049"],
|
||||
["zsh", "$'\\q\\8\\-\\c'", "q8-c"],
|
||||
["zsh", "$'a\\\nb'", "a\nb"],
|
||||
] as const)("decodes unknown ANSI-C escapes like %s: %s", (dialect, word, value) => {
|
||||
expect(ShellScan.scan(`printf '%s' ${word} | od -c`, dialect)).toMatchObject({
|
||||
kind: "scanned",
|
||||
commands: [{ words: ["printf", "%s", value] }, { words: ["od", "-c"] }],
|
||||
})
|
||||
})
|
||||
|
||||
test("decodes unknown escapes in ANSI-C heredoc delimiters like each dialect", () => {
|
||||
const source = "cat <<$'E\\[F'\nE[F\nE\\[F\nprintf done"
|
||||
expect(ShellScan.scan(source, "bash")).toMatchObject({
|
||||
kind: "scanned",
|
||||
commands: [{ words: ["cat"] }, { words: ["printf", "done"] }],
|
||||
})
|
||||
expect(ShellScan.scan(source, "zsh")).toMatchObject({
|
||||
kind: "scanned",
|
||||
commands: [{ words: ["cat"] }, { words: ["E[F"] }, { words: ["printf", "done"] }],
|
||||
})
|
||||
})
|
||||
|
||||
test.each([
|
||||
["posix", "$'\\['"],
|
||||
["bash", "$'\\cA'"],
|
||||
["bash", "$'a\\0b'"],
|
||||
["zsh", "$'\\C-a'"],
|
||||
["zsh", "$'\\M-a'"],
|
||||
["zsh", "$'\\xg'"],
|
||||
["zsh", "$'\\u'"],
|
||||
] as const)("rejects ANSI-C escapes whose value differs between shells in %s: %s", (dialect, word) => {
|
||||
expect(ShellScan.scan(`printf '%s' ${word}`, dialect)).toEqual({ kind: "opaque", reason: "unsupported-escape" })
|
||||
})
|
||||
|
||||
test.each([
|
||||
["coproc job { scan_probe; }", ["scan_probe"]],
|
||||
["case x in @(one|$(scan_probe))) ;; esac", ["scan_probe"]],
|
||||
|
|
|
|||
|
|
@ -501,6 +501,8 @@ const fixtures = [
|
|||
"$'scan_probe\\Uz'",
|
||||
"$'scan_probe\\C-@x'",
|
||||
"$'scan_probe\\C@x'",
|
||||
"$'scan\\_probe'",
|
||||
": <<$'E\\[F'\nE[F\nscan_probe\nE\\[F",
|
||||
"a=(1); set -A 'a[$(scan_probe)]' 1",
|
||||
"a=(1); set +A 'a[$(scan_probe)]' 1",
|
||||
"unsetopt noglobsubst; x='*(e:scan_probe:)'; echo $x",
|
||||
|
|
|
|||
3
packages/protocol/openapi.json
generated
3
packages/protocol/openapi.json
generated
|
|
@ -16794,6 +16794,9 @@
|
|||
"mcp_events": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"full_codemode": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"part_rows": {
|
||||
"type": "boolean"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -15,11 +15,13 @@ export class Info extends Schema.Class<Info>("ConfigExperimental.Info")({
|
|||
}),
|
||||
all_flags: Schema.Boolean.pipe(optional).annotate({
|
||||
description:
|
||||
"Turn every feature flag on regardless of the build channel, like OPENCODE_FLAGS=all; explicit per-flag settings still win, and false is not a kill switch.",
|
||||
"Enable all flags except opt-in-only flags on any build channel, like OPENCODE_FLAGS=all. Per-flag config settings take precedence over all_flags; false leaves the build defaults in effect.",
|
||||
}),
|
||||
...Record.map(ConfigFlag.registry, (description) =>
|
||||
...Record.map(ConfigFlag.registry, (description, key) =>
|
||||
Schema.Boolean.pipe(optional).annotate({
|
||||
description: `${description} Defaults to on in local and dev builds and off in releases.`,
|
||||
description: ConfigFlag.optInOnly.has(key)
|
||||
? description
|
||||
: `${description} Defaults to on in local and dev builds and off in releases.`,
|
||||
}),
|
||||
),
|
||||
part_rows: Schema.Boolean.pipe(optional).annotate({
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
export * as ConfigFlag from "./flag.js"
|
||||
|
||||
/** The `OPENCODE_FLAGS` entry that turns every flag on, as in `all,-media_blob`. It is not a flag key. */
|
||||
/** The `OPENCODE_FLAGS` entry that enables all flags except opt-in-only flags, as in `all,-media_blob`. */
|
||||
export const wildcard = "all"
|
||||
|
||||
/**
|
||||
* Every feature flag, by key, with what it turns on. A flag is on in local and dev builds and off in released ones;
|
||||
* `experimental.<key>` in config and `OPENCODE_FLAGS` override that, and `OPENCODE_FLAGS=all` or
|
||||
* `experimental.all_flags: true` turn every flag on. Read one with Core's `Flag.enabled("<key>")`.
|
||||
* Flags default to on in local and dev builds and off in releases, except for `optInOnly` flags, which must be
|
||||
* named explicitly in `experimental.<key>` or `OPENCODE_FLAGS`. Read a flag with Core's `Flag.enabled("<key>")`.
|
||||
*/
|
||||
export const registry = {
|
||||
todo: "Enable the experimental todowrite tool.",
|
||||
|
|
@ -19,5 +18,9 @@ export const registry = {
|
|||
"Watch Slack threads, GitHub pull requests, issues, commits and Actions runs, and the workspace's MCP servers' events through OpenCode Console, and wake sessions when they change.",
|
||||
mcp_events:
|
||||
"Enable experimental MCP Events, a draft MCP extension: declare support to MCP servers and read the events of servers that offer them.",
|
||||
full_codemode:
|
||||
"Enable the full Code Mode work in progress. Off by default in every build, including local and dev; opt in with OPENCODE_FLAGS=full_codemode or experimental.full_codemode: true.",
|
||||
} as const satisfies Record<string, string>
|
||||
export type Key = keyof typeof registry
|
||||
|
||||
export const optInOnly: ReadonlySet<Key> = new Set(["full_codemode"])
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ describe("Config.Entry", () => {
|
|||
})
|
||||
})
|
||||
|
||||
test("no flag is named after the everything-on switches", () => {
|
||||
test("wildcard switches are reserved flag names", () => {
|
||||
expect(ConfigFlag.registry).not.toHaveProperty("all_flags")
|
||||
expect(ConfigFlag.registry).not.toHaveProperty(ConfigFlag.wildcard)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -43,11 +43,13 @@ export function openSessionTab(tabs: SessionTab[], tab: SessionTab): SessionTab[
|
|||
return tabs.map((item, position) => (position === index ? { ...item, title: tab.title } : item))
|
||||
}
|
||||
|
||||
export function closeSessionTab(tabs: SessionTab[], sessionID: string) {
|
||||
export function closeSessionTab(tabs: SessionTab[], sessionID: string, lastIndex?: number) {
|
||||
const index = tabs.findIndex((tab) => tab.sessionID === sessionID)
|
||||
// Like openSessionTab and moveSessionTab, a no-op returns the same reference so callers can
|
||||
// detect it by identity.
|
||||
if (index === -1) return { tabs, next: undefined }
|
||||
// detect it by identity. Another TUI sharing the tab list may already have closed the tab, so
|
||||
// its last known index still picks the neighbour that took its place.
|
||||
if (index === -1)
|
||||
return { tabs, next: lastIndex === undefined ? undefined : tabs[Math.min(lastIndex, tabs.length - 1)]?.sessionID }
|
||||
return {
|
||||
tabs: tabs.filter((tab) => tab.sessionID !== sessionID),
|
||||
next: tabs[index + 1]?.sessionID ?? tabs[index - 1]?.sessionID,
|
||||
|
|
|
|||
|
|
@ -150,6 +150,15 @@ export const { use: useSessionTabs, provider: SessionTabsProvider } = createSimp
|
|||
const sessionID = current()
|
||||
return sessionID !== undefined && !state().tabs.some((tab) => tab.sessionID === sessionID)
|
||||
}, false)
|
||||
// Where the viewed session's tab last sat. Another TUI sharing the tab list can close it while
|
||||
// this one keeps showing the session; closing it here then still moves to a neighbour.
|
||||
const currentTab = createMemo<{ sessionID: string; index: number } | undefined>((previous) => {
|
||||
const sessionID = current()
|
||||
if (!sessionID) return
|
||||
const index = state().tabs.findIndex((tab) => tab.sessionID === sessionID)
|
||||
if (index !== -1) return { sessionID, index }
|
||||
if (previous?.sessionID === sessionID) return previous
|
||||
})
|
||||
const status = (sessionID: string) => {
|
||||
const session = root(sessionID)
|
||||
const members = family(session)
|
||||
|
|
@ -353,7 +362,8 @@ export const { use: useSessionTabs, provider: SessionTabsProvider } = createSimp
|
|||
scrollAnchors.delete(id)
|
||||
setExpandedGroups(id, undefined)
|
||||
})
|
||||
const closed = closeSessionTab(state().tabs, target)
|
||||
const known = currentTab()
|
||||
const closed = closeSessionTab(state().tabs, target, known?.sessionID === target ? known.index : undefined)
|
||||
const selected = navigate && current() === target
|
||||
if (closed.tabs === state().tabs && !selected) return
|
||||
const previous = selected
|
||||
|
|
|
|||
|
|
@ -112,6 +112,14 @@ describe("session tabs", () => {
|
|||
expect(closeSessionTab(tabs, "missing").tabs).toBe(tabs)
|
||||
})
|
||||
|
||||
test("closing an already removed tab picks the neighbour at its last index", () => {
|
||||
const tabs = [{ sessionID: "a" }, { sessionID: "c" }]
|
||||
expect(closeSessionTab(tabs, "b", 1)).toEqual({ tabs, next: "c" })
|
||||
expect(closeSessionTab(tabs, "d", 2).next).toBe("c")
|
||||
expect(closeSessionTab(tabs, "b").next).toBeUndefined()
|
||||
expect(closeSessionTab([], "b", 0).next).toBeUndefined()
|
||||
})
|
||||
|
||||
test("cycles through a filtered tab set in either direction", () => {
|
||||
const tabs = ["a", "c", "e"].map((sessionID) => ({ sessionID }))
|
||||
expect(cycleSessionTab(tabs, "c", 1)?.sessionID).toBe("e")
|
||||
|
|
|
|||
|
|
@ -728,6 +728,39 @@ test("closing a tab is not undone by another TUI viewing the same session", asyn
|
|||
}
|
||||
})
|
||||
|
||||
test("closing a session whose tab another TUI closed selects its former neighbour", async () => {
|
||||
await using temporary = await tmpdir()
|
||||
const clients: Awaited<ReturnType<typeof renderSessionTabs>>[] = []
|
||||
|
||||
try {
|
||||
const first = await renderSessionTabs("one", {
|
||||
state: temporary.path,
|
||||
persisted: ["one", "two", "three", "four", "five"],
|
||||
})
|
||||
clients.push(first)
|
||||
const second = await renderSessionTabs("three", { state: temporary.path })
|
||||
clients.push(second)
|
||||
await wait(() => second.tabs.tabs().length === 5, 2_000, "second client to load tabs")
|
||||
|
||||
first.tabs.close("three")
|
||||
await first.flush()
|
||||
await wait(
|
||||
() => !second.tabs.tabs().some((tab) => tab.sessionID === "three"),
|
||||
2_000,
|
||||
"second client to observe close",
|
||||
)
|
||||
// The other client's close leaves this view in place rather than switching sessions under the user.
|
||||
expect(second.route.data).toEqual({ type: "session", sessionID: "three" })
|
||||
|
||||
second.tabs.close()
|
||||
await wait(() => second.route.data.type !== "session" || second.route.data.sessionID !== "three")
|
||||
expect(second.route.data).toEqual({ type: "session", sessionID: "four" })
|
||||
expect(second.tabs.tabs().map((tab) => tab.sessionID)).toEqual(["one", "two", "four", "five"])
|
||||
} finally {
|
||||
await Promise.allSettled(clients.map((client) => client.destroy()))
|
||||
}
|
||||
})
|
||||
|
||||
test("user prompt admissions pulse an already-busy background tab", async () => {
|
||||
const setup = await renderSessionTabs("background", { persisted: ["background"] })
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue