Skip to content

Commit 034dee1

Browse files
committed
Refactor rule installation logic to toggle rule content in CLAUDE.md
- Implemented functionality to add or remove rules based on their existence in the current content. - Enhanced newline handling to prevent multiple consecutive newlines after rule modifications.
1 parent c523105 commit 034dee1

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

app/templates/components/workspace_actions.html

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,22 @@ <h3 class="text-lg font-black text-black mb-3">Quick Actions</h3>
354354
}
355355
}
356356

357-
// Append rule content to CLAUDE.md
358-
const newContent = currentContent + (currentContent ? '\n' : '') + result.content;
357+
// Toggle behavior: if rule already exists, remove it; if not, add it
358+
const ruleContent = result.content.trim();
359+
let newContent;
360+
361+
if (currentContent.includes(ruleContent)) {
362+
// Remove the rule
363+
newContent = currentContent
364+
.split('\n')
365+
.filter(line => line.trim() !== ruleContent)
366+
.join('\n')
367+
.replace(/\n\n+/g, '\n\n') // Clean up multiple newlines
368+
.trim();
369+
} else {
370+
// Add the rule
371+
newContent = currentContent + (currentContent ? '\n' : '') + ruleContent;
372+
}
359373

360374
// Add to virtual workspace
361375
if (window.workspaceManager && window.workspaceManager.currentState) {

0 commit comments

Comments
 (0)