Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion packages/opencode/src/cli/cmd/tui/context/sync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
break

case "session.deleted": {
const result = Binary.search(store.session, event.properties.info.id, (s) => s.id)
const deletedID = event.properties.info.id
const result = Binary.search(store.session, deletedID, (s) => s.id)
if (result.found) {
setStore(
"session",
Expand All @@ -370,6 +371,27 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
}),
)
}
batch(() => {
setStore("message", deletedID, undefined as any)
setStore("todo", deletedID, undefined as any)
setStore("task", deletedID, undefined as any)
setStore("actor", deletedID, undefined as any)
setStore("permission", deletedID, undefined as any)
setStore("question", deletedID, undefined as any)
setStore("session_cwd", deletedID, undefined as any)
setStore("session_diff", deletedID, undefined as any)
setStore("session_goal", deletedID, undefined as any)
setStore("session_status", deletedID, undefined as any)
const msgs = store.message[deletedID]
if (msgs) {
const msgIDs = new Set(msgs.map((m: any) => m.id))
setStore("part", produce((draft: any) => {
for (const key of Object.keys(draft)) {
if (msgIDs.has(key)) delete draft[key]
}
}))
}
})
break
}
case "session.updated": {
Expand Down
15 changes: 8 additions & 7 deletions packages/opencode/src/cli/cmd/tui/util/system-locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,12 @@ function detectTimezoneLocale(): Locale | undefined {
}

export function detectSystemLocale(): Locale {
const tz = detectTimezoneLocale()
if (tz) return tz
// Priority: 1) system language (most accurate), 2) env vars, 3) timezone (geographic hint)
try {
const intl = Intl.DateTimeFormat().resolvedOptions().locale.toLowerCase()
const match = matchers.find((m) => m.test(intl))
if (match) return match.locale
} catch {}
for (const env of ["LC_ALL", "LC_MESSAGES", "LANG", "LANGUAGE"] as const) {
const value = process.env[env]
if (!value) continue
Expand All @@ -200,10 +204,7 @@ export function detectSystemLocale(): Locale {
if (match) return match.locale
}
}
try {
const intl = Intl.DateTimeFormat().resolvedOptions().locale.toLowerCase()
const match = matchers.find((m) => m.test(intl))
if (match) return match.locale
} catch {}
const tz = detectTimezoneLocale()
if (tz) return tz
return "en"
}