Skip to content

feat(skills): live refresh from the filesystem#2606

Merged
k11kirky merged 2 commits into
mainfrom
posthog-code/skills-03-live-refresh
Jun 12, 2026
Merged

feat(skills): live refresh from the filesystem#2606
k11kirky merged 2 commits into
mainfrom
posthog-code/skills-03-live-refresh

Conversation

@k11kirky

@k11kirky k11kirky commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Problem

Skills loaded in the UI do not reflect external changes made on disk (e.g. edits from a terminal, agent sessions, or another editor) until the page is manually refreshed.

Changes

A watchSkills method was added to SkillsService that watches the writable skill roots (~/.claude/skills and each repo's .claude/skills directory) using WatcherService. File system events are debounced (300 ms) and collapsed into a single { changed: true } event to avoid flooding the UI with updates.

A skills.watch tRPC subscription endpoint was added to the skills router, exposing this stream to the frontend.

A useSkillsWatcher hook was introduced that subscribes to skills.watch and calls queryClient.invalidateQueries on all skills queries whenever a change event arrives. This hook is mounted inside SkillsView so the skills list and file contents stay in sync with disk automatically.

The hardcoded staleTime: 30_000 overrides were removed from useSkills, useSkillContents, and useSkillFile since live invalidation via the watcher makes manual staleness tuning unnecessary.

WatcherService is now bound in skillsModule so that hosts loading only the skills module (e.g. Electron main) have the dependency available without requiring a separate binding.

How did you test this?

  • Added a watchSkillDirs integration test that creates a skill directory on disk after the watcher attaches and asserts that a debounced change event is emitted within 10 seconds.
  • Added a unit test confirming watchSkillDirs finishes immediately when given an empty directory list.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown

React Doctor could not complete this scan.

No React dependency found in /tmp/react-doctor-baseline-qF8HM6/package.json. Add "react" to dependencies (or peerDependencies) and re-run.

Reviewed by React Doctor for commit 5b8c1af.

@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
packages/workspace-server/src/services/skills/schemas.ts:82-84
**Exported schema is never used**

`skillsChangedEvent` is defined and exported here but not referenced anywhere else — it doesn't appear in `skills.router.ts` as `.output(skillsChangedEvent)` and no other file imports it. Every other procedure in the router uses an explicit output schema; the `watch` subscription currently carries no runtime validation. Either wire it up with `.output(skillsChangedEvent)` on the procedure, or remove the schema.

Reviews (1): Last reviewed commit: "feat(skills): live refresh from the file..." | Re-trigger Greptile

Comment thread packages/workspace-server/src/services/skills/schemas.ts Outdated
@k11kirky k11kirky marked this pull request as ready for review June 11, 2026 13:53
Comment thread packages/workspace-server/src/services/skills/skills.ts
@k11kirky k11kirky force-pushed the posthog-code/skills-02-crud branch from 0b5ff98 to 34baff5 Compare June 12, 2026 07:50
@k11kirky k11kirky force-pushed the posthog-code/skills-03-live-refresh branch from a0b806d to 1e80286 Compare June 12, 2026 07:50
@k11kirky k11kirky force-pushed the posthog-code/skills-02-crud branch from 34baff5 to 83a4081 Compare June 12, 2026 08:19
@k11kirky k11kirky force-pushed the posthog-code/skills-03-live-refresh branch from 1e80286 to 5df364a Compare June 12, 2026 08:19

k11kirky commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

@k11kirky k11kirky changed the base branch from posthog-code/skills-02-crud to graphite-base/2606 June 12, 2026 11:32
@k11kirky k11kirky force-pushed the graphite-base/2606 branch from 83a4081 to fc872b6 Compare June 12, 2026 11:43
@k11kirky k11kirky force-pushed the posthog-code/skills-03-live-refresh branch from 5df364a to 017c36e Compare June 12, 2026 11:43
@k11kirky k11kirky changed the base branch from graphite-base/2606 to posthog-code/skills-02-crud June 12, 2026 11:43
@k11kirky k11kirky changed the base branch from posthog-code/skills-02-crud to graphite-base/2606 June 12, 2026 11:54
@k11kirky k11kirky changed the base branch from graphite-base/2606 to main June 12, 2026 11:55
k11kirky added 2 commits June 12, 2026 11:55
- SkillsService.watchSkills merges @parcel/watcher streams over
  ~/.claude/skills (created if missing) and each open workspace
  folder's .claude/skills into a single debounced "skills changed"
  event stream. One failing root cannot break the others.
- skills.watch tRPC subscription using the async-generator pattern,
  with the watcher bound alongside SkillsService in skills.module.
- useSkillsWatcher subscribes once at the SkillsView boundary and
  invalidates every skills query on change; the 30s staleTime
  fallbacks are gone.

Generated-By: PostHog Code
Task-Id: f4e84f1a-19c9-490c-9b98-47787a7dddcf
…chema

Review feedback on #2606: watchSkillDirs now polls directories that do
not exist yet (e.g. a repo .claude/skills created after the watch
started) and attaches a watcher once they appear; the unused
skillsChangedEvent schema is removed (tRPC output validation does not
apply to async-generator subscriptions in our version).

Generated-By: PostHog Code
Task-Id: f4e84f1a-19c9-490c-9b98-47787a7dddcf
@k11kirky k11kirky force-pushed the posthog-code/skills-03-live-refresh branch from 017c36e to 5b8c1af Compare June 12, 2026 11:55
@k11kirky k11kirky merged commit fde4478 into main Jun 12, 2026
24 checks passed
@k11kirky k11kirky deleted the posthog-code/skills-03-live-refresh branch June 12, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants