p4r5kpftnp-cmd Claude Sonnet 4.6 commited on
Commit
0834777
·
1 Parent(s): 23a1c60

Redesign Gradio UI with VSCode-style Claude theme

Browse files

Three-pane layout: editor on the left, proof+logs in the middle, config
panel on the right. Custom CSS overrides Gradio's default chrome to match
a dark VSCode look — JetBrains Mono code font, file-tab headers, Claude
orange (#D97757) accents on the cursor, primary button, and bottom status
bar. The status bar mimics VSCode's blue strip but in Claude orange and
shows verification state inline.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +245 -32
app.py CHANGED
@@ -25,12 +25,193 @@ theorem add_zero_simple (n : ℕ) : n + 0 = n := by
25
  """
26
 
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  def solve_proof(lean_code: str, model_name: str, max_retries: int) -> tuple[str, str, str]:
29
  if not lean_code.strip():
30
- return "Please enter some Lean 4 code.", "", ""
31
 
32
  if not os.environ.get("GROQ_API_KEY"):
33
- return "GROQ_API_KEY is not set. Add it as a Space secret.", "", ""
34
 
35
  tmp = tempfile.NamedTemporaryFile(suffix=".lean", mode="w", delete=False, dir="/tmp")
36
  try:
@@ -48,58 +229,90 @@ def solve_proof(lean_code: str, model_name: str, max_retries: int) -> tuple[str,
48
  logs = log_buf.getvalue()
49
 
50
  if result["success"]:
51
- status = f"Proof verified on attempt {result['solved_at_attempt']} of {result['total_attempts']}."
52
  else:
53
- status = f"Could not find a proof after {result['total_attempts']} attempts."
54
 
55
  return status, final_code, logs
56
 
57
  except Exception as exc:
58
- return f"Error: {exc}", "", ""
59
  finally:
60
  os.unlink(tmp.name)
61
 
62
 
63
- with gr.Blocks(title="Lean 4 Proof Assistant") as demo:
64
- gr.Markdown(
65
- "# Lean 4 Proof Assistant\n"
66
- "Paste Lean 4 code containing `sorry` placeholders. "
67
- "The agent will use Mathlib RAG + an LLM to complete the proof and verify it with the Lean REPL.\n\n"
68
- "> **Note:** Proof attempts can take 1–5 minutes. Please be patient."
 
 
 
 
 
 
 
 
 
 
 
69
  )
70
 
71
- with gr.Row():
72
- with gr.Column(scale=1):
 
 
73
  lean_input = gr.Code(
74
- label="Lean 4 Code",
75
  language=None,
76
  value=EXAMPLE_CODE,
77
- lines=18,
 
78
  )
79
- with gr.Row():
80
- model_dropdown = gr.Dropdown(
81
- choices=GROQ_MODELS,
82
- value=GROQ_MODELS[0],
83
- label="Model",
84
- )
85
- retries_slider = gr.Slider(
86
- minimum=1, maximum=10, value=5, step=1,
87
- label="Max Retries",
88
- )
89
- submit_btn = gr.Button("Solve Proof", variant="primary")
90
-
91
- with gr.Column(scale=1):
92
- status_output = gr.Textbox(label="Status", interactive=False, lines=2)
93
  code_output = gr.Code(
94
- label="Completed Proof",
95
  language=None,
96
  interactive=False,
97
  lines=14,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  )
99
- logs_output = gr.Textbox(label="Agent Logs", interactive=False, lines=8)
 
 
 
 
 
 
 
 
100
 
101
  submit_btn.click(
102
- solve_proof,
103
  inputs=[lean_input, model_dropdown, retries_slider],
104
  outputs=[status_output, code_output, logs_output],
105
  )
 
25
  """
26
 
27
 
28
+ CUSTOM_CSS = """
29
+ /* ----- Reset Gradio chrome ----- */
30
+ .gradio-container {
31
+ background: #1e1e1e !important;
32
+ color: #d4d4d4 !important;
33
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif !important;
34
+ max-width: 100% !important;
35
+ padding: 0 !important;
36
+ margin: 0 !important;
37
+ }
38
+
39
+ footer { display: none !important; }
40
+ .show-api { display: none !important; }
41
+
42
+ /* ----- Top title bar (VSCode menu strip) ----- */
43
+ #title-bar {
44
+ background: #323233;
45
+ border-bottom: 1px solid #1e1e1e;
46
+ padding: 6px 16px;
47
+ font-size: 13px;
48
+ color: #cccccc;
49
+ display: flex;
50
+ align-items: center;
51
+ gap: 16px;
52
+ }
53
+
54
+ #title-bar .logo {
55
+ color: #D97757;
56
+ font-weight: 700;
57
+ letter-spacing: 0.3px;
58
+ }
59
+
60
+ #title-bar .subtle {
61
+ color: #858585;
62
+ font-size: 12px;
63
+ }
64
+
65
+ /* ----- Tab bar above editors ----- */
66
+ .editor-tab {
67
+ background: #2d2d30 !important;
68
+ border: none !important;
69
+ border-bottom: 1px solid #1e1e1e !important;
70
+ padding: 0 !important;
71
+ margin: 0 !important;
72
+ }
73
+
74
+ .editor-tab .tab-label {
75
+ display: inline-block;
76
+ background: #1e1e1e;
77
+ color: #ffffff;
78
+ padding: 8px 14px;
79
+ font-size: 12px;
80
+ border-right: 1px solid #252526;
81
+ border-top: 2px solid #D97757;
82
+ font-family: 'JetBrains Mono', 'SF Mono', ui-monospace, Menlo, monospace;
83
+ }
84
+
85
+ .editor-tab .tab-label-inactive {
86
+ background: #2d2d30;
87
+ color: #969696;
88
+ border-top: 2px solid transparent;
89
+ }
90
+
91
+ /* ----- Code editor styling (Monaco/CodeMirror overrides) ----- */
92
+ .cm-editor {
93
+ background: #1e1e1e !important;
94
+ font-family: 'JetBrains Mono', 'SF Mono', ui-monospace, Menlo, monospace !important;
95
+ font-size: 13px !important;
96
+ line-height: 1.6 !important;
97
+ }
98
+
99
+ .cm-content { color: #d4d4d4 !important; }
100
+ .cm-gutters { background: #1e1e1e !important; color: #858585 !important; border-right: 1px solid #252526 !important; }
101
+ .cm-activeLine { background: #2a2d2e !important; }
102
+ .cm-activeLineGutter { background: #2a2d2e !important; color: #c6c6c6 !important; }
103
+ .cm-cursor { border-left-color: #D97757 !important; }
104
+
105
+ /* Code block wrapper */
106
+ .block.gr-block, .gradio-container .block {
107
+ background: #1e1e1e !important;
108
+ border: 1px solid #2d2d30 !important;
109
+ border-radius: 0 !important;
110
+ box-shadow: none !important;
111
+ }
112
+
113
+ /* Hide Gradio's default labels above code blocks (we use our own tabs) */
114
+ .gr-code label, .code-container > label {
115
+ display: none !important;
116
+ }
117
+
118
+ /* ----- Sidebar / control panel ----- */
119
+ .control-panel {
120
+ background: #252526 !important;
121
+ border-left: 1px solid #1e1e1e !important;
122
+ padding: 16px !important;
123
+ }
124
+
125
+ /* ----- Labels ----- */
126
+ label, .label-wrap {
127
+ color: #cccccc !important;
128
+ font-size: 11px !important;
129
+ text-transform: uppercase !important;
130
+ letter-spacing: 0.6px !important;
131
+ font-weight: 600 !important;
132
+ margin-bottom: 6px !important;
133
+ }
134
+
135
+ /* ----- Dropdown ----- */
136
+ .gradio-dropdown, select, .wrap.dropdown {
137
+ background: #3c3c3c !important;
138
+ color: #d4d4d4 !important;
139
+ border: 1px solid #3e3e42 !important;
140
+ border-radius: 2px !important;
141
+ font-size: 12px !important;
142
+ }
143
+
144
+ .gradio-dropdown input { color: #d4d4d4 !important; }
145
+
146
+ /* ----- Slider ----- */
147
+ input[type="range"] { accent-color: #D97757 !important; }
148
+ .gradio-slider .head { color: #d4d4d4 !important; }
149
+
150
+ /* ----- Buttons ----- */
151
+ button.lg, button.primary, .gr-button-primary {
152
+ background: #D97757 !important;
153
+ color: #ffffff !important;
154
+ border: none !important;
155
+ border-radius: 3px !important;
156
+ padding: 8px 18px !important;
157
+ font-weight: 500 !important;
158
+ font-size: 12px !important;
159
+ text-transform: uppercase !important;
160
+ letter-spacing: 0.5px !important;
161
+ box-shadow: none !important;
162
+ transition: background 0.15s ease;
163
+ }
164
+
165
+ button.lg:hover, button.primary:hover, .gr-button-primary:hover {
166
+ background: #c56a4d !important;
167
+ }
168
+
169
+ button.lg:disabled {
170
+ background: #555 !important;
171
+ cursor: not-allowed !important;
172
+ }
173
+
174
+ /* ----- Textbox / output ----- */
175
+ textarea, .gradio-textbox textarea, .gr-text-input {
176
+ background: #1e1e1e !important;
177
+ color: #d4d4d4 !important;
178
+ border: 1px solid #2d2d30 !important;
179
+ border-radius: 2px !important;
180
+ font-family: 'JetBrains Mono', 'SF Mono', ui-monospace, Menlo, monospace !important;
181
+ font-size: 12px !important;
182
+ }
183
+
184
+ /* ----- Status bar (VSCode bottom strip) ----- */
185
+ #status-bar {
186
+ background: #D97757;
187
+ color: #ffffff;
188
+ padding: 4px 16px;
189
+ font-size: 11px;
190
+ font-family: 'JetBrains Mono', 'SF Mono', ui-monospace, Menlo, monospace;
191
+ display: flex;
192
+ align-items: center;
193
+ gap: 16px;
194
+ }
195
+
196
+ #status-bar .pill {
197
+ padding: 1px 8px;
198
+ background: rgba(0,0,0,0.15);
199
+ border-radius: 2px;
200
+ }
201
+
202
+ /* ----- Layout tweaks ----- */
203
+ .gr-row, .row { gap: 0 !important; }
204
+ .gr-column, .column { gap: 8px !important; }
205
+ .gradio-container > div { gap: 0 !important; }
206
+ """
207
+
208
+
209
  def solve_proof(lean_code: str, model_name: str, max_retries: int) -> tuple[str, str, str]:
210
  if not lean_code.strip():
211
+ return "● No input.", "", ""
212
 
213
  if not os.environ.get("GROQ_API_KEY"):
214
+ return "● GROQ_API_KEY missing — add it as a Space secret.", "", ""
215
 
216
  tmp = tempfile.NamedTemporaryFile(suffix=".lean", mode="w", delete=False, dir="/tmp")
217
  try:
 
229
  logs = log_buf.getvalue()
230
 
231
  if result["success"]:
232
+ status = f"✓ Verified on attempt {result['solved_at_attempt']} / {result['total_attempts']}"
233
  else:
234
+ status = f"✗ No proof found after {result['total_attempts']} attempts"
235
 
236
  return status, final_code, logs
237
 
238
  except Exception as exc:
239
+ return f"✗ Error: {exc}", "", ""
240
  finally:
241
  os.unlink(tmp.name)
242
 
243
 
244
+ with gr.Blocks(
245
+ title="Lean 4 Proof Assistant",
246
+ theme=gr.themes.Base(
247
+ primary_hue="orange",
248
+ neutral_hue="slate",
249
+ font=[gr.themes.GoogleFont("Inter"), "system-ui", "sans-serif"],
250
+ font_mono=[gr.themes.GoogleFont("JetBrains Mono"), "ui-monospace", "monospace"],
251
+ ),
252
+ css=CUSTOM_CSS,
253
+ ) as demo:
254
+ gr.HTML(
255
+ """
256
+ <div id="title-bar">
257
+ <span class="logo">◆ Lean 4 Proof Assistant</span>
258
+ <span class="subtle">— Mathlib RAG · Groq · LangGraph</span>
259
+ </div>
260
+ """
261
  )
262
 
263
+ with gr.Row(equal_height=True):
264
+ # Left pane: editor
265
+ with gr.Column(scale=3):
266
+ gr.HTML('<div class="editor-tab"><span class="tab-label">theorem.lean</span></div>')
267
  lean_input = gr.Code(
 
268
  language=None,
269
  value=EXAMPLE_CODE,
270
+ lines=22,
271
+ show_label=False,
272
  )
273
+
274
+ # Right pane: output
275
+ with gr.Column(scale=3):
276
+ gr.HTML('<div class="editor-tab"><span class="tab-label">proof.lean</span><span class="tab-label tab-label-inactive">logs</span></div>')
 
 
 
 
 
 
 
 
 
 
277
  code_output = gr.Code(
 
278
  language=None,
279
  interactive=False,
280
  lines=14,
281
+ show_label=False,
282
+ )
283
+ logs_output = gr.Textbox(
284
+ interactive=False,
285
+ lines=7,
286
+ show_label=False,
287
+ placeholder="agent logs will stream here…",
288
+ )
289
+
290
+ # Far right: controls
291
+ with gr.Column(scale=1, elem_classes="control-panel"):
292
+ gr.HTML('<div style="color:#858585;font-size:11px;text-transform:uppercase;letter-spacing:0.6px;margin-bottom:12px;">Configuration</div>')
293
+ model_dropdown = gr.Dropdown(
294
+ choices=GROQ_MODELS,
295
+ value=GROQ_MODELS[0],
296
+ label="Model",
297
+ show_label=True,
298
+ )
299
+ retries_slider = gr.Slider(
300
+ minimum=1, maximum=10, value=5, step=1,
301
+ label="Max retries",
302
+ show_label=True,
303
  )
304
+ submit_btn = gr.Button("Solve Proof", variant="primary", size="lg")
305
+ gr.HTML('<div style="color:#858585;font-size:11px;margin-top:12px;line-height:1.5;">Proofs typically take 1–5 minutes. The agent will retry on failure.</div>')
306
+
307
+ status_output = gr.HTML('<div id="status-bar"><span class="pill">idle</span><span>ready</span></div>')
308
+
309
+ def wrap_status(status: str, code: str, logs: str):
310
+ pill = "ok" if status.startswith("✓") else ("err" if status.startswith("✗") else "...")
311
+ html = f'<div id="status-bar"><span class="pill">{pill}</span><span>{status}</span></div>'
312
+ return html, code, logs
313
 
314
  submit_btn.click(
315
+ lambda code, model, retries: wrap_status(*solve_proof(code, model, retries)),
316
  inputs=[lean_input, model_dropdown, retries_slider],
317
  outputs=[status_output, code_output, logs_output],
318
  )