It's done by hook in $PROMPT_COMMAND and trap ... DEBUG too,
as well as abusing GNU/Screen's terminal logging feature.
I might publish its code once I tidy it up.
Command lines are saved in a separate history file with extra info:
The UI is done by fzf.
Bring it up by the usual Ctrl-R. It looks like this:

Ignore the first line now – that's my git prompt addon.
See the selected command line is displayed in the preview panel on right hand side. This is useful if a long command does not fit in 1 line.

It shows exit codes in red – unless it's all zero:

If the shell session was inside a properly configured GNU/Screen, the output is recorded and you can see it in the preview panel by Alt-L (L for log). Switch back the preview panel by Alt-H.

F1 shows keybindings.

keybindings...

Pressing Alt-C composes a command line which chdirs into the selected command's working directory
and issues the command itself. You can edit it before invoke.

Select multiple command by TAB. In this case a command line is composed which invokes all of them in order. You can select multiple items and press ALT-C to run each in their respective workdir as well.

This is a command line generated out of the selected 2:

Lastly, the Alt-R fzf keybinding makes this bash array, so you can work a given command's (or multiple commands') screen log files programatically (script-o-matically).

For example, just cat it and terminal control codes – including ANSI color codes – which were produced by the recalled command
are printed as well:

QED