real-time-sync
ما الذي تفعله
تحدد هذه المهارة متى ينبغي أن تحدّث الشاشة نفسها بسبب تغييرات أجراها آخرون، وكيفية تشغيل قناة التحديث المشتركة بأمان. وهي مخصصة للمطورين الذين يبنون صفحات تتغير بياناتها تلقائياً.
متى تستخدمها
- ✓عندما يجب أن تُظهر الصفحة تغييرات أجراها شخص آخر قبل أن يحدّث المستخدم.
- ✓عندما يجب أن يُحدَّث تقدم مهمة في الخلفية أثناء متابعة المستخدم لها.
- ✓عندما لا تحتاج صفحة عامة أو صفحة إعدادات أو نموذج إلى تحديثات مباشرة، وينبغي أن تبقى مغلقة.
رابط المهارة
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/real-time-sync/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“اجعل صندوق الوارد يتحدث وحده عندما تصل رسائل جديدة، دون أن أحدّث الصفحة.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
تضع المهارة قاعدة بسيطة: تفعيل الفحص المباشر فقط عندما قد تتغير البيانات دون المستخدم ويحتاج المستخدم إلى رؤية ذلك. وإلا تُحدَّث الصفحة عند التركيز أو التنقل.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
Real-Time Sync
Decision rule
Opt in only when both are true:
- The data can change without the current user acting.
- The user needs to see that change before refreshing or navigating.
A local agent edit does not meet this rule. The chat run stream already invalidates action queries and source counters after each side-effecting tool and again at run end, without opening a background poll.
Opt in
- Slides deck editor: another collaborator can edit the open deck.
- Mail inbox: new mail can arrive while the inbox is open.
- A watched job: a background job changes progress while the user watches it.
- Cross-tab state: state must converge across this user's open tabs without a new action.
Keep it off
- Public, anonymous, marketing, docs, and SSR pages.
- Settings, forms, and read-mostly lists or dashboards. Refresh them on focus or navigation instead.
- Single-user agent edits. The chat run stream handles those.
- Pages where an update is useful eventually but not before the next refresh.
Cost and behavior
useDbSync() has no background transport unless the page opts in with a
non-empty reason. One transport is shared per tab. A visible opted-in tab polls
at 1 minute, then 2, then 5 minutes while idle; user activity or a local
mutation resets that sequence. Hidden tabs pause by default. During an active
agent run, opted-in sync can poll at its configured interval; local tool
completion and run-end invalidation do not depend on that poll.
On a long-lived host, same-process changes stream over
/_agent-native/events; polling is the cross-process fallback. On a production
serverless host, the local events endpoint refuses the long-lived stream and
/_agent-native/poll carries remote changes. The paid Hosted Realtime Sync
Gateway is not required for this pattern.
While a collab doc shows another person present, the transport polls every
2.5 s instead (acquireCollabPollBoost(), held by the collab client, not by
pages). It is a no-op whenever a stream is connected, lapses after 3 minutes
without input or remote events, and never applies to lone tabs.
Use the hook
Declare the reason beside the route gate so reviewers can see why the page pays for remote sync:
useDbSync({
queryClient,
realtime: isPrivateDeckEditorPath(location.pathname)
? { reason: "other collaborators can edit this deck while it is open" }
: undefined,
pauseWhenHidden: true,
});
The reason is required by the TypeScript API. Opt in only for a named private or authenticated route; public, documentation, and SSR pages should not start a background transport.
An opted-in page only hears about an action when its change event reaches the
current user. By default an action event reaches the actor alone, so a
collaborator's comment, save, or agent edit never arrives. Declare
changeResource: (input, result) => ({ resourceType, resourceId }) on the
mutating action and the event also reaches everyone who can read that resource.
Name it from input when the call carries the resource id (Content's
documentChangeResource, Slides' comment actions) and from result when the
call is keyed by a child id (Design's designChangeResource for
delete-file); return null for a call that changed nothing. Do not publish a
parallel per-template event for the same purpose.
Do not start subscribeSyncEvents() or an EventSource in a feature to bypass
the decision. subscribeSyncEvents() is a lower-level transport subscription
used by the existing Yjs collaboration client and narrow framework plumbing.
Keep Yjs collaborative editing on its existing channel.
Query freshness
Prefer useActionQuery() for action-backed data. Mutating actions refresh local
action observers; the chat run stream also invalidates them for agent tool
side effects. Raw queries should include the relevant source counters:
const versions = useChangeVersions(["dashboards", "action"]);
useQuery({
queryKey: ["dashboard", id, versions],
queryFn: () => fetchDashboard(id),
placeholderData: (previous) => previous,
});
That covers local chat-run edits. Remote edits reach the counter through
useDbSync() only on an opted-in page. Use useReconciledState when a form or
inline editor copies a query value into local state so incoming data does not
replace active typing.
URL commands (__set_url__, set-url, and set-search-params) and
refresh-screen also flow through local chat events. The sideb
الأسئلة الشائعة
هل تحتاج تعديلات الوكيل إلى مزامنة مباشرة؟
لا. يحدّث تشغيل المحادثة البيانات بالفعل بعد كل تغيير يجريه الوكيل.
هل تعمل الفحوصات المباشرة في التبويبات المخفية؟
لا. تتوقف التبويبات المخفية افتراضياً.
كم مرة تفحص التبويبة المرئية؟
تفحص تقريباً كل دقيقة في البداية، ثم تقل عندما تكون خاملة.
التفاصيل
الوصف الأصلي من المؤلف
Decide whether a page needs external changes before refresh, then use the opt-in shared SSE and polling transport safely.
repo: BuilderIO/agent-native
الشعبية
- نجوم GitHub
- 7.6k
- الترتيب
- #13175
- الترخيص
- MIT
- آخر تحديث
- 2/11/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
design-exploration
7.6kيساعد وكيلك على استكشاف عدة اتجاهات تصميم لواجهة المستخدم جنباً إلى جنب، ثم تختار أنت واحداً، ويحسّن الوكيل التصميم المختار.
visual-edit
7.6kيساعد وكيلك على فتح تطبيق محلي يعمل في محرر مرئي، لتراجع شاشاته الحقيقية وتحررها معاً.
turn-into-app
7.6kيحوّل سير عمل أو جدول بيانات أو مشروعاً إلى تطبيق مرئي مصقول، فيه شاشات مملوءة بالبيانات ووكيل يعمل خلف أدوات التحكم.
visual-plan
7.6kيحوّل خطة نصية عادية إلى خطة مرئية تفاعلية فيها مخططات وخرائط ملفات ومقتطفات كود وأسئلة مفتوحة.
مهارات مشابهة
angular-developer
280kيساعد وكيلك على كتابة شيفرة Angular وتقديم نصائح لبنية المشروع، ويفيد في بدء المشاريع الجديدة وإنشاء المكونات وتحسين الأداء وإمكانية الوصول.
frontend-a11y
280kيساعد وكيلك على جعل واجهات الويب متاحة للجميع، فيضمن أن المواقع والتطبيقات تعمل جيدًا مع قارئات الشاشة والتنقل بلوحة المفاتيح.
frontend-patterns
280kيطبّق وكيلك أنماط تطوير الواجهات الحديثة، فيحسّن الأداء ويدير الحالة ويتبع أفضل الممارسات في React وNext.js.