moe icon indicating copy to clipboard operation
moe copied to clipboard

Replaying latest changes

Open tobimensch opened this issue 3 years ago • 0 comments

This is another advanced feature idea, I've not seen in any editor, and therefore this is definitely of low priority, and I'm not even sure it's a great idea. However, I still want to pitch the idea to you, so here we go.

Imagine you're editing multiple different source files for your latest project (let's call it moe) and then you go to sleep. On the next day you have other things to do, so you go to sleep again, but without having touched the code again.

Now on day three your memory has started to fade a little bit. Did you work on source file A or source file B three days before? Okay, it was both, but which one did you make the last edit on, and what exactly was that edit?

Now you sit down and type :replay

A split window appears. It contains a buffer for the very last file/buffer you edited last time, but this window/buffer/split is readonly. It contains line numbers and HH:MM:SS formatted times aligned to the left of the source, and the status bar of this split window contains a progress bar going from the first point in time this animation/replay preserved and will show, to the last point in time this animation/replay preserved and will show.

Like this:

14 | Monday    |  var i = 0
15 | Monday    |  var j = 0
16 | Monday    |  var k = 0
17 | 11:34:20  |  i = 100
18 | 11:34:34  |  j = 100 + i
19 | 5.6.2020  |  # this fake comment was supposedly made on 5.6.2020
20 | 10:32:03  |  # here the comment was changed today at around 10:30

REPLAY | [10:32:03]#########                                   [14:34:39]

In the example above the statusbar is showing REPLAY mode, and in this statusbar the # symbols are used to show the progress from the first point in time where the replay started, to the last point in time where the replay will end. Currently the progress is somewhere around the 11:30 mark in this replay, and therefore you can see changes on lines 20 (where the replay began), 17 and 18 (where the replay currently is at).

While the replay progresses, the buffer changes to the state the corresponding buffer/file was in at the point in time that is supposed to be represented by the progress bar.

So as the progress bar moves on, the buffer/file changes to a newer state, from each change to each change.

In order to be useful this replay has to be slow enough in order for the user to be able to follow what happened. The user should also be able to stop/play/go forward/go backward/jump to the end/jump to the beginning like in a media player. For stop/play the space key makes sense, for forward backward movements h, l, and similar vim keys as well as the arrow keys make sense. G, gg, for beginning and end.

To implement this feature moe needs to keep detailed track of the changes made in the last X (configurable) amount of hours. Of course, this is already the case in the sense that moe has an undo/redo feature, but the replay feature is supposed to work on buffers/files/projects/workspaces, even when you shutdown your computer, so in order to accomplish this, moe has to save the undo/redo buffer for a given amount of time since the last edit was made.

Say I want to keep the last 4 hours of changes for each file. This means we need to save the last 4 hours of undos/redos that happened before the last edit that has occurred on each buffer.

The REPLAY feature could then be implemented on a per file/buffer, per workspace/project, per sourcefolder, basis. The easiest implementation is of course for single file's and their buffers. However it would be more useful to see all the work you have done in the last 4 hours you worked, over your whole project, with the progress bar guiding you along over multiple files (all files that were edited), because with this method you're less likely to miss something.

As can be seen by my example pseudo output, there also needs to be a way to indicate when the lines that weren't touched in the X hour time frame, were touched, to give even more context. For this a SCM needs to be in place, and usually this will be git.

I think this would be a fine feature.

When you sit down again on day three and type ```:replay```` you should get a nice overview of what your latest work was, which files you touched and in which order, what exactly you changed and how long it took for you to make those changes.

Cherry on top: What would be even better than just replaying source changes, would be to replay the QuickRun/run output that went along with those changes. (optionally!) It should be possible to keep a log of all the times QuickRun/(any build process that ends with a run and produces savable output) has run and what output it produced. The output should be stored and retrieved. Exit codes (0 => success, everything else => failure) and said output should be printed in another split window that automatically closes, when the progress bar is moved.

Example:

[11:00]###############                                 [13:00]

Imagine that the # bar is at 12:00 and there was a QuickRun exactly at that time, producing a failure Output of some kind. Now the REPLAY feature should of course position the buffer that was last edited at 12:00 at the position this edit happened at. Because there was a QuickRun done on 12:00 another split window should open replaying(!) the results (instead of producing them again, it's better for performance and replay accuracy). But when the progress cursor (the # thing) is moved back in time, or further along, the quick run window should disappear again, to always only show information that was relevant at that specific point in time.

This way we'd be able to follow our own work of the last day or even last week, in exactly the way that we did it.

It would hopefully allow us to refresh our memory, which is the goal of this feature proposal.

And with the refreshed memory getting back to work would hopefully be quicker, so we get more done, and maybe we'll be happier coders.

Another use case: Say you're working at a company on some project, and then your boss comes by and wants to know what you did today. You could ask your boss, if he wants to see a quick replay of the last hours of work, (optionally including outputs). Your boss then would see what you've done and you could stop/play with the spacebar to talk about the changes in more detail. In a nutshell: It could be useful for sharing your latest progress with others, so they can understand what you've done.

tobimensch avatar Jul 18 '20 17:07 tobimensch