Commit Graph

42 Commits

Author SHA1 Message Date
swanadiva 408681c8e4 feat: Phase 2 UX Polish — theme system, config profiles, error banner, tests
- Add Theme struct with 3 predefined themes (dark/light/druntime)
- Add Profile struct for named configuration profiles
- Add ErrorBanner with severity levels and auto-dismiss
- Add unit tests for theme, error banner, and models
- Update CHANGELOG.md and PROJECT_STATE.md
2026-06-29 11:50:46 +07:00
swanadiva 93957e3989 feat: auto-detect encrypted files + CLI --password flag
- Storage.IsDataEncrypted() checks if hosts.json is encrypted
- TUI auto-detects encrypted files, prompts password automatically
- Root command: --password flag for all CLI commands
- newStorage() helper applies password flag to storage
- add/list/edit/delete commands now support encrypted storage
- passwordSetMsg loads hosts after password is set
2026-06-25 14:34:41 +07:00
swanadiva 94f2142d3d feat: encryption password prompt + --encrypt flag
- PasswordPromptTab: setup/unlock modes, password + confirm fields
- --encrypt flag: shows password prompt on TUI startup
- Model.ShowEncryptPrompt() triggers prompt on first render
- passwordSetMsg stores password in Model.storagePassword
- Tab interface: added Close() method to PasswordPromptTab
2026-06-25 13:38:59 +07:00
swanadiva 1d2e29d20a feat: integrate security features into TUI
- SFTPBrowserTab: added storagePassword, passphraseCallback fields
- Model: added storagePassword, knownHosts fields
- cmd/hostkeeper/tui.go: initialize known_hosts on startup
- SFTP connect: wire passphrase callback to SSH client
- SetStoragePassword/SetKnownHosts/SetPassphraseCallback methods
2026-06-25 13:32:59 +07:00
swanadiva 611b794fc7 feat: Phase 2 Security Enhancement
- pkg/crypto: AES-256-GCM encryption with PBKDF2 key derivation
  - 100k iterations, 16-byte salt, SHA-256
  - Encrypt/Decrypt/IsEncrypted/HashPassword
- Storage layer encryption:
  - JSONStorage.SetPassword() enables transparent encrypt/decrypt
  - readJSON auto-decrypts, replace* auto-encrypts
- pkg/knownhosts: TOFU host key verification
  - Verify/Add/Remove host keys
  - HostKeyCallback for SSH config
- SSH client security:
  - SetHostKeyCallback() replaces InsecureIgnoreHostKey()
  - SetPassphraseCallback() for encrypted private keys
  - getKeySigner() tries passphrase on encrypted keys
- Models: AppConfig gains EncryptionEnabled, PasswordHash, KnownHostsFile
2026-06-25 13:28:46 +07:00
swanadiva a1cd3d5dc0 feat: SFTP rename files and directories
- M key enters rename mode with current name pre-filled
- Type new name, Enter to confirm, Esc to cancel
- renameItem: client.Rename() for remote, os.Rename() for local
- Clear cache + refresh after rename
- Footer updated: M:rename
- Filter mode allows M to pass through
2026-06-24 16:27:39 +07:00
swanadiva eb663c2634 fix: SFTP auto-refresh + filter mode + delete refresh
- Clear dirCache before refresh after transfer/delete/mkdir
- Cache was stale: old entries returned instead of fresh data
- Filter mode: allow commands (c,d,n,r) and nav (↑↓,Tab) to pass through
- Filter mode no longer blocks transfer/delete/mkdir/pane-switch
- Delete: clear cache + program.Send() for re-render
- Mkdir: clear cache + program.Send() for re-render
2026-06-24 16:19:56 +07:00
swanadiva 55b5c7b5a0 fix: SFTP auto-refresh after file transfer
- Added program *tea.Program to SFTPBrowserTab and Model
- SetProgram() allows goroutines to send messages to Bubble Tea
- After transfer: program.Send(sftpRefreshMsg{}) triggers re-render
- Model stores program reference, passes to SFTP tab on creation
2026-06-24 14:32:30 +07:00
swanadiva 6b95385094 feat: SFTP file transfer progress bar + auto-refresh
- Progress bar: [████████░░░░] 67% 12.3MB/18.5MB
- progressWriter wraps io.Writer, reports bytes via callback
- Footer shows live progress during upload/download
- Auto-refresh destination pane after transfer completes
- Success message shown for 1 second before clearing
2026-06-24 14:25:11 +07:00
swanadiva a597ea5291 fix: rename SFTP footer C:copy → C:transfer for clarity 2026-06-24 14:11:17 +07:00
swanadiva 8f1f2226f3 perf: SFTP directory listing cache
- Added dirCache map to sftpPane for caching directory listings
- Cache hit: instant navigation (no disk/network I/O)
- Cache miss: read from disk/SFTP, store in cache per path
- R key clears current directory cache and forces fresh read
- Significant speedup when navigating back to previously visited folders
2026-06-24 11:46:17 +07:00
swanadiva 25a53d990b fix: SFTP default to Local pane + fixed border height
- Default active pane changed from Remote to Local on SFTP init
- renderPane now takes maxH parameter for fixed border height
- paneStyle.Height(maxH) prevents border from shrinking/growing on scroll
- Stacked mode: maxH = t.height - 6; Side-by-side: t.height - 5
2026-06-24 11:30:54 +07:00
swanadiva 2e10308c75 fix: SFTP stacked mode — render only active pane + indicator bar
Stacked mode (<50 cols) now shows only the active pane (Local/Remote)
with a visual indicator bar. Tab switches between panes. Side-by-side
mode (>=50 cols) unchanged.
2026-06-24 11:22:21 +07:00
swanadiva ebd72cf16c fix: SFTP pane width — account for border in halfW calculation, fix innerW to maxW-2 (padding only), truncate filter line
Root cause: lipgloss Width(maxW) = content area inside border, border adds 2 chars extra.
- halfW was t.width/2, should be t.width/2-2 (reserve border per pane)
- innerW was maxW-4, should be maxW-2 (padding only, not border)
- Each pane total = maxW + 2 (content + border)
2026-06-23 19:22:58 +07:00
swanadiva 2cc9392e2b fix: SFTP pane truncation — use lipgloss.Width instead of len(), account for border+padding overhead, compact file listing on narrow panes 2026-06-23 19:15:21 +07:00
swanadiva d75621e9b4 feat: responsive TUI layout — mobile/tablet/desktop support
- NEW responsive.go: wrapFooter, adaptiveSidePad, clampWidth, truncateStr
- Footer auto-wraps to multi-line on narrow terminals (full labels preserved)
- Box width clamped to terminal width across all tabs
- Host/key/snippet rows truncated with ellipsis; compact format <35 cols
- SFTP panes stack vertically when terminal < 50 cols
- Tab bar truncates names on overflow
- Form contentW minimum lowered 50->30 for mobile
- Fixed: key_list_tab & snippet_list_tab dropped last data row (off-by-one bug)
2026-06-23 19:08:44 +07:00
swanadiva 7d41391e13 fix: Space/Left/Right passthrough in host form, key/snippet refresh on save/delete, WindowSize to all tabs, footer improvements 2026-06-23 18:48:50 +07:00
swanadiva 07899c154b fix: auto-generate ID+timestamps in storage layer on save 2026-06-23 18:18:10 +07:00
swanadiva 512cf5ce1f fix: add E:edit to footer, generate UUID+timestamps in TUI forms 2026-06-23 18:15:36 +07:00
swanadiva 9b27388455 fix(tui): center rows per-line, fix footers per-context 2026-06-23 18:04:11 +07:00
swanadiva e5d32bd22e fix(tui): unify keybinding footer, remove duplicate status bar 2026-06-23 17:45:06 +07:00
swanadiva f9b2337612 fix(tui): restore muted status bar, remove duplicate global keys from tab footers 2026-06-23 17:15:39 +07:00
swanadiva 7f197b9e3a fix(tui): center all tabs, full-screen SFTP, muted inline keybindings 2026-06-23 17:12:12 +07:00
swanadiva c7568e0bf4 feat: clear screen on SSH enter/exit, host list scrolling, 'e' edit key
- tea.Batch(tea.ClearScreen, sshConnectCmd) before SSH starts so TUI
  output doesn't bleed into SSH terminal
- tea.ClearScreen after SSH exits so SSH output doesn't ghost in TUI
- Host list now paginates: only (term_height - 8) / 5 cards shown,
  viewport follows selectedIndex with centered scrolling
- Shows 'N of M hosts' indicator when content is clipped
- Added 'e' key alias for editing host (Ctrl+E or E)
2026-06-23 16:04:38 +07:00
swanadiva 2442920616 feat: centered footer + auth type toggle pills
- Status bar footer centered within terminal width using lipgloss.Width
- Auth Type field replaced with toggle pills (password/key)
  Space/Enter/←/→ cycle between options on the focused field
  Selected type shown with SelectedStyle/TagStyle (green),
  inactive type shown in muted SubtitleStyle
  Help hint 'Space/←/→ to toggle' shown when focused
- Added toggleAuthType() and cycleAuthType() helpers
2026-06-23 15:59:54 +07:00
swanadiva 5b456104e8 fix: form tab input not responding to typing
Bug: t.inputs[t.focus].Update(msg) discarded the returned textinput.Model,
so typed characters were never stored in the input state.

Fix: capture both updated model and cmd from textinput.Update():
  t.inputs[t.focus], cmd = t.inputs[t.focus].Update(msg)
  return t, cmd

Same fix applied to all 3 forms (host, key, snippet).
Also moved ctrl+s out of default to its own case for clarity.
2026-06-23 15:53:32 +07:00
swanadiva daa20ac72b fix: sshCmd closure bug + error display
CRITICAL BUG: sshConnectCmd wrapped tea.ExecProcess inside an extra
closure, so Bubble Tea never executed the SSH process — Enter appeared
to do nothing.

Fix:
- sshConnectCmd now returns tea.ExecProcess directly (no extra closure)
- tea.ExecProcess handles all process lifecycle (start, PTY, exit)
- sshExitMsg errors are shown in host list view (ErrorStyle)
- Error routed via Model.Error → HostListTab.err → View()
2026-06-23 15:50:20 +07:00
swanadiva 79f3917a66 fix: cap vertical padding + horizontal centering per line
- 2 lines top padding instead of aggressive vertical centering
- centerText() uses lipgloss.Width for accurate ANSI-aware centering
- Each card line centered individually within terminal width
- Card width capped at 74 chars
2026-06-23 15:45:13 +07:00
swanadiva 53db03814e feat: centered card-style host list layout
- Each host rendered as a bordered card (HostCardStyle / HostCardActiveStyle)
- Title centered horizontally
- Content constrained to 80 columns max
- Vertical centering padding
- Selected host card gets green border (gbGreen #a9b665)
- Empty state message centered
- Removed old plain-text renderHost/renderSelectedHost functions
2026-06-23 15:42:03 +07:00
swanadiva c957a97cdb feat: dual-pane SFTP browser (local ↔ remote)
Phase B — Tamagosh-inspired dual-pane file browser:
- Left pane: local filesystem (starts at /Users/swanadiva)
- Right pane: remote filesystem via SFTP
- Tab key switches active pane (green border = active)
- Local CWD indicator per pane
- File listing with dir/ file size display
- Filter mode with / key
- Copy files: C key copies from active pane to opposite pane
- Delete (D), mkdir (N on remote), Refresh (R)
- Esc to close
- File size formatting (B/KiB/MiB/GiB)
- Progress message during transfers
- StylePaneActive (green border) / StylePaneInactive (muted border)
2026-06-23 15:38:48 +07:00
swanadiva 7b06793002 feat: native SSH delegation via tea.ExecProcess + Gruvbox palette
Phase A — Tamagosh-inspired redesign:
- Replace goroutine-based SSH (crypto/ssh) with tea.ExecProcess + native ssh binary
- Zero-lag SSH: native binary pegang TTY langsung, ga ada Go buffering
- Password auth via sshpass -e (SSHPASS env)
- Key auth via ssh -i <tmpfile> + SSH_ASKPASS for passphrase
- ControlMaster sockets for fast reconnect
- Add askpass subcommand for SSH_ASKPASS support
- Gruvbox Material Dark Hard palette for comfortable viewing
- Clean up old session messages (openSessionMsg, sessionOutputMsg, sessionDoneMsg)
- Remove 354-line session.go, replace with 150-line ssh.go
2026-06-23 15:36:40 +07:00
swanadiva 43858dda87 feat: TUI Key & Snippet Management - Task 19
- KeyListTab: view/add/edit/delete SSH keys (Ctrl+K from host list)
- KeyFormTab: add/edit key form with name, type, private key, passphrase
- SnippetListTab: view/add/edit/delete snippets (Ctrl+P from host list)
- SnippetFormTab: add/edit snippet form with name, command, description, tags
- Updated status bar with new hints
- Save/delete commands for both key pairs and snippets
2026-06-23 15:10:20 +07:00
swanadiva 94ec00c303 feat: TUI SFTP Browser Tab - Task 18
- SFTPBrowserTab with remote directory browsing
- Open via Ctrl+F from host list
- Navigate dirs, filter with /, refresh with r
- Dir/icon display with file sizes
- Sort dirs first, then by name
2026-06-23 15:08:22 +07:00
swanadiva 3dc482e353 feat: TUI Host Forms (add/edit) - Task 17
- HostFormTab with textinput fields for all host fields
- Add (Ctrl+N) and Edit (Ctrl+E) from host list
- Save to JSON storage, auto-reload on save
- Esc to cancel, navigable form with keyboard
2026-06-23 15:05:08 +07:00
swanadiva 809ac1d2e8 fix: session tab I/O — stdin direct write, pollSession triggers re-render 2026-06-23 14:59:48 +07:00
swanadiva 98dfc1c79c feat: Task 16 — SSH Session Tab (multi-session)
- pkg/tui/session.go — SessionTab with live SSH terminal in a tab
- pkg/tui/messages.go — quitMsg, openSessionMsg, sessionOutputMsg
- pkg/tui/tabs.go — Tab.Close() interface, Add() returns tea.Cmd
- pkg/tui/host_list_tab.go — Enter opens session tab, q quits
- pkg/tui/tui.go — handle openSessionMsg/quitMsg, SetDataDir
- cmd/hostkeeper/tui.go — pass dataDir to model
2026-06-23 14:54:44 +07:00
swanadiva 5d9e38f8db feat: Task 15 — TUI Tab Framework + Orange Theme
- pkg/tui/styles.go — orange theme palette and component styles
- pkg/tui/tabs.go — Tab interface + TabManager with add/close/next/prev
- pkg/tui/host_list_tab.go — HostListTab implementing Tab interface
- pkg/tui/tui.go — refactored to use TabManager (backward compatible)
- pkg/tui/host_list.go — removed (logic moved to host_list_tab.go)
- pkg/tui/tui_test.go — adapted + added TabManager tests
2026-06-23 14:51:13 +07:00
swanadiva b3878de9af feat: Go SSH interactive shell default, --native flag for system SSH 2026-06-23 14:26:58 +07:00
swanadiva fbe444c3ab feat: implement basic TUI framework with host list
- Add Bubble Tea TUI model with Init/Update/View
- Implement host list screen with keyboard navigation (up/down/enter/q)
- Add styled rendering for hosts, selection, tags
- Create hostkeeper tui CLI command
- Add tests for TUI initialization and host loading
- Update project state documentation
2026-06-23 13:54:49 +07:00
Swana Diva Borneos 4087c5fdc7 feat: add & list commands with deadlock fix
- Add 'add' command: register hosts via flags or interactive prompts
  Supports password/key/both auth, groups, tags, notes, port override
- Add 'list' command: display hosts with filtering and formatting
  Supports --group, --tag filters, --sort, table/json/wide output
- Fix deadlock bug in JSON storage (RLock within Lock)
  Introduced internal list functions that don't lock
  Affects: ListHosts/GetHost/SaveHost/DeleteHost + KeyPair + Snippet
- Add comprehensive tests for add and list commands
- Update PROJECT_STATE.md (Tasks 1-8 complete, ~55% done)
2026-06-23 10:56:04 +07:00
swanadiva 8ea4b6e990 feat: Implement SSH client with authentication support (Task 5)
- Add SSH client with Connect/Execute/Close/IsConnected
- Implement password, key, and both authentication methods
- Support default key discovery (~/.ssh/id_ed25519, id_rsa, etc.)
- Support passphrase-protected keys via ParsePrivateKeyWithPassphrase
- Path expansion for ~ in KeyID
- Integrate with HandleSSHError for user-friendly errors
- All 4 SSH tests passing + 5 error tests still passing (9 total)

Progress: Tasks 1-5 complete (~40%)
2026-06-22 16:16:16 +07:00
swanadiva 33947816b7 feat: complete Tasks 1-3 (setup, models+storage, config management)
- Task 1: Project setup (go.mod, Makefile, .gitignore, main.go)
- Task 2: Core data models (Host, KeyPair, Snippet, AppConfig) + JSON storage layer
- Task 3: Configuration management with cross-platform path support (macOS/Linux/Windows)
- Updated PROJECT_STATE.md with progress tracking
2026-06-22 16:09:02 +07:00