Commit Graph

67 Commits

Author SHA1 Message Date
GitHub Copilot 583ece5ce9 Remove textLength attribute - fixes cursor positioning issues
The textLength with lengthAdjust='spacing' approach was causing visual
positioning problems. While x coordinates were calculated correctly,
the browser's spacing adjustments shifted subsequent text visually,
causing cursor and text to appear offset.

Removed textLength entirely. Accepting slight visual gaps in horizontal
box-drawing lines is preferable to cursor misalignment.

Version bump to 0.3.10
2026-01-24 19:36:39 +00:00
GitHub Copilot b896464c81 Handle corrupted horizontal box chars with threshold-based detection
Changed _is_all_horizontal_box_drawing to _is_mostly_horizontal_box_drawing
with 80% threshold. This handles cases where terminal data has occasional
corrupted characters (like U+FFFD replacement chars) mixed in with
horizontal line characters.

Version bump to 0.3.9
2026-01-24 19:25:37 +00:00
GitHub Copilot d8d3885efb Fix horizontal box-drawing alignment with textLength attribute
Horizontal line characters (─━═) render narrower than the intended
character width in most fonts, causing gaps when followed by other
characters. Now using textLength + lengthAdjust='spacing' to force
horizontal box-drawing spans to occupy their correct width.

- Added _is_all_horizontal_box_drawing() helper
- Added textLength attribute for horizontal line spans > 1 char
- Added comprehensive tests for new functionality
- svg_exporter.py now has 100% test coverage

Version bump to 0.3.8
2026-01-24 19:19:08 +00:00
GitHub Copilot 076bf4cd5d Add SVG CSS: dominant-baseline and text-rendering for proper alignment
- Added dominant-baseline: text-before-edge for proper vertical text positioning
- Added text-rendering: optimizeLegibility for crisper text
- Simplified y-position calculation (top-aligned with baseline)
- Added tests for box drawing character detection helpers
- Added test for CSS properties
- Removed unreachable dead code paths (empty span checks)
- svg_exporter.py now has 100% test coverage

Version bump to 0.3.7
2026-01-24 19:14:28 +00:00
GitHub Copilot c032911c79 Allow horizontal box-drawing chars to merge, break only on vertical/corners
Horizontal lines (─━═) can merge since they form continuous lines.
Vertical lines (│┃║) and corners/junctions need separate x positioning
to align properly with adjacent characters.
2026-01-24 19:09:05 +00:00
GitHub Copilot bcc4fb0c6d Limit box-drawing detection to actual box chars (U+2500-U+257F)
Block elements (█▀▄) and geometric shapes should merge normally.
Only box-drawing lines/corners/junctions need separate positioning.
2026-01-24 19:07:11 +00:00
GitHub Copilot dede6b09bf Use integer character width (8px) instead of fractional (8.4px)
Integer pixel positions render more crisply and align better
with browser rendering.
2026-01-24 19:03:57 +00:00
GitHub Copilot ebb1104085 Allow same box-drawing chars to merge, break on different ones
Same box-drawing characters (like ───) can now merge into a single
tspan, but different box-drawing characters (like │╯) are kept
separate for precise positioning. This reduces SVG size while
maintaining alignment at character transitions.
2026-01-24 19:02:50 +00:00
GitHub Copilot ba1f89af54 Don't merge box-drawing characters for precise positioning
Box-drawing and block element characters (U+2500-U+259F, U+25A0-U+25FF)
are now rendered as individual tspans with their own x positions to
prevent visual misalignment caused by font rendering variations.
2026-01-24 18:58:19 +00:00
GitHub Copilot 7c2a273ec0 Revert textLength - causes severe character distortion
textLength with lengthAdjust='spacingAndGlyphs' distorts glyphs.
Revert to using only x positioning for character placement.
2026-01-24 18:54:07 +00:00
GitHub Copilot d82f40c4fa Fix character alignment with textLength attribute
Use SVG textLength and lengthAdjust='spacingAndGlyphs' to enforce
exact character spacing, preventing gaps between box-drawing and
other characters that may render at slightly different widths.

Also include whitespace spans in output for proper alignment.
2026-01-24 18:51:10 +00:00
GitHub Copilot 6e66f01521 Fix SVG structure: render background rects before text elements
Background rect elements were being inserted inside text elements,
causing invalid SVG structure. Now collect all background rects first,
then render them before the text element for each row.
2026-01-24 18:44:43 +00:00
GitHub Copilot 4f4b811967 Fix wide character alignment in SVG exporter
Track column count separately from character count to properly
handle wide characters (CJK, emoji) that occupy 2 terminal columns
but have a single character + empty placeholder in pyte buffer.
2026-01-24 18:36:03 +00:00
GitHub Copilot e161d94bcc Fix hex color handling in SVG exporter
pyte provides 256-color/truecolor values without # prefix (e.g., 'ff8700').
Added check to prepend # for 6-digit hex strings.
2026-01-24 18:34:13 +00:00
GitHub Copilot d5a060d6aa Add custom SVG exporter, remove Rich from screenshot rendering
- Created svg_exporter.py with direct pyte-to-SVG rendering
- Eliminates Rich's export_svg() quirks (clip path count mismatch)
- Added 63 comprehensive tests for SVG exporter
- Removed Rich imports from local_server.py, terminal_session.py,
  app_session.py, and cli.py
- Replaced RichHandler with standard logging.basicConfig
- Replaced @rich.repr.auto with standard __repr__ methods
- Rich is no longer directly imported (still transitive via textual-serve)

Bump version to 0.3.0
2026-01-24 17:11:20 +00:00
GitHub Copilot d4acdbb4f1 Fix SVG clip path count by increasing console height
Rich's SVG export creates fewer clip paths than content lines.
Work around by adding +2 to console height.
2026-01-24 17:00:23 +00:00
GitHub Copilot 1a5222ab2a Simplify terminal resize - no more size toggling
Remove all the -1 column toggle tricks for forcing tmux redraws.
Just set the size directly.
2026-01-24 16:53:53 +00:00
GitHub Copilot 3f265f19dc Fix double redraw flash on reconnect
- Remove separate force_redraw on WebSocket connect
- Integrate size toggle into set_terminal_size for single redraw
- Update test to expect two executor calls (toggle pattern)
2026-01-24 16:48:53 +00:00
GitHub Copilot 032d46b2a9 Skip empty placeholder cells in SVG rendering
Wide characters (emoji, CJK) in pyte are followed by empty placeholder
cells. Skipping these fixes Rich's SVG character positioning.
2026-01-24 16:46:54 +00:00
GitHub Copilot 8285e9f910 Force tmux redraw when pyte syncs to PTY size
Toggle PTY size after resize to trigger tmux redraw, with brief
delay to let redraw data arrive before taking screenshot
2026-01-24 16:45:19 +00:00
GitHub Copilot a6e37b87c3 Fix extra line in SVG screenshot
Don't add newline after last row to prevent Rich from creating an extra line
2026-01-24 16:43:43 +00:00
GitHub Copilot 9ae00e113d Sync pyte screen to actual PTY size before screenshots
Query PTY size with TIOCGWINSZ and resize pyte screen to match.
Fixes tmux status bar wrapping when terminal was resized externally.
2026-01-24 16:39:29 +00:00
GitHub Copilot 3da68eaaf8 Improve tmux redraw by toggling terminal size
Toggle width -1 then back to force tmux to fully redraw all panes
2026-01-24 16:32:49 +00:00
GitHub Copilot ffd0f91d9d Simplify screenshot dimensions
Remove width/height query params from screenshot endpoint.
New sessions created by screenshot use DEFAULT_TERMINAL_SIZE.
Existing sessions keep their current size.
2026-01-24 16:29:26 +00:00
GitHub Copilot 728681a195 Force terminal redraw on reconnect
- Track last known terminal size in TerminalSession
- Add force_redraw() method that re-sends SIGWINCH to trigger redraw
- Call force_redraw() when WebSocket reconnects to existing session
- Helps tmux and similar apps restore proper display after disconnect
2026-01-24 16:28:50 +00:00
GitHub Copilot 2f61bd7747 Don't resize terminal on session disconnect
Rename DISCONNECT_RESIZE to DEFAULT_TERMINAL_SIZE
Update tests for removed _resize_on_disconnect and stricter available check

Bump version to 0.2.7
2026-01-24 16:11:39 +00:00
GitHub Copilot b5b144dcd0 Initialize sparklines to start at zero
Bump version to 0.2.6
2026-01-24 12:55:45 +00:00
GitHub Copilot cc2ab79859 Fix Docker sparklines and Ctrl-C exit
- Fix Ctrl-C to exit immediately by setting exit_event before cleanup
- Filter Docker containers by compose project name to match correct stack
- Derive compose project from manifest directory (matches docker-compose default)
- Improve Docker socket availability check to test actual connectivity
- Add DOCKER_HOST env var support for alternate socket paths
- Better error logging for socket permission issues

Bump version to 0.2.5
2026-01-24 12:53:09 +00:00
GitHub Copilot 6ab7503748 Clean up Docker stats logging
- Remove excessive debug logging
- Add single warning when no containers found (with hint about socket mount)
- Use HTTP/1.0 to avoid chunked encoding complexity
- Simplify response parsing
2026-01-24 12:30:39 +00:00
GitHub Copilot 83b6503501 Improve Docker API response parsing
- Refactor into separate methods for cleaner code
- Better handling of chunked transfer encoding
- Add more debug logging to diagnose parsing failures
- Log body preview when JSON not found
2026-01-24 12:25:08 +00:00
GitHub Copilot 8d966ca203 Add debug logging for Docker stats collection
Helps diagnose empty sparklines by logging:
- Container discovery results and matches
- Stats request failures
- CPU calculation results
- What containers/services were found vs expected
2026-01-24 12:21:55 +00:00
GitHub Copilot de5ea155a0 Throttle SSE notifications and debounce client refreshes
Server-side:
- Limit SSE notifications to max once per second per route
- Track last notification time per route

Client-side:
- Debounce screenshot refreshes with 2s minimum interval per tile
- Pending refreshes are scheduled if events arrive during debounce window
2026-01-24 12:20:49 +00:00
GitHub Copilot 92651e236b Fix sparkline slug-to-service mapping initialization
- Initialize _slug_to_service as instance variable in __init__
- Add logging to help debug empty sparklines
- Log the mapping at startup
2026-01-24 12:13:38 +00:00
GitHub Copilot 5536c4ac51 Invalidate screenshot cache on terminal resize
When terminal resizes, old screenshot content is stale until
the app (tmux etc) re-renders at new dimensions. Clear cache
to force re-capture after resize.
2026-01-24 11:59:23 +00:00
GitHub Copilot 02d941af6a Fix sparkline service name mapping
- Pass service names (not slugs) to DockerStatsCollector
- Create slug->name mapping for sparkline lookups
- Stats are stored by service name, looked up by slug
- Add debug logging when no containers found
2026-01-24 11:57:16 +00:00
GitHub Copilot be2f18c8ba Auto-focus terminal on page load
- Try to focus xterm textarea after initialization
- Retry with delays (100ms, 500ms, 1s) as terminal loads async
- Re-focus when window regains focus (tab switching)
2026-01-24 11:45:07 +00:00
GitHub Copilot bd477c1b3c Use SSE for real-time screenshot updates
- New /events SSE endpoint pushes activity notifications to browsers
- Dashboard subscribes to SSE stream instead of polling
- Screenshots refresh instantly when terminal activity occurs
- Sparklines still poll every 30s (appropriate for 30min history)
- SSE includes keepalive every 30s and auto-reconnect on error
- Removes inefficient 5s polling; updates only on actual changes
2026-01-24 11:44:29 +00:00
GitHub Copilot 1ba4ce2a34 Adjust sparkline and screenshot timing
Sparklines:
- Poll interval: 2s -> 10s
- History size: 30 -> 180 readings
- Now shows 30 minutes of CPU history

Screenshots:
- Dashboard refresh interval: 15s -> 5s
- Combined with dirty tracking, updates on activity with 5s cap
2026-01-24 11:41:01 +00:00
GitHub Copilot 3e29f925e2 Rename dashboard title to 'Session Dashboard' 2026-01-24 11:34:02 +00:00
GitHub Copilot 1f51d878c8 Add CPU sparkline to dashboard in compose mode
- New docker_stats.py module reads container stats from Docker socket
  using only asyncio + stdlib (no new dependencies)
- Calculates CPU % from delta of cpu_usage and system_cpu_usage
- Maintains ring buffer of last 30 CPU readings per container
- render_sparkline_svg() generates mini SVG chart from history
- DockerStatsCollector polls containers every 2 seconds
- New /cpu-sparkline.svg endpoint serves sparkline for a container
- Dashboard shows sparkline in tile header next to container name
- Only active in compose mode (--compose-manifest flag)
- Graceful degradation if Docker socket unavailable

Bump version to 0.1.17
2026-01-24 11:33:27 +00:00
GitHub Copilot ff8f5efabd Optimize screenshot updates using pyte dirty tracking
- get_screen_state() now returns has_changes flag indicating if screen changed
- pyte's dirty set tracks which rows have been modified since last read
- Screenshot handler returns cached SVG immediately when no changes detected
- Removed _screenshot_last_rendered_activity tracking (replaced by dirty flag)
- Added test for dirty flag behavior

Bump version to 0.1.16
2026-01-24 11:27:33 +00:00
GitHub Copilot 8ae3f77f23 fix: reuse same browser tab when clicking dashboard tiles
Use tile slug as window name in window.open() so clicking the same
tile twice focuses the existing tab instead of opening a new one.

Changed: window.open(url, '_blank') -> window.open(url, 'webterm-{slug}')
2026-01-24 11:23:43 +00:00
GitHub Copilot 0cae07cba6 fix: complete pyte-to-Rich color mapping
Audited all color names from both libraries and added complete mappings:

pyte standard ANSI:
- brown -> yellow (pyte uses 'brown' for ANSI color 33)

pyte bright/AIXTERM colors:
- brightblack -> bright_black
- brightred -> bright_red
- brightgreen -> bright_green
- brightbrown -> bright_yellow
- brightblue -> bright_blue
- brightmagenta -> bright_magenta
- bfightmagenta -> bright_magenta (typo in pyte's BG_AIXTERM)
- brightcyan -> bright_cyan
- brightwhite -> bright_white

Also handles hex colors from 256-color and truecolor modes
by adding '#' prefix (e.g., 'ff8700' -> '#ff8700').

Bumps version to 0.1.15.
2026-01-24 11:23:01 +00:00
GitHub Copilot 0d53952ff7 fix: handle all pyte color formats for Rich compatibility
- Add 'brown' -> 'yellow' mapping (pyte uses 'brown' for ANSI yellow)
- Add helper function to convert hex colors (pyte outputs 'ff8700',
  Rich needs '#ff8700')
- Handles 256-color and truecolor (24-bit) ANSI codes properly

Bumps version to 0.1.14.
2026-01-24 11:21:09 +00:00
GitHub Copilot 4d3a13f6ef fix: resolve terminal lifecycle race conditions
1. Lock pyte screen initialization in open() to prevent races with
   concurrent _update_screen() calls

2. Reorder session registration: call open() BEFORE adding to
   sessions/routes dicts, so sessions are fully initialized before
   other code can access them

3. Add clarifying comment that PTY resize completes before pyte resize

These fixes prevent dimension mismatches between PTY and pyte screen
that could cause content wrapping in screenshots.
2026-01-24 11:17:18 +00:00
GitHub Copilot db22fd9357 fix: use requested dimensions when creating screenshot sessions
When creating a new session for screenshot:
1. Use width/height query params instead of hardcoded DISCONNECT_RESIZE
2. Add a small delay (0.5s) after creating session to allow initial output

This ensures new sessions are created with the correct dimensions
matching what the screenshot expects.
2026-01-24 11:15:01 +00:00
GitHub Copilot e85213315e fix: use session's actual screen state for screenshots
The screenshot was creating a new pyte screen with arbitrary dimensions
from query params, but the replay buffer contains ANSI sequences meant
for the session's actual terminal size. This mismatch caused wrapping.

Now we use get_screen_state() which returns the actual screen buffer
from the terminal session's pyte screen, with the correct dimensions.
This ensures the screenshot matches exactly what the terminal rendered.
2026-01-24 11:14:12 +00:00
GitHub Copilot 3e433f5af5 fix: map pyte color names to Rich-compatible names
Pyte uses 'brightblack', 'brightred', etc. but Rich expects
'bright_black', 'bright_red' with underscores. Added PYTE_TO_RICH_COLOR
mapping to translate color names in screenshot rendering.
2026-01-24 11:11:35 +00:00
GitHub Copilot 4f8c7d88d5 fix: repair broken tests and remove unused dependencies
Test fixes:
- Fix app_session.py to use 'textual-webterm' package name (not 'textual-web')
- Fix CLI version test to not hardcode version number
- Fix static path test to not use removed Path._flavour attribute

Removed unused dependencies:
- xdg
- msgpack
- httpx

All 209 tests pass with 86% coverage.
2026-01-24 10:40:26 +00:00
GitHub Copilot f9196da9f8 fix: use pyte+Rich hybrid for colored SVG screenshots
Screenshots now properly preserve terminal colors:
1. Replay buffer provides raw ANSI data with color codes
2. pyte interprets escape sequences for accurate screen state
3. Rich renders the pyte buffer with colors to SVG

This gives us both accurate terminal state (no creeping/wrapping)
and proper color preservation in screenshots.

Bumps version to 0.1.12.
2026-01-24 10:37:54 +00:00