fix: terminal 4004 infinite reconnect loop for pi-agent tool type
- Add stdin_open: true and tty: true to dockerfile-based compose generation. Without these, bash (PID 1) exits immediately, causing a container restart loop that makes the instance invisible to docker ps and triggers 4004. - Treat WebSocket close codes 4001/4003/4004 as permanent errors in the frontend. Stop retrying and show the server reason to the user. - Prevent visibilitychange handler from resetting retry attempts after a permanent error has occurred. - Use docker ps -a in get_container_id/get_container_name to find stopped/exited containers for diagnostics. Quality gates: tsc --noEmit (pass), pytest (98 passed, 4 pre-existing failures)
This commit is contained in:
@@ -659,6 +659,8 @@ services:
|
||||
app:
|
||||
image: {image_tag}
|
||||
container_name: {instance_name.lower()}
|
||||
stdin_open: true
|
||||
tty: true
|
||||
{ports_section} volumes:
|
||||
- {repo_path}:/workspace
|
||||
restart: unless-stopped
|
||||
|
||||
@@ -136,6 +136,8 @@ def execute_compose_command(
|
||||
def get_container_id(instance_name: str) -> str | None:
|
||||
"""Get the container ID for a compose service.
|
||||
|
||||
Searches all containers including stopped/exited ones.
|
||||
|
||||
Args:
|
||||
instance_name: The service name in compose
|
||||
|
||||
@@ -143,7 +145,7 @@ def get_container_id(instance_name: str) -> str | None:
|
||||
Container ID or None if not found
|
||||
"""
|
||||
result = subprocess.run(
|
||||
["docker", "ps", "-q", "--filter", f"name={instance_name}"],
|
||||
["docker", "ps", "-a", "-q", "--filter", f"name={instance_name}"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
@@ -156,6 +158,8 @@ def get_container_id(instance_name: str) -> str | None:
|
||||
def get_container_name(instance_name: str) -> str | None:
|
||||
"""Get the full container name for a compose service.
|
||||
|
||||
Searches all containers including stopped/exited ones.
|
||||
|
||||
Args:
|
||||
instance_name: The service name in compose
|
||||
|
||||
@@ -163,7 +167,7 @@ def get_container_name(instance_name: str) -> str | None:
|
||||
Container name or None if not found
|
||||
"""
|
||||
result = subprocess.run(
|
||||
["docker", "ps", "--format", "{{.Names}}", "--filter", f"name={instance_name}"],
|
||||
["docker", "ps", "-a", "--format", "{{.Names}}", "--filter", f"name={instance_name}"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user