window.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package hostbridge
  2. import (
  3. "context"
  4. "fmt"
  5. "log"
  6. proto "github.com/cline/grpc-go/host"
  7. )
  8. // WindowService implements the proto.WindowServiceServer interface
  9. type WindowService struct {
  10. proto.UnimplementedWindowServiceServer
  11. coreAddress string
  12. verbose bool
  13. }
  14. // NewWindowService creates a new WindowService
  15. func NewWindowService(coreAddress string, verbose bool) *WindowService {
  16. return &WindowService{
  17. coreAddress: coreAddress,
  18. verbose: verbose,
  19. }
  20. }
  21. // ShowTextDocument opens a text document for viewing/editing
  22. func (s *WindowService) ShowTextDocument(ctx context.Context, req *proto.ShowTextDocumentRequest) (*proto.TextEditorInfo, error) {
  23. if s.verbose {
  24. log.Printf("ShowTextDocument called for path: %s", req.GetPath())
  25. }
  26. // For console implementation, we'll just log that we would open the document
  27. fmt.Printf("[Cline] Would open document: %s\n", req.GetPath())
  28. return &proto.TextEditorInfo{
  29. DocumentPath: req.GetPath(),
  30. IsActive: true,
  31. }, nil
  32. }
  33. // ShowOpenDialogue shows a file open dialog
  34. func (s *WindowService) ShowOpenDialogue(ctx context.Context, req *proto.ShowOpenDialogueRequest) (*proto.SelectedResources, error) {
  35. if s.verbose {
  36. log.Printf("ShowOpenDialogue called")
  37. }
  38. // For console implementation, return empty list (user cancelled)
  39. return &proto.SelectedResources{
  40. Paths: []string{},
  41. }, nil
  42. }
  43. // ShowMessage displays a message to the user
  44. func (s *WindowService) ShowMessage(ctx context.Context, req *proto.ShowMessageRequest) (*proto.SelectedResponse, error) {
  45. if s.verbose {
  46. log.Printf("ShowMessage called: %s", req.GetMessage())
  47. }
  48. // Display message to console
  49. fmt.Printf("[Cline] %s\n", req.GetMessage())
  50. return &proto.SelectedResponse{}, nil
  51. }