···11+# Rendering of current status:
22+- Should use some kind of mailbox processor
33+- When it gets triggered, it checks the current status and runs jj to fill the various buffers with the latest graph and such
44+- Should have a cache that gets invalidated whenever jj says there was a change
55+ - The cache can store the fully processed data for the view buffers
66+ iiee
+15-18
jj_tui/bin/file_view.ml
···100100 |> List.map (fun (_modifier, file) ->
101101 W.Lists.{ data = file; ui = W.Lists.selectable_item (W.string file) })
102102 in
103103- let show_diff_promise = ref @@ Promise.of_value () in
104104- (*TODO:
105105- This should be redesigned completely
106106- There will be a new function that renders the show state
107107- It will have a cancellation system just like this one.
108108- when any of the dependencies change, selected file, selected rev, focus etc, it will re-render if needed and cancel the current rendering.
109109-110110-103103+ (*TODO:
104104+ This should be redesigned completely
105105+ There will be a new function that renders the show state
106106+ It will have a cancellation system just like this one.
107107+ when any of the dependencies change, selected file, selected rev, focus etc, it will re-render if needed and cancel the current rendering.
111108 *)
112112- let show_selected_file_diff ()=
109109+ let show_selected_file_diff () =
113110 (* kill any existing process writing to the show buffer*)
114114- !show_diff_promise |> Promise.terminate;
111111+ !(Vars.ui_state.jj_show_promise) |> Promise.terminate;
115112 (* set self as current process writing to show buffer*)
116116- show_diff_promise
113113+ Vars.ui_state.jj_show_promise
117114 := Picos_std_structured.Flock.fork_as_promise (fun () ->
118115 let rev = Vars.get_selected_rev () in
119116 let selected = Lwd.peek selected_file in
120117 Vars.ui_state.jj_show
121118 $=
122119 if selected != ""
123123- then
124124- let log=jj_no_log [ "diff"; "-r"; rev; selected ] in
125125- Control.yield();
126126- let res=log|> AnsiReverse.colored_string in
127127- Control.yield();
128128- res
120120+ then (
121121+ let log = jj_no_log [ "diff"; "-r"; rev; selected ] in
122122+ Control.yield ();
123123+ let res = log |> AnsiReverse.colored_string in
124124+ Control.yield ();
125125+ res)
129126 else I.string A.empty "")
130127 in
131128 W.Lists.selection_list_custom
132129 ~on_selection_change:(fun selected ->
133130 Lwd.set selected_file selected;
134134- if Focus.peek_has_focus focus then show_selected_file_diff())
131131+ if Focus.peek_has_focus focus then show_selected_file_diff ())
135132 ~custom_handler:(fun _ key ->
136133 match key with `ASCII k, [] -> handleInputs command_mapping k | _ -> `Unhandled)
137134 file_uis
+11-6
jj_tui/bin/global_funcs.ml
···4646 (* From now on we use ignore-working-copy so we don't re-snapshot the state and so
4747 we can operate in paralell *)
4848 (* TODO: stop using dop last twice *)
4949- let log_res =
5050- Flock.fork_as_promise (fun _ ->
5151- jj_no_log ~snapshot:false [ "show"; "-s"; "--color-words"; "-r"; rev ]
5252- |> colored_string)
4949+ let _=
5050+ (* TODO: could these all just run in fully paralell like this ?*)
5151+ !(Vars.ui_state.jj_show_promise) |> Promise.terminate;
5252+ Vars.ui_state.jj_show_promise
5353+ := Flock.fork_as_promise @@ fun () ->
5454+ let show_data =
5555+ jj_no_log ~snapshot:false [ "show"; "-s"; "--color-words"; "-r"; rev ]
5656+ |> colored_string
5757+ in
5858+ Vars.ui_state.jj_show $= show_data
5359 and branches =
5460 Flock.fork_as_promise (fun _ ->
5561 jj_no_log ~snapshot:false [ "branch"; "list"; "-a" ] |> colored_string)
5662 and files_list = Flock.fork_as_promise (fun _ -> list_files ~rev ()) in
5763 (*wait for all our tasks*)
5858- let log_res= Promise.await log_res
5959- and files_list = Promise.await files_list
6464+ let files_list = Promise.await files_list
6065 and branches = Promise.await branches in
6166 (*now we can assign our results*)
6267 (* Vars.ui_state.jj_show $= log_res; *)
+12-9
jj_tui/bin/global_vars.ml
···11open Notty
22open Nottui
33open Eio.Std
44+open Picos_std_structured
45open Lwd_infix
56open Jj_tui.Process
67···1819 ; input : [ `Normal | `Mode of char -> Ui.may_handle ] Lwd.var
1920 ; show_popup : (ui Lwd.t * string) option Lwd.var
2021 ; show_prompt : W.Overlay.text_prompt_data option Lwd.var
2121- (* ; show_graph_selection_prompt : *)
2222+ (* ; show_graph_selection_prompt : *)
2223 (* rev_id maybe_unique W.Overlay.filterable_selection_list_prompt_data option Lwd.var *)
2324 ; show_string_selection_prompt :
2425 string W.Overlay.filterable_selection_list_prompt_data option Lwd.var
···2627 ; command_log : string list Lwd.var
2728 ; jj_tree : I.t Lwd.var
2829 ; jj_show : I.t Lwd.var
3030+ ; jj_show_promise : (unit Promise.t) ref
2931 ; jj_branches : I.t Lwd.var
3032 ; jj_change_files : (string * string) list Lwd.var
3133 ; selected_revision : rev_id maybe_unique Lwd.var
3234 ; revset : string option Lwd.var
3335 ; trigger_update : unit Lwd.var
3436}
3535- let get_unique_id maybe_unique_rev =
3636- match maybe_unique_rev with
3737- | Unique { change_id; _ } ->
3838- change_id
3939- | Duplicate { commit_id; _ } ->
4040- commit_id
4141- ;;
3737+3838+let get_unique_id maybe_unique_rev =
3939+ match maybe_unique_rev with
4040+ | Unique { change_id; _ } ->
4141+ change_id
4242+ | Duplicate { commit_id; _ } ->
4343+ commit_id
4444+;;
42454346(** Global variables for the ui. Here we keep anything that's just a pain to pipe around*)
4447module type Vars = sig
···8285 view = Lwd.var `Main
8386 ; jj_tree = Lwd.var I.empty
8487 ; jj_show = Lwd.var I.empty
8888+ ; jj_show_promise = ref @@ Promise.of_value ()
8589 ; jj_branches = Lwd.var I.empty
8690 ; jj_change_files = Lwd.var []
8791 ; selected_revision = Lwd.var (Unique { change_id = "@"; commit_id = "@" })
···115119 let get_eio_env () = (Option.get !eio).env
116120 let get_eio_vars () = Option.get !eio
117121 let get_term () = Option.get !term
118118-119122120123 (**Gets an id for the selected revision. If the change_id is unique we use that, if it's not we return a commit_id instead*)
121124 let get_selected_rev () = Lwd.peek ui_state.selected_revision |> get_unique_id
+4-5
jj_tui/bin/graph_view.ml
···77 open! Jj_tui.Util
88 open Jj_commands.Make (Vars)
99 open Jj_widgets.Make (Vars)
1010- module Process =Jj_process.Make (Vars)
1010+ module Process = Jj_process.Make (Vars)
1111 open Process
1212- open Jj_tui.Process_wrappers.Make(Process)
1212+ open Jj_tui.Process_wrappers.Make (Process)
13131414 let branch_select_prompt get_branch_list name func =
1515 Selection_prompt
···348348349349 (*TODO:make a custom widget the renders the commit with and without selection.
350350 with selection replace the dot with a blue version and slightly blue tint the background *)
351351- let graph_view () =
351351+ let graph_view ()=
352352 (*We have a seperate error var here instead of using a result type. This allows us to avoid using Lwd.bind which would cause our list selection to get reset anytime the content changes *)
353353 let error_var = Lwd.var None in
354354 let revset_ui =
···418418 (* Eio.Fiber.fork ~sw @@ fun _ -> *)
419419 (* Vars.update_ui_state @@ fun _ -> *)
420420 (* TODO: Do i need this now that we have the concurrency safeguards?*)
421421- Picos_std_structured.Flock.fork(fun ()->
422421 Lwd.set Vars.ui_state.selected_revision revision;
423423- Global_funcs.update_views ()))
422422+ Picos_std_structured.Flock.fork (fun () -> Global_funcs.update_views ()))
424423 ~custom_handler:(fun _ key -> handleKeys key)
425424 in
426425 let final_ui =