Skip to content

Conversation

@tecosaur
Copy link
Member

@tecosaur tecosaur commented Oct 25, 2025

#59819 gave us a fancy new history UX, but there's more we can do make the REPL history as useful as possible! We can show what commands errored, what type they produced, and how long they took. Recording the working directory allows for filtering for code you've previously run a certain directory.

image

NB: I'm experimenting with putting error-indicator dots where the mode squares currently are, and with a new mode-indication column on the left. Neither of these styles are set, I'm just trying them out. The same with the particular style of the type/time box in the preview.

Sample of the expanded history file format;

# id: Dr7qjQYy795/1
# time: 2025-10-24 18:24:28Z
# mode: julia
# cwd: /home/tec
    using REPL
# result: Nothing in 0.03429s (Dr7qjQYy795/1)
# id: Dr7qjQYy795/2
# time: 2025-10-24 18:28:51Z
# mode: julia
    2^8
# result: Int64 in 0.01053s (Dr7qjQYy795/2)
# id: Dr7qjQYy795/3
# time: 2025-10-24 18:29:07Z
# mode: julia
    "hello " + "world"
# result: !MethodError in 0.01089s (Dr7qjQYy795/3)

Closes: #44681

Succeeds: #45076

Record information on:
- Session ID
- The current directory
- The result time
- Evaluation time
- Output type
- Error state

This allows for much richer use of history information going forwards,
both for display and interaction (e.g. showing what history entries
errored, searching for history in the current directory, etc.).
@tecosaur tecosaur added REPL Julia's REPL (Read Eval Print Loop) display and printing Aesthetics and correctness of printed representations of objects. stdlib Julia's standard library don't squash Don't squash merge labels Oct 25, 2025
setglobal!(Base.MainInclude, :ans, value)
put!(backend.response_channel, Pair{Any, Bool}(value, false))
push!(backend.hist.histfile,
HistUpdate(backend.hist.session, nameof(typeof(value)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pleased to see this only saves the nameof the type. Types can often be large and expensive to print (and also break the history format), so this is a nice compromise.

Really uncommon corner case, but it is possible for a typename to include a newline:

julia> struct var"Foo
       Bar"; end
julia> println(nameof(getproperty(Main, Symbol("Foo\nBar"))))
Foo
Bar

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this is cursed knowledge 😂. I'll strip/mangle them. Thanks for pointing this edge-case out 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

display and printing Aesthetics and correctness of printed representations of objects. don't squash Don't squash merge REPL Julia's REPL (Read Eval Print Loop) stdlib Julia's standard library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repl session uuid

2 participants