fix(terminal): split panes lose source cwd when shell omits OSC 7 (#1313)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinwoo Hong
2026-05-01 12:25:41 -07:00
committed by GitHub
co-authored by Orca
parent 48d7e20493
commit 22b80f8ce5
2 changed files with 17 additions and 5 deletions
+5 -1
View File
@@ -70,7 +70,11 @@ async function doResolve(pid: number): Promise<string> {
}
try {
const { stdout } = await execFile('lsof', ['-p', String(pid), '-d', 'cwd', '-Fn'], {
// Why: `-a` ANDs the -p and -d filters. Without it, macOS lsof ORs them
// and emits cwd records for every process on the system, so the n-line
// scan below picks up the first unrelated process (often pid ~391 with
// cwd `/`) and returns `/` regardless of the target pid's real cwd.
const { stdout } = await execFile('lsof', ['-a', '-p', String(pid), '-d', 'cwd', '-Fn'], {
encoding: 'utf-8',
timeout: LSOF_TIMEOUT_MS
})
+12 -4
View File
@@ -42,10 +42,18 @@ export async function resolveProcessCwd(pid: number, fallbackCwd: string): Promi
// lsof returns ALL open files (sockets, log files, TTYs) and the first `n`-line
// could be any of them — not the actual working directory.
try {
const { stdout: output } = await execFile('lsof', ['-p', String(pid), '-d', 'cwd', '-Fn'], {
encoding: 'utf-8',
timeout: 3000
})
// Why: `-a` ANDs the -p and -d filters. Without it, macOS lsof ORs them
// and emits cwd records for every process on the system, so the n-line
// scan below picks up the first unrelated process (often pid ~391 with
// cwd `/`) and returns `/` regardless of the target pid's real cwd.
const { stdout: output } = await execFile(
'lsof',
['-a', '-p', String(pid), '-d', 'cwd', '-Fn'],
{
encoding: 'utf-8',
timeout: 3000
}
)
const lines = output.split('\n')
for (const line of lines) {
if (line.startsWith('n') && line.includes('/')) {