MCPcopy Create free account
hub / github.com/experdot/pointer / useChatTopics

Function useChatTopics

src/renderer/src/hooks/useChatTopics.ts:41–186  ·  view source on GitHub ↗
({
  pageId,
  messages,
  currentPath,
  topics
}: UseChatTopicsOptions)

Source from the content-addressed store, hash-verified

39}
40
41export function useChatTopics({
42 pageId,
43 messages,
44 currentPath,
45 topics
46}: UseChatTopicsOptions): UseChatTopicsResult {
47 const [isSegmenting, setIsSegmenting] = useState(false)
48
49 const createTopic = useCallback(
50 async (messageId: string, name: string): Promise<Topic | undefined> => {
51 try {
52 return await messagesService.createTopic(pageId, name, messageId)
53 } catch (error) {
54 console.error('Failed to create topic:', error)
55 return undefined
56 }
57 },
58 [pageId]
59 )
60
61 const updateTopic = useCallback(
62 async (topicId: string, updates: Partial<Omit<Topic, 'id'>>) => {
63 try {
64 await messagesService.updateTopic(pageId, topicId, updates)
65 } catch (error) {
66 console.error('Failed to update topic:', error)
67 }
68 },
69 [pageId]
70 )
71
72 const deleteTopic = useCallback(
73 async (topicId: string) => {
74 try {
75 await messagesService.deleteTopic(pageId, topicId)
76 } catch (error) {
77 console.error('Failed to delete topic:', error)
78 }
79 },
80 [pageId]
81 )
82
83 const toggleTopicCollapse = useCallback(
84 async (topicId: string) => {
85 try {
86 await messagesService.toggleTopicCollapse(pageId, topicId)
87 } catch (error) {
88 console.error('Failed to toggle topic collapse:', error)
89 }
90 },
91 [pageId]
92 )
93
94 const findTopicByMessageId = useCallback(
95 (messageId: string): Topic | undefined => {
96 return messagesService.findTopicByStartMessageId(topics, messageId)
97 },
98 [topics]

Callers 1

useChatFunction · 0.90

Calls 7

getSwitchGenerationFunction · 0.90
generateTopicTitleFunction · 0.90
analyzeTopicSegmentsFunction · 0.90
updateTopicMethod · 0.80
deleteTopicMethod · 0.80

Tested by

no test coverage detected