Skip to content

Commit 36d239d

Browse files
author
Rafael Teodoro
committed
Improve TUI authentication screen for easier JSON path input
Makes it much easier to upload credentials.json: Improvements: - 📂 Shows current working directory - 💡 Displays path examples (backend/credentials.json, ~/Documents/creds.json) - 🔘 'Use Default Path' button auto-fills backend/credentials.json - 🏠 Expands ~ to home directory automatically - ❌ Better error messages showing full path attempted Usage: 1. Click 'Use Default Path' button (auto-fills backend/credentials.json) 2. Or type any path (relative, absolute, or with ~) 3. Click 'Upload JSON' Examples that now work: - backend/credentials.json (relative) - ~/Documents/credentials.json (home dir) - /full/path/to/credentials.json (absolute)
1 parent a09cd8a commit 36d239d

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

tui.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,23 @@ class AuthenticationScreen(Screen):
199199
]
200200

201201
def compose(self) -> ComposeResult:
202+
import os
203+
cwd = os.getcwd()
204+
202205
with Vertical(id="auth-container"):
203206
yield Label("🔐 Authentication", classes="title")
207+
yield Label(f"Current directory: {cwd}", classes="subtitle")
204208

205209
with Vertical(classes="section"):
206210
yield Label("📄 Upload Credentials JSON:")
211+
yield Label("Examples: backend/credentials.json or ~/Documents/creds.json", classes="subtitle")
207212
yield Input(
208213
placeholder="Path to credentials.json file...",
209214
id="credentials-path"
210215
)
211-
yield Button("Upload JSON", id="upload-json-btn", variant="primary")
216+
with Horizontal():
217+
yield Button("Upload JSON", id="upload-json-btn", variant="primary")
218+
yield Button("Use Default Path", id="use-default-btn", variant="default")
212219

213220
with Vertical(classes="section"):
214221
yield Label("🔑 Or use Service Account:")
@@ -221,16 +228,28 @@ def compose(self) -> ComposeResult:
221228
yield Label("", id="auth-status")
222229
yield Button("Skip (for testing)", id="skip-btn", variant="default")
223230

231+
@on(Button.Pressed, "#use-default-btn")
232+
def use_default_path(self):
233+
"""Fill input with default credentials path"""
234+
path_input = self.query_one("#credentials-path", Input)
235+
path_input.value = "backend/credentials.json"
236+
self.notify("Default path filled! Press 'Upload JSON' to continue.")
237+
224238
@on(Button.Pressed, "#upload-json-btn")
225239
async def upload_json_credentials(self):
226240
"""Upload JSON credentials file"""
241+
import os
227242
status = self.query_one("#auth-status", Label)
228243
path_input = self.query_one("#credentials-path", Input)
229244

230-
path = Path(path_input.value.strip())
245+
# Expand ~ to home directory
246+
path_str = os.path.expanduser(path_input.value.strip())
247+
path = Path(path_str)
231248

232249
if not path.exists():
233-
status.update("❌ File not found!")
250+
# Show helpful error with full path attempted
251+
abs_path = path.resolve()
252+
status.update(f"❌ File not found: {abs_path}")
234253
return
235254

236255
try:

0 commit comments

Comments
 (0)