Skip to content

Commit 5c9619a

Browse files
authored
Merge pull request #15 from jaseci-labs/clean
Clean
2 parents d31766a + f47df54 commit 5c9619a

13 files changed

Lines changed: 40 additions & 122 deletions

File tree

components/mcp/history_panel.cl.jac

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cl import from ..ui.json_viewer { JsonViewer }
55
cl import from ...store.mcp_store { useMcpStore }
66

77
def HistoryEntry(props: Any) -> JsxElement {
8-
`entry = props.entry;
8+
hist_entry = props.entry;
99

1010
has expanded: bool = False;
1111

@@ -21,21 +21,21 @@ def HistoryEntry(props: Any) -> JsxElement {
2121
"pending": "border-warning/10 hover:border-warning/20"
2222
};
2323

24-
entryStatus = `entry.status if `entry else "pending";
24+
entryStatus = hist_entry.status if hist_entry else "pending";
2525
entryIcon = statusIcon.success if entryStatus == "success" else (statusIcon.error if entryStatus == "error" else statusIcon.pending);
2626
entryBgCls = statusBg.success if entryStatus == "success" else (statusBg.error if entryStatus == "error" else statusBg.pending);
2727
entryStatusCls = "text-success" if entryStatus == "success" else ("text-destructive" if entryStatus == "error" else "text-warning");
28-
entryTimestamp = `entry.timestamp or "";
29-
entryServerName = `entry.serverName or "";
30-
entryDuration = `entry.durationMs;
28+
entryTimestamp = hist_entry.timestamp or "";
29+
entryServerName = hist_entry.serverName or "";
30+
entryDuration = hist_entry.durationMs;
3131

3232
return <div className={f"border rounded-lg overflow-hidden text-xs transition-colors {entryBgCls}"}>
3333
<button
3434
className="w-full flex items-center gap-2 px-3 py-2 bg-card/30 hover:bg-card/60 transition-colors text-left cursor-pointer"
3535
onClick={lambda -> None { expanded = not expanded; }}
3636
>
3737
{entryIcon}
38-
<span className="flex-1 font-mono text-foreground/80 truncate">{`entry.method}</span>
38+
<span className="flex-1 font-mono text-foreground/80 truncate">{hist_entry.method}</span>
3939
{entryDuration and <span className="flex items-center gap-0.5 text-muted-foreground/60"><Clock size={9}/>{entryDuration}ms</span>}
4040
{<ChevronDown size={11} className="text-muted-foreground/40 flex-shrink-0"/> if expanded else <ChevronRight size={11} className="text-muted-foreground/40 flex-shrink-0"/>}
4141
</button>
@@ -48,15 +48,15 @@ def HistoryEntry(props: Any) -> JsxElement {
4848
4949
<div>
5050
<p className="text-muted-foreground mb-1 font-medium text-xs">Request</p>
51-
<JsonViewer data={`entry.request} maxHeight="150px"/>
51+
<JsonViewer data={hist_entry.request} maxHeight="150px"/>
5252
</div>
5353
54-
{`entry.response and <div>
54+
{hist_entry.response and <div>
5555
<p className={f"mb-1 font-medium text-xs {entryStatusCls}"}>Response</p>
56-
<JsonViewer data={`entry.response} maxHeight="200px"/>
56+
<JsonViewer data={hist_entry.response} maxHeight="200px"/>
5757
</div>}
5858
59-
{`entry.status == "pending" and <p className="text-warning text-xs italic">Waiting for response...</p>}
59+
{hist_entry.status == "pending" and <p className="text-warning text-xs italic">Waiting for response...</p>}
6060
</div>}
6161
</div>;
6262
}
@@ -107,8 +107,8 @@ def:pub HistoryPanel(props: Any) -> JsxElement {
107107
<p className="text-xs font-medium text-muted-foreground/60">No logs yet</p>
108108
<p className="text-xs text-muted-foreground/40">Requests will appear here</p>
109109
</div>}
110-
{len(filtered) > 0 and filtered.map(lambda(`entry: Any) -> Any {
111-
return <HistoryEntry key={`entry.id} entry={`entry}/>;
110+
{len(filtered) > 0 and filtered.map(lambda(hist_entry: Any) -> Any {
111+
return <HistoryEntry key={hist_entry.id} entry={hist_entry}/>;
112112
})}
113113
</div>
114114
</div>;

components/ui/primitives.cl.jac

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -155,29 +155,3 @@ def:pub Textarea(props: Any) -> JsxElement {
155155
</div>;
156156
}
157157

158-
def:pub Panel(props: Any) -> JsxElement {
159-
title = props.title;
160-
children = props.children;
161-
actions = props.actions;
162-
extraClass = props.className or "";
163-
164-
return <div className={cn(["bg-card border border-border rounded-xl overflow-hidden", extraClass])}>
165-
{title and <div className="flex items-center justify-between px-4 py-2.5 border-b border-border bg-muted/30">
166-
<span className="text-sm font-semibold text-foreground">{title}</span>
167-
{actions and <div className="flex items-center gap-2">{actions}</div>}
168-
</div>}
169-
<div className="p-4">{children}</div>
170-
</div>;
171-
}
172-
173-
def:pub Empty(props: Any) -> JsxElement {
174-
icon = props.icon or "";
175-
message = props.message or "Nothing here";
176-
sub = props.sub;
177-
178-
return <div className="flex flex-col items-center justify-center py-12 gap-2 text-muted-foreground">
179-
<span className="text-3xl">{icon}</span>
180-
<p className="text-sm font-medium">{message}</p>
181-
{sub and <p className="text-xs text-muted-foreground/70">{sub}</p>}
182-
</div>;
183-
}

components/ui/schema_form.cl.jac

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ def RenderFieldForSchema(schema: Any, path: Any, value: Any, onChange: Any) -> A
5050
return <div className="pl-3 border-l border-border flex flex-col gap-3">
5151
{Object.keys(subProps).map(lambda(key: Any) -> Any {
5252
subSchema = subProps[key] or {};
53-
subValue = (value or {})[key]; return <div key={key}>
53+
subValue = (value or {})[key];
54+
return <div key={key}>
5455
<label className="block text-xs font-medium text-muted-foreground mb-1">{key}</label>
5556
<RenderFieldForSchema schema={subSchema} path={f"{path}.{key}"} value={subValue} onChange={onChange}/>
5657
</div>;
@@ -168,9 +169,9 @@ def RenderFieldForSchema(schema: Any, path: Any, value: Any, onChange: Any) -> A
168169
/>;
169170
}
170171

171-
def setNestedValue(`obj: Any, path: Any, value: Any) -> Any {
172+
def setNestedValue(source: Any, path: Any, value: Any) -> Any {
172173
parts = path.split(".");
173-
result = {**`obj};
174+
result = {**source};
174175
current = result;
175176
i = 0;
176177
while i < len(parts) - 1 {

data/mcp_servers.cl.jac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Central MCP server registry – add new servers here."""
22

3-
def:pub getMcpServers -> Any {
3+
def:pub getMcpServers -> list {
44
return [
55
{
66
"id": "jac-mcp",

hooks/useMcpClient.cl.jac

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ Routes all calls through the backend /api/mcp-proxy endpoint which handles CORS.
66
cl import from ..store.mcp_store { useMcpStore }
77

88
# Module-level session cache — updated synchronously, bypasses React state timing.
9-
# Keyed by connection ID, stores the mcp-session-id value.
10-
glob _sessions: Any = {};
9+
glob sessions: Any = {};
10+
11+
glob MCP_PROXY_ENDPOINT: str = "/function/mcp_proxy";
1112

1213
def buildRpcRequest(method: Any, params: Any = None) -> Any {
1314
req = {
@@ -48,7 +49,7 @@ def:pub useMcpClient -> Any {
4849
authHeaders = buildAuthHeaders(connection.auth);
4950

5051
# Attach session ID from synchronous cache (not React state)
51-
sid = _sessions[connection.id];
52+
sid = sessions[connection.id];
5253
if sid {
5354
authHeaders["mcp-session-id"] = sid;
5455
}
@@ -68,7 +69,7 @@ def:pub useMcpClient -> Any {
6869
addHistoryEntry(histEntry);
6970

7071
try {
71-
fetchResp = await fetch("/function/mcp_proxy", {
72+
fetchResp = await fetch(MCP_PROXY_ENDPOINT, {
7273
"method": "POST",
7374
"headers": {"Content-Type": "application/json"},
7475
"body": JSON.stringify({
@@ -102,7 +103,7 @@ def:pub useMcpClient -> Any {
102103

103104
# Save session ID synchronously in module-level cache
104105
if resp.sessionId {
105-
_sessions[connection.id] = resp.sessionId;
106+
sessions[connection.id] = resp.sessionId;
106107
updateConnection(connection.id, {"sessionId": resp.sessionId});
107108
}
108109

@@ -128,7 +129,7 @@ def:pub useMcpClient -> Any {
128129

129130
async def initialize(connection: Any) -> Any {
130131
# Clear stale session synchronously before connecting
131-
_sessions[connection.id] = None;
132+
sessions[connection.id] = None;
132133
updateConnection(connection.id, {"status": "connecting", "sessionId": None});
133134

134135
resp = await sendRpc(connection, "initialize", {

jac.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ jaclang = ">=0.12.0"
2828
[dependencies.npm]
2929
jac-client-node = "1.0.7"
3030
tailwindcss = "latest"
31-
zod = "^3.23.0"
32-
react-hook-form = "^7.53.0"
3331
"@uiw/react-json-view" = "^2.0.0-alpha.30"
3432
"@monaco-editor/react" = "^4.6.0"
3533
lucide-react = "^0.468.0"

pages/playground/[id].jac

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,7 @@ cl {
3737

3838
setActiveConnection(connId);
3939

40-
connection = None;
41-
for conn in connections {
42-
if conn.id == connId {
43-
connection = conn;
44-
}
45-
}
40+
connection = connections.find(lambda(c: Any) -> Any { return c.id == connId; }) or None;
4641

4742
if not connection {
4843
return <div className="flex flex-col items-center justify-center h-[calc(100vh-3.5rem)] gap-6 text-muted-foreground">

pages/playground/prompt/[name].jac

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,15 @@ cl {
2323
has argValues: Any = {};
2424
has copied: bool = False;
2525

26-
# Find active connection
27-
activeConnection = None;
28-
for conn in connections {
29-
if conn.id == activeConnectionId {
30-
activeConnection = conn;
31-
}
32-
}
26+
activeConnection = connections.find(lambda(c: Any) -> Any { return c.id == activeConnectionId; }) or None;
3327

3428
backPath = f"/playground/{activeConnectionId}" if activeConnectionId else "/playground";
3529

36-
# Find prompt
3730
prompt = selectedPrompt;
3831
if activeConnection and activeConnection.status == "connected" and activeConnection.capabilities {
3932
prompts = activeConnection.capabilities.prompts or [];
40-
for p in prompts {
41-
if p.name == promptName {
42-
prompt = p;
43-
}
44-
}
33+
found = prompts.find(lambda(p: Any) -> Any { return p.name == promptName; });
34+
if found { prompt = found; }
4535
}
4636

4737
if not prompt {

pages/playground/resource/[uri].jac

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,15 @@ cl {
2323
has error: Any = None;
2424
has copied: bool = False;
2525

26-
# Find active connection
27-
activeConnection = None;
28-
for conn in connections {
29-
if conn.id == activeConnectionId {
30-
activeConnection = conn;
31-
}
32-
}
26+
activeConnection = connections.find(lambda(c: Any) -> Any { return c.id == activeConnectionId; }) or None;
3327

3428
backPath = f"/playground/{activeConnectionId}" if activeConnectionId else "/playground";
3529

36-
# Find resource
3730
resource = selectedResource;
3831
if activeConnection and activeConnection.status == "connected" and activeConnection.capabilities {
3932
resources = activeConnection.capabilities.resources or [];
40-
for r in resources {
41-
if r.uri == resourceUri {
42-
resource = r;
43-
}
44-
}
33+
found = resources.find(lambda(r: Any) -> Any { return r.uri == resourceUri; });
34+
if found { resource = found; }
4535
}
4636

4737
if not resource {

pages/playground/tool/[name].jac

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,15 @@ cl {
2323
has resultError: Any = None;
2424
has copied: bool = False;
2525

26-
# Find active connection
27-
activeConnection = None;
28-
for conn in connections {
29-
if conn.id == activeConnectionId {
30-
activeConnection = conn;
31-
}
32-
}
26+
activeConnection = connections.find(lambda(c: Any) -> Any { return c.id == activeConnectionId; }) or None;
3327

3428
backPath = f"/playground/{activeConnectionId}" if activeConnectionId else "/playground";
3529

36-
# Find tool from capabilities or store
3730
tool = selectedTool;
3831
if activeConnection and activeConnection.status == "connected" and activeConnection.capabilities {
3932
tools = activeConnection.capabilities.tools or [];
40-
for t in tools {
41-
if t.name == toolName {
42-
tool = t;
43-
}
44-
}
33+
found = tools.find(lambda(t: Any) -> Any { return t.name == toolName; });
34+
if found { tool = found; }
4535
}
4636

4737
if not tool {

0 commit comments

Comments
 (0)