MCPcopy Create free account
hub / github.com/cortexkit/magic-context / showConflictDialog

Function showConflictDialog

packages/plugin/src/tui/index.tsx:56–88  ·  view source on GitHub ↗
(api: TuiPluginApi, directory: string, reasons: string[], conflicts: ReturnType<typeof detectConflicts>["conflicts"])

Source from the content-addressed store, hash-verified

54}
55
56function showConflictDialog(api: TuiPluginApi, directory: string, reasons: string[], conflicts: ReturnType<typeof detectConflicts>["conflicts"]) {
57 api.ui.dialog.replace(() => (
58 <api.ui.DialogConfirm
59 title="⚠️ Magic Context Disabled"
60 message={`${reasons.join("\n")}\n\nFix these conflicts automatically?`}
61 onConfirm={() => {
62 const actions = fixConflicts(directory, conflicts)
63 const actionSummary = actions.length > 0
64 ? actions.map(a => `• ${a}`).join("\n")
65 : "No changes needed"
66 // DialogConfirm calls dialog.clear() after onConfirm, so defer the next dialog
67 setTimeout(() => {
68 api.ui.dialog.replace(() => (
69 <api.ui.DialogAlert
70 title="✅ Configuration Fixed"
71 message={`${actionSummary}\n\nPlease restart OpenCode for changes to take effect.`}
72 onConfirm={() => {
73 showToast(api, {
74 message: "Restart OpenCode to enable Magic Context",
75 variant: "warning",
76 durationOverrideMs: 10_000,
77 })
78 }}
79 />
80 ))
81 }, 50)
82 }}
83 onCancel={() => {
84 showToast(api, { message: "Magic Context remains disabled. Run: npx @cortexkit/opencode-magic-context@latest doctor", variant: "warning" })
85 }}
86 />
87 ))
88}
89
90function fmt(n: number): string {
91 if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`

Callers 1

tuiFunction · 0.85

Calls 2

fixConflictsFunction · 0.90
showToastFunction · 0.70

Tested by

no test coverage detected