Skip to content

Commit 811d4ab

Browse files
committed
refac
1 parent c4f47b2 commit 811d4ab

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

open_terminal/env.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ def _resolve_file_env(var: str, default: str = "") -> str:
161161
config.get("info", ""),
162162
)
163163

164+
FILE_BROWSER_ROOT = os.environ.get(
165+
"OPEN_TERMINAL_FILE_BROWSER_ROOT",
166+
config.get("file_browser_root", "home"),
167+
).strip().lower()
168+
164169
# How long (in seconds) to keep per-session cwd entries in memory.
165170
# Sliding window — refreshed on every access.
166171
SESSION_CWD_TTL: float = float(
@@ -170,4 +175,3 @@ def _resolve_file_env(var: str, default: str = "") -> str:
170175
)
171176
)
172177

173-

open_terminal/main.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
2525
from pydantic import BaseModel, Field
2626

27-
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
27+
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
2828
from open_terminal.utils.runner import PipeRunner, ProcessRunner, create_runner
2929
from open_terminal.utils.fs import UserFS
3030

@@ -441,14 +441,16 @@ async def get_cwd(
441441
fs: UserFS = Depends(get_filesystem),
442442
):
443443
session_id = http_request.headers.get("x-session-id")
444-
return {
444+
response = {
445445
"cwd": _get_session_cwd(session_id, fs),
446446
"home": fs.home,
447-
"root": {
447+
}
448+
if FILE_BROWSER_ROOT != "filesystem":
449+
response["root"] = {
448450
"path": fs.home,
449451
"label": "Home",
450-
},
451-
}
452+
}
453+
return response
452454

453455

454456
@app.post(

0 commit comments

Comments
 (0)