fix(app): pass the Home automations entry into the projects view instead of reading contexts there (#66635)

Co-authored-by: opencodejr[bot] <348916617+opencodejr[bot]@users.noreply.github.com>
Co-authored-by: Filip <filip@anoma.ly>
This commit is contained in:
opencodejr[bot] 2026-11-26 17:37:11 +01:00 • committed by GitHub
parent 104bda5ba3
commit 93e053ff89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 32 additions and 13 deletions

View file

@ -12,12 +12,16 @@ import { Schema } from "effect"
import { Persistence } from "@/runtime/persistence/schema"
import type { HomeController } from "../model"
import { createProjectActions } from "./actions"
import type { HomeAutomationsEntry } from "./view"
export type HomeProjectsUtility = { settings: () => void; help: () => void; automations?: HomeAutomationsEntry }
export const HomeServersSchema = Schema.Struct({
collapsed: Persistence.record(Persistence.fallback(Schema.Boolean, () => false)),
})
export function createHomeProjectsController(home: HomeController) {
// Automations come from the shell's AutomationSource; surfaces mounted without it (stories) leave the entry out.
export function createHomeProjectsController(home: HomeController, options?: { automations?: HomeAutomationsEntry }) {
const platform = usePlatform()
const pickDirectory = useDirectoryPicker()
@ -47,6 +51,13 @@ export function createHomeProjectsController(home: HomeController) {
})
}
const utility: HomeProjectsUtility = {
settings: openSettings,
help: () => platform.openExternal("https://opencode.ai/desktop-feedback"),
}
if (options?.automations) utility.automations = options.automations
return {
copy: {
language,
@ -99,10 +110,7 @@ export function createHomeProjectsController(home: HomeController) {
canReveal: actions.canReveal,
reveal: actions.reveal,
},
utility: {
settings: openSettings,
help: () => platform.openExternal("https://opencode.ai/desktop-feedback"),
},
utility,
}
}

View file

@ -58,6 +58,7 @@ export function HomeProjects(props: {
onHideProject={props.projects.project.hide}
onOpenSettings={props.projects.utility.settings}
onOpenHelp={props.projects.utility.help}
automations={props.projects.utility.automations}
/>
)
}

View file

@ -1,6 +1,4 @@
import { createMemo, For, type JSX, onCleanup, Show, splitProps } from "solid-js"
import { useAutomationSource } from "@/automations/source"
import { useNavigate } from "@solidjs/router"
import { createStore } from "solid-js/store"
import { createResizeObserver } from "@solid-primitives/resize-observer"
import { Popover } from "@kobalte/core/popover"
@ -83,6 +81,8 @@ export type HomeProjectsViewProps = {
onHideProject: (server: ServerConnection.Any, project: LocalProject) => void
onOpenSettings: () => void
onOpenHelp: () => void
/** Opens Automations; the entry shows only while it is available. */
automations?: HomeAutomationsEntry
/** With `dropdown`, opens the panel from a compact picker at the end of Home's search field. */
scope?: boolean
/** With several servers and no project chosen, names the focused server instead of "All projects". */
@ -382,33 +382,34 @@ function HomeProjectsPanel(props: HomeProjectsViewProps) {
classList={{ "!hidden": !!props.dropdown }}
onOpenSettings={props.onOpenSettings}
onOpenHelp={props.onOpenHelp}
automations={props.automations}
language={props.language}
/>
</aside>
)
}
export type HomeAutomationsEntry = { available: () => boolean; open: () => void }
export function HomeUtilityNav(props: {
class?: string
classList?: Record<string, boolean>
onOpenSettings: () => void
onOpenHelp: () => void
automations?: HomeAutomationsEntry
language: ReturnType<typeof useLanguage>
}) {
const navigate = useNavigate()
const automations = useAutomationSource()
return (
<div
class={`${props.class ?? ""} min-w-0 flex-row justify-between gap-1 lg:flex-col lg:justify-start lg:pr-3 [&>button]:w-auto lg:[&>button]:w-full`}
classList={props.classList}
>
<Show when={automations.available()}>
<Show when={props.automations?.available()}>
<HomeProjectNavButton
type="button"
data-action="home-automations"
class="text-v2-text-text-faint [&>[data-slot=icon-svg]]:text-v2-icon-icon-muted"
onClick={() => navigate("/automations")}
onClick={() => props.automations?.open()}
>
<Icon name="clock" size="small" />
<span class={HOME_PROJECT_NAV_LABEL}>{props.language.t("automations.title")}</span>

View file

@ -1,6 +1,8 @@
import { ScrollView } from "@opencode/ui/scroll-view"
import { createMediaQuery } from "@solid-primitives/media"
import { useNavigate } from "@solidjs/router"
import { createMemo, onMount, Show } from "solid-js"
import { useAutomationSource } from "@/automations/source"
import { useLayout } from "@/shell/state/layout"
import { useSettings } from "@/settings/model"
import { useProjectNavigation } from "@/shell/project-navigation"
@ -35,7 +37,13 @@ function HomeOverview() {
const layout = useLayout()
const settings = useSettings()
const home = createHomeController()
const projects = createHomeProjectsController(home)
const automations = useAutomationSource()
const navigate = useNavigate()
const projects = createHomeProjectsController(home, {
automations: { available: automations.available, open: () => navigate("/automations") },
})
const sessions = createHomeSessionsController(home)
const search = createHomeSessionSearchController(home, sessions, settings.appearance.navigationPrototype)
@ -138,6 +146,7 @@ export function HomeView(props: {
class="flex"
onOpenSettings={props.projects.utility.settings}
onOpenHelp={props.projects.utility.help}
automations={props.projects.utility.automations}
language={props.projects.copy.language}
/>
</div>