You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "chihumyum (via GitHub)" <gi...@apache.org> on 2026/08/23 18:32:44 UTC
[PR] refactor(desktop): extract Module Hub feature slice [maka]
chihumyum opened a new pull request, #3649:
URL: https://github.com/apache/maka/pull/3649
## Summary
- Extract Module Hub from AppShell into a vertical feature slice with a public controller/host, service ports, a Desktop adapter, and testing fakes.
- Move Skills, Scheduled Tasks, keep-awake, and the Shell-owned Daily Review actions/bridge into the slice. AppShell now supplies navigation and cross-feature intents, renders ModuleHubHost, and consumes only the Scheduled Tasks and Skills revision selectors needed elsewhere.
- Preserve UI, IPC, storage, copy, shortcuts, navigation, page mount semantics, Runtime Host fencing, first-frame refresh, subscriptions, and mutation feedback behavior.
- Keep MCP as an explicit page-owned direct-bridge exception; ModuleHubHost only composes that existing leaf.
Refs #3439
## Verification
- npm run lint
- npm run format:check
- npm run build
- npm run typecheck
- npm --workspace @maka/desktop test — 1368 passed
- npx knip --workspace apps/desktop — no issues; existing pkill/tail config hints only
- npx knip --workspace packages/ui — passed
- npm run astryx:surface-inventory:write — 208 aligned, 0 blocker, 0 polish
- npm run astryx:surface-inventory — passed
- Desktop Storybook build plus render smoke — 178 stories passed
- Related Playwright coverage — 4 passed: Module Hub routing/create-once, composer skill invocation, and skill draft lifecycle
- git diff --check
- git merge-tree --write-tree upstream/main HEAD — clean against 5525be38f
## Review focus
The adversarial AI red/blue pass reproduced and fixed keep-awake UI resync, late Skills/Daily Review feedback, superseded projection errors, stale Runtime Host mutation feedback, and destructive confirmation after controller disposal. A fresh full read of exact head 0764fd567 found no surviving in-scope P0–P3 findings. This is supporting evidence only and does not count as independent human approval; human review remains pending.
## AI use
Select exactly one:
- [ ] No generative tool made a substantive contribution
- [x] Generative tooling made a substantive contribution
Tool(s) and scope: OpenAI Codex implemented the feature slice, authored tests and documentation, ran local verification, and performed the disclosed red/blue adversarial review. Affected commits retain Generated-by: Codex trailers.
## Checklist
- [x] Tests cover the change and fail without it
- [x] Lint, format, typecheck and the affected suites pass locally
Does this PR entail a change in behavior?
- [ ] Yes — described under Summary above
- [x] No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): extract Module Hub feature slice [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on PR #3649:
URL: https://github.com/apache/maka/pull/3649#issuecomment-5397625523
LGTM. Merging at @AstroHan's request — `test` is green on `27e57719a3b0d729e44f41a98ae08570fa2089ab`.
Note for the two sibling slice extractions: this one has landed, so please rebase before the next one goes in.
<details>
<summary>简体中文</summary>
LGTM,按 @AstroHan 的要求合并——`27e57719a3b0d729e44f41a98ae08570fa2089ab` 上 `test` 为绿。
给另外两个同系列切片 PR 的提醒:这个已经合入,请在下一个合并前先 rebase。
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): extract Module Hub feature slice [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han merged PR #3649:
URL: https://github.com/apache/maka/pull/3649
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): extract Module Hub feature slice [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #3649:
URL: https://github.com/apache/maka/pull/3649#discussion_r3840349621
##########
apps/desktop/src/renderer/features/module-hub/controller/use-skills-controller.ts:
##########
@@ -0,0 +1,835 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import type { UiLocale } from "@maka/core/ui-locale";
+import type {
+ BundledSkillCatalogEntry,
+ ManagedSkillSourceEntry,
+ ManagedSkillUpdatePreview,
+ SkillEntry,
+ ToastApi,
+} from "@maka/ui";
+import {
+ getShellCopy,
+ localizedShellErrorMessage,
+} from "../../../locales/shell-copy.js";
+import type { ModuleHubRuntimeHostRef } from "../ports.js";
+import { useModuleHubServices } from "../services-context.js";
+import {
+ defaultRuntimeHostDiagnosticTarget,
+ defaultRuntimeHostOperationHost,
+ isDefaultRuntimeHostCurrent,
+ runIfDefaultRuntimeHostCurrent,
+ runOnDefaultRuntimeHost,
+} from "./default-runtime-host.js";
+
+type SkillsToastApi = Pick<ToastApi, "success" | "error">;
+
+type RefreshOptions = {
+ shouldShowError?: () => boolean;
+};
+
+export interface SkillsHostModel {
+ skills: SkillEntry[];
+ managedSkillSources: ManagedSkillSourceEntry[];
+ bundledSkillCatalog: BundledSkillCatalogEntry[];
+ onRefreshSkills(): Promise<void>;
+ onOpenSkill?: (skillId: string) => Promise<void>;
+ onUseSkill(skillId: string, skillName: string): void;
+ onOpenSkillsFolder?: () => void | Promise<void>;
+ onRefreshManagedSkillSources(): Promise<void>;
+ onImportManagedSkillSource(): Promise<void>;
+ onInstallManagedSkill(sourceId: string): Promise<void>;
+ onRefreshBundledSkillCatalog(): Promise<void>;
+ onInstallBundledSkill(id: string): Promise<void>;
+ onPreviewManagedSkillUpdate(
+ skillId: string,
+ ): Promise<ManagedSkillUpdatePreview | null>;
+ onUpdateManagedSkill(
+ skillId: string,
+ options?: {
+ force?: boolean;
+ expectedCurrentSha256?: string;
+ expectedSourceSha256?: string;
+ },
+ ): Promise<boolean>;
+ onSetSkillEnabled(skillId: string, enabled: boolean): Promise<void>;
+ onSetSkillPinned(skillRef: string, pinned: boolean): Promise<void>;
+ onDeleteSkill(skillRef: string): Promise<void>;
+}
+
+export interface SkillsController {
+ host: SkillsHostModel;
+ /** Changes only when the current default Host's installed-Skills projection commits. */
+ readonly revision: number;
+ /** Refreshes every project-scoped Skills projection after a project change. */
+ refreshProjectSkills(): Promise<void>;
+}
+
+export interface UseSkillsControllerInput {
+ uiLocale: UiLocale;
+ active: boolean;
+ toastApi: SkillsToastApi;
+ useSkillInChat(skillId: string, skillName: string): void;
+ openSkillsFolder?: () => void | Promise<void>;
+}
+
+type SkillsProjection =
+ "skills" | "managedSkillSources" | "bundledSkillCatalog";
+
+/** Owns the three Skills projections, their Host fences, and every Skills mutation. */
+export function useSkillsController(
+ input: UseSkillsControllerInput,
+): SkillsController {
+ const services = useModuleHubServices();
+ const [skills, setSkills] = useState<SkillEntry[]>([]);
+ const [revision, setRevision] = useState(0);
+ const [managedSkillSources, setManagedSkillSources] = useState<
+ ManagedSkillSourceEntry[]
+ >([]);
+ const [bundledSkillCatalog, setBundledSkillCatalog] = useState<
+ BundledSkillCatalogEntry[]
+ >([]);
+ const generationsRef = useRef<Record<SkillsProjection, number>>({
+ skills: 0,
+ managedSkillSources: 0,
+ bundledSkillCatalog: 0,
+ });
+ const mountedRef = useRef(true);
+ const inputRef = useRef(input);
+ inputRef.current = input;
+
+ useEffect(() => {
+ mountedRef.current = true;
+ return () => {
+ mountedRef.current = false;
+ generationsRef.current.skills += 1;
+ generationsRef.current.managedSkillSources += 1;
+ generationsRef.current.bundledSkillCatalog += 1;
+ };
+ }, []);
+
+ const isSkillsSurfaceActive = useCallback(
+ () => mountedRef.current && inputRef.current.active,
+ [],
+ );
+
+ const isOperationHostCurrent = useCallback(
+ async (error: unknown): Promise<boolean> => {
+ if (!mountedRef.current) return false;
+ const host = defaultRuntimeHostOperationHost(error);
+ if (!host) return mountedRef.current;
+ const current = await isDefaultRuntimeHostCurrent(
+ services.runtimeHosts,
+ host,
+ );
+ return mountedRef.current && current;
+ },
+ [services.runtimeHosts],
+ );
+
+ const shouldReportRefreshError = useCallback(
+ async (options: RefreshOptions, error: unknown): Promise<boolean> => {
+ const shouldShowError = options.shouldShowError;
+ if (shouldShowError && !shouldShowError()) return false;
+ if (!(await isOperationHostCurrent(error))) return false;
+ return shouldShowError?.() ?? true;
+ },
+ [isOperationHostCurrent],
+ );
+
+ const reportRuntimeHostError = useCallback(
+ (title: string, fallback: string, error: unknown): void => {
+ const current = inputRef.current;
+ current.toastApi.error(
+ title,
+ localizedShellErrorMessage(error, fallback, current.uiLocale),
+ undefined,
+ defaultRuntimeHostDiagnosticTarget(error),
+ );
+ },
+ [],
+ );
+
+ const refreshSkills = useCallback(
+ async (options: RefreshOptions = {}): Promise<void> => {
+ const generation = ++generationsRef.current.skills;
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.list(host),
+ );
+ await runIfDefaultRuntimeHostCurrent(
+ services.runtimeHosts,
+ next.host,
+ () => {
+ if (
+ mountedRef.current &&
+ generation === generationsRef.current.skills
+ ) {
+ setSkills(next.value);
+ setRevision((current) => current + 1);
+ }
+ },
+ );
+ } catch (error) {
+ if (!mountedRef.current || generation !== generationsRef.current.skills)
+ return;
+ const shouldReport = await shouldReportRefreshError(options, error);
+ if (
+ mountedRef.current &&
+ generation === generationsRef.current.skills &&
+ shouldReport
+ ) {
+ reportRuntimeHostError(
+ copy.refreshSkillsFailedTitle,
+ copy.refreshSkillsFallback,
+ error,
+ );
+ }
+ }
+ },
+ [
+ isOperationHostCurrent,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportRefreshError,
+ ],
+ );
+
+ const refreshManagedSkillSources = useCallback(
+ async (options: RefreshOptions = {}): Promise<void> => {
+ const generation = ++generationsRef.current.managedSkillSources;
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.listManagedSources(host),
+ );
+ await runIfDefaultRuntimeHostCurrent(
+ services.runtimeHosts,
+ next.host,
+ () => {
+ if (
+ mountedRef.current &&
+ generation === generationsRef.current.managedSkillSources
+ ) {
+ setManagedSkillSources(next.value);
+ }
+ },
+ );
+ } catch (error) {
+ if (
+ !mountedRef.current ||
+ generation !== generationsRef.current.managedSkillSources
+ ) {
+ return;
+ }
+ const shouldReport = await shouldReportRefreshError(options, error);
+ if (
+ mountedRef.current &&
+ generation === generationsRef.current.managedSkillSources &&
+ shouldReport
+ ) {
+ reportRuntimeHostError(
+ copy.refreshSourcesFailedTitle,
+ copy.refreshSourcesFallback,
+ error,
+ );
+ }
+ }
+ },
+ [
+ isOperationHostCurrent,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportRefreshError,
+ ],
+ );
+
+ const refreshBundledSkillCatalog = useCallback(
+ async (options: RefreshOptions = {}): Promise<void> => {
+ const generation = ++generationsRef.current.bundledSkillCatalog;
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.listBundledCatalog(host),
+ );
+ await runIfDefaultRuntimeHostCurrent(
+ services.runtimeHosts,
+ next.host,
+ () => {
+ if (
+ mountedRef.current &&
+ generation === generationsRef.current.bundledSkillCatalog
+ ) {
+ setBundledSkillCatalog(next.value);
+ }
+ },
+ );
+ } catch (error) {
+ if (
+ !mountedRef.current ||
+ generation !== generationsRef.current.bundledSkillCatalog
+ ) {
+ return;
+ }
+ const shouldReport = await shouldReportRefreshError(options, error);
+ if (
+ mountedRef.current &&
+ generation === generationsRef.current.bundledSkillCatalog &&
+ shouldReport
+ ) {
+ reportRuntimeHostError(
+ copy.refreshBundledFailedTitle,
+ copy.refreshBundledFallback,
+ error,
+ );
+ }
+ }
+ },
+ [
+ isOperationHostCurrent,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportRefreshError,
+ ],
+ );
+
+ const shouldReportMutation = useCallback(
+ async (host: ModuleHubRuntimeHostRef): Promise<boolean> => {
+ if (!isSkillsSurfaceActive()) return false;
+ let activeAfterHostCheck = false;
+ const current = await runIfDefaultRuntimeHostCurrent(
+ services.runtimeHosts,
+ host,
+ () => {
+ activeAfterHostCheck = isSkillsSurfaceActive();
+ },
+ );
+ return current && activeAfterHostCheck;
+ },
+ [isSkillsSurfaceActive, services.runtimeHosts],
+ );
+
+ const shouldReportOperationError = useCallback(
+ async (error: unknown): Promise<boolean> => {
+ if (!isSkillsSurfaceActive()) return false;
+ if (!(await isOperationHostCurrent(error))) return false;
+ return isSkillsSurfaceActive();
+ },
+ [isOperationHostCurrent, isSkillsSurfaceActive],
+ );
+
+ const importManagedSkillSource = useCallback(async (): Promise<void> => {
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.importManagedSource(host),
+ );
+ if (!next.value.ok) {
+ if (
+ next.value.reason !== "cancelled" &&
+ (await shouldReportMutation(next.host))
+ ) {
+ inputRef.current.toastApi.error(
+ copy.importSourceFailedTitle,
+ copy.sourceFailures[next.value.reason],
+ undefined,
+ next.diagnosticTarget,
+ );
+ }
+ return;
+ }
+ await refreshManagedSkillSources({
+ shouldShowError: isSkillsSurfaceActive,
+ });
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.success(
+ copy.importedSourceTitle,
+ next.value.source.name,
+ );
+ }
+ } catch (error) {
+ if (await shouldReportOperationError(error)) {
+ reportRuntimeHostError(
+ copy.importSourceFailedTitle,
+ copy.importSourceFallback,
+ error,
+ );
+ }
+ }
+ }, [
+ isSkillsSurfaceActive,
+ refreshManagedSkillSources,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportOperationError,
+ shouldReportMutation,
+ ]);
+
+ const installManagedSkill = useCallback(
+ async (sourceId: string): Promise<void> => {
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.installManaged(sourceId, host),
+ );
+ if (!next.value.ok) {
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.error(
+ copy.installFailedTitle,
+ copy.installFailures[next.value.reason],
+ undefined,
+ next.diagnosticTarget,
+ );
+ }
+ return;
+ }
+ await refreshSkills({ shouldShowError: isSkillsSurfaceActive });
+ await refreshManagedSkillSources({
+ shouldShowError: isSkillsSurfaceActive,
+ });
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.success(
+ copy.installedTitle,
+ copy.installedDescription(next.value.skill.id),
+ );
+ }
+ } catch (error) {
+ if (await shouldReportOperationError(error)) {
+ reportRuntimeHostError(
+ copy.installFailedTitle,
+ copy.installFallback,
+ error,
+ );
+ }
+ }
+ },
+ [
+ isSkillsSurfaceActive,
+ refreshManagedSkillSources,
+ refreshSkills,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportOperationError,
+ shouldReportMutation,
+ ],
+ );
+
+ const installBundledSkill = useCallback(
+ async (id: string): Promise<void> => {
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.installBundled(id, host),
+ );
+ if (!next.value.ok) {
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.error(
+ copy.installBundledFailedTitle,
+ copy.installFailures[next.value.reason],
+ undefined,
+ next.diagnosticTarget,
+ );
+ }
+ return;
+ }
+ await refreshSkills({ shouldShowError: isSkillsSurfaceActive });
+ await refreshBundledSkillCatalog({
+ shouldShowError: isSkillsSurfaceActive,
+ });
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.success(
+ copy.installedBundledTitle,
+ copy.installedDescription(next.value.skill.id),
+ );
+ }
+ } catch (error) {
+ if (await shouldReportOperationError(error)) {
+ reportRuntimeHostError(
+ copy.installBundledFailedTitle,
+ copy.installBundledFallback,
+ error,
+ );
+ }
+ }
+ },
+ [
+ isSkillsSurfaceActive,
+ refreshBundledSkillCatalog,
+ refreshSkills,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportOperationError,
+ shouldReportMutation,
+ ],
+ );
+
+ const previewManagedSkillUpdate = useCallback(
+ async (skillId: string): Promise<ManagedSkillUpdatePreview | null> => {
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.previewUpdate(skillId, host),
+ );
+ if (!next.value.ok) {
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.error(
+ copy.previewFailedTitle,
+ copy.previewFailures[next.value.reason],
+ undefined,
+ next.diagnosticTarget,
+ );
+ }
+ return null;
+ }
+ return (await shouldReportMutation(next.host))
+ ? next.value.preview
+ : null;
+ } catch (error) {
+ if (await shouldReportOperationError(error)) {
+ reportRuntimeHostError(
+ copy.previewFailedTitle,
+ copy.previewFallback,
+ error,
+ );
+ }
+ return null;
+ }
+ },
+ [
+ isSkillsSurfaceActive,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportOperationError,
+ shouldReportMutation,
+ ],
+ );
+
+ const updateManagedSkill = useCallback(
+ async (
+ skillId: string,
+ options: {
+ force?: boolean;
+ expectedCurrentSha256?: string;
+ expectedSourceSha256?: string;
+ } = {},
+ ): Promise<boolean> => {
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.updateManaged(skillId, options, host),
+ );
+ if (!next.value.ok) {
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.error(
+ copy.updateFailedTitle,
+ copy.updateFailures[next.value.reason],
+ undefined,
+ next.diagnosticTarget,
+ );
+ }
+ return false;
+ }
+ await refreshSkills({ shouldShowError: isSkillsSurfaceActive });
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.success(
+ options.force ? copy.forceUpdatedTitle : copy.updatedTitle,
+ copy.updatedDescription(next.value.skill.id),
+ );
+ }
+ return true;
+ } catch (error) {
+ if (await shouldReportOperationError(error)) {
+ reportRuntimeHostError(
+ copy.updateFailedTitle,
+ copy.updateFallback,
+ error,
+ );
+ }
+ return false;
+ }
+ },
+ [
+ isSkillsSurfaceActive,
+ refreshSkills,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportOperationError,
+ shouldReportMutation,
+ ],
+ );
+
+ const setSkillEnabled = useCallback(
+ async (skillId: string, enabled: boolean): Promise<void> => {
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.setEnabled(skillId, enabled, host),
+ );
+ if (!next.value.ok) {
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.error(
+ copy.toggleFailedTitle,
+ copy.runtimeFailures[next.value.reason],
+ undefined,
+ next.diagnosticTarget,
+ );
+ }
+ return;
+ }
+ await refreshSkills({ shouldShowError: isSkillsSurfaceActive });
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.success(
+ enabled ? copy.enabledTitle : copy.disabledTitle,
+ copy.runtimeDescription(next.value.skill.name),
+ );
+ }
+ } catch (error) {
+ if (await shouldReportOperationError(error)) {
+ reportRuntimeHostError(
+ copy.toggleFailedTitle,
+ copy.toggleFallback,
+ error,
+ );
+ }
+ }
+ },
+ [
+ isSkillsSurfaceActive,
+ refreshSkills,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportOperationError,
+ shouldReportMutation,
+ ],
+ );
+
+ const setSkillPinned = useCallback(
+ async (skillRef: string, pinned: boolean): Promise<void> => {
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.setPinned(skillRef, pinned, host),
+ );
+ if (!next.value.ok) {
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.error(
+ copy.toggleFailedTitle,
+ copy.runtimeFailures[next.value.reason],
+ undefined,
+ next.diagnosticTarget,
+ );
+ }
+ return;
+ }
+ await refreshSkills({ shouldShowError: isSkillsSurfaceActive });
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.success(
+ pinned ? copy.pinnedTitle : copy.unpinnedTitle,
+ next.value.skill.name,
+ );
+ }
+ } catch (error) {
+ if (await shouldReportOperationError(error)) {
+ reportRuntimeHostError(
+ copy.toggleFailedTitle,
+ copy.toggleFallback,
+ error,
+ );
+ }
+ }
+ },
+ [
+ isSkillsSurfaceActive,
+ refreshSkills,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportOperationError,
+ shouldReportMutation,
+ ],
+ );
+
+ const deleteSkill = useCallback(
+ async (skillRef: string): Promise<void> => {
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.delete(skillRef, host),
+ );
+ if (!next.value.ok) {
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.error(
+ copy.deleteFailedTitle,
+ copy.deleteFailures[next.value.reason],
+ undefined,
+ next.diagnosticTarget,
+ );
+ }
+ return;
+ }
+ await refreshSkills({ shouldShowError: isSkillsSurfaceActive });
+ await refreshBundledSkillCatalog({
+ shouldShowError: isSkillsSurfaceActive,
+ });
+ if (await shouldReportMutation(next.host)) {
+ const displayId = skillRef.slice(skillRef.lastIndexOf(":") + 1);
+ inputRef.current.toastApi.success(
+ copy.deletedTitle,
+ copy.deletedDescription(displayId),
+ );
+ }
+ } catch (error) {
+ if (await shouldReportOperationError(error)) {
+ reportRuntimeHostError(
+ copy.deleteFailedTitle,
+ copy.deleteFallback,
+ error,
+ );
+ }
+ }
+ },
+ [
+ isSkillsSurfaceActive,
+ refreshBundledSkillCatalog,
+ refreshSkills,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportOperationError,
+ shouldReportMutation,
+ ],
+ );
+
+ const openSkill = useCallback(
+ async (skillId: string): Promise<void> => {
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.open(skillId, "file", host),
+ );
+ if (!next.value.ok && (await shouldReportMutation(next.host))) {
+ inputRef.current.toastApi.error(
+ copy.openFailedTitle,
+ copy.openFailures[next.value.reason],
+ undefined,
+ next.diagnosticTarget,
+ );
+ }
+ } catch (error) {
+ if (await shouldReportOperationError(error)) {
+ reportRuntimeHostError(
+ copy.openFailedTitle,
+ copy.openFallback,
+ error,
+ );
+ }
+ }
+ },
+ [
+ isSkillsSurfaceActive,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportOperationError,
+ shouldReportMutation,
+ ],
+ );
+
+ const refreshProjectSkills = useCallback(async (): Promise<void> => {
+ await Promise.all([
+ refreshSkills(),
+ refreshManagedSkillSources(),
+ refreshBundledSkillCatalog(),
+ ]);
+ }, [refreshBundledSkillCatalog, refreshManagedSkillSources, refreshSkills]);
+
+ const host = useMemo<SkillsHostModel>(
+ () => ({
+ skills,
+ managedSkillSources,
+ bundledSkillCatalog,
+ onRefreshSkills: refreshSkills,
+ onUseSkill: input.useSkillInChat,
+ ...(input.openSkillsFolder
+ ? {
+ onOpenSkill: openSkill,
+ onOpenSkillsFolder: input.openSkillsFolder,
+ }
+ : {}),
+ onRefreshManagedSkillSources: refreshManagedSkillSources,
+ onImportManagedSkillSource: importManagedSkillSource,
Review Comment:
**[P2]** The `viewClientPath` capability gate on skill-source import was dropped in the refactor, so the import entry point reappears in environments that are not permitted to browse client paths.
Before, in `app-shell.tsx:2985-2987` at base `5525be38`:
```
onImportManagedSkillSource={projectCapabilities.viewClientPath
? () => importManagedSkillSource()
: undefined}
```
Here it is attached unconditionally. The equivalent gate for the sibling handlers survived — `:793-797` still spreads `onOpenSkill` / `onOpenSkillsFolder` only when `input.openSkillsFolder` is set, which is itself gated at `app-shell.tsx:1572` — so this is the one condition in the group that was lost rather than a deliberate policy change across the surface.
The consumer keys purely off prop presence: `packages/ui/src/skills-panel.tsx:662` renders the import item whenever `props.onImportManagedSkillSource` exists, exactly as the neighbouring item does for `onOpenSkillsFolder`.
Reproduction: open a remote-host project (`runtime-host-boot.ts:977-983` reports `viewClientPath: false`), then Extensions to Skills, and open the source menu. The Import entry is present and invokes `bridge.skills.sources.importLocalFile(host)`. On the old UI that button does not render in this environment.
Worth stating why nothing caught this: the guard *is* the deleted line, so no remaining assertion can miss it, and the unit tests inject the full services mock without ever modelling a host with `viewClientPath: false`. A test that pins the gate would construct the controller against a capability set with `viewClientPath` false and assert the prop is absent.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): extract Module Hub feature slice [maka]
Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on PR #3649:
URL: https://github.com/apache/maka/pull/3649#issuecomment-5394668802
Rebased again onto current `upstream/main` (`8801edc32`) and force-pushed exact head `a9be3ce70` with an explicit lease. GitHub now reports the PR mergeable and the merge-tree is clean.
The only generated-file conflict was resolved by regenerating the Astryx inventory. During the overlap review I also removed two obsolete Session-setting queue refs carried by the previous AppShell conflict resolution, so this branch now leaves #3619's `useSessionSettingIntent` authority intact. The latest slash-picker stabilization in `use-composer-mentions` is preserved alongside Module Hub's skill-catalog revision invalidation.
Local exact-head evidence: lint, format, build, typecheck, Desktop 1409/1409, both Knip workspaces, Astryx inventory, Storybook 194/194, related Playwright 4/4, `git diff --check`, and clean merge-tree.
Hosted CI currently stops at ASF headers because base `8801edc32` already contains five unlicensed plugin-runtime files: [base run](https://github.com/apache/maka/actions/runs/32718531259) and [this exact-head run](https://github.com/apache/maka/actions/runs/32722866966) fail at the same step. The Module Hub diff does not touch those files, so I left that upstream repair out of this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): extract Module Hub feature slice [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on PR #3649:
URL: https://github.com/apache/maka/pull/3649#issuecomment-5388339346
Gate status note, so this is not mistaken for a logic problem: this PR had no checks at all on head `0764fd56` because its workflow run was parked at `action_required`, which is where fork PR runs sit until someone releases them. I released it, and `test` has now come back terminal **failure** — the failing step is `Check ASF source headers`.
That is mechanical: the new files this refactor adds are missing their Apache license headers. `npm run write:asf-headers` should fix it.
Note that the PR is also currently conflicting with `main`, so a rebase is needed regardless. A code review is being prepared separately and will be posted on its own.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): extract Module Hub feature slice [maka]
Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on PR #3649:
URL: https://github.com/apache/maka/pull/3649#issuecomment-5395102754
The failed exact-head CI has been cleared.
I rebased onto current `upstream/main` (`1053c1926`), which includes #3708's ASF header repair, and force-pushed exact head `27e57719a` with an explicit lease. The 11 Module Hub commits are range-diff equivalent to the previous head and have no file overlap with the two new upstream commits.
[Exact-head CI run 32725579836](https://github.com/apache/maka/actions/runs/32725579836) is now **green**. It passed ASF headers, lint/format, inventory, build/typecheck, both Knip gates, affected workspace tests, Desktop E2E, Browser smoke, alignment audit, and Storybook build/smoke. Local exact-head verification is also green, including Desktop 1409/1409 and related Playwright 4/4.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): extract Module Hub feature slice [maka]
Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on code in PR #3649:
URL: https://github.com/apache/maka/pull/3649#discussion_r3840389334
##########
apps/desktop/src/renderer/features/module-hub/controller/use-skills-controller.ts:
##########
@@ -0,0 +1,835 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import type { UiLocale } from "@maka/core/ui-locale";
+import type {
+ BundledSkillCatalogEntry,
+ ManagedSkillSourceEntry,
+ ManagedSkillUpdatePreview,
+ SkillEntry,
+ ToastApi,
+} from "@maka/ui";
+import {
+ getShellCopy,
+ localizedShellErrorMessage,
+} from "../../../locales/shell-copy.js";
+import type { ModuleHubRuntimeHostRef } from "../ports.js";
+import { useModuleHubServices } from "../services-context.js";
+import {
+ defaultRuntimeHostDiagnosticTarget,
+ defaultRuntimeHostOperationHost,
+ isDefaultRuntimeHostCurrent,
+ runIfDefaultRuntimeHostCurrent,
+ runOnDefaultRuntimeHost,
+} from "./default-runtime-host.js";
+
+type SkillsToastApi = Pick<ToastApi, "success" | "error">;
+
+type RefreshOptions = {
+ shouldShowError?: () => boolean;
+};
+
+export interface SkillsHostModel {
+ skills: SkillEntry[];
+ managedSkillSources: ManagedSkillSourceEntry[];
+ bundledSkillCatalog: BundledSkillCatalogEntry[];
+ onRefreshSkills(): Promise<void>;
+ onOpenSkill?: (skillId: string) => Promise<void>;
+ onUseSkill(skillId: string, skillName: string): void;
+ onOpenSkillsFolder?: () => void | Promise<void>;
+ onRefreshManagedSkillSources(): Promise<void>;
+ onImportManagedSkillSource(): Promise<void>;
+ onInstallManagedSkill(sourceId: string): Promise<void>;
+ onRefreshBundledSkillCatalog(): Promise<void>;
+ onInstallBundledSkill(id: string): Promise<void>;
+ onPreviewManagedSkillUpdate(
+ skillId: string,
+ ): Promise<ManagedSkillUpdatePreview | null>;
+ onUpdateManagedSkill(
+ skillId: string,
+ options?: {
+ force?: boolean;
+ expectedCurrentSha256?: string;
+ expectedSourceSha256?: string;
+ },
+ ): Promise<boolean>;
+ onSetSkillEnabled(skillId: string, enabled: boolean): Promise<void>;
+ onSetSkillPinned(skillRef: string, pinned: boolean): Promise<void>;
+ onDeleteSkill(skillRef: string): Promise<void>;
+}
+
+export interface SkillsController {
+ host: SkillsHostModel;
+ /** Changes only when the current default Host's installed-Skills projection commits. */
+ readonly revision: number;
+ /** Refreshes every project-scoped Skills projection after a project change. */
+ refreshProjectSkills(): Promise<void>;
+}
+
+export interface UseSkillsControllerInput {
+ uiLocale: UiLocale;
+ active: boolean;
+ toastApi: SkillsToastApi;
+ useSkillInChat(skillId: string, skillName: string): void;
+ openSkillsFolder?: () => void | Promise<void>;
+}
+
+type SkillsProjection =
+ "skills" | "managedSkillSources" | "bundledSkillCatalog";
+
+/** Owns the three Skills projections, their Host fences, and every Skills mutation. */
+export function useSkillsController(
+ input: UseSkillsControllerInput,
+): SkillsController {
+ const services = useModuleHubServices();
+ const [skills, setSkills] = useState<SkillEntry[]>([]);
+ const [revision, setRevision] = useState(0);
+ const [managedSkillSources, setManagedSkillSources] = useState<
+ ManagedSkillSourceEntry[]
+ >([]);
+ const [bundledSkillCatalog, setBundledSkillCatalog] = useState<
+ BundledSkillCatalogEntry[]
+ >([]);
+ const generationsRef = useRef<Record<SkillsProjection, number>>({
+ skills: 0,
+ managedSkillSources: 0,
+ bundledSkillCatalog: 0,
+ });
+ const mountedRef = useRef(true);
+ const inputRef = useRef(input);
+ inputRef.current = input;
+
+ useEffect(() => {
+ mountedRef.current = true;
+ return () => {
+ mountedRef.current = false;
+ generationsRef.current.skills += 1;
+ generationsRef.current.managedSkillSources += 1;
+ generationsRef.current.bundledSkillCatalog += 1;
+ };
+ }, []);
+
+ const isSkillsSurfaceActive = useCallback(
+ () => mountedRef.current && inputRef.current.active,
+ [],
+ );
+
+ const isOperationHostCurrent = useCallback(
+ async (error: unknown): Promise<boolean> => {
+ if (!mountedRef.current) return false;
+ const host = defaultRuntimeHostOperationHost(error);
+ if (!host) return mountedRef.current;
+ const current = await isDefaultRuntimeHostCurrent(
+ services.runtimeHosts,
+ host,
+ );
+ return mountedRef.current && current;
+ },
+ [services.runtimeHosts],
+ );
+
+ const shouldReportRefreshError = useCallback(
+ async (options: RefreshOptions, error: unknown): Promise<boolean> => {
+ const shouldShowError = options.shouldShowError;
+ if (shouldShowError && !shouldShowError()) return false;
+ if (!(await isOperationHostCurrent(error))) return false;
+ return shouldShowError?.() ?? true;
+ },
+ [isOperationHostCurrent],
+ );
+
+ const reportRuntimeHostError = useCallback(
+ (title: string, fallback: string, error: unknown): void => {
+ const current = inputRef.current;
+ current.toastApi.error(
+ title,
+ localizedShellErrorMessage(error, fallback, current.uiLocale),
+ undefined,
+ defaultRuntimeHostDiagnosticTarget(error),
+ );
+ },
+ [],
+ );
+
+ const refreshSkills = useCallback(
+ async (options: RefreshOptions = {}): Promise<void> => {
+ const generation = ++generationsRef.current.skills;
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.list(host),
+ );
+ await runIfDefaultRuntimeHostCurrent(
+ services.runtimeHosts,
+ next.host,
+ () => {
+ if (
+ mountedRef.current &&
+ generation === generationsRef.current.skills
+ ) {
+ setSkills(next.value);
+ setRevision((current) => current + 1);
+ }
+ },
+ );
+ } catch (error) {
+ if (!mountedRef.current || generation !== generationsRef.current.skills)
+ return;
+ const shouldReport = await shouldReportRefreshError(options, error);
+ if (
+ mountedRef.current &&
+ generation === generationsRef.current.skills &&
+ shouldReport
+ ) {
+ reportRuntimeHostError(
+ copy.refreshSkillsFailedTitle,
+ copy.refreshSkillsFallback,
+ error,
+ );
+ }
+ }
+ },
+ [
+ isOperationHostCurrent,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportRefreshError,
+ ],
+ );
+
+ const refreshManagedSkillSources = useCallback(
+ async (options: RefreshOptions = {}): Promise<void> => {
+ const generation = ++generationsRef.current.managedSkillSources;
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.listManagedSources(host),
+ );
+ await runIfDefaultRuntimeHostCurrent(
+ services.runtimeHosts,
+ next.host,
+ () => {
+ if (
+ mountedRef.current &&
+ generation === generationsRef.current.managedSkillSources
+ ) {
+ setManagedSkillSources(next.value);
+ }
+ },
+ );
+ } catch (error) {
+ if (
+ !mountedRef.current ||
+ generation !== generationsRef.current.managedSkillSources
+ ) {
+ return;
+ }
+ const shouldReport = await shouldReportRefreshError(options, error);
+ if (
+ mountedRef.current &&
+ generation === generationsRef.current.managedSkillSources &&
+ shouldReport
+ ) {
+ reportRuntimeHostError(
+ copy.refreshSourcesFailedTitle,
+ copy.refreshSourcesFallback,
+ error,
+ );
+ }
+ }
+ },
+ [
+ isOperationHostCurrent,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportRefreshError,
+ ],
+ );
+
+ const refreshBundledSkillCatalog = useCallback(
+ async (options: RefreshOptions = {}): Promise<void> => {
+ const generation = ++generationsRef.current.bundledSkillCatalog;
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.listBundledCatalog(host),
+ );
+ await runIfDefaultRuntimeHostCurrent(
+ services.runtimeHosts,
+ next.host,
+ () => {
+ if (
+ mountedRef.current &&
+ generation === generationsRef.current.bundledSkillCatalog
+ ) {
+ setBundledSkillCatalog(next.value);
+ }
+ },
+ );
+ } catch (error) {
+ if (
+ !mountedRef.current ||
+ generation !== generationsRef.current.bundledSkillCatalog
+ ) {
+ return;
+ }
+ const shouldReport = await shouldReportRefreshError(options, error);
+ if (
+ mountedRef.current &&
+ generation === generationsRef.current.bundledSkillCatalog &&
+ shouldReport
+ ) {
+ reportRuntimeHostError(
+ copy.refreshBundledFailedTitle,
+ copy.refreshBundledFallback,
+ error,
+ );
+ }
+ }
+ },
+ [
+ isOperationHostCurrent,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportRefreshError,
+ ],
+ );
+
+ const shouldReportMutation = useCallback(
+ async (host: ModuleHubRuntimeHostRef): Promise<boolean> => {
+ if (!isSkillsSurfaceActive()) return false;
+ let activeAfterHostCheck = false;
+ const current = await runIfDefaultRuntimeHostCurrent(
+ services.runtimeHosts,
+ host,
+ () => {
+ activeAfterHostCheck = isSkillsSurfaceActive();
+ },
+ );
+ return current && activeAfterHostCheck;
+ },
+ [isSkillsSurfaceActive, services.runtimeHosts],
+ );
+
+ const shouldReportOperationError = useCallback(
+ async (error: unknown): Promise<boolean> => {
+ if (!isSkillsSurfaceActive()) return false;
+ if (!(await isOperationHostCurrent(error))) return false;
+ return isSkillsSurfaceActive();
+ },
+ [isOperationHostCurrent, isSkillsSurfaceActive],
+ );
+
+ const importManagedSkillSource = useCallback(async (): Promise<void> => {
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.importManagedSource(host),
+ );
+ if (!next.value.ok) {
+ if (
+ next.value.reason !== "cancelled" &&
+ (await shouldReportMutation(next.host))
+ ) {
+ inputRef.current.toastApi.error(
+ copy.importSourceFailedTitle,
+ copy.sourceFailures[next.value.reason],
+ undefined,
+ next.diagnosticTarget,
+ );
+ }
+ return;
+ }
+ await refreshManagedSkillSources({
+ shouldShowError: isSkillsSurfaceActive,
+ });
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.success(
+ copy.importedSourceTitle,
+ next.value.source.name,
+ );
+ }
+ } catch (error) {
+ if (await shouldReportOperationError(error)) {
+ reportRuntimeHostError(
+ copy.importSourceFailedTitle,
+ copy.importSourceFallback,
+ error,
+ );
+ }
+ }
+ }, [
+ isSkillsSurfaceActive,
+ refreshManagedSkillSources,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportOperationError,
+ shouldReportMutation,
+ ]);
+
+ const installManagedSkill = useCallback(
+ async (sourceId: string): Promise<void> => {
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.installManaged(sourceId, host),
+ );
+ if (!next.value.ok) {
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.error(
+ copy.installFailedTitle,
+ copy.installFailures[next.value.reason],
+ undefined,
+ next.diagnosticTarget,
+ );
+ }
+ return;
+ }
+ await refreshSkills({ shouldShowError: isSkillsSurfaceActive });
+ await refreshManagedSkillSources({
+ shouldShowError: isSkillsSurfaceActive,
+ });
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.success(
+ copy.installedTitle,
+ copy.installedDescription(next.value.skill.id),
+ );
+ }
+ } catch (error) {
+ if (await shouldReportOperationError(error)) {
+ reportRuntimeHostError(
+ copy.installFailedTitle,
+ copy.installFallback,
+ error,
+ );
+ }
+ }
+ },
+ [
+ isSkillsSurfaceActive,
+ refreshManagedSkillSources,
+ refreshSkills,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportOperationError,
+ shouldReportMutation,
+ ],
+ );
+
+ const installBundledSkill = useCallback(
+ async (id: string): Promise<void> => {
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.installBundled(id, host),
+ );
+ if (!next.value.ok) {
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.error(
+ copy.installBundledFailedTitle,
+ copy.installFailures[next.value.reason],
+ undefined,
+ next.diagnosticTarget,
+ );
+ }
+ return;
+ }
+ await refreshSkills({ shouldShowError: isSkillsSurfaceActive });
+ await refreshBundledSkillCatalog({
+ shouldShowError: isSkillsSurfaceActive,
+ });
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.success(
+ copy.installedBundledTitle,
+ copy.installedDescription(next.value.skill.id),
+ );
+ }
+ } catch (error) {
+ if (await shouldReportOperationError(error)) {
+ reportRuntimeHostError(
+ copy.installBundledFailedTitle,
+ copy.installBundledFallback,
+ error,
+ );
+ }
+ }
+ },
+ [
+ isSkillsSurfaceActive,
+ refreshBundledSkillCatalog,
+ refreshSkills,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportOperationError,
+ shouldReportMutation,
+ ],
+ );
+
+ const previewManagedSkillUpdate = useCallback(
+ async (skillId: string): Promise<ManagedSkillUpdatePreview | null> => {
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.previewUpdate(skillId, host),
+ );
+ if (!next.value.ok) {
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.error(
+ copy.previewFailedTitle,
+ copy.previewFailures[next.value.reason],
+ undefined,
+ next.diagnosticTarget,
+ );
+ }
+ return null;
+ }
+ return (await shouldReportMutation(next.host))
+ ? next.value.preview
+ : null;
+ } catch (error) {
+ if (await shouldReportOperationError(error)) {
+ reportRuntimeHostError(
+ copy.previewFailedTitle,
+ copy.previewFallback,
+ error,
+ );
+ }
+ return null;
+ }
+ },
+ [
+ isSkillsSurfaceActive,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportOperationError,
+ shouldReportMutation,
+ ],
+ );
+
+ const updateManagedSkill = useCallback(
+ async (
+ skillId: string,
+ options: {
+ force?: boolean;
+ expectedCurrentSha256?: string;
+ expectedSourceSha256?: string;
+ } = {},
+ ): Promise<boolean> => {
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.updateManaged(skillId, options, host),
+ );
+ if (!next.value.ok) {
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.error(
+ copy.updateFailedTitle,
+ copy.updateFailures[next.value.reason],
+ undefined,
+ next.diagnosticTarget,
+ );
+ }
+ return false;
+ }
+ await refreshSkills({ shouldShowError: isSkillsSurfaceActive });
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.success(
+ options.force ? copy.forceUpdatedTitle : copy.updatedTitle,
+ copy.updatedDescription(next.value.skill.id),
+ );
+ }
+ return true;
+ } catch (error) {
+ if (await shouldReportOperationError(error)) {
+ reportRuntimeHostError(
+ copy.updateFailedTitle,
+ copy.updateFallback,
+ error,
+ );
+ }
+ return false;
+ }
+ },
+ [
+ isSkillsSurfaceActive,
+ refreshSkills,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportOperationError,
+ shouldReportMutation,
+ ],
+ );
+
+ const setSkillEnabled = useCallback(
+ async (skillId: string, enabled: boolean): Promise<void> => {
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.setEnabled(skillId, enabled, host),
+ );
+ if (!next.value.ok) {
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.error(
+ copy.toggleFailedTitle,
+ copy.runtimeFailures[next.value.reason],
+ undefined,
+ next.diagnosticTarget,
+ );
+ }
+ return;
+ }
+ await refreshSkills({ shouldShowError: isSkillsSurfaceActive });
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.success(
+ enabled ? copy.enabledTitle : copy.disabledTitle,
+ copy.runtimeDescription(next.value.skill.name),
+ );
+ }
+ } catch (error) {
+ if (await shouldReportOperationError(error)) {
+ reportRuntimeHostError(
+ copy.toggleFailedTitle,
+ copy.toggleFallback,
+ error,
+ );
+ }
+ }
+ },
+ [
+ isSkillsSurfaceActive,
+ refreshSkills,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportOperationError,
+ shouldReportMutation,
+ ],
+ );
+
+ const setSkillPinned = useCallback(
+ async (skillRef: string, pinned: boolean): Promise<void> => {
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.setPinned(skillRef, pinned, host),
+ );
+ if (!next.value.ok) {
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.error(
+ copy.toggleFailedTitle,
+ copy.runtimeFailures[next.value.reason],
+ undefined,
+ next.diagnosticTarget,
+ );
+ }
+ return;
+ }
+ await refreshSkills({ shouldShowError: isSkillsSurfaceActive });
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.success(
+ pinned ? copy.pinnedTitle : copy.unpinnedTitle,
+ next.value.skill.name,
+ );
+ }
+ } catch (error) {
+ if (await shouldReportOperationError(error)) {
+ reportRuntimeHostError(
+ copy.toggleFailedTitle,
+ copy.toggleFallback,
+ error,
+ );
+ }
+ }
+ },
+ [
+ isSkillsSurfaceActive,
+ refreshSkills,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportOperationError,
+ shouldReportMutation,
+ ],
+ );
+
+ const deleteSkill = useCallback(
+ async (skillRef: string): Promise<void> => {
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.delete(skillRef, host),
+ );
+ if (!next.value.ok) {
+ if (await shouldReportMutation(next.host)) {
+ inputRef.current.toastApi.error(
+ copy.deleteFailedTitle,
+ copy.deleteFailures[next.value.reason],
+ undefined,
+ next.diagnosticTarget,
+ );
+ }
+ return;
+ }
+ await refreshSkills({ shouldShowError: isSkillsSurfaceActive });
+ await refreshBundledSkillCatalog({
+ shouldShowError: isSkillsSurfaceActive,
+ });
+ if (await shouldReportMutation(next.host)) {
+ const displayId = skillRef.slice(skillRef.lastIndexOf(":") + 1);
+ inputRef.current.toastApi.success(
+ copy.deletedTitle,
+ copy.deletedDescription(displayId),
+ );
+ }
+ } catch (error) {
+ if (await shouldReportOperationError(error)) {
+ reportRuntimeHostError(
+ copy.deleteFailedTitle,
+ copy.deleteFallback,
+ error,
+ );
+ }
+ }
+ },
+ [
+ isSkillsSurfaceActive,
+ refreshBundledSkillCatalog,
+ refreshSkills,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportOperationError,
+ shouldReportMutation,
+ ],
+ );
+
+ const openSkill = useCallback(
+ async (skillId: string): Promise<void> => {
+ const copy = getShellCopy(inputRef.current.uiLocale).skillActions;
+ try {
+ const next = await runOnDefaultRuntimeHost(
+ services.runtimeHosts,
+ (host) => services.skills.open(skillId, "file", host),
+ );
+ if (!next.value.ok && (await shouldReportMutation(next.host))) {
+ inputRef.current.toastApi.error(
+ copy.openFailedTitle,
+ copy.openFailures[next.value.reason],
+ undefined,
+ next.diagnosticTarget,
+ );
+ }
+ } catch (error) {
+ if (await shouldReportOperationError(error)) {
+ reportRuntimeHostError(
+ copy.openFailedTitle,
+ copy.openFallback,
+ error,
+ );
+ }
+ }
+ },
+ [
+ isSkillsSurfaceActive,
+ reportRuntimeHostError,
+ services.runtimeHosts,
+ services.skills,
+ shouldReportOperationError,
+ shouldReportMutation,
+ ],
+ );
+
+ const refreshProjectSkills = useCallback(async (): Promise<void> => {
+ await Promise.all([
+ refreshSkills(),
+ refreshManagedSkillSources(),
+ refreshBundledSkillCatalog(),
+ ]);
+ }, [refreshBundledSkillCatalog, refreshManagedSkillSources, refreshSkills]);
+
+ const host = useMemo<SkillsHostModel>(
+ () => ({
+ skills,
+ managedSkillSources,
+ bundledSkillCatalog,
+ onRefreshSkills: refreshSkills,
+ onUseSkill: input.useSkillInChat,
+ ...(input.openSkillsFolder
+ ? {
+ onOpenSkill: openSkill,
+ onOpenSkillsFolder: input.openSkillsFolder,
+ }
+ : {}),
+ onRefreshManagedSkillSources: refreshManagedSkillSources,
+ onImportManagedSkillSource: importManagedSkillSource,
Review Comment:
Fixed in 5136cf6f9. The existing optional openSkillsFolder input is the feature capability token supplied only when projectCapabilities.viewClientPath is true, so onOpenSkill, onOpenSkillsFolder, and onImportManagedSkillSource are now exposed together from the Skills host. The controller test now asserts that all three are absent without the capability and present with it; the focused Skills and boundary suites pass on the rebased head.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): extract Module Hub feature slice [maka]
Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on PR #3649:
URL: https://github.com/apache/maka/pull/3649#issuecomment-5390128563
Addressed the review blockers and pushed rebased exact head `24545560eaef5205bfb5091f8562e20ca4ae4165`.
- Restored the `viewClientPath` behavior gate for local Skill-source import and added false/true capability coverage.
- Added the ASF header to the Module Hub README using `npm run write:asf-headers`; `npm run check:asf-headers` now passes.
- Rebased onto current `upstream/main` (`8e7fa68dc`), including #3619 and the subsequent runtime fix. The only AppShell conflict preserved the new Session setting intent/queue authority while removing the migrated Scheduled Task nonce. Final merge-tree is clean.
- Removed three unused production-entry type exports found by current Knip.
Fresh exact-head verification: lint, format, ASF headers, full build, typecheck, Desktop 1363/1363, Desktop/UI Knip, Astryx 208/208, Storybook 178/178, related Playwright 4/4, and `git diff --check` all pass.
I also re-reviewed the final upstream-to-head diff after the fixes. The capability projection now matches the baseline, the #3619 wiring remains intact, Module Hub has no Desktop global or reverse AppShell dependency, and I found no additional actionable P0-P3 issue. This self-review is not a substitute for your independent re-review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org