Commit Graph

118 Commits

Author SHA1 Message Date
Brian Krabach d897c05c61 feat: add device-badge, group-header, filter-bar, and sidebar-device-header CSS classes 2026-03-30 23:29:30 -07:00
Brian Krabach 4ed8303b6e feat: update getVisibleSessions to only hide local sessions by name
- Replace getVisibleSessions filter logic: only hide sessions where
  sourceUrl is empty/absent AND name matches hidden_sessions list
- Remote sessions with the same name as a hidden local session now
  remain visible (task-7 spec requirement)
- Export getVisibleSessions in module.exports so tests can access it

Tests added:
- 'getVisibleSessions exported and filters hidden sessions': verifies
  export and that local hidden sessions are filtered
- 'getVisibleSessions hides local sessions by name but not remote
  sessions with same name': verifies remote sessions survive

All 155 tests pass.
2026-03-30 23:22:55 -07:00
Brian Krabach 48e87af3f8 feat: wire buildSources into loadServerSettings startup
After fetching /api/settings and caching in _serverSettings,
call _sources = buildSources(_serverSettings) so the polling
layer immediately knows which sources to query.

Implements task-6 of multi-device federation phase 1.
2026-03-30 23:14:48 -07:00
Brian Krabach e95a8d4282 refactor: improve pollSessions error handling and test coverage 2026-03-30 23:09:08 -07:00
Brian Krabach e7ed300b37 feat: rewrite pollSessions for multi-source parallel polling (task-5) 2026-03-30 22:59:08 -07:00
Brian Krabach 593f1639db style: align tagSessions and mergeSources with ES6 file conventions 2026-03-30 22:52:36 -07:00
Brian Krabach 55f9597e1a feat: add tagSessions and mergeSources for multi-source parallel polling
These two functions enable multi-source session federation:
- tagSessions(sessions, deviceName, sourceUrl): tags each session with
  deviceName, sourceUrl, and sessionKey (format: sourceUrl::name),
  returns new objects without mutating originals
- mergeSources(results): takes [{source, sessions}] objects, tags each
  source's sessions and concatenates into a single flat array

Both functions are exported in module.exports.
6 new tests added covering all specified behaviors.
2026-03-30 22:42:55 -07:00
Brian Krabach 07c61a0baf style: expand test-only helper bodies to match section formatting 2026-03-30 22:37:08 -07:00
Brian Krabach 844311b475 feat: add federation state globals and test-only helpers to app.js
Add new module-level globals:
- let _gridViewMode = 'flat'
- let _activeFilterDevice = 'all'

Add test-only helper functions:
- _setSources(sources): sets internal _sources array
- _setServerSettings(settings): sets internal _serverSettings
- _getGridViewMode(): returns current _gridViewMode value
- _getSources(): returns current _sources array

All 4 helpers exported in module.exports.

Tests added (all passing, 143/143):
- '_setSources sets internal _sources array'
- '_setServerSettings sets internal _serverSettings'
- '_getGridViewMode returns current _gridViewMode value'
- '_getSources returns current _sources array'

Task: task-3 (federation state helpers)
2026-03-30 22:29:30 -07:00
Brian Krabach 8c0675157a feat: three dashboard view modes — Auto, Fit, Compact
Auto: current behavior (auto-fill grid, fixed tile height, scrollable).
Fit: calculates cols × rows to fill viewport exactly, zero scroll.
Compact: 80px tiles, high density, auto-fill with 200px min-width.

Toggle button (▦) in overview header cycles modes. Fit recalculates
on window resize. View mode persisted in localStorage alongside other
display settings (viewMode: 'auto' default in DISPLAY_DEFAULTS).

- CSS: .session-grid--fit and .session-grid--compact modifiers
- JS: VIEW_MODES, cycleViewMode(), applyFitLayout() functions
- HTML: #view-mode-btn between + and ⚙ in overview header
- Tests: 8 new JS tests, 3 CSS tests, 1 HTML test all passing
2026-03-30 22:22:59 -07:00
Brian Krabach ecf57441cf feat: add buildSources to construct session source list from settings
🤖 Generated with Amplifier

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
2026-03-30 22:21:45 -07:00
Brian Krabach 93c5170581 feat: refactor api() to accept optional baseUrl for cross-origin requests
Add 4th parameter `baseUrl` to `api()`. When provided, strips trailing
slash and prepends to path, and sets `credentials: 'include'` for
cross-origin cookie sending. Behavior is unchanged when no baseUrl is
given (backward compatible). Export `api` in module.exports.

All 135 tests pass.

🤖 Generated with Amplifier <https://github.com/microsoft/amplifier>

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
2026-03-30 22:12:57 -07:00
Brian Krabach 3a102ba9d8 fix: add 18px font option, click-outside-dialog to dismiss settings
Added 18px to font size select. Dialog click handler checks
e.target === settingsDialog (click landed on ::backdrop area,
not dialog content) and closes settings.
2026-03-30 22:07:38 -07:00
Brian Krabach 70da8dad38 fix: don't clear bells when browser tab is hidden
sendHeartbeat() always reported _viewingSession even when the user
switched to another browser tab. The server saw 'device is watching
session X' and cleared bells immediately. Fix: use Page Visibility API
(document.hidden) to send viewing_session=null when the tab is in the
background. Bells accumulate correctly, favicon badge shows activity,
and indicators appear in the dashboard/sidebar. When the user switches
back to the muxplex tab, the next heartbeat restores the real session.
2026-03-30 19:03:27 -07:00
Brian Krabach 79576bcbfe feat: customizable delete session command template
Symmetric with create template. Default: 'tmux kill-session -t {name}'.
Configurable in Settings → Commands tab (renamed from 'New Session').
DELETE /api/sessions/{name} reads template from settings, substitutes
{name}, runs synchronously via subprocess.run with 30s timeout.

Enables custom teardown workflows like:
  amplifier-dev ~/dev/{name} --destroy

Changes:
- settings.py: add delete_session_template to DEFAULT_SETTINGS
- main.py: DELETE endpoint uses subprocess.run + template instead of run_tmux
- index.html: add delete template textarea + reset btn; rename tab to Commands
- app.js: DELETE_SESSION_DEFAULT_TEMPLATE constant, openSettings loads it,
  bindStaticEventListeners wires input/reset; constant exported

Tests added:
- test_settings.py: 3 tests for default, load, and patch of delete_session_template
- test_api.py: 2 tests for custom/default template substitution via subprocess mock;
  update existing test_delete_session_calls_kill_session to match new implementation
- test_frontend_html.py: 5 tests for textarea, placeholder, rows, reset btn, tab label
- test_app.mjs: 5 tests for constant definition, value, and wiring in openSettings/bindStaticEventListeners
2026-03-30 17:17:34 -07:00
Brian Krabach b448f120c5 feat: dynamic favicon badge — amber dot overlay when sessions have unseen bells 2026-03-30 08:06:34 -07:00
Brian Krabach e6add00f0d feat: loading placeholder tile while new session is being created
- Inject .tile--loading skeleton tile into #session-grid immediately after
  POST /api/sessions succeeds, giving instant visual feedback while the
  backend creates the tmux session (which may take several seconds)
- Remove the placeholder when the poll finds the session or on timeout
- Add shimmer animation via @keyframes shimmer to style.css
- Tile placed after original .tile-body pre rule to avoid selector-substring
  match in _extract_rule_block CSS tests
2026-03-30 07:39:18 -07:00
Brian Krabach b38c87185a fix: settings dialog always visible — display:flex overrode native <dialog> hidden state
<dialog> is hidden by default via UA stylesheet (display:none). Our CSS
set display:flex unconditionally, overriding the UA rule and making the
dialog always visible. Fix: only apply display:flex when the dialog has
the [open] attribute (added by showModal()).
2026-03-30 07:14:24 -07:00
Brian Krabach d1c245a2c3 test: remove 26 stale command palette tests (palette was removed in Phase 1) 2026-03-30 03:45:42 -07:00
Brian Krabach 17616166bc feat: kill session — DELETE endpoint, hover × button with confirmation 2026-03-30 03:35:39 -07:00
Brian Krabach ffa8167c8f fix: new session poll-until-ready before auto-opening 2026-03-30 03:30:16 -07:00
Brian Krabach 424a4f5377 fix: settings modal dismiss — add close button, fix backdrop click 2026-03-30 03:27:47 -07:00
Brian Krabach bac23f26dc fix: apply getVisibleSessions filter in renderSheetList for mobile bottom sheet
Hidden sessions were still appearing in the mobile bottom-sheet session
switcher because renderSheetList() read _currentSessions directly,
bypassing the getVisibleSessions() helper used by renderGrid() and
renderSidebar().

- app.js: sortByPriority now receives getVisibleSessions(_currentSessions)
  instead of _currentSessions directly in renderSheetList()
- test_frontend_js.py: add test_render_sheet_list_filters_hidden_sessions
  to assert getVisibleSessions is called in renderSheetList body

Completes consistent hidden-sessions filtering across all three render
paths (grid, sidebar, mobile bottom sheet).

Co-authored-by: Amplifier <amplifier@amplified.dev>
2026-03-30 02:49:41 -07:00
Brian Krabach 851036bac0 refactor: code quality improvements for task-7 settings effects
- Extract getVisibleSessions() helper to consolidate hidden-session
  filter used by renderGrid() and renderSidebar() (DRY reduction)
- Add comment to terminal.js magic literal 600 noting it matches
  MOBILE_THRESHOLD in app.js
- Move TERMINAL_JS_PATH and _TERMINAL_JS module fixtures to the top
  of the test file alongside JS_PATH and _JS for consistency
- Strengthen test_render_grid_uses_visible_for_empty_state_check to
  assert visible.length specifically, distinguishing it from
  test_render_grid_creates_visible_array
- Update renderGrid/renderSidebar filter tests to assert getVisibleSessions()
  call; add test_get_visible_sessions_filters_hidden_sessions to cover
  the extracted helper directly
2026-03-30 02:28:54 -07:00
Brian Krabach 142c68d644 feat: apply settings effects — font size, grid columns, hidden sessions, sort order
- terminal.js createTerminal(): read fontSize from localStorage 'muxplex.display',
  default 14, apply Math.min(storedFontSize, 12) mobile cap
- app.js renderGrid(): filter hidden sessions via _serverSettings.hidden_sessions,
  create visible array, apply alphabetical sort via localeCompare when sort_order is
  'alphabetical'; 'recent'/'manual' use server-provided order
- app.js renderSidebar(): apply same hidden sessions filter, use visible array
- app.js DOMContentLoaded: call loadServerSettings() after startPolling() in restoreState().then()
- tests: 13 new tests in test_frontend_js.py covering all spec requirements

Co-authored-by: Amplifier <amplifier@example.com>
2026-03-30 02:16:45 -07:00
Brian Krabach 1af141a294 docs: fix orphaned JSDoc — move showNewSessionInput comment above its function 2026-03-30 02:07:15 -07:00
Brian Krabach 5b971a0ecc refactor: apply code quality suggestions from task-6-mobile-fab review
Three suggestions from the code review applied:

1. Extract _createSessionInput() factory to eliminate five-line
   duplication between showNewSessionInput and showFabSessionInput.
   Both functions now call the shared factory. Updated 4 existing
   tests to check _createSessionInput's body; added 7 new tests
   covering factory behavior and factory usage in each consumer.

2. Fix .new-session-fab:focus-visible outline color from var(--accent)
   to var(--bg) — the FAB background is already var(--accent), so
   using the same color for the outline created zero contrast.
   Added 1 new test to guard this going forward.

3. Add early-return guard in showFabSessionInput against duplicate
   overlays: if (document.querySelector('.fab-input-overlay')) return;
   Prevents a second overlay being created if called programmatically
   while one is already open. Added 1 new test.

532 tests pass (9 new tests added, 523 unchanged).
2026-03-30 02:00:22 -07:00
Brian Krabach 9978544dc1 fix: use fixed-position overlay for FAB session input (mobile visibility) 2026-03-30 01:45:51 -07:00
Brian Krabach dbb8b2bd73 feat: add mobile FAB for new session creation 2026-03-30 01:34:31 -07:00
Brian Krabach d76042560a feat: add sidebar + New sticky footer with inline input
- Add div.sidebar-footer with button#sidebar-new-session-btn.sidebar-new-btn
  ('+ New') to #session-sidebar in index.html, positioned after #sidebar-list
- Add CSS for .sidebar-footer (padding: 8px, border-top, flex-shrink: 0)
- Add CSS for .sidebar-new-btn (width: 100%, dashed border, dim text, hover
  effects with muted text and border color)
- Bind #sidebar-new-session-btn click to showNewSessionInput() in
  bindStaticEventListeners()
- Add 15 tests covering HTML structure, CSS rules, and JS binding

🤖 Co-authored-by: Amplifier <amplifier@example.com>
2026-03-30 01:23:37 -07:00
Brian Krabach 84fb7826d7 feat: add header + button with inline name input for session creation
- Add showNewSessionInput(btn): creates inline text input with class
  'new-session-input', placeholder 'Session name…', autocomplete off,
  spellcheck false; hides button, inserts input before it, focuses it.
  Handles Enter (create), Escape (cancel), and blur (150ms delayed cleanup).
- Add createNewSession(name): POSTs to /api/sessions, shows toast with
  created session name, calls pollSessions(), and if ss.auto_open_created
  !== false calls openSession(data.name) after 500ms delay.
- Bind #new-session-btn click to showNewSessionInput in bindStaticEventListeners.
- Export showNewSessionInput and createNewSession from module.exports.
- Add .new-session-input CSS (bg, border 1px solid accent, border-radius 4px,
  font-size 13px, font-ui, padding 4px 10px, width 180px, outline none) and
  ::placeholder { color: var(--text-dim) } in style.css.
- Add 28 new tests covering all spec requirements (19 JS structural, 9 CSS).
2026-03-30 01:08:19 -07:00
Brian Krabach 5f81b87348 feat: add New Session settings tab with template textarea 2026-03-30 01:03:54 -07:00
Brian Krabach 2e86692c3c fix: add null guard to _updateNotificationUI and .catch() to requestPermission
- _updateNotificationUI: add guard 'if (!statusEl || !reqBtn) return;' so
  future call sites without explicit null checks cannot throw TypeError
- Notification.requestPermission(): add .catch(console.error) for defensive
  error handling — promise always resolves in practice but unhandled rejections
  would be silently swallowed
- Tests: add test_update_notification_ui_has_null_guard and
  test_bind_static_event_listeners_permission_btn_has_catch to enforce both

435 tests pass (2 new)

Co-authored-by: Amplifier <amplifier@amp.dev>
2026-03-30 00:35:21 -07:00
Brian Krabach e5827a8037 refactor: extract _updateNotificationUI helper, use const, fix double query
- Extract shared _updateNotificationUI(statusEl, reqBtn, permission) helper
  to remove duplicated notification status UI update logic from openSettings
  and the requestPermission click handler
- Replace var with const for local bindings in new Notifications handlers
- Use this.checked in bell sound change handler instead of re-querying
  the DOM element that was already looked up for addEventListener
2026-03-30 00:29:38 -07:00
Brian Krabach 2f909eae89 feat: add Notifications settings tab 2026-03-30 00:18:05 -07:00
Brian Krabach c955aadad1 feat: add Sessions settings tab with server-side persistence 2026-03-29 23:57:22 -07:00
Brian Krabach f380307f08 fix: rename data-panel to data-tab on settings panels to match switchSettingsTab()
switchSettingsTab() in app.js reads panel.dataset.tab (data-tab attribute).
The four .settings-panel elements in index.html were using data-panel instead,
causing all panels to get hidden on every tab click — the settings dialog rendered
as a blank content area after any tab interaction.

Fix: Change data-panel="..." to data-tab="..." on all four panel divs.

Tests added:
- test_html_settings_panels_use_data_tab: verifies each .settings-panel uses
  data-tab and not data-panel
- test_html_settings_tab_panel_data_tab_alignment: cross-checks that every tab
  button data-tab value has a matching .settings-panel data-tab value, preventing
  this class of HTML/JS attribute mismatch from recurring
2026-03-29 23:47:59 -07:00
Brian Krabach fd4e91bc51 feat: wire Display tab — font size, hover delay, grid columns with immediate apply 2026-03-29 23:28:12 -07:00
Brian Krabach bb21ce7aa9 style: reformat DISPLAY_DEFAULTS to multi-line, simplify switchSettingsTab panel lookup 2026-03-29 23:21:48 -07:00
Brian Krabach 1eec617cb9 feat: add settings dialog open/close, tab switching, localStorage management 2026-03-29 23:16:19 -07:00
Brian Krabach b20759c6cb feat: add settings dialog HTML structure and CSS 2026-03-29 23:04:11 -07:00
Brian Krabach 8e4f17068d refactor: remove command palette JavaScript 2026-03-29 22:28:20 -07:00
Brian Krabach a971cb9bbd refactor: remove orphaned command palette HTML remnants from index.html 2026-03-29 22:16:03 -07:00
Brian Krabach 80dc082df0 refactor: remove command palette HTML and CSS 2026-03-29 22:12:07 -07:00
Brian Krabach e4efadddf4 fix: remove gradient fades, fix sidebar active indicator full-height
Remove tile-body::before and sidebar-item-body::before gradient overlays
that obscured ANSI colors at the bottom of previews. Replace box-shadow
inset with border-left on sidebar-item--active so the cyan accent stripe
spans the full item height (was only showing on the header).
2026-03-29 19:41:49 -07:00
Brian Krabach 583de6ec2d feat: match preview styling to xterm.js — palette, background, font, line-height
ANSI_COLORS: replaced with xterm.js default GTK/Tango palette.
Background: #000000 on tile-body, sidebar-item-body, preview-popover.
Font: 'SF Mono', 'Fira Code', Consolas, monospace (same as terminal).
Line-height: 1.0 across all preview surfaces (xterm.js default).
Gradient overlays: fade to #000 instead of theme bg.
Result: previews are visually indistinguishable from the terminal.
2026-03-29 19:19:05 -07:00
Brian Krabach 85298abdcc fix: match tile + sidebar preview text color to xterm.js foreground (#c9d1d9) 2026-03-29 18:59:44 -07:00
Brian Krabach 71fdd544b2 fix: match preview text color to xterm.js foreground (#c9d1d9) 2026-03-29 18:48:51 -07:00
Brian Krabach bf76affef2 refactor: remove dimmer overlay, add cyan border to preview popover
ANSI colors make the overlay content readable without dimming. Removed
preview-dimmer, liftHoveredTile(), tile--previewing/item--previewing —
all dead code now. Added var(--accent) 2px border to .preview-popover
for visual separation.
2026-03-29 18:44:55 -07:00
Brian Krabach b3b2165524 feat: ANSI color rendering in preview snapshots
Server: add -e flag to tmux capture-pane to preserve escape sequences.
Frontend: ansiToHtml() parser converts SGR codes (bold, italic, dim,
16-color, 256-color) to <span> tags with inline styles. Applied to
dashboard tiles, sidebar items, and hover overlay. No external deps.
2026-03-29 18:24:15 -07:00