fix(tui): gate Zed context on terminal env (#28517)

This commit is contained in:
Kit Langton
2026-05-20 16:52:33 -04:00
committed by GitHub
parent 09603ed52f
commit 43c24d8d0f
4 changed files with 48 additions and 8 deletions

View File

@@ -195,6 +195,10 @@ export function resolveZedDbPath() {
return candidates.find((item) => isFile(item))
}
export function isZedTerminal() {
return process.env.ZED_TERM === "true" || process.env.TERM_PROGRAM?.toLowerCase() === "zed"
}
function isFile(item: string) {
try {
return Filesystem.stat(item)?.isFile() === true

View File

@@ -6,7 +6,7 @@ import { createStore } from "solid-js/store"
import { Option, Schema, SchemaGetter } from "effect"
import { isRecord } from "@/util/record"
import { createSimpleContext } from "./helper"
import { resolveZedDbPath, resolveZedSelection } from "./editor-zed"
import { isZedTerminal, resolveZedDbPath, resolveZedSelection } from "./editor-zed"
const MCP_PROTOCOL_VERSION = "2025-11-25"
@@ -173,6 +173,12 @@ export const { use: useEditorContext, provider: EditorContextProvider } = create
const connection = resolveEditorConnection(directory)
if (!connection) {
if (!isZedTerminal()) {
setStore("status", "disabled")
scheduleReconnect()
return
}
const dbPath = resolveZedDbPath()
if (!dbPath) {
setStore("status", "disabled")
@@ -311,7 +317,7 @@ export const { use: useEditorContext, provider: EditorContextProvider } = create
return {
enabled() {
return Boolean(resolveEditorConnection(directory) || resolveZedDbPath())
return Boolean(resolveEditorConnection(directory) || (isZedTerminal() && resolveZedDbPath()))
},
connected() {
return store.status === "connected"

View File

@@ -48,12 +48,14 @@ export const Service =
}
static get defaultLayer() {
const tag = this
return Layer.effect(
this,
Config.all(fields).pipe(
tag,
Effect.gen(function* () {
const config = yield* Config.all(fields)
// oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion -- Config.all preserves the field shape, but its conditional return type also supports iterable inputs.
Effect.map((config) => this.of(config as Shape<Fields>)),
),
return tag.of(config as Shape<Fields>)
}),
)
}
}