@@ -89,16 +89,16 @@ def _generate_prompt_output_layout(self) -> Panel:
89
89
# Calculate available height for content
90
90
panel_height = 15 # Fixed panel height
91
91
available_lines = panel_height - 2 # Subtract 2 for panel borders
92
- lines_per_entry = available_lines // len (requests ) if requests else 0
92
+ lines_per_request = available_lines // len (requests ) if requests else 0
93
93
94
94
for (prompt , output ) in reversed (requests ):
95
95
prompt_icon , output_icon = "💬️" , "🤖"
96
96
97
- # Calculate max lines for prompt and output
98
- max_prompt_lines = max ( 3 , lines_per_entry // 2 ) # Ensure at least 3 lines for prompt
99
- max_output_lines = lines_per_entry - max_prompt_lines - 1 # Remaining space minus spacing
97
+ # Equal space allocation for prompt and output
98
+ max_prompt_lines = lines_per_request // 2
99
+ max_output_lines = lines_per_request - max_prompt_lines - 1 # -1 for spacing
100
100
101
- # Process prompt with more generous line allocation
101
+ # Process prompt
102
102
prompt_lines = []
103
103
for line in prompt .split ('\n ' ):
104
104
words = line .split ()
@@ -118,53 +118,55 @@ def _generate_prompt_output_layout(self) -> Panel:
118
118
if current_line :
119
119
prompt_lines .append (' ' .join (current_line ))
120
120
121
- # Show more prompt content and append ellipses to last line if needed
121
+ # Truncate prompt if needed
122
122
if len (prompt_lines ) > max_prompt_lines :
123
123
prompt_lines = prompt_lines [:max_prompt_lines ]
124
- # Append ellipses to last line if there's room, otherwise truncate last line
125
- last_line = prompt_lines [- 1 ]
126
- if len (last_line ) + 4 <= max_width : # +4 for " ..."
127
- prompt_lines [- 1 ] = last_line + " ..."
128
- else :
129
- prompt_lines [- 1 ] = last_line [:max_width - 4 ] + " ..."
124
+ if prompt_lines :
125
+ last_line = prompt_lines [- 1 ]
126
+ if len (last_line ) + 4 <= max_width :
127
+ prompt_lines [- 1 ] = last_line + " ..."
128
+ else :
129
+ prompt_lines [- 1 ] = last_line [:max_width - 4 ] + " ..."
130
130
131
131
prompt_text = Text (f"{ prompt_icon } " , style = "bold bright_blue" )
132
132
prompt_text .append ('\n ' .join (prompt_lines ), style = "white" )
133
+ content .append (prompt_text )
133
134
134
- # Process output - same word-aware wrapping
135
- output_lines = []
136
- for line in output .split ('\n ' ):
137
- words = line .split ()
138
- current_line = []
139
- current_length = 0
140
-
141
- for word in words :
142
- if current_length + len (word ) + 1 <= max_width :
143
- current_line .append (word )
144
- current_length += len (word ) + 1
145
- else :
146
- if current_line :
147
- output_lines .append (' ' .join (current_line ))
148
- current_line = [word ]
149
- current_length = len (word )
150
-
151
- if current_line :
152
- output_lines .append (' ' .join (current_line ))
153
-
154
- if len (output_lines ) > max_output_lines :
155
- output_lines = output_lines [:max_output_lines ]
156
- last_line = output_lines [- 1 ] if output_lines else None
157
- if last_line :
158
- if len (last_line ) + 4 <= max_width :
159
- output_lines [- 1 ] = last_line + " ..."
160
- else :
161
- output_lines [- 1 ] = last_line [:max_width - 4 ] + " ..."
162
-
163
- output_text = Text (f"\n { output_icon } " , style = "bold bright_magenta" )
164
- output_text .append ('\n ' .join (output_lines ), style = "white" )
135
+ # Process output with similar word wrapping
136
+ if output : # Only process output if it exists
137
+ output_lines = []
138
+ for line in output .split ('\n ' ):
139
+ words = line .split ()
140
+ current_line = []
141
+ current_length = 0
142
+
143
+ for word in words :
144
+ if current_length + len (word ) + 1 <= max_width :
145
+ current_line .append (word )
146
+ current_length += len (word ) + 1
147
+ else :
148
+ if current_line :
149
+ output_lines .append (' ' .join (current_line ))
150
+ current_line = [word ]
151
+ current_length = len (word )
152
+
153
+ if current_line :
154
+ output_lines .append (' ' .join (current_line ))
155
+
156
+ # Truncate output if needed
157
+ if len (output_lines ) > max_output_lines :
158
+ output_lines = output_lines [:max_output_lines ]
159
+ if output_lines :
160
+ last_line = output_lines [- 1 ]
161
+ if len (last_line ) + 4 <= max_width :
162
+ output_lines [- 1 ] = last_line + " ..."
163
+ else :
164
+ output_lines [- 1 ] = last_line [:max_width - 4 ] + " ..."
165
+
166
+ output_text = Text (f"{ output_icon } " , style = "bold bright_magenta" )
167
+ output_text .append ('\n ' .join (output_lines ), style = "white" )
168
+ content .append (output_text )
165
169
166
- content .append (prompt_text )
167
- content .append (output_text )
168
170
content .append (Text ()) # Empty line between entries
169
171
170
172
return Panel (
0 commit comments