Skip to content

Commit 8a215eb

Browse files
NSHkrNSHkr
authored andcommitted
Update phoenix test app
1 parent f6aca62 commit 8a215eb

25 files changed

Lines changed: 1098 additions & 697 deletions

File tree

test_apps/CURSOR.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,8 @@
4646
- [ ] Add example sessions
4747

4848
## 📚 Documentation Reference Map
49-
Key sections in ELIXIRSCOPE_DOCS.md:
50-
- Project Overview: Lines 1-20
51-
- Directory Structure: Lines 21-50
52-
- Integration Guide: Lines 51-150
53-
- Performance Characteristics: Lines 151-200
54-
- Testing Guidelines: Lines 201-250
55-
- Debugging Tips: Lines 251-300
56-
- Future Applications: Lines 301-350
57-
58-
This mapping helps locate relevant documentation sections for each phase of development. Refer to these sections when implementing specific features or troubleshooting issues.
49+
50+
5951

6052
## Project Overview
6153

test_apps/CURSOR_PROMPT.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# ElixirScope Project Continuation Prompt
2+
3+
## Current Project State
4+
5+
We are working on a Phoenix LiveView application called "phoenix_scope_player" for debugging session playback. The application has been partially implemented with the following key components:
6+
7+
1. **Session Data Structure**
8+
- Events are stored in JSON format
9+
- Each session contains metadata, events, and source code
10+
- Events include function calls, returns, and variable states
11+
12+
2. **Working Features**
13+
- Session listing on homepage shows event counts
14+
- Basic playback interface implemented
15+
- Event navigation (Previous/Next) functionality
16+
- Source code viewer with file selection
17+
18+
3. **Current Issues**
19+
- Detail page needs improvement in displaying session information
20+
- Session metadata display needs enhancement
21+
- Some process lifecycle events are marked as "Unhandled trace messages"
22+
23+
## Development Environment
24+
25+
- Using Phoenix LiveView
26+
- Mix commands:
27+
- `mix test.trace` - For bypassing slow live LLM API tests
28+
- `mix test.all` or `mix test.live` - For testing LLM integrations
29+
- `mixsw` - Alias to suppress warnings and show only errors
30+
31+
## Next Steps
32+
33+
Please attach the following documents to continue development:
34+
1. Original CURSOR.md for base project context
35+
2. ELIXIRSCOPE_DOCS.md for ElixirScope-specific documentation
36+
37+
## Current Focus
38+
39+
The immediate focus is on improving the session playback interface, specifically:
40+
1. Enhancing session metadata display
41+
2. Improving event visualization
42+
3. Better handling of trace messages
43+
44+
## Notes
45+
46+
- Date reference: May 28, 2025
47+
- Code mapping guide: CURSOR_CODE_MAPPING.md
48+
- Implementation guide: CURSOR_IMPLEMENTATION_GUIDE.md

test_apps/assets/css/app.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@import "tailwindcss/base";
2+
@import "tailwindcss/components";
3+
@import "tailwindcss/utilities";
4+
5+
/* Custom styles can go here */

test_apps/lib/phoenix_scope_player/application.ex

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 73 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,114 @@
11
defmodule PhoenixScopePlayer.DataProvider do
22
@moduledoc """
3-
Provides access to session data, source code, and AST mappings.
4-
Handles data loading, caching, and efficient retrieval.
3+
Provides access to debug session data stored in the priv directory.
54
"""
65

76
require Logger
87

9-
@type session_meta :: %{
10-
id: String.t(),
11-
name: String.t(),
12-
description: String.t(),
13-
timestamp: DateTime.t(),
14-
event_count: integer(),
15-
trigger: String.t(),
16-
duration: integer(),
17-
status: :completed | :error
18-
}
8+
@sessions_dir Path.join([:code.priv_dir(:phoenix_scope_player), "captured_data"])
199

2010
@doc """
21-
Lists all available debugging sessions
11+
Lists all available debug sessions.
2212
"""
23-
@spec list_sessions() :: [session_meta()]
2413
def list_sessions do
25-
captured_data_path = Path.join(:code.priv_dir(:phoenix_scope_player), "captured_data")
26-
27-
case File.ls(captured_data_path) do
14+
IO.puts("\n=== Listing Sessions ===")
15+
case File.ls(@sessions_dir) do
2816
{:ok, session_dirs} ->
29-
session_dirs
17+
IO.puts("Found #{length(session_dirs)} session directories")
18+
sessions = session_dirs
3019
|> Enum.map(&load_session_metadata/1)
3120
|> Enum.reject(&is_nil/1)
32-
21+
|> Enum.sort_by(& &1["date"], :desc)
22+
23+
IO.puts("Processed #{length(sessions)} valid sessions:")
24+
Enum.each(sessions, fn session ->
25+
IO.puts(" - #{session["id"]}: #{session["event_count"]} events")
26+
end)
27+
28+
sessions
29+
3330
{:error, reason} ->
34-
Logger.error("Failed to list sessions: #{inspect(reason)}")
31+
IO.puts("Error listing sessions: #{inspect(reason)}")
3532
[]
3633
end
3734
end
3835

3936
@doc """
40-
Gets all data for a specific session
37+
Gets the complete data for a specific session.
4138
"""
42-
@spec get_session_data(String.t()) :: {:ok, map()} | {:error, :not_found}
43-
def get_session_data(session_id) when is_binary(session_id) do
44-
with {:ok, events} <- load_events(session_id),
45-
{:ok, source_code} <- load_source_code(session_id),
46-
{:ok, ast_map} <- load_ast_map(session_id) do
39+
def get_session_data(session_id) do
40+
IO.puts("\n=== Getting Session Data: #{session_id} ===")
41+
session_dir = Path.join(@sessions_dir, session_id)
42+
43+
with {:ok, metadata} <- read_json_file(session_dir, "metadata.json"),
44+
{:ok, events} <- read_json_file(session_dir, "events.json"),
45+
{:ok, source_code} <- read_json_file(session_dir, "source_code.json") do
46+
47+
IO.puts("Metadata: #{inspect(metadata)}")
48+
IO.puts("Events count: #{length(events || [])}")
49+
4750
{:ok, %{
48-
events: events,
49-
source_code_map: source_code,
50-
ast_map: ast_map
51+
metadata: metadata,
52+
events: events, # The events are directly in the root of events.json
53+
source_code: source_code
5154
}}
5255
else
53-
error ->
54-
Logger.error("Failed to load session data: #{inspect(error)}")
56+
error ->
57+
IO.puts("Error reading session data: #{inspect(error)}")
5558
{:error, :not_found}
5659
end
5760
end
5861

59-
@doc """
60-
Gets source code for a specific session
61-
"""
62-
@spec get_session_source_code(String.t()) :: {:ok, map()} | {:error, :not_found}
63-
def get_session_source_code(session_id) when is_binary(session_id) do
64-
load_source_code(session_id)
65-
end
62+
# Private helpers
6663

67-
@doc """
68-
Gets AST mapping for a specific session
69-
"""
70-
@spec get_session_ast_map(String.t()) :: {:ok, map()} | {:error, :not_found}
71-
def get_session_ast_map(session_id) when is_binary(session_id) do
72-
load_ast_map(session_id)
73-
end
64+
defp load_session_metadata(session_dir) do
65+
IO.puts("\nLoading metadata for session: #{session_dir}")
66+
case read_json_file(Path.join(@sessions_dir, session_dir), "metadata.json") do
67+
{:ok, metadata} ->
68+
# Read events file to get actual event count
69+
events_path = Path.join([@sessions_dir, session_dir, "events.json"])
70+
actual_event_count = case File.read(events_path) do
71+
{:ok, content} ->
72+
case Jason.decode(content) do
73+
{:ok, events} when is_list(events) -> length(events)
74+
_ -> 0
75+
end
76+
_ -> 0
77+
end
7478

75-
# Private Functions
79+
session = Map.merge(metadata, %{
80+
"id" => session_dir,
81+
"name" => session_dir |> String.replace("_", " ") |> String.capitalize(),
82+
"date" => metadata["timestamp"] || "Unknown",
83+
"description" => "Debug session with #{actual_event_count} events"
84+
})
85+
86+
IO.puts(" Loaded session: #{inspect(session, pretty: true)}")
87+
session
7688

77-
defp load_session_metadata(session_id) do
78-
path = session_data_path(session_id, "metadata.json")
79-
80-
case load_json_file(path) do
81-
{:ok, metadata} -> metadata
82-
{:error, _} -> nil
89+
error ->
90+
IO.puts(" Error loading metadata: #{inspect(error)}")
91+
nil
8392
end
8493
end
8594

86-
defp load_events(session_id) do
87-
path = session_data_path(session_id, "events.json")
88-
load_json_file(path)
89-
end
90-
91-
defp load_source_code(session_id) do
92-
path = session_data_path(session_id, "source_code.json")
93-
load_json_file(path)
94-
end
95-
96-
defp load_ast_map(session_id) do
97-
path = session_data_path(session_id, "ast_map.json")
98-
load_json_file(path)
99-
end
95+
defp read_json_file(dir, filename) do
96+
path = Path.join(dir, filename)
97+
IO.puts("Reading JSON file: #{path}")
10098

101-
defp load_json_file(path) do
10299
case File.read(path) do
103-
{:ok, content} ->
100+
{:ok, content} ->
104101
case Jason.decode(content) do
105-
{:ok, data} -> {:ok, data}
106-
{:error, reason} ->
107-
Logger.error("Failed to decode JSON from #{path}: #{inspect(reason)}")
108-
{:error, :invalid_json}
102+
{:ok, data} ->
103+
IO.puts(" Successfully decoded JSON")
104+
{:ok, data}
105+
error ->
106+
IO.puts(" Error decoding JSON: #{inspect(error)}")
107+
error
109108
end
110-
{:error, reason} ->
111-
Logger.error("Failed to read file #{path}: #{inspect(reason)}")
109+
{:error, reason} ->
110+
IO.puts(" Error reading file: #{inspect(reason)}")
112111
{:error, :not_found}
113112
end
114113
end
115-
116-
defp session_data_path(session_id, filename) do
117-
Path.join([
118-
:code.priv_dir(:phoenix_scope_player),
119-
"captured_data",
120-
session_id,
121-
filename
122-
])
123-
end
124114
end

0 commit comments

Comments
 (0)