mirror of
https://github.com/Alishahryar1/free-claude-code.git
synced 2026-06-02 06:13:46 +02:00
Add clear command functionality to message handler
- Implemented handling of the `/clear` command to clear specific branches or entire trees based on message replies. - Added tests for various scenarios of the clear command, including clearing branches, handling unknown replies, and clearing entire trees. - Enhanced `TreeQueueManager` with methods to cancel branches and remove subtrees, ensuring proper state management in the session store. - Updated `SessionStore` and `TreeRepository` to support removal of node mappings and trees, improving data integrity during clear operations.
This commit is contained in:
@@ -288,6 +288,22 @@ class SessionStore:
|
||||
self._node_to_tree[node_id] = root_id
|
||||
self._schedule_save()
|
||||
|
||||
def remove_node_mappings(self, node_ids: List[str]) -> None:
|
||||
"""Remove node IDs from the node-to-tree mapping."""
|
||||
with self._lock:
|
||||
for nid in node_ids:
|
||||
self._node_to_tree.pop(nid, None)
|
||||
self._schedule_save()
|
||||
|
||||
def remove_tree(self, root_id: str) -> None:
|
||||
"""Remove a tree and all its node mappings from the store."""
|
||||
with self._lock:
|
||||
tree_data = self._trees.pop(root_id, None)
|
||||
if tree_data:
|
||||
for node_id in tree_data.get("nodes", {}).keys():
|
||||
self._node_to_tree.pop(node_id, None)
|
||||
self._schedule_save()
|
||||
|
||||
def get_all_trees(self) -> Dict[str, dict]:
|
||||
"""Get all stored trees (public accessor)."""
|
||||
with self._lock:
|
||||
|
||||
Reference in New Issue
Block a user