MCPcopy
hub / github.com/anomalyco/opencode / SessionHeader

Function SessionHeader

packages/app/src/components/session/session-header.tsx:138–520  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

136}
137
138export function SessionHeader() {
139 const layout = useLayout()
140 const command = useCommand()
141 const server = useServer()
142 const platform = usePlatform()
143 const language = useLanguage()
144 const settings = useSettings()
145 const sync = useSync()
146 const terminal = useTerminal()
147 const { params, view } = useSessionLayout()
148
149 const projectDirectory = createMemo(() => decode64(params.dir) ?? "")
150 const project = createMemo(() => {
151 const directory = projectDirectory()
152 if (!directory) return
153 return layout.projects.list().find((p) => p.worktree === directory || p.sandboxes?.includes(directory))
154 })
155 const name = createMemo(() => {
156 const current = project()
157 if (current) return current.name || getFilename(current.worktree)
158 return getFilename(projectDirectory())
159 })
160 const hotkey = createMemo(() => command.keybind("file.open"))
161 const os = createMemo(() => detectOS(platform))
162 const isV2 = settings.general.newLayoutDesigns
163 const search = settings.visibility.search
164 const status = settings.visibility.status
165 const isDesktop = createMediaQuery("(min-width: 768px)")
166
167 const [exists, setExists] = createStore<Partial<Record<OpenApp, boolean>>>({
168 finder: true,
169 })
170
171 const apps = createMemo(() => {
172 if (os() === "macos") return MAC_APPS
173 if (os() === "windows") return WINDOWS_APPS
174 return LINUX_APPS
175 })
176
177 const fileManager = createMemo(() => {
178 if (os() === "macos") return { label: "session.header.open.finder", icon: "finder" as const }
179 if (os() === "windows") return { label: "session.header.open.fileExplorer", icon: "file-explorer" as const }
180 return { label: "session.header.open.fileManager", icon: "finder" as const }
181 })
182
183 createEffect(() => {
184 if (platform.platform !== "desktop") return
185 if (!platform.checkAppExists) return
186
187 const list = apps()
188
189 setExists(Object.fromEntries(list.map((app) => [app.id, undefined])) as Partial<Record<OpenApp, boolean>>)
190
191 void Promise.all(
192 list.map((app) =>
193 Promise.resolve(platform.checkAppExists?.(app.openWith))
194 .then((value) => Boolean(value))
195 .catch(() => false)

Callers

nothing calls this directly

Calls 15

useSyncFunction · 0.90
useSessionLayoutFunction · 0.90
decode64Function · 0.90
getFilenameFunction · 0.90
persistedFunction · 0.90
messageAgentColorFunction · 0.90
reviewTooltipKeybindFunction · 0.90
viewFunction · 0.85
canOpenFunction · 0.85
openDirFunction · 0.85
selectAppFunction · 0.85
copyPathFunction · 0.85

Tested by

no test coverage detected