olcli icon indicating copy to clipboard operation
olcli copied to clipboard

[Feature] add message to comment thread

Open rarensu opened this issue 5 months ago • 3 comments

I want to be able to add a message to a comment thread.

I would call this a reply. Perhaps something like

olcli comments reply <projectId> <threadId> <body>

Based on my browser's network activity, I think the route looks like

Request URL: https://www.overleaf.com/project/<id>/thread/<id>/messages
Request Method: POST
Payload: {"content": <body>}

rarensu avatar Jun 23 '26 20:06 rarensu

Actually, the client method already exists. Therefore, all that is needed is a new command in cli.js.

commentsCmd
    .command('reply <threadId> <body> [project]')
    .description('Reply to a comment thread with a message')
    .option('--json', 'Output as JSON')
    .option('--cookie <session>', 'Session cookie override')
    .action(async (threadId, body, project, options) => {
    const spinner = ora('Posting reply...').start();
    try {
        const client = await getClient(options.cookie);
        const proj = await resolveProject(client, project);
        const message = await client.postCommentMessage(proj.id, threadId, body);
        if (options.json) {
            spinner.stop();
            console.log(JSON.stringify({ replied: true, message }, null, 2));
            return;
        }
        spinner.succeed(`Replied to ${threadId}`);
        setLastProject(proj.id);
    }
    catch (error) {
        spinner.fail(`Failed: ${error.message}`);
        process.exit(1);
    }
});

rarensu avatar Jun 29 '26 18:06 rarensu

And an MCP tool, tool

// ---------------------------------------------------------------------------
// Tool: reply_to_comment
// ---------------------------------------------------------------------------
server.tool('reply_to_comment', 'Add a reply to an existing comment thread on an Overleaf project.', {
    project_id: z.string().describe('The Overleaf project ID'),
    thread_id: z.string().describe('The comment thread ID (from list_comments)'),
    content: z.string().describe('The reply message text'),
}, async ({ project_id, thread_id, content }) => wrapTool(async () => {
    const client = await getClient();
    const message = await client.postCommentMessage(project_id, thread_id, content);
    return { replied: true, thread_id, message };
}));

rarensu avatar Jun 29 '26 18:06 rarensu

Implemented in v0.6.0!

olcli comments reply <threadId> <body> [project]

Also available as the reply_to_comment MCP tool for AI agents. Thanks for both the issue and the PR - your approach was spot-on.

Released in v0.6.0.

aloth avatar Jun 30 '26 14:06 aloth