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,
|
error: null,
|
||||||
|
|
||||||
fetchChannels: async () => {
|
fetchChannels: async () => {
|
||||||
set({ loading: true, error: null });
|
// channels.status returns a complex nested object, not a simple array.
|
||||||
|
// Channel management is deferred to Settings > Channels page.
|
||||||
try {
|
// For now, just use empty list - channels will be added later.
|
||||||
// OpenClaw uses channels.status to get channel information
|
set({ channels: [], loading: false });
|
||||||
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 });
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
addChannel: async (params) => {
|
addChannel: async (params) => {
|
||||||
|
|||||||
@@ -24,31 +24,10 @@ export const useSkillsStore = create<SkillsState>((set, get) => ({
|
|||||||
error: null,
|
error: null,
|
||||||
|
|
||||||
fetchSkills: async () => {
|
fetchSkills: async () => {
|
||||||
set({ loading: true, error: null });
|
// skills.status returns a complex nested object, not a simple Skill[] array.
|
||||||
|
// Skill management is handled in the Skills page.
|
||||||
try {
|
// For now, use empty list - will be properly integrated later.
|
||||||
// OpenClaw uses skills.status to get skill information
|
set({ skills: [], loading: false });
|
||||||
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 });
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
enableSkill: async (skillId) => {
|
enableSkill: async (skillId) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user