(ctx context.Context, raw json.RawMessage)
| 854 | type hostAPIResourceRecord = extensioncontract.ResourceRecord |
| 855 | |
| 856 | func (h *HostAPIHandler) handleSessionsList(ctx context.Context, raw json.RawMessage) (any, error) { |
| 857 | if h.sessions == nil { |
| 858 | return nil, errors.New("extension: session manager is not configured") |
| 859 | } |
| 860 | |
| 861 | var params hostAPISessionsListParams |
| 862 | if err := decodeHostAPIParams(raw, ¶ms); err != nil { |
| 863 | return nil, err |
| 864 | } |
| 865 | |
| 866 | infos, err := h.sessions.ListAll(ctx) |
| 867 | if err != nil { |
| 868 | return nil, err |
| 869 | } |
| 870 | |
| 871 | filterWorkspaceID := "" |
| 872 | filterWorkspaceRoot := "" |
| 873 | if workspaceRef := strings.TrimSpace(params.Workspace); workspaceRef != "" { |
| 874 | if h.workspaces != nil { |
| 875 | resolved, resolveErr := h.workspaces.Resolve(ctx, workspaceRef) |
| 876 | if resolveErr != nil { |
| 877 | return nil, resolveErr |
| 878 | } |
| 879 | filterWorkspaceID, resolveErr = hostAPIResolvedWorkspaceID(&resolved) |
| 880 | if resolveErr != nil { |
| 881 | return nil, resolveErr |
| 882 | } |
| 883 | filterWorkspaceRoot = strings.TrimSpace(resolved.RootDir) |
| 884 | } else { |
| 885 | filterWorkspaceID = workspaceRef |
| 886 | filterWorkspaceRoot = workspaceRef |
| 887 | } |
| 888 | } |
| 889 | |
| 890 | result := make([]hostAPISessionSummary, 0, len(infos)) |
| 891 | for _, info := range infos { |
| 892 | if info == nil { |
| 893 | continue |
| 894 | } |
| 895 | if filterWorkspaceID != "" || filterWorkspaceRoot != "" { |
| 896 | if info.WorkspaceID != filterWorkspaceID && info.Workspace != filterWorkspaceRoot { |
| 897 | continue |
| 898 | } |
| 899 | } |
| 900 | result = append(result, hostAPISessionSummary{ |
| 901 | ID: info.ID, |
| 902 | Name: info.Name, |
| 903 | Agent: info.AgentName, |
| 904 | Provider: info.Provider, |
| 905 | Workspace: info.Workspace, |
| 906 | State: info.State, |
| 907 | CreatedAt: info.CreatedAt, |
| 908 | }) |
| 909 | } |
| 910 | |
| 911 | return result, nil |
| 912 | } |
| 913 |
nothing calls this directly
no test coverage detected