ProfessionalMario commited on
Commit
39f65bf
Β·
1 Parent(s): b617b0d

command fix

Browse files
Files changed (1) hide show
  1. app.py +20 -11
app.py CHANGED
@@ -55,8 +55,15 @@ def run_space_interface():
55
 
56
  def terminal_logic(command):
57
  output_buffer = io.StringIO()
58
- # No color_system means no "gibberish" ANSI codes, just clean text tables
59
- temp_console = Console(file=output_buffer, force_terminal=True, width=100, color_system=None)
 
 
 
 
 
 
 
60
 
61
  import cli_app.command_handler as handler
62
  old_console = getattr(handler, 'console', None)
@@ -65,6 +72,7 @@ def run_space_interface():
65
  try:
66
  result = handler.handle_command(command)
67
  captured = output_buffer.getvalue()
 
68
  return captured if not result else f"{captured}\n{result}"
69
  except Exception as e:
70
  return f"Error: {str(e)}"
@@ -72,15 +80,16 @@ def run_space_interface():
72
  if old_console:
73
  handler.console = old_console
74
 
75
- # Using Interface + Code block instead of ChatInterface
76
- demo = gr.Interface(
77
- fn=terminal_logic,
78
- inputs=gr.Textbox(label="Terminal Input", placeholder="Type command (e.g., 'help' or 'list')..."),
79
- outputs=gr.Code(label="Terminal Output", language="markdown"), # language=markdown helps with table spacing
80
- title="πŸ“Š EDA Explorer Terminal",
81
- allow_flagging="never"
82
- )
83
-
 
84
  demo.launch(server_name="0.0.0.0", server_port=7860)
85
 
86
  if __name__ == "__main__":
 
55
 
56
  def terminal_logic(command):
57
  output_buffer = io.StringIO()
58
+ # width=80 is safer for mobile/small screens
59
+ # color_system=None is CRITICAL to stop the  junk
60
+ temp_console = Console(
61
+ file=output_buffer,
62
+ force_terminal=True,
63
+ width=80,
64
+ color_system=None,
65
+ legacy_windows=False
66
+ )
67
 
68
  import cli_app.command_handler as handler
69
  old_console = getattr(handler, 'console', None)
 
72
  try:
73
  result = handler.handle_command(command)
74
  captured = output_buffer.getvalue()
75
+ # If your handler already prints, we just return the captured text
76
  return captured if not result else f"{captured}\n{result}"
77
  except Exception as e:
78
  return f"Error: {str(e)}"
 
80
  if old_console:
81
  handler.console = old_console
82
 
83
+ with gr.Blocks(title="EDA Explorer Terminal", theme="monochrome") as demo:
84
+ gr.Markdown("# πŸ“Š EDA Explorer Terminal")
85
+ gr.Markdown("Type `help` to see commands or `list` to see datasets.")
86
+
87
+ input_box = gr.Textbox(label="Command", placeholder="Type here...", autofocus=True)
88
+ # gr.Code forces the Monospace font so the table lines (┏━┓) align!
89
+ output_box = gr.Code(label="Console Output", language="text", lines=20)
90
+
91
+ input_box.submit(fn=terminal_logic, inputs=input_box, outputs=output_box)
92
+
93
  demo.launch(server_name="0.0.0.0", server_port=7860)
94
 
95
  if __name__ == "__main__":