@@ -8,6 +8,8 @@ module Model = {
88 type t = {
99 current: state ,
1010 future_log: list ((float , History . Update . t )),
11+ past_log: list ((float , History . Update . t )),
12+ replay_messages: list (string ),
1113 replay_toggle: bool ,
1214 };
1315
@@ -16,6 +18,8 @@ module Model = {
1618 let init = () => {
1719 current: History . Model . init() ,
1820 future_log: [] ,
21+ past_log: [] ,
22+ replay_messages: [] ,
1923 replay_toggle: false ,
2024 };
2125};
@@ -27,13 +31,6 @@ module Update = {
2731 type t = History . Update . t ;
2832
2933 // let sexp = History.Update.sexp_of_t(action);
30- // For now, we don't ignore any actions; add here if needed
31- // check if str contains "(Select (Term (Id" (ignoring whitespace)
32- // let str = Sexplib.Sexp.to_string(sexp);
33- // StringUtil.match(StringUtil.regexp("Select\\s*\\(Term\\s*\\(Id"), str);
34- let ignore_if_action_fails_in_log_replay = (_action: t ): bool => {
35- false ;
36- };
3734
3835 [@ deriving (show({with_path: false }), sexp, yojson)]
3936 let update =
@@ -62,35 +59,29 @@ module Update = {
6259 |> Sexplib . Sexp . of_string
6360 |> Log . Entry . s_of_sexp_opt
6461 |> List . filter_map(x => x);
65- let actions =
66- data
67- |> of_data
68- |> Log . flatten_imports(~of_data)
69- |> (
70- x => {
71- LogSidebar . log_info(
72- "Imported log entries: " ++ string_of_int(List . length(x)),
73- );
74- x;
75- }
76- );
62+ let actions = data |> of_data |> Log . flatten_imports(~of_data);
7763 {
7864 ... model,
7965 future_log: model. future_log @ actions,
66+ replay_messages: [
67+ "Imported log entries: " ++ string_of_int(List . length(actions)),
68+ ... model. replay_messages,
69+ ] ,
8070 }
8171 |> Updated . return_quiet;
8272 | NextLog =>
8373 switch (model. future_log) {
8474 | [] =>
85- LogSidebar . log_info("No next log action to perform" );
86- model |> Updated . return_quiet;
75+ {
76+ ... model,
77+ replay_messages: [
78+ "No next log action to perform" ,
79+ ... model. replay_messages,
80+ ] ,
81+ }
82+ |> Updated . return_quiet
8783 | [ (t , next ), ... rest ] =>
88- LogSidebar . log_action(
89- "Applying next log action" ,
90- Some (JsUtil . print_timestamp(t)),
91- );
92- // Keep full action expression in console for detailed debugging
93- print_endline("Full action: " ++ History . Update . show(next));
84+ print_endline("Applying next log action..." );
9485 try ({
9586 let updated =
9687 History . Update . update(
@@ -105,6 +96,8 @@ module Update = {
10596 model: {
10697 current: updated. model,
10798 future_log: rest,
99+ past_log: [ (t, next), ... model. past_log] ,
100+ replay_messages: model. replay_messages,
108101 replay_toggle: model. replay_toggle,
109102 },
110103 };
@@ -113,29 +106,38 @@ module Update = {
113106 LogSidebar . log_error("Failed to apply log action" );
114107 Model . {
115108 ... model,
116- future_log :
117- ignore_if_action_fails_in_log_replay (next)
118- ? rest : model. future_log ,
119- replay_toggle :
120- ignore_if_action_fails_in_log_replay(next)
121- ? model . replay_toggle : false ,
109+ replay_messages : [
110+ "Error applying log action : " ++ History . Update . show (next),
111+ ... model. replay_messages ,
112+ ] ,
113+ future_log : model . future_log ,
114+ replay_toggle: false ,
122115 }
123- |> Updated . return_quiet;
116+ |> return_quiet;
124117 };
125118 }
126119 | SkipLog =>
127- LogSidebar . log_action("Skipping the next log entry" , None );
128120 switch (model. future_log) {
129121 | [] =>
130- LogSidebar . log_info("No log entry to skip" );
131- model |> return_quiet;
122+ {
123+ ... model,
124+ replay_messages: [
125+ "No log entry to skip" ,
126+ ... model. replay_messages,
127+ ] ,
128+ }
129+ |> return_quiet
132130 | [ (_ , _ ), ... rest ] =>
133131 {
134132 ... model,
133+ replay_messages: [
134+ "Skipped a log entry" ,
135+ ... model. replay_messages,
136+ ] ,
135137 future_log: rest,
136138 }
137139 |> return_quiet
138- };
140+ }
139141 | ToggleReplay =>
140142 Model . {
141143 ... model,
@@ -144,8 +146,16 @@ module Update = {
144146 |> return_quiet
145147 | ClearLog =>
146148 Log . DB . clear_and(() => () );
147- LogSidebar . log_info("Log cleared" );
148- model |> return_quiet;
149+ {
150+ ... model,
151+ future_log: [] ,
152+ past_log: [] ,
153+ replay_messages: [
154+ "Cleared all log entries" ,
155+ ... model. replay_messages,
156+ ] ,
157+ }
158+ |> return_quiet;
149159 }
150160 | action =>
151161 let current =
@@ -162,7 +172,9 @@ module Update = {
162172 model: {
163173 current: current. model,
164174 future_log: model. future_log,
175+ past_log: model. past_log,
165176 replay_toggle: model. replay_toggle,
177+ replay_messages: model. replay_messages,
166178 },
167179 };
168180 };
@@ -179,6 +191,8 @@ module Update = {
179191 model. current
180192 |> History . Update . calculate(~schedule_action, ~is_edited, ~dynamics),
181193 future_log: model. future_log,
194+ past_log: model. past_log,
195+ replay_messages: model. replay_messages,
182196 replay_toggle: model. replay_toggle,
183197 };
184198};
@@ -196,6 +210,19 @@ module Selection = {
196210module View = {
197211 let view =
198212 (~get_log_and, ~inject: Update . t => Ui_effect . t (unit ), model: Model . t ) => {
199- History . View . view(~get_log_and, ~inject, model. current);
213+ History . View . view(
214+ ~log_model=
215+ LogSidebar . Model . {
216+ messages: model. replay_messages,
217+ is_playing: model. replay_toggle,
218+ current_step: List . length(model. past_log),
219+ total_steps:
220+ List . length(model. past_log) + List . length(model. future_log),
221+ show_details: true ,
222+ },
223+ ~get_log_and,
224+ ~inject,
225+ model. current,
226+ );
200227 };
201228};
0 commit comments