Skip to content

Commit eba8448

Browse files
author
Dylan Huang
authored
in progress log viewer (part 2) (#26)
* simple solution to updating the client * fix layout of expanded row * Refactor ChatInterface and MetadataSection components for improved layout and functionality - Adjusted default chat height in ChatInterface from 512px to 400px for better UI consistency. - Enhanced MetadataSection to include expandable functionality, allowing users to toggle visibility of metadata details. - Updated Row component to set defaultExpanded prop for MetadataSection, ensuring sections are expanded by default. * Enhance StatusIndicator to show spinner for running status - Updated Row component to pass showSpinner prop to StatusIndicator when the status is "running". - Modified StatusIndicator to conditionally render a spinner based on the showSpinner prop, improving user feedback during loading states. * Implement row expansion management in GlobalState and Dashboard - Added functionality to manage expanded rows in GlobalState, including methods to toggle individual row expansion and set all rows expanded or collapsed. - Updated Dashboard component to include buttons for expanding and collapsing all rows, and display the count of currently expanded rows. - Refactored Row component to utilize GlobalState for determining and toggling row expansion state. * Add auto-scroll functionality to ChatInterface for new messages - Implemented auto-scrolling to the bottom of the chat window when new messages are received, enhancing user experience during conversations. - Introduced a new scrollContainerRef to manage scrolling behavior effectively. * Refactor GlobalState and Dashboard components for improved data handling and UI - Changed dataset and expandedRows in GlobalState from arrays and sets to objects for better performance and reactivity. - Updated setDataset method to create a new dataset object, preserving expansion state more efficiently. - Refactored Dashboard to utilize totalCount for dataset management and replaced the Row component with EvaluationTable for cleaner structure. - Introduced EvaluationRow and EvaluationTable components to enhance modularity and maintainability of the evaluation display. * Enhance auto-scroll functionality in ChatInterface to prevent initial scroll on mount - Added a reference to track the initial mount state, preventing auto-scrolling on the first render. - Updated the scrolling logic to only trigger after the initial mount when new messages are received, improving user experience during chat interactions. * Refactor auto-scroll logic in ChatInterface to enhance user experience - Replaced initial mount reference with a previous messages length reference to prevent scrolling on the first render and only scroll when new messages are added. - Improved scrolling behavior to avoid unnecessary scrolls when messages are removed, ensuring a smoother chat interaction. * update build * Remove redundant arguments from logs command in CLI and simplify serve_logs call * Update logs command to use default localhost settings and simplify output - Removed the ability to specify watch paths, defaulting to 'current directory'. - Changed server host and port to fixed values (localhost:8000) for consistency. * Implement message expansion feature in MessageBubble component - Added state management to toggle message expansion for long messages. - Introduced a helper function to format message content based on its type. - Updated rendering logic to display a "Show more" / "Show less" button for long messages, enhancing user interaction. * update build
1 parent 0fb7071 commit eba8448

21 files changed

+591
-345
lines changed

eval_protocol/cli.py

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
)
2626
from .cli_commands.deploy import deploy_command
2727
from .cli_commands.deploy_mcp import deploy_mcp_command
28+
from .cli_commands.logs import logs_command
2829
from .cli_commands.preview import preview_command
2930
from .cli_commands.run_eval_cmd import hydra_cli_entry_point
30-
from .cli_commands.logs import logs_command
3131

3232

3333
def parse_args(args=None):
@@ -289,36 +289,6 @@ def parse_args(args=None):
289289

290290
# Logs command
291291
logs_parser = subparsers.add_parser("logs", help="Serve logs with file watching and real-time updates")
292-
logs_parser.add_argument(
293-
"--build-dir",
294-
default="dist",
295-
help="Path to the Vite build output directory (default: dist)",
296-
)
297-
logs_parser.add_argument(
298-
"--host",
299-
default="localhost",
300-
help="Host to bind the server to (default: localhost)",
301-
)
302-
logs_parser.add_argument(
303-
"--port",
304-
type=int,
305-
default=4789,
306-
help="Port to bind the server to (default: 4789)",
307-
)
308-
logs_parser.add_argument(
309-
"--index-file",
310-
default="index.html",
311-
help="Name of the main index file (default: index.html)",
312-
)
313-
logs_parser.add_argument(
314-
"--watch-paths",
315-
help="Comma-separated list of paths to watch for file changes (default: current directory)",
316-
)
317-
logs_parser.add_argument(
318-
"--reload",
319-
action="store_true",
320-
help="Enable auto-reload (default: False)",
321-
)
322292

323293
# Run command (for Hydra-based evaluations)
324294
# This subparser intentionally defines no arguments itself.

eval_protocol/cli_commands/logs.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,15 @@
1111
def logs_command(args):
1212
"""Serve logs with file watching and real-time updates"""
1313

14-
# Parse watch paths
15-
watch_paths = None
16-
if args.watch_paths:
17-
watch_paths = args.watch_paths.split(",")
18-
watch_paths = [path.strip() for path in watch_paths if path.strip()]
19-
2014
print(f"🚀 Starting Eval Protocol Logs Server")
21-
print(f"🌐 URL: http://{args.host}:{args.port}")
22-
print(f"🔌 WebSocket: ws://{args.host}:{args.port}/ws")
23-
print(f"👀 Watching paths: {watch_paths or ['current directory']}")
15+
print(f"🌐 URL: http://localhost:8000")
16+
print(f"🔌 WebSocket: ws://localhost:8000/ws")
17+
print(f"👀 Watching paths: {['current directory']}")
2418
print("Press Ctrl+C to stop the server")
2519
print("-" * 50)
2620

2721
try:
28-
serve_logs(
29-
host=args.host,
30-
port=args.port,
31-
watch_paths=watch_paths,
32-
reload=args.reload,
33-
)
22+
serve_logs()
3423
return 0
3524
except KeyboardInterrupt:
3625
print("\n🛑 Server stopped by user")

eval_protocol/utils/logs_server.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@ def broadcast_file_update(self, update_type: str, file_path: str):
9797
return
9898
logger.info(f"Broadcasting file update: {update_type} {file_path}")
9999

100+
logs = default_logger.read()
101+
# send initialize_logs message to all connected clients
102+
for connection in self.active_connections:
103+
asyncio.run_coroutine_threadsafe(
104+
connection.send_text(
105+
json.dumps(
106+
{"type": "initialize_logs", "logs": [log.model_dump_json(exclude_none=True) for log in logs]}
107+
)
108+
),
109+
self._loop,
110+
)
111+
100112
message = {"type": update_type, "path": file_path, "timestamp": time.time()}
101113
# Include file contents for created and modified events
102114
if update_type in ["file_created", "file_changed"] and os.path.exists(file_path):
@@ -137,7 +149,7 @@ def __init__(
137149
os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "vite-app", "dist")
138150
),
139151
host: str = "localhost",
140-
port: Optional[int] = None,
152+
port: Optional[int] = 8000,
141153
index_file: str = "index.html",
142154
watch_paths: Optional[List[str]] = None,
143155
):
4.65 KB
Loading

vite-app/dist/assets/index-BqeSuXV9.js

Lines changed: 0 additions & 61 deletions
This file was deleted.

vite-app/dist/assets/index-BqeSuXV9.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

vite-app/dist/assets/index-BySN1scz.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vite-app/dist/assets/index-CRkZ6JGL.js

Lines changed: 88 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vite-app/dist/assets/index-CRkZ6JGL.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vite-app/dist/assets/index-DFYonil9.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)