mirror of
https://github.com/browser-use/web-ui.git
synced 2026-03-22 11:17:17 +08:00
make html invisible when in not headless mode
This commit is contained in:
20
webui.py
20
webui.py
@@ -540,8 +540,7 @@ async def run_with_stream(
|
||||
max_input_tokens=max_input_tokens
|
||||
)
|
||||
# Add HTML content at the start of the result array
|
||||
html_content = f"<h1 style='width:{stream_vw}vw; height:{stream_vh}vh'>Using browser...</h1>"
|
||||
yield [html_content] + list(result)
|
||||
yield [gr.update(visible=False)] + list(result)
|
||||
else:
|
||||
try:
|
||||
# Run the browser agent in the background
|
||||
@@ -593,7 +592,7 @@ async def run_with_stream(
|
||||
|
||||
if _global_agent and _global_agent.state.stopped:
|
||||
yield [
|
||||
html_content,
|
||||
gr.HTML(value=html_content, visible=True),
|
||||
final_result,
|
||||
errors,
|
||||
model_actions,
|
||||
@@ -607,7 +606,7 @@ async def run_with_stream(
|
||||
break
|
||||
else:
|
||||
yield [
|
||||
html_content,
|
||||
gr.HTML(value=html_content, visible=True),
|
||||
final_result,
|
||||
errors,
|
||||
model_actions,
|
||||
@@ -634,7 +633,7 @@ async def run_with_stream(
|
||||
errors = f"Agent error: {str(e)}"
|
||||
|
||||
yield [
|
||||
html_content,
|
||||
gr.HTML(value=html_content, visible=True),
|
||||
final_result,
|
||||
errors,
|
||||
model_actions,
|
||||
@@ -649,7 +648,9 @@ async def run_with_stream(
|
||||
except Exception as e:
|
||||
import traceback
|
||||
yield [
|
||||
f"<h1 style='width:{stream_vw}vw; height:{stream_vh}vh'>Waiting for browser session...</h1>",
|
||||
gr.HTML(
|
||||
value=f"<h1 style='width:{stream_vw}vw; height:{stream_vh}vh'>Waiting for browser session...</h1>",
|
||||
visible=True),
|
||||
"",
|
||||
f"Error: {str(e)}\n{traceback.format_exc()}",
|
||||
"",
|
||||
@@ -947,6 +948,7 @@ def create_ui(config, theme_name="Ocean"):
|
||||
browser_view = gr.HTML(
|
||||
value="<h1 style='width:80vw; height:50vh'>Waiting for browser session...</h1>",
|
||||
label="Live Browser View",
|
||||
visible=False
|
||||
)
|
||||
|
||||
gr.Markdown("### Results")
|
||||
@@ -1070,13 +1072,13 @@ def create_ui(config, theme_name="Ocean"):
|
||||
|
||||
with gr.TabItem("📁 UI Configuration", id=8):
|
||||
config_file_input = gr.File(
|
||||
label="Load Config File",
|
||||
label="Load UI Settings from Config File",
|
||||
file_types=[".pkl"],
|
||||
interactive=True
|
||||
)
|
||||
with gr.Row():
|
||||
load_config_button = gr.Button("Load Existing Config From File", variant="primary")
|
||||
save_config_button = gr.Button("Save Current Config", variant="primary")
|
||||
load_config_button = gr.Button("Load Config", variant="primary")
|
||||
save_config_button = gr.Button("Save UI Settings", variant="primary")
|
||||
|
||||
config_status = gr.Textbox(
|
||||
label="Status",
|
||||
|
||||
Reference in New Issue
Block a user