Skip to content

Commit a9b0ad5

Browse files
authored
Merge pull request #922 from refly-ai/fix/local-storage-quota
fix: local storage quota exceeded errors
2 parents be34949 + b635e08 commit a9b0ad5

File tree

9 files changed

+586
-163
lines changed

9 files changed

+586
-163
lines changed

packages/ai-workspace-common/src/components/canvas/launchpad/config-manager/index.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,17 +323,13 @@ export const ConfigManager = React.memo(
323323
return formErrors?.[field];
324324
};
325325

326-
console.log('tplConfig', tplConfig);
327-
328326
// Handle initial setup - only run on mount and when tplConfig changes significantly
329327
useEffect(() => {
330328
// Skip if already initialized with this config
331329
if (initializedRef.current) {
332330
return;
333331
}
334332

335-
console.log('Initializing ConfigManager with tplConfig:', tplConfig);
336-
337333
// Track this initialization
338334
initializedRef.current = true;
339335
prevTplConfigRef.current = tplConfig ? { ...tplConfig } : undefined;

packages/ai-workspace-common/src/components/canvas/node-chat-panel/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ export const ChatPanel = memo(
264264
const handleTplConfigChange = useCallback(
265265
(config: SkillTemplateConfig) => {
266266
if (setTplConfig && JSON.stringify(config) !== JSON.stringify(initialTplConfig)) {
267-
console.log('Config changed:', { old: initialTplConfig, new: config });
268267
setTplConfig(config);
269268
}
270269
},

packages/ai-workspace-common/src/hooks/canvas/use-action-polling.ts

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export const useActionPolling = () => {
2424
startTimeout,
2525
updateLastEventTime,
2626
clearTimeout: clearTimeoutState,
27-
trackResultUsage,
2827
} = useActionResultStoreShallow((state) => ({
2928
startPolling: state.startPolling,
3029
stopPolling: state.stopPolling,
@@ -34,7 +33,6 @@ export const useActionPolling = () => {
3433
startTimeout: state.startTimeout,
3534
updateLastEventTime: state.updateLastEventTime,
3635
clearTimeout: state.clearTimeout,
37-
trackResultUsage: state.trackResultUsage,
3836
}));
3937

4038
const onUpdateResult = useUpdateActionResult();
@@ -61,9 +59,6 @@ export const useActionPolling = () => {
6159
}
6260

6361
try {
64-
// Track result usage when polling to keep it in the recent list
65-
trackResultUsage(resultId);
66-
6762
const { data: result } = await getClient().getActionResult({
6863
query: { resultId, version },
6964
});
@@ -120,14 +115,7 @@ export const useActionPolling = () => {
120115
}, POLLING_INTERVAL);
121116
}
122117
},
123-
[
124-
incrementErrorCount,
125-
resetErrorCount,
126-
stopPolling,
127-
onUpdateResult,
128-
updateLastPollTime,
129-
trackResultUsage,
130-
],
118+
[incrementErrorCount, resetErrorCount, stopPolling, onUpdateResult, updateLastPollTime],
131119
);
132120

133121
const startPolling = useCallback(
@@ -136,9 +124,6 @@ export const useActionPolling = () => {
136124
const pollingState = pollingStateMap[resultId];
137125
const currentResult = resultMap[resultId];
138126

139-
// Track result usage when starting polling to ensure it's kept in storage
140-
trackResultUsage(resultId);
141-
142127
// Don't restart polling for results that are already marked as failed
143128
if (failedResultIds.has(resultId) || currentResult?.status === 'failed') {
144129
return;
@@ -154,17 +139,12 @@ export const useActionPolling = () => {
154139
// Start the polling cycle
155140
await pollActionResult(resultId, version);
156141
},
157-
[clearTimeoutState, startPollingState, pollActionResult, trackResultUsage],
142+
[clearTimeoutState, startPollingState, pollActionResult],
158143
);
159144

160-
const resetFailedState = useCallback(
161-
(resultId: string) => {
162-
failedResultIds.delete(resultId);
163-
// Track usage when resetting failed state
164-
trackResultUsage(resultId);
165-
},
166-
[trackResultUsage],
167-
);
145+
const resetFailedState = useCallback((resultId: string) => {
146+
failedResultIds.delete(resultId);
147+
}, []);
168148

169149
// Cleanup all polling on unmount
170150
useEffect(() => {
@@ -177,19 +157,13 @@ export const useActionPolling = () => {
177157
(resultId: string, version: number) => {
178158
let timeoutId: NodeJS.Timeout;
179159

180-
// Track result usage to ensure it's kept in storage
181-
trackResultUsage(resultId);
182-
183160
const resetTimeout = () => {
184161
if (timeoutId) {
185162
clearTimeout(timeoutId);
186163
}
187164

188165
updateLastEventTime(resultId);
189166

190-
// Track usage when timeout is reset
191-
trackResultUsage(resultId);
192-
193167
timeoutId = setTimeout(() => {
194168
const result = useActionResultStore.getState().resultMap[resultId];
195169

@@ -220,14 +194,7 @@ export const useActionPolling = () => {
220194
},
221195
};
222196
},
223-
[
224-
startTimeout,
225-
updateLastEventTime,
226-
startPolling,
227-
clearTimeoutState,
228-
stopPolling,
229-
trackResultUsage,
230-
],
197+
[startTimeout, updateLastEventTime, startPolling, clearTimeoutState, stopPolling],
231198
);
232199

233200
return {

packages/ai-workspace-common/src/hooks/canvas/use-debounced-context-update.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ export const useContextUpdateByResultId = ({
9595
const updateContextItemsFromResultId = useCallback(() => {
9696
if (!resultId) return;
9797

98-
console.log('updateContextItemsFromResultId', resultId);
99-
10098
// Find the node associated with this resultId
10199
const nodes = getNodes();
102100
const currentNode = nodes.find(

packages/ai-workspace-common/src/hooks/canvas/use-find-thread-history.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,6 @@ export const useFindThreadHistory = () => {
2323

2424
const edges = getEdges();
2525

26-
console.log('startNode', startNode);
27-
28-
// Create a more detailed mapping for debugging
29-
const allConnections = edges.map((edge) => ({
30-
source: edge.source,
31-
target: edge.target,
32-
sourceNode: getNode(edge.source),
33-
targetNode: getNode(edge.target),
34-
}));
35-
36-
console.log('All connections:', allConnections);
37-
3826
// Create two maps to handle bidirectional traversal if needed
3927
const targetToSourceMap = new Map();
4028
const sourceToTargetsMap = new Map();
@@ -53,9 +41,6 @@ export const useFindThreadHistory = () => {
5341
sourceToTargetsMap.get(edge.source).push(edge.target);
5442
}
5543

56-
// For debugging
57-
console.log('Target to Source Map:', [...targetToSourceMap.entries()]);
58-
5944
const history = [startNode];
6045
const visited = new Set<string>();
6146

@@ -68,7 +53,6 @@ export const useFindThreadHistory = () => {
6853
const sourceIds = targetToSourceMap.get(nodeId) || [];
6954
for (const sourceId of sourceIds) {
7055
const sourceNode = getNode(sourceId);
71-
console.log('Exploring source node:', sourceId, sourceNode?.type);
7256

7357
if (sourceNode?.type === 'skillResponse') {
7458
// Only add if not already in history
@@ -84,15 +68,6 @@ export const useFindThreadHistory = () => {
8468
// Start the recursive search from the start node
8569
findSourceNodes(startNode.id);
8670

87-
console.log(
88-
'Found history nodes:',
89-
history.map((node) => ({
90-
id: node.id,
91-
type: node.type,
92-
entityId: node.data?.entityId,
93-
})),
94-
);
95-
9671
// Return nodes in reverse order (oldest to newest)
9772
return history.reverse();
9873
},

0 commit comments

Comments
 (0)