fix: added Cursor OAuth provider and fixed authentication flow race conditions
- Added Cursor OAuth provider support to CLI authentication flow. - Fixed race conditions in OAuth callback handling and session picker cleanup. - Improved JWT token parsing and error handling across OAuth providers. - Replaced Bun.sleep() with abortable sleep for proper cancellation support. - Enhanced process execution with concurrent stream reading and better timeout handling. - Added cache cleanup mechanism for auth storage with 5-minute intervals.
This commit is contained in:
@@ -247,16 +247,16 @@ export default function planModeExtension(pi: ExtensionAPI) {
|
||||
}
|
||||
}
|
||||
|
||||
function togglePlanMode(ctx: ExtensionContext) {
|
||||
async function togglePlanMode(ctx: ExtensionContext) {
|
||||
planModeEnabled = !planModeEnabled;
|
||||
executionMode = false;
|
||||
todoItems = [];
|
||||
|
||||
if (planModeEnabled) {
|
||||
pi.setActiveTools(PLAN_MODE_TOOLS);
|
||||
await pi.setActiveTools(PLAN_MODE_TOOLS);
|
||||
ctx.ui.notify(`Plan mode enabled. Tools: ${PLAN_MODE_TOOLS.join(", ")}`);
|
||||
} else {
|
||||
pi.setActiveTools(NORMAL_MODE_TOOLS);
|
||||
await pi.setActiveTools(NORMAL_MODE_TOOLS);
|
||||
ctx.ui.notify("Plan mode disabled. Full access restored.");
|
||||
}
|
||||
updateStatus(ctx);
|
||||
@@ -266,7 +266,7 @@ export default function planModeExtension(pi: ExtensionAPI) {
|
||||
pi.registerCommand("plan", {
|
||||
description: "Toggle plan mode (read-only exploration)",
|
||||
handler: async (_args, ctx) => {
|
||||
togglePlanMode(ctx);
|
||||
await togglePlanMode(ctx);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -294,7 +294,7 @@ export default function planModeExtension(pi: ExtensionAPI) {
|
||||
pi.registerShortcut(Key.shift("p"), {
|
||||
description: "Toggle plan mode",
|
||||
handler: async (ctx) => {
|
||||
togglePlanMode(ctx);
|
||||
await togglePlanMode(ctx);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -417,7 +417,7 @@ Execute each step in order.`,
|
||||
|
||||
executionMode = false;
|
||||
todoItems = [];
|
||||
pi.setActiveTools(NORMAL_MODE_TOOLS);
|
||||
await pi.setActiveTools(NORMAL_MODE_TOOLS);
|
||||
updateStatus(ctx);
|
||||
}
|
||||
return;
|
||||
@@ -470,7 +470,7 @@ Execute each step in order.`,
|
||||
if (choice?.startsWith("Execute")) {
|
||||
planModeEnabled = false;
|
||||
executionMode = hasTodos;
|
||||
pi.setActiveTools(NORMAL_MODE_TOOLS);
|
||||
await pi.setActiveTools(NORMAL_MODE_TOOLS);
|
||||
updateStatus(ctx);
|
||||
|
||||
// Simple execution message - context event filters old plan mode messages
|
||||
@@ -519,7 +519,7 @@ Execute each step in order.`,
|
||||
}
|
||||
|
||||
if (planModeEnabled) {
|
||||
pi.setActiveTools(PLAN_MODE_TOOLS);
|
||||
await pi.setActiveTools(PLAN_MODE_TOOLS);
|
||||
}
|
||||
updateStatus(ctx);
|
||||
});
|
||||
|
||||
@@ -31,12 +31,12 @@ export default function toolsExtension(pi: ExtensionAPI) {
|
||||
}
|
||||
|
||||
// Apply current tool selection
|
||||
function applyTools() {
|
||||
pi.setActiveTools(Array.from(enabledTools));
|
||||
async function applyTools() {
|
||||
await pi.setActiveTools(Array.from(enabledTools));
|
||||
}
|
||||
|
||||
// Find the last tools-config entry in the current branch
|
||||
function restoreFromBranch(ctx: ExtensionContext) {
|
||||
async function restoreFromBranch(ctx: ExtensionContext) {
|
||||
allTools = pi.getAllTools();
|
||||
|
||||
// Get entries in current branch only
|
||||
@@ -55,7 +55,7 @@ export default function toolsExtension(pi: ExtensionAPI) {
|
||||
if (savedTools) {
|
||||
// Restore saved tool selection (filter to only tools that still exist)
|
||||
enabledTools = new Set(savedTools.filter((t: string) => allTools.includes(t)));
|
||||
applyTools();
|
||||
await applyTools();
|
||||
} else {
|
||||
// No saved state - sync with currently active tools
|
||||
enabledTools = new Set(pi.getActiveTools());
|
||||
@@ -130,16 +130,16 @@ export default function toolsExtension(pi: ExtensionAPI) {
|
||||
|
||||
// Restore state on session start
|
||||
pi.on("session_start", async (_event, ctx) => {
|
||||
restoreFromBranch(ctx);
|
||||
await restoreFromBranch(ctx);
|
||||
});
|
||||
|
||||
// Restore state when navigating the session tree
|
||||
pi.on("session_tree", async (_event, ctx) => {
|
||||
restoreFromBranch(ctx);
|
||||
await restoreFromBranch(ctx);
|
||||
});
|
||||
|
||||
// Restore state after branching
|
||||
pi.on("session_branch", async (_event, ctx) => {
|
||||
restoreFromBranch(ctx);
|
||||
await restoreFromBranch(ctx);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user