MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / moveGoalQueueItem

Function moveGoalQueueItem

apps/kimi-code/src/tui/goal-queue-store.ts:113–131  ·  view source on GitHub ↗
(
  session: GoalQueueSession,
  input: { readonly goalId: string; readonly direction: GoalQueueMoveDirection },
)

Source from the content-addressed store, hash-verified

111}
112
113export async function moveGoalQueueItem(
114 session: GoalQueueSession,
115 input: { readonly goalId: string; readonly direction: GoalQueueMoveDirection },
116): Promise<GoalQueueSnapshot> {
117 return withQueueMutationLock(session, async () => {
118 const state = await readQueueFile(session);
119 const index = findGoalIndex(state, input.goalId);
120 const targetIndex = input.direction === 'up' ? index - 1 : index + 1;
121 if (targetIndex < 0 || targetIndex >= state.goals.length) {
122 return toSnapshot(state);
123 }
124 const goals = [...state.goals];
125 const [goal] = goals.splice(index, 1);
126 goals.splice(targetIndex, 0, goal!);
127 const next: GoalQueueFile = { version: GOAL_QUEUE_VERSION, goals };
128 await writeQueueFile(session, next);
129 return toSnapshot(next);
130 });
131}
132
133function goalQueuePath(session: GoalQueueSession): string {
134 const sessionDir = session.summary?.sessionDir;

Callers 2

Calls 5

withQueueMutationLockFunction · 0.85
findGoalIndexFunction · 0.85
toSnapshotFunction · 0.85
writeQueueFileFunction · 0.85
readQueueFileFunction · 0.70

Tested by

no test coverage detected