|
7 | 7 | "encoding/json" |
8 | 8 | "errors" |
9 | 9 | "fmt" |
10 | | - "os/exec" |
11 | 10 | "os" |
| 11 | + "os/exec" |
12 | 12 | "path/filepath" |
13 | 13 | "sort" |
14 | 14 | "strings" |
@@ -193,14 +193,7 @@ func listLisaSocketPathsFromProcessTable() ([]string, error) { |
193 | 193 | if err != nil { |
194 | 194 | return nil, err |
195 | 195 | } |
196 | | - paths := extractTmuxSocketPathsFromCommands(commands) |
197 | | - out := make([]string, 0, len(paths)) |
198 | | - for _, path := range paths { |
199 | | - if isLikelyLisaSocketPath(path) { |
200 | | - out = append(out, path) |
201 | | - } |
202 | | - } |
203 | | - return out, nil |
| 196 | + return extractTmuxSocketPathsFromCommands(commands), nil |
204 | 197 | } |
205 | 198 |
|
206 | 199 | func listProcessCommands() ([]string, error) { |
@@ -274,19 +267,11 @@ func listLisaSocketPathsFromLISA(cfg config) ([]string, error) { |
274 | 267 | return nil, fmt.Errorf("lisa list failed: %s", strings.TrimSpace(string(out))) |
275 | 268 | } |
276 | 269 |
|
277 | | - projectRoots, err := lisaProjectRootsFromListPayload(out) |
| 270 | + socketPaths, err := lisaSocketPathsFromListPayload(out) |
278 | 271 | if err != nil { |
279 | 272 | return nil, fmt.Errorf("lisa list invalid json") |
280 | 273 | } |
281 | | - paths := make([]string, 0, len(projectRoots)*2) |
282 | | - for _, root := range projectRoots { |
283 | | - paths = append(paths, tmuxSocketPathForProjectRoot(root)) |
284 | | - legacy := tmuxLegacySocketPathForProjectRoot(root) |
285 | | - if legacy != "" && legacy != paths[len(paths)-1] { |
286 | | - paths = append(paths, legacy) |
287 | | - } |
288 | | - } |
289 | | - return dedupePaths(paths), nil |
| 274 | + return socketPaths, nil |
290 | 275 | } |
291 | 276 |
|
292 | 277 | func runLisaSessionList(ctx context.Context, withNextAction bool) ([]byte, error) { |
@@ -317,24 +302,34 @@ func lisaUnknownWithNextActionError(out []byte) bool { |
317 | 302 | return strings.Contains(lower, "unknown flag") && strings.Contains(lower, "--with-next-action") |
318 | 303 | } |
319 | 304 |
|
320 | | -func lisaProjectRootsFromListPayload(out []byte) ([]string, error) { |
| 305 | +func lisaSocketPathsFromListPayload(out []byte) ([]string, error) { |
321 | 306 | var payload struct { |
322 | 307 | Items []struct { |
323 | 308 | ProjectRoot string `json:"projectRoot"` |
| 309 | + SocketPath string `json:"socketPath"` |
324 | 310 | } `json:"items"` |
325 | 311 | } |
326 | 312 | if err := json.Unmarshal(out, &payload); err != nil { |
327 | 313 | return nil, err |
328 | 314 | } |
329 | | - roots := make([]string, 0, len(payload.Items)) |
| 315 | + paths := make([]string, 0, len(payload.Items)*2) |
330 | 316 | for _, item := range payload.Items { |
| 317 | + socketPath := strings.TrimSpace(item.SocketPath) |
| 318 | + if socketPath != "" { |
| 319 | + paths = append(paths, filepath.Clean(socketPath)) |
| 320 | + continue |
| 321 | + } |
331 | 322 | root := canonicalProjectRoot(item.ProjectRoot) |
332 | 323 | if root == "" { |
333 | 324 | continue |
334 | 325 | } |
335 | | - roots = append(roots, root) |
| 326 | + paths = append(paths, tmuxSocketPathForProjectRoot(root)) |
| 327 | + legacy := tmuxLegacySocketPathForProjectRoot(root) |
| 328 | + if legacy != "" { |
| 329 | + paths = append(paths, legacy) |
| 330 | + } |
336 | 331 | } |
337 | | - return dedupePaths(roots), nil |
| 332 | + return dedupePaths(paths), nil |
338 | 333 | } |
339 | 334 |
|
340 | 335 | func canonicalProjectRoot(projectRoot string) string { |
@@ -408,14 +403,6 @@ func preferredTmuxSocketDir() string { |
408 | 403 | return filepath.Clean(tmp) |
409 | 404 | } |
410 | 405 |
|
411 | | -func isLikelyLisaSocketPath(path string) bool { |
412 | | - base := strings.ToLower(filepath.Base(strings.TrimSpace(path))) |
413 | | - if base == "lisa-codex-nosb.sock" { |
414 | | - return true |
415 | | - } |
416 | | - return strings.HasPrefix(base, "lisa-") && strings.HasSuffix(base, ".sock") |
417 | | -} |
418 | | - |
419 | 406 | func makeSocketTarget(path string) socketTarget { |
420 | 407 | return socketTarget{ |
421 | 408 | path: path, |
|
0 commit comments