···1414;;
15151616let check_startup () =
1717- match jj_no_log_errorable ~color:false ~snapshot:false [ "op";"log"; "-l";"0" ] with
1818- | Ok _ ->
1919- `Good
2020- | Error (`BadExit (i, str)) ->
2121- if str |> Base.String.is_substring ~substring:"There is no jj repo"
2222- then `NotInRepo
2323- else `OtherError str
2424- | Error (`Exception e) ->
2525- `CantStartProcess e
1717+ let result = Lwd.var `Good in
1818+ (* In the happy path making this a fiber and returning an Lwd.t makes this not delay rendering. In the unhappy path, after 150-50ms the error message will show*)
1919+ Flock.fork (fun x ->
2020+ let res =
2121+ match
2222+ (*we snapshot here in the first request to make sure the editor is showing the latest changes*)
2323+ jj_no_log_errorable ~color:false ~snapshot:true [ "op"; "log"; "-l"; "0" ]
2424+ with
2525+ | Ok _ ->
2626+ `Good
2727+ | Error (`BadExit (i, str)) ->
2828+ if str |> Base.String.is_substring ~substring:"There is no jj repo"
2929+ then `NotInRepo
3030+ else `OtherError str
3131+ | Error (`Exception e) ->
3232+ `CantStartProcess e
3333+ in
3434+ (*we don't want to trigger a re-render if the result is still good *)
3535+ if res != Lwd.peek result then result $= res);
3636+ result |> Lwd.get
2637;;
27382839(**Updates the status windows; Without snapshotting the working copy by default
+7-9
jj_tui/bin/jj_ui.ml
···3737 W.button (Printf.sprintf "quit ") (fun () -> Vars.quit $= true) |> Lwd.pure
3838 ;;
39394040-4140 let inputs ?(custom = fun _ -> `Unhandled) ui =
4241 let$ input_state = Lwd.get ui_state.input
4342 and$ ui = ui in
···4645 match custom event with
4746 | `Unhandled ->
4847 (match event with
4949- | `Arrow (`Left), _ ->
5050- `Remap (`Focus `Up,[])
5151- | `Arrow (`Right), _ ->
5252- `Remap (`Focus `Down,[])
4848+ | `Arrow `Left, _ ->
4949+ `Remap (`Focus `Up, [])
5050+ | `Arrow `Right, _ ->
5151+ `Remap (`Focus `Down, [])
5352 | `ASCII 'q', _ ->
5453 Vars.quit $= true;
5554 `Handled
···145144 |> W.Overlay.selection_list_prompt_filterable
146145 ~show_prompt_var:ui_state.show_string_selection_prompt
147146 |> inputs ~custom:(function
148148-149147 | `Enter, [] ->
150148 Focus.request_reversable summary_focus;
151149 `Handled
···169167170168 let mainUi () =
171169 (*we want to initialize our states and keep them up to date*)
172172- match check_startup () with
170170+ let$* startup_result = check_startup () in
171171+ match startup_result with
173172 | `Good ->
174174- (* update_status ~cause_snapshot:true (); *)
175173 Flock.fork (fun () ->
176174 while true do
177175 Picos.Fiber.sleep ~seconds:5.0;
178178- (*we need to lock this becasue we could end up updating while the ui is rendering*)
179176 update_status ~cause_snapshot:true ()
177177+ (*we need to lock this becasue we could end up updating while the ui is rendering*)
180178 done;
181179 ());
182180 let$* running = Lwd.get ui_state.view in