Skip to content

Commit 0d27d1a

Browse files
committed
fix: duplicate input display + CLI polish (full-width separators, ❯ prompt)
- LineEditor: use \r\n instead of \n in raw mode to fix ghost duplicate line - Prompt: minimal ❯ character instead of full directory path - Separators: full terminal width, no indent — matches Claude Code style - Banner: add separator line at bottom, shortened path (~/…/ProjectName)
1 parent 6f21c1d commit 0d27d1a

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

lib/optimal_system_agent/channels/cli.ex

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ defmodule OptimalSystemAgent.Channels.CLI do
3838
# Initialize history storage in ETS
3939
init_history()
4040

41-
IO.puts("")
4241
loop(session_id)
4342
end
4443

4544
defp loop(session_id) do
46-
dir = prompt_dir()
47-
prompt = "#{@dim}#{dir}#{@reset} #{@bold}#{@cyan}>#{@reset} "
45+
prompt = "#{@bold}#{@cyan}#{@reset} "
4846
history = get_history(session_id)
4947

5048
case LineEditor.readline(prompt, history) do
@@ -430,8 +428,8 @@ defmodule OptimalSystemAgent.Channels.CLI do
430428
end
431429

432430
defp print_separator do
433-
width = min(terminal_width() - 4, 72)
434-
IO.puts("#{@dim} #{String.duplicate("─", width)}#{@reset}\n")
431+
width = terminal_width()
432+
IO.puts("\n#{@dim}#{String.duplicate("─", width)}#{@reset}")
435433
end
436434

437435
defp format_elapsed(ms) when ms < 1_000, do: "<1s"
@@ -492,6 +490,7 @@ defmodule OptimalSystemAgent.Channels.CLI do
492490
version = Application.spec(:optimal_system_agent, :vsn) |> to_string()
493491
git_hash = git_short_hash()
494492
cwd = prompt_dir()
493+
width = terminal_width()
495494

496495
IO.puts("""
497496
#{@bold}#{@cyan}
@@ -505,6 +504,7 @@ defmodule OptimalSystemAgent.Channels.CLI do
505504
#{@dim}#{provider} / #{model} · #{skill_count} skills · soul: #{soul_status}#{@reset}
506505
#{@dim}#{cwd}#{@reset}
507506
#{@dim}/help#{@reset} #{@dim}commands · #{@bold}/model#{@reset} #{@dim}switch · #{@bold}exit#{@reset} #{@dim}quit#{@reset}
507+
#{@dim}#{String.duplicate("─", width)}#{@reset}
508508
""")
509509
end
510510

@@ -589,10 +589,18 @@ defmodule OptimalSystemAgent.Channels.CLI do
589589
cwd = File.cwd!()
590590
home = System.get_env("HOME") || ""
591591

592-
if home != "" and String.starts_with?(cwd, home) do
593-
"~" <> String.trim_leading(cwd, home)
594-
else
595-
cwd
592+
shortened =
593+
if home != "" and String.starts_with?(cwd, home) do
594+
"~" <> String.trim_leading(cwd, home)
595+
else
596+
cwd
597+
end
598+
599+
# Show abbreviated path: ~/…/ProjectName for deep paths
600+
parts = Path.split(shortened)
601+
case length(parts) do
602+
n when n > 3 -> "~/…/" <> List.last(parts)
603+
_ -> shortened
596604
end
597605
rescue
598606
_ -> "."

lib/optimal_system_agent/channels/cli/line_editor.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ defmodule OptimalSystemAgent.Channels.CLI.LineEditor do
5959

6060
IO.write(prompt)
6161
result = input_loop(state)
62-
IO.write("\n")
62+
# In raw mode (-onlcr), \n is just LF without CR — cursor stays at column.
63+
# Use \r\n to properly move to column 0 on the next line.
64+
IO.write("\r\n")
6365
result
6466
after
6567
restore_stty(saved)

0 commit comments

Comments
 (0)