MCPcopy
hub / github.com/Dimillian/CodexMonitor / usePlanReadyActions

Function usePlanReadyActions

src/features/app/hooks/usePlanReadyActions.ts:36–194  ·  view source on GitHub ↗
({
  activeWorkspace,
  activeThreadId,
  collaborationModes,
  resolvedModel,
  resolvedEffort,
  connectWorkspace,
  sendUserMessageToThread,
  setSelectedCollaborationModeId,
  persistThreadCodexParams,
}: UsePlanReadyActionsOptions)

Source from the content-addressed store, hash-verified

34};
35
36export function usePlanReadyActions({
37 activeWorkspace,
38 activeThreadId,
39 collaborationModes,
40 resolvedModel,
41 resolvedEffort,
42 connectWorkspace,
43 sendUserMessageToThread,
44 setSelectedCollaborationModeId,
45 persistThreadCodexParams,
46}: UsePlanReadyActionsOptions) {
47 const findCollaborationMode = useCallback(
48 (wanted: string) => {
49 const normalized = wanted.trim().toLowerCase();
50 if (!normalized) {
51 return null;
52 }
53 return (
54 collaborationModes.find(
55 (mode) => mode.id.trim().toLowerCase() === normalized,
56 ) ??
57 collaborationModes.find(
58 (mode) => (mode.mode || mode.id).trim().toLowerCase() === normalized,
59 ) ??
60 null
61 );
62 },
63 [collaborationModes],
64 );
65
66 const isPlanMode = useCallback((mode: CollaborationModeOption | null) => {
67 if (!mode) {
68 return false;
69 }
70 const modeValue = (mode.mode || mode.id).trim().toLowerCase();
71 return modeValue === "plan";
72 }, []);
73
74 const findImplementationMode = useCallback(() => {
75 const defaultMode = findCollaborationMode("default");
76 if (defaultMode && !isPlanMode(defaultMode)) {
77 return defaultMode;
78 }
79
80 const codeMode = findCollaborationMode("code");
81 if (codeMode && !isPlanMode(codeMode)) {
82 return codeMode;
83 }
84
85 return collaborationModes.find((mode) => !isPlanMode(mode)) ?? null;
86 }, [collaborationModes, findCollaborationMode, isPlanMode]);
87
88 const buildCollaborationModePayloadFor = useCallback(
89 (mode: CollaborationModeOption | null) => {
90 if (!mode) {
91 return null;
92 }
93

Callers 2

MainAppFunction · 0.90
renderPlanReadyActionsFunction · 0.90

Calls 3

connectWorkspaceFunction · 0.85

Tested by 1

renderPlanReadyActionsFunction · 0.72