This commit is contained in:
Timothy Jaeryang Baek 2026-06-22 16:56:50 +02:00
parent c4f47b2776
commit 811d4abc18
2 changed files with 12 additions and 6 deletions

View file

@ -161,6 +161,11 @@ OPEN_TERMINAL_INFO = os.environ.get(
config.get("info", ""),
)
FILE_BROWSER_ROOT = os.environ.get(
"OPEN_TERMINAL_FILE_BROWSER_ROOT",
config.get("file_browser_root", "home"),
).strip().lower()
# How long (in seconds) to keep per-session cwd entries in memory.
# Sliding window — refreshed on every access.
SESSION_CWD_TTL: float = float(
@ -170,4 +175,3 @@ SESSION_CWD_TTL: float = float(
)
)

View file

@ -24,7 +24,7 @@ from fastapi.responses import JSONResponse, Response
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from pydantic import BaseModel, Field
from open_terminal.env import API_KEY, BINARY_FILE_MIME_PREFIXES, CORS_ALLOWED_ORIGINS, ENABLE_NOTEBOOKS, ENABLE_SYSTEM_PROMPT, ENABLE_TERMINAL, EXECUTE_DESCRIPTION, EXECUTE_TIMEOUT, LOG_DIR, MAX_TERMINAL_SESSIONS, MULTI_USER, OPEN_TERMINAL_INFO, PROCESS_LOG_RETENTION, SESSION_CWD_TTL, SYSTEM_PROMPT, TERMINAL_TERM
from open_terminal.env import API_KEY, BINARY_FILE_MIME_PREFIXES, CORS_ALLOWED_ORIGINS, ENABLE_NOTEBOOKS, ENABLE_SYSTEM_PROMPT, ENABLE_TERMINAL, EXECUTE_DESCRIPTION, EXECUTE_TIMEOUT, FILE_BROWSER_ROOT, LOG_DIR, MAX_TERMINAL_SESSIONS, MULTI_USER, OPEN_TERMINAL_INFO, PROCESS_LOG_RETENTION, SESSION_CWD_TTL, SYSTEM_PROMPT, TERMINAL_TERM
from open_terminal.utils.runner import PipeRunner, ProcessRunner, create_runner
from open_terminal.utils.fs import UserFS
@ -441,14 +441,16 @@ async def get_cwd(
fs: UserFS = Depends(get_filesystem),
):
session_id = http_request.headers.get("x-session-id")
return {
response = {
"cwd": _get_session_cwd(session_id, fs),
"home": fs.home,
"root": {
}
if FILE_BROWSER_ROOT != "filesystem":
response["root"] = {
"path": fs.home,
"label": "Home",
},
}
}
return response
@app.post(