Skip to content

Commit 6bc91e2

Browse files
authored
feat: Merge upstream PR anomalyco#6478 - parallel subtasks and model fixes (anomalyco#229)
* fix(opencode): restore variant field in session prompt API The variant field was accidentally removed during a cherry-pick that fixed plugin commands. This restores variant support in PromptInput, CommandInput, and the corresponding message/command handlers. * refactor(opencode): extract CORS logic to dedicated module Move CORS origin validation to cors.ts for better testability and add support for *.shuv.ai domain alongside *.opencode.ai. * feat(app): add server URL persistence and welcome screen for hosted environments - Persist active server selection across sessions (server.v4 storage) - Add WelcomeScreen for hosted environments when server connection fails - Add connection state machine (connecting/ready/needs_config/error) - Add hosted environment detection utilities * feat(app): improve review pane with width constraints and empty state - Add REVIEW_PANE constants for centralized width configuration - Enforce max review pane width ratio (33% of viewport) - Handle window resize to maintain width constraints - Add empty state UI when no files to review * refactor(app): reorder header buttons for better UX - Move Theme/Font pickers before Review and Terminal toggles - Add clarifying comments for button groups * feat: merge upstream PR anomalyco#6478 - parallel subtasks, model inheritance, command.execute.before hook Merges changes from anomalyco#6478: - Add parallel subtask execution via Promise.all() - Fix model inheritance for subtasks with parent context restoration - Add command.execute.before plugin hook for pre-execution logic - Improve model resolution with proper fallback chain: command frontmatter > agent model > session model > default model - Extend SubtaskPart schema with model, parentAgent, parentModel fields - Update task tool to use ctx.extra.model for model override Closes anomalyco#225 --------- Co-authored-by: shuv <[email protected]>
1 parent 35b2b80 commit 6bc91e2

16 files changed

Lines changed: 913 additions & 242 deletions

File tree

‎packages/app/src/components/header.tsx‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ export function Header(props: {
5959
when={layout.projects.list().length > 0 && params.dir}
6060
fallback={
6161
<div class="hidden md:flex items-center gap-2 ml-auto">
62-
<FontPicker />
6362
<ThemePicker />
63+
<FontPicker />
6464
</div>
6565
}
6666
>
@@ -121,6 +121,12 @@ export function Header(props: {
121121
</Show>
122122
</div>
123123
<div class="flex items-center gap-4">
124+
{/* Theme and Font first - desktop only */}
125+
<div class="hidden md:flex items-center gap-2">
126+
<ThemePicker />
127+
<FontPicker />
128+
</div>
129+
{/* Review toggle - requires session */}
124130
<Show when={currentSession()}>
125131
<Tooltip
126132
class="hidden md:block shrink-0"
@@ -152,6 +158,7 @@ export function Header(props: {
152158
</Button>
153159
</Tooltip>
154160
</Show>
161+
{/* Terminal toggle - always visible on desktop */}
155162
<Tooltip
156163
class="hidden md:block shrink-0"
157164
value={
@@ -181,6 +188,7 @@ export function Header(props: {
181188
</div>
182189
</Button>
183190
</Tooltip>
191+
{/* Share - requires session and share enabled */}
184192
<Show when={shareEnabled() && currentSession()}>
185193
<Popover
186194
title="Share session"
@@ -216,10 +224,6 @@ export function Header(props: {
216224
})}
217225
</Popover>
218226
</Show>
219-
<div class="hidden md:flex items-center gap-2">
220-
<FontPicker />
221-
<ThemePicker />
222-
</div>
223227
</div>
224228
</>
225229
)
Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
import { createEffect, createMemo, createSignal, onCleanup, Show, For } from "solid-js"
2+
import { createStore, reconcile } from "solid-js/store"
3+
import { AsciiLogo } from "@opencode-ai/ui/logo"
4+
import { Button } from "@opencode-ai/ui/button"
5+
import { TextField } from "@opencode-ai/ui/text-field"
6+
import { Icon } from "@opencode-ai/ui/icon"
7+
import { normalizeServerUrl, serverDisplayName, useServer } from "@/context/server"
8+
import { usePlatform } from "@/context/platform"
9+
import { createOpencodeClient } from "@opencode-ai/sdk/v2/client"
10+
import { isHostedEnvironment, hasUrlQueryParam, getUrlQueryParam } from "@/utils/hosted"
11+
12+
type ServerStatus = { healthy: boolean; version?: string }
13+
14+
async function checkHealth(url: string, fetch?: typeof globalThis.fetch): Promise<ServerStatus> {
15+
const sdk = createOpencodeClient({
16+
baseUrl: url,
17+
fetch,
18+
signal: AbortSignal.timeout(3000),
19+
})
20+
return sdk.global
21+
.health()
22+
.then((x) => ({ healthy: x.data?.healthy === true, version: x.data?.version }))
23+
.catch(() => ({ healthy: false }))
24+
}
25+
26+
export interface WelcomeScreenProps {
27+
attemptedUrl?: string
28+
onRetry?: () => void
29+
}
30+
31+
export function WelcomeScreen(props: WelcomeScreenProps) {
32+
const server = useServer()
33+
const platform = usePlatform()
34+
const [store, setStore] = createStore({
35+
url: "",
36+
connecting: false,
37+
error: "",
38+
status: {} as Record<string, ServerStatus | undefined>,
39+
})
40+
41+
const urlOverride = getUrlQueryParam()
42+
const isLocalhost = () => {
43+
const url = props.attemptedUrl || ""
44+
return url.includes("localhost") || url.includes("127.0.0.1")
45+
}
46+
47+
const items = createMemo(() => {
48+
const list = server.list
49+
return list.filter((x) => x !== props.attemptedUrl)
50+
})
51+
52+
async function refreshHealth() {
53+
const results: Record<string, ServerStatus> = {}
54+
await Promise.all(
55+
items().map(async (url) => {
56+
results[url] = await checkHealth(url, platform.fetch)
57+
}),
58+
)
59+
setStore("status", reconcile(results))
60+
}
61+
62+
createEffect(() => {
63+
if (items().length === 0) return
64+
refreshHealth()
65+
const interval = setInterval(refreshHealth, 10_000)
66+
onCleanup(() => clearInterval(interval))
67+
})
68+
69+
async function handleConnect(url: string, persist = false) {
70+
const normalized = normalizeServerUrl(url)
71+
if (!normalized) return
72+
73+
setStore("connecting", true)
74+
setStore("error", "")
75+
76+
const result = await checkHealth(normalized, platform.fetch)
77+
setStore("connecting", false)
78+
79+
if (!result.healthy) {
80+
setStore("error", "Could not connect to server")
81+
return
82+
}
83+
84+
if (persist) {
85+
server.add(normalized)
86+
} else {
87+
server.setActive(normalized)
88+
}
89+
props.onRetry?.()
90+
}
91+
92+
async function handleSubmit(e: SubmitEvent) {
93+
e.preventDefault()
94+
const value = normalizeServerUrl(store.url)
95+
if (!value) return
96+
await handleConnect(value, true)
97+
}
98+
99+
return (
100+
<div class="relative flex-1 h-screen w-screen min-h-0 flex flex-col items-center justify-center bg-background-base font-sans p-4">
101+
<div class="w-full max-w-lg flex flex-col items-center justify-center gap-6">
102+
<AsciiLogo scale={1.0} class="opacity-40 shrink-0" />
103+
104+
<div class="flex flex-col items-center gap-2 text-center">
105+
<h1 class="text-lg font-medium text-text-strong">Welcome to Shuvcode</h1>
106+
<p class="text-sm text-text-weak">
107+
{urlOverride
108+
? `Could not connect to the server at ${urlOverride}`
109+
: "Connect to a Shuvcode server to get started"}
110+
</p>
111+
</div>
112+
113+
{/* Local Server Section */}
114+
<div class="w-full bg-background-subtle rounded-lg p-4 flex flex-col gap-3">
115+
<div class="flex items-center gap-2">
116+
<Icon name="console" class="text-icon-base" />
117+
<h2 class="text-sm font-medium text-text-strong">Local Server</h2>
118+
</div>
119+
120+
<Show when={isLocalhost()}>
121+
<div class="text-xs text-text-weak bg-background-base rounded p-3 font-mono">
122+
<p class="mb-2">Start a local server by running:</p>
123+
<code class="text-text-interactive-base">shuvcode</code>
124+
<p class="mt-2 text-text-weak">or</p>
125+
<code class="text-text-interactive-base">npx shuvcode</code>
126+
</div>
127+
</Show>
128+
129+
<Button
130+
variant="secondary"
131+
size="normal"
132+
onClick={() => handleConnect(props.attemptedUrl || "http://localhost:4096")}
133+
disabled={store.connecting}
134+
>
135+
{store.connecting ? "Connecting..." : "Retry Connection"}
136+
</Button>
137+
</div>
138+
139+
{/* Remote Server Section */}
140+
<div class="w-full bg-background-subtle rounded-lg p-4 flex flex-col gap-3">
141+
<div class="flex items-center gap-2">
142+
<Icon name="square-arrow-top-right" class="text-icon-base" />
143+
<h2 class="text-sm font-medium text-text-strong">Remote Server</h2>
144+
</div>
145+
146+
<form onSubmit={handleSubmit} class="flex flex-col gap-2">
147+
<div class="flex items-start gap-2">
148+
<div class="flex-1 min-w-0">
149+
<TextField
150+
type="text"
151+
label="Server URL"
152+
hideLabel
153+
placeholder="https://your-server.example.com"
154+
value={store.url}
155+
onChange={(v) => {
156+
setStore("url", v)
157+
setStore("error", "")
158+
}}
159+
validationState={store.error ? "invalid" : "valid"}
160+
error={store.error}
161+
/>
162+
</div>
163+
<Button type="submit" variant="primary" size="large" disabled={store.connecting || !store.url.trim()}>
164+
Connect
165+
</Button>
166+
</div>
167+
</form>
168+
169+
<p class="text-xs text-text-weak">
170+
Note: Connecting to a remote server means trusting that server with your data.
171+
</p>
172+
</div>
173+
174+
{/* Saved Servers Section */}
175+
<Show when={items().length > 0}>
176+
<div class="w-full bg-background-subtle rounded-lg p-4 flex flex-col gap-3">
177+
<h2 class="text-sm font-medium text-text-strong">Saved Servers</h2>
178+
<div class="flex flex-col gap-2">
179+
<For each={items()}>
180+
{(url) => (
181+
<button
182+
type="button"
183+
class="flex items-center gap-3 p-2 rounded hover:bg-background-base transition-colors text-left"
184+
onClick={() => handleConnect(url)}
185+
disabled={store.status[url]?.healthy === false}
186+
>
187+
<div
188+
classList={{
189+
"size-2 rounded-full shrink-0": true,
190+
"bg-icon-success-base": store.status[url]?.healthy === true,
191+
"bg-icon-critical-base": store.status[url]?.healthy === false,
192+
"bg-border-weak-base": store.status[url] === undefined,
193+
}}
194+
/>
195+
<span
196+
class="truncate text-sm"
197+
classList={{ "text-text-weak": store.status[url]?.healthy === false }}
198+
>
199+
{serverDisplayName(url)}
200+
</span>
201+
<Show when={store.status[url]?.version}>
202+
<span class="text-xs text-text-weak ml-auto">{store.status[url]?.version}</span>
203+
</Show>
204+
</button>
205+
)}
206+
</For>
207+
</div>
208+
</div>
209+
</Show>
210+
211+
{/* Troubleshooting Section */}
212+
<Show when={isHostedEnvironment()}>
213+
<details class="w-full text-xs text-text-weak">
214+
<summary class="cursor-pointer hover:text-text-base">Troubleshooting</summary>
215+
<div class="mt-2 p-3 bg-background-subtle rounded-lg flex flex-col gap-2">
216+
<p>
217+
<strong>Server not running:</strong> Make sure you have a Shuvcode server running locally or accessible
218+
remotely.
219+
</p>
220+
<p>
221+
<strong>CORS blocked:</strong> The server must allow requests from{" "}
222+
<code class="text-text-interactive-base">{location.origin}</code>. Local servers automatically allow
223+
this domain.
224+
</p>
225+
<p>
226+
<strong>Mixed content:</strong> If connecting to an <code>http://</code> server from this{" "}
227+
<code>https://</code> page, your browser may block the connection. Use <code>https://</code> for remote
228+
servers.
229+
</p>
230+
</div>
231+
</details>
232+
</Show>
233+
234+
<Show when={platform.version}>
235+
<p class="text-xs text-text-weak">Version: {platform.version}</p>
236+
</Show>
237+
</div>
238+
</div>
239+
)
240+
}

0 commit comments

Comments
 (0)