feat(rpc): support Command Palette actions via commands.execute and manifest contributions - #73
Merged
Conversation
…anifest contributions. Closes #48 Querya Desktop's Command Palette invokes commands.execute for actions declared under contributions.commands in manifest.json, but the driver neither declared any commands nor implemented the method (returning -32601 Method not found). - manifest.json now declares four ClickHouse maintenance commands: clickhouse.optimizeFinal, clickhouse.deduplicate, clickhouse.serverStats, clickhouse.dropPartition. - New src/rpc/handlers/commands.rs implements handle_execute, dispatching on commandId. clickhouse.serverStats delegates straight to handle_get_server_stats. The other three build the same SQL as their sdui.contextActions equivalents (OPTIMIZE ... FINAL / DEDUPLICATE, ALTER ... DROP PARTITION) and run it through handle_query, reusing existing Safe Mode and injection-safe quoting/escaping. - The Command Palette doesn't yet forward workspace selection (nodeId) to drivers, so database/table/partition are accepted as optional params; a command that needs a target and doesn't get one returns a clear -32602 error instead of guessing or operating on the wrong object. - Registered "commands.execute" in router.rs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Querya Desktop's Command Palette (
Ctrl+Shift+P) sendscommands.executefor actions declared undercontributions.commandsinmanifest.json. Neither existed: the manifest declared no commands, andcommands.executefell through to-32601 Method not foundinrouter.rs.manifest.jsonnow declares four commands undercontributions.commands:clickhouse.optimizeFinal,clickhouse.deduplicate,clickhouse.serverStats,clickhouse.dropPartition.src/rpc/handlers/commands.rsimplementshandle_execute(params), dispatching oncommandId:clickhouse.serverStatsdelegates straight tohandle_get_server_stats.clickhouse.optimizeFinal/clickhouse.deduplicate/clickhouse.dropPartitionbuild the same SQL as theirsdui.contextActionsequivalents (OPTIMIZE ... FINAL/DEDUPLICATE,ALTER ... DROP PARTITION) and run it throughhandle_query, reusing the existing Safe Mode precheck and injection-safequote_identifier/escape_sql_string_literal.nodeId) to drivers, sodatabase/table/partitionare accepted as optional params oncommands.execute. A command that needs a target it didn't get returns a clear-32602error ("requires 'database' and 'table' parameters...") instead of guessing or silently no-oping."commands.execute" => commands::handle_execute(params).awaitinrouter.rs.Closes #48
Test plan
cargo test— 105/105 passing, including new tests for each command (server stats, optimize/deduplicate, drop partition, missing-target errors, unknown commandId, missing params) and a router dispatch testcargo fmt --all -- --checkcargo clippy --all-targets --all-features -- -D warningsmanifest.jsonvalidated as well-formed JSON