Repository navigation
feat(settings): browse and sync agent skills and instructions #24377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+5,720
−1
Closed
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
6a1f225
feat(settings): sync selected skills and instructions across machines
saphid b80b309
fix(settings): keep fleet skill sync revisions and selections stable
saphid 0b1a58f
fix(sync): recover saved state and avoid unnecessary bundle transfers
saphid 50c4c81
fix(sync): preserve local edits and recover interrupted updates
saphid 4db1357
fix(sync): protect instruction edits and surface destination conflicts
saphid 874ebae
fix(sync): validate instruction installation and portable skill paths
saphid 6e56820
fix(sync): align inventory limits and clean up setup receipts
saphid 60777f9
fix(sync): normalize Windows instruction undo revisions
saphid 0e2500e
fix(sync): validate refresh identity before journaling
saphid df0ae56
fix(sync): preserve subscriptions after unreadable state recovery
saphid 30717ab
fix(sync): clean up unpublished subscription baselines
saphid 4216b12
fix(sync): reconcile catalog publication before setup rollback
saphid b352cb1
fix(sync): finish admitted mutations across client disconnects
saphid d8aa4ec
feat(settings): browse skills and instruction files before sharing
saphid 36e961d
fix(settings): retain sharing controls for unavailable files
saphid 97f3ebd
fix(settings): refresh the open skill with its inventory
saphid df7f163
fix(settings): honor file scope and explicit sharing controls
saphid aaf0c2b
fix(settings): keep project location labels consistent
saphid 6f746f4
Merge remote-tracking branch 'upstream/main' into feat/fleet-skills-i…
saphid 8090a4c
fix(web): Skills & instructions is back in the settings sidebar
saphid 8f8fbd0
chore: merge main into fleet skills instructions
maria-rcks 2b346a0
fix(sync): explain lifecycle effects for lint
maria-rcks 21ab4d5
chore: merge main into fleet skills instructions
maria-rcks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
apps/mobile/src/features/settings/AgentFileSyncCoordinator.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { startAgentFileSyncRelay } from "@t3tools/client-runtime/state/agentFileSync"; | ||
| import { EnvironmentId } from "@t3tools/contracts"; | ||
| import { useEffect, useState } from "react"; | ||
| import { AppState } from "react-native"; | ||
| import { appAtomRegistry } from "../../state/atom-registry"; | ||
| import { agentFileSync } from "../../state/agentFileSync"; | ||
| import { useEnvironments } from "../../state/environments"; | ||
|
|
||
| export function AgentFileSyncCoordinator() { | ||
| const { environments } = useEnvironments(); | ||
| const [active, setActive] = useState(AppState.currentState === "active"); | ||
| const key = environments | ||
| .filter( | ||
| (env) => | ||
| env.connection.phase === "connected" && | ||
| env.serverConfig?.environment.capabilities.agentFileSync, | ||
| ) | ||
| .map((env) => env.environmentId) | ||
| .sort() | ||
| .join(","); | ||
| // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- Tracks native app activity so background clients stop relaying file changes. | ||
| useEffect(() => { | ||
| const subscription = AppState.addEventListener("change", (state) => | ||
| setActive(state === "active"), | ||
| ); | ||
| return () => subscription.remove(); | ||
| }, []); | ||
| // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- Keeps the sync relay running only while the app is active and these connections are mounted. | ||
| useEffect( | ||
| () => | ||
| active | ||
| ? startAgentFileSyncRelay( | ||
| appAtomRegistry, | ||
| agentFileSync, | ||
| key ? key.split(",").map((id) => EnvironmentId.make(id)) : [], | ||
| ) | ||
| : undefined, | ||
| [active, key], | ||
| ); | ||
| return null; | ||
| } |
89 changes: 89 additions & 0 deletions
89
apps/mobile/src/features/settings/AgentFileSyncSection.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import { useAtomValue } from "@effect/atom-react"; | ||
| import { runAtomCommand, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime"; | ||
| import type { EnvironmentId } from "@t3tools/contracts"; | ||
| import { useEffect, useState } from "react"; | ||
| import { View } from "react-native"; | ||
| import { AppText as Text } from "../../components/ui/AppText"; | ||
| import { appAtomRegistry } from "../../state/atom-registry"; | ||
| import { agentFileSync } from "../../state/agentFileSync"; | ||
| import { useEnvironmentQuery } from "../../state/query"; | ||
| import { ListActionRow as SettingsActionRow } from "../../components/ui/ListActionRow"; | ||
| import { SettingsSection } from "./components/SettingsSection"; | ||
|
|
||
| const syncErrorMessage = (cause: unknown) => | ||
| cause instanceof Error ? cause.message : "Could not update sync."; | ||
|
|
||
| export function AgentFileSyncSection({ environmentId }: { environmentId: EnvironmentId }) { | ||
| const links = useEnvironmentQuery(agentFileSync.links({ environmentId, input: {} })); | ||
| const allowed = useAtomValue(agentFileSync.manage.permissionAtom(environmentId)); | ||
| const [busy, setBusy] = useState(false); | ||
| const [error, setError] = useState<string | null>(null); | ||
| // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- Owns the subscription refresh timer while these settings are mounted. | ||
| useEffect(() => { | ||
| const timer = setInterval(links.refresh, 15_000); | ||
| return () => clearInterval(timer); | ||
| }, [links.refresh]); | ||
| const manage = async (id: string, action: "pause" | "resume" | "remove") => { | ||
| setBusy(true); | ||
| setError(null); | ||
| try { | ||
| const result = await runAtomCommand( | ||
| appAtomRegistry, | ||
| agentFileSync.manage, | ||
| { environmentId, input: { id, action } }, | ||
| { reportFailure: false }, | ||
| ); | ||
| if (result._tag === "Failure") { | ||
| setError(syncErrorMessage(squashAtomCommandFailure(result))); | ||
| } | ||
| links.refresh(); | ||
| } catch (cause) { | ||
| setError(syncErrorMessage(cause)); | ||
| } | ||
| setBusy(false); | ||
| }; | ||
| return ( | ||
| <SettingsSection | ||
| title="Skills & instructions" | ||
| footer="Choose skills and instruction sections in web or desktop Settings. Sync continues while a T3 client connects both machines. Stopping sync keeps the current files." | ||
| > | ||
| {(links.data ?? []).map((link) => ( | ||
| <View key={link.id}> | ||
| <View className="gap-1 p-4"> | ||
| <Text> | ||
| From {link.label} · {link.paused ? "Paused" : "Automatic"} | ||
| </Text> | ||
| <Text className="text-sm text-foreground-muted"> | ||
| {link.scope.cwd ?? "Personal files"} | ||
| </Text> | ||
| {link.error ? ( | ||
| <Text className="text-sm text-danger-foreground">{link.error}</Text> | ||
| ) : null} | ||
| </View> | ||
| <SettingsActionRow | ||
| label={link.paused ? "Resume sync" : "Pause sync"} | ||
| disabled={busy || !allowed} | ||
| onPress={() => void manage(link.id, link.paused ? "resume" : "pause")} | ||
| /> | ||
| <SettingsActionRow | ||
| label="Stop sync" | ||
| disabled={busy || !allowed} | ||
| onPress={() => void manage(link.id, "remove")} | ||
| /> | ||
| </View> | ||
| ))} | ||
| {!links.data?.length ? ( | ||
| <View className="p-4"> | ||
| <Text className="text-sm text-foreground-muted"> | ||
| {links.error ?? "No automatic sync subscriptions."} | ||
| </Text> | ||
| </View> | ||
| ) : null} | ||
| {error ? ( | ||
| <View className="p-4"> | ||
| <Text className="text-sm text-danger-foreground">{error}</Text> | ||
| </View> | ||
| ) : null} | ||
| </SettingsSection> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { createAgentFileSyncAtoms } from "@t3tools/client-runtime/state/agentFileSync"; | ||
| import { connectionAtomRuntime } from "../connection/runtime"; | ||
| export const agentFileSync = createAgentFileSyncAtoms(connectionAtomRuntime); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.