From d6e20ef7c10db141166cf77bf30f847d6fe227cb Mon Sep 17 00:00:00 2001 From: Kyriakos Akriotis Date: Fri, 23 Oct 2026 14:07:29 +0200 Subject: [PATCH] enhance plugin resource commands to refresh ad-hoc after completion #166 --- internal/plugins/resource.go | 6 ++++++ pluginsdk/grpc_client.go | 4 +++- pluginsdk/grpc_server.go | 4 +++- pluginsdk/plugin.go | 7 ++++--- pluginsdk/proto/plugin.pb.go | 25 +++++++++++++++++-------- pluginsdk/proto/plugin.proto | 1 + 6 files changed, 34 insertions(+), 13 deletions(-) diff --git a/internal/plugins/resource.go b/internal/plugins/resource.go index 1fbcfd8..1c17257 100644 --- a/internal/plugins/resource.go +++ b/internal/plugins/resource.go @@ -146,6 +146,12 @@ func (r *pluginResource) Execute(command resource.Command, row resource.Row) tea } } + if result.RefreshOnComplete { + return resource.CommandCompletedMsg{ + RefreshOnCompletion: result.RefreshOnComplete, + } + } + return nil } } diff --git a/pluginsdk/grpc_client.go b/pluginsdk/grpc_client.go index 1937c6a..ab13ad0 100644 --- a/pluginsdk/grpc_client.go +++ b/pluginsdk/grpc_client.go @@ -137,7 +137,9 @@ func (r *grpcResource) Execute(ctx context.Context, command Command, row Row) (R return Result{}, nil } - result := Result{} + result := Result{ + RefreshOnComplete: response.Result.RefreshOnComplete, + } if response.Result.Details != nil { result.Details = &Details{ diff --git a/pluginsdk/grpc_server.go b/pluginsdk/grpc_server.go index bd6eff6..c6c05b8 100644 --- a/pluginsdk/grpc_server.go +++ b/pluginsdk/grpc_server.go @@ -139,7 +139,9 @@ func (s *grpcServer) Execute(ctx context.Context, request *pb.ExecuteRequest) (* return nil, fmt.Errorf("invalid result: %w", err) } - response := &pb.Result{} + response := &pb.Result{ + RefreshOnComplete: result.RefreshOnComplete, + } if result.Details != nil { response.Details = &pb.Details{ diff --git a/pluginsdk/plugin.go b/pluginsdk/plugin.go index 2e67b1c..42461cf 100644 --- a/pluginsdk/plugin.go +++ b/pluginsdk/plugin.go @@ -66,9 +66,10 @@ type Resource interface { } type Result struct { - Details *Details - Navigate *Navigate - Terminal *Terminal + Details *Details + Navigate *Navigate + Terminal *Terminal + RefreshOnComplete bool } type Details struct { diff --git a/pluginsdk/proto/plugin.pb.go b/pluginsdk/proto/plugin.pb.go index 6fbb537..c301b1d 100644 --- a/pluginsdk/proto/plugin.pb.go +++ b/pluginsdk/proto/plugin.pb.go @@ -762,12 +762,13 @@ func (x *ExecuteResponse) GetResult() *Result { } type Result struct { - state protoimpl.MessageState `protogen:"open.v1"` - Details *Details `protobuf:"bytes,1,opt,name=details,proto3" json:"details,omitempty"` - Navigate *Navigate `protobuf:"bytes,2,opt,name=navigate,proto3" json:"navigate,omitempty"` - Terminal *Terminal `protobuf:"bytes,3,opt,name=terminal,proto3" json:"terminal,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Details *Details `protobuf:"bytes,1,opt,name=details,proto3" json:"details,omitempty"` + Navigate *Navigate `protobuf:"bytes,2,opt,name=navigate,proto3" json:"navigate,omitempty"` + Terminal *Terminal `protobuf:"bytes,3,opt,name=terminal,proto3" json:"terminal,omitempty"` + RefreshOnComplete bool `protobuf:"varint,4,opt,name=refresh_on_complete,json=refreshOnComplete,proto3" json:"refresh_on_complete,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Result) Reset() { @@ -821,6 +822,13 @@ func (x *Result) GetTerminal() *Terminal { return nil } +func (x *Result) GetRefreshOnComplete() bool { + if x != nil { + return x.RefreshOnComplete + } + return false +} + type Details struct { state protoimpl.MessageState `protogen:"open.v1"` Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` @@ -1066,11 +1074,12 @@ const file_pluginsdk_proto_plugin_proto_rawDesc = "" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"@\n" + "\x0fExecuteResponse\x12-\n" + - "\x06result\x18\x01 \x01(\v2\x15.o7k.plugin.v1.ResultR\x06result\"\xa4\x01\n" + + "\x06result\x18\x01 \x01(\v2\x15.o7k.plugin.v1.ResultR\x06result\"\xd4\x01\n" + "\x06Result\x120\n" + "\adetails\x18\x01 \x01(\v2\x16.o7k.plugin.v1.DetailsR\adetails\x123\n" + "\bnavigate\x18\x02 \x01(\v2\x17.o7k.plugin.v1.NavigateR\bnavigate\x123\n" + - "\bterminal\x18\x03 \x01(\v2\x17.o7k.plugin.v1.TerminalR\bterminal\"3\n" + + "\bterminal\x18\x03 \x01(\v2\x17.o7k.plugin.v1.TerminalR\bterminal\x12.\n" + + "\x13refresh_on_complete\x18\x04 \x01(\bR\x11refreshOnComplete\"3\n" + "\aDetails\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\x12\x18\n" + "\acontent\x18\x02 \x01(\fR\acontent\"\xd6\x01\n" + diff --git a/pluginsdk/proto/plugin.proto b/pluginsdk/proto/plugin.proto index a47dd6a..e4b2e4b 100644 --- a/pluginsdk/proto/plugin.proto +++ b/pluginsdk/proto/plugin.proto @@ -93,6 +93,7 @@ message Result { Details details = 1; Navigate navigate = 2; Terminal terminal = 3; + bool refresh_on_complete = 4; } message Details {