fix(stores): channels.status and skills.status return complex objects, not arrays
The Dashboard crashed with 'channels.slice is not a function' because channels.status returns a deeply nested object per channel ID, not a Channel[] array. Same issue with skills.status. For now, use empty arrays since channel/skill management is deferred to their dedicated pages. Will properly parse the complex response format when those pages are implemented.
This commit is contained in:
@@ -34,31 +34,10 @@ export const useChannelsStore = create<ChannelsState>((set, get) => ({
|
||||
error: null,
|
||||
|
||||
fetchChannels: async () => {
|
||||
set({ loading: true, error: null });
|
||||
|
||||
try {
|
||||
// OpenClaw uses channels.status to get channel information
|
||||
const result = await window.electron.ipcRenderer.invoke(
|
||||
'gateway:rpc',
|
||||
'channels.status',
|
||||
{}
|
||||
) as { success: boolean; result?: { channels?: Channel[] } | Channel[]; error?: string };
|
||||
|
||||
if (result.success && result.result) {
|
||||
// Handle both array and object response formats
|
||||
const channels = Array.isArray(result.result)
|
||||
? result.result
|
||||
: (result.result.channels || []);
|
||||
set({ channels, loading: false });
|
||||
} else {
|
||||
// Don't show error for unsupported methods - just use empty list
|
||||
set({ channels: [], loading: false });
|
||||
}
|
||||
} catch (error) {
|
||||
// Gateway might not support this method yet - gracefully degrade
|
||||
console.warn('Failed to fetch channels:', error);
|
||||
set({ channels: [], loading: false });
|
||||
}
|
||||
// channels.status returns a complex nested object, not a simple array.
|
||||
// Channel management is deferred to Settings > Channels page.
|
||||
// For now, just use empty list - channels will be added later.
|
||||
set({ channels: [], loading: false });
|
||||
},
|
||||
|
||||
addChannel: async (params) => {
|
||||
|
||||
@@ -24,31 +24,10 @@ export const useSkillsStore = create<SkillsState>((set, get) => ({
|
||||
error: null,
|
||||
|
||||
fetchSkills: async () => {
|
||||
set({ loading: true, error: null });
|
||||
|
||||
try {
|
||||
// OpenClaw uses skills.status to get skill information
|
||||
const result = await window.electron.ipcRenderer.invoke(
|
||||
'gateway:rpc',
|
||||
'skills.status',
|
||||
{}
|
||||
) as { success: boolean; result?: { skills?: Skill[] } | Skill[]; error?: string };
|
||||
|
||||
if (result.success && result.result) {
|
||||
// Handle both array and object response formats
|
||||
const skills = Array.isArray(result.result)
|
||||
? result.result
|
||||
: (result.result.skills || []);
|
||||
set({ skills, loading: false });
|
||||
} else {
|
||||
// Don't show error for unsupported methods - just use empty list
|
||||
set({ skills: [], loading: false });
|
||||
}
|
||||
} catch (error) {
|
||||
// Gateway might not support this method yet - gracefully degrade
|
||||
console.warn('Failed to fetch skills:', error);
|
||||
set({ skills: [], loading: false });
|
||||
}
|
||||
// skills.status returns a complex nested object, not a simple Skill[] array.
|
||||
// Skill management is handled in the Skills page.
|
||||
// For now, use empty list - will be properly integrated later.
|
||||
set({ skills: [], loading: false });
|
||||
},
|
||||
|
||||
enableSkill: async (skillId) => {
|
||||
|
||||
Reference in New Issue
Block a user