Repository navigation
cmux omx tmux-compat shim does not report session_attached, breaking omx question #3233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3279,6 +3279,8 @@ struct CMUXCLI { | |||||
| "set-buffer", | ||||||
| "paste-buffer", | ||||||
| "list-buffers", | ||||||
| "list-clients", | ||||||
| "list-sessions", | ||||||
| "respawn-pane", | ||||||
| "display-message": | ||||||
| try runTmuxCompatCommand( | ||||||
|
|
@@ -11578,6 +11580,12 @@ struct CMUXCLI { | |||||
| let canonicalWorkspaceId = try resolveWorkspaceId(workspaceId, client: client) | ||||||
| var context: [String: String] = [ | ||||||
| "session_name": "cmux", | ||||||
| "session_attached": "1", | ||||||
| "session_id": "@\(canonicalWorkspaceId)", | ||||||
| "session_index": "", | ||||||
| "client_name": "cmux", | ||||||
| "client_attached": "1", | ||||||
| "client_tty": "", | ||||||
| "window_id": "@\(canonicalWorkspaceId)", | ||||||
| "window_uuid": canonicalWorkspaceId | ||||||
| ] | ||||||
|
|
@@ -11588,6 +11596,8 @@ struct CMUXCLI { | |||||
| }) { | ||||||
| if let index = intFromAny(workspace["index"]) { | ||||||
| context["window_index"] = String(index) | ||||||
| context["session_index"] = String(index) | ||||||
| context["session_id"] = "$\(index)" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||||||
| } | ||||||
| let title = ((workspace["title"] as? String) ?? "").trimmingCharacters(in: .whitespacesAndNewlines) | ||||||
| if !title.isEmpty { | ||||||
|
|
@@ -13229,6 +13239,16 @@ struct CMUXCLI { | |||||
| print(tmuxRenderFormat(parsed.value("-F"), context: context, fallback: fallback)) | ||||||
| } | ||||||
|
|
||||||
| case "list-clients", "list-sessions": | ||||||
| try runTmuxCompatCommand( | ||||||
| command: command, | ||||||
| commandArgs: rawArgs, | ||||||
| client: client, | ||||||
| jsonOutput: jsonOutput, | ||||||
| idFormat: idFormat, | ||||||
| windowOverride: windowOverride | ||||||
| ) | ||||||
|
|
||||||
| case "rename-window", "renamew": | ||||||
| let parsed = try parseTmuxArguments(rawArgs, valueFlags: ["-t"], boolFlags: []) | ||||||
| let title = parsed.positional.joined(separator: " ").trimmingCharacters(in: .whitespacesAndNewlines) | ||||||
|
|
@@ -13939,6 +13959,42 @@ struct CMUXCLI { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| case "list-clients": | ||||||
| let parsed = try parseTmuxArguments(commandArgs, valueFlags: ["-F", "-t"], boolFlags: []) | ||||||
| let workspaceId = try { | ||||||
| if let target = parsed.value("-t") { | ||||||
| return try tmuxResolveWorkspaceTarget(target, client: client) | ||||||
| } | ||||||
| if let windowOverride { | ||||||
| return try resolveWorkspaceId(windowOverride, client: client) | ||||||
| } | ||||||
| return try resolveWorkspaceId(nil, client: client) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||||||
| }() | ||||||
| let context = try tmuxFormatContext(workspaceId: workspaceId, client: client) | ||||||
| let fallback = [ | ||||||
| context["client_name"] ?? "cmux", | ||||||
| context["session_name"] ?? "cmux", | ||||||
| context["client_attached"] ?? "1" | ||||||
| ].joined(separator: "|") | ||||||
| print(tmuxRenderFormat(parsed.value("-F"), context: context, fallback: fallback)) | ||||||
|
|
||||||
| case "list-sessions": | ||||||
| let parsed = try parseTmuxArguments(commandArgs, valueFlags: ["-F", "-t"], boolFlags: []) | ||||||
| let targetWorkspaceId: String? = try { | ||||||
| if let target = parsed.value("-t") { | ||||||
| return try tmuxResolveWorkspaceTarget(target, client: client) | ||||||
| } | ||||||
| return nil | ||||||
| }() | ||||||
| let workspaceItems = try tmuxWorkspaceItems(client: client) | ||||||
| for item in workspaceItems { | ||||||
| guard let workspaceId = item["id"] as? String else { continue } | ||||||
| if let targetWorkspaceId, workspaceId != targetWorkspaceId { continue } | ||||||
| let context = try tmuxFormatContext(workspaceId: workspaceId, client: client) | ||||||
| let fallback = context["session_name"] ?? context["window_name"] ?? workspaceId | ||||||
| print(tmuxRenderFormat(parsed.value("-F"), context: context, fallback: fallback)) | ||||||
| } | ||||||
|
|
||||||
|
Comment on lines
+13983
to
+13997
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
| case "paste-buffer": | ||||||
| let workspaceArg = workspaceFromArgsOrEnv(commandArgs, windowOverride: windowOverride) | ||||||
| let surfaceArg = optionValue(commandArgs, name: "--surface") | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
session_idfallback valuesession_idis initialized to"@\(canonicalWorkspaceId)"— the@sigil is tmux's window-ID prefix, not a session-ID prefix (which uses$). When no matching workspace is found inworkspaceItems(so theif let indexbranch never executes), the context emits a malformed session ID. Callers that parse#{session_id}and validate the sigil — including omx's session-attached check — will fail silently.