fix(ssh): remove remote mcp config via trap when the tile kills ssh
This commit is contained in:
@@ -336,10 +336,11 @@ public sealed class InteractiveLaunchSpecService
|
||||
|
||||
// No double quotes anywhere: ConPTY flattens Args into one Windows command line.
|
||||
// ssh runs a non-interactive shell whose .bashrc bails early, so the native installer's ~/.local/bin is added by hand.
|
||||
// Closing the tile kills ssh → remote shell gets SIGHUP; a trailing "; rm -f" never runs, the trap does.
|
||||
var remote =
|
||||
$"export PATH=$HOME/.local/bin:$PATH && umask 077 && mkdir -p ~/.claudedo && echo {b64} | base64 -d > {cfgFile}" +
|
||||
$"export PATH=$HOME/.local/bin:$PATH && trap 'rm -f {cfgFile}' EXIT HUP TERM && umask 077 && mkdir -p ~/.claudedo && echo {b64} | base64 -d > {cfgFile}" +
|
||||
$" && cd {SshWorkspace.QuoteRemotePath(ws.RemotePath)}" +
|
||||
$" && MCP_TOOL_TIMEOUT={McpToolTimeoutMs} claude --mcp-config {cfgFile}; rm -f {cfgFile}";
|
||||
$" && MCP_TOOL_TIMEOUT={McpToolTimeoutMs} claude --mcp-config {cfgFile}";
|
||||
|
||||
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||
return new LaunchSpec(home, ssh,
|
||||
|
||||
@@ -1692,7 +1692,7 @@ public sealed class InteractiveLaunchSpecServiceTests : IDisposable
|
||||
Assert.StartsWith("export PATH=$HOME/.local/bin:$PATH && ", remote);
|
||||
Assert.Contains("cd ~/'app'", remote);
|
||||
Assert.Contains($"MCP_TOOL_TIMEOUT={InteractiveLaunchSpecService.McpToolTimeoutMs} claude --mcp-config ~/.claudedo/mcp-{paneId}.json", remote);
|
||||
Assert.EndsWith($"rm -f ~/.claudedo/mcp-{paneId}.json", remote);
|
||||
Assert.Contains($"trap 'rm -f ~/.claudedo/mcp-{paneId}.json' EXIT HUP TERM && ", remote);
|
||||
|
||||
var b64 = System.Text.RegularExpressions.Regex.Match(remote, @"echo ([A-Za-z0-9+/=]+) \| base64 -d").Groups[1].Value;
|
||||
using var json = System.Text.Json.JsonDocument.Parse(Convert.FromBase64String(b64));
|
||||
|
||||
Reference in New Issue
Block a user