(block *waveobj.Block)
| 75 | } |
| 76 | |
| 77 | func MakeBlockShortDesc(block *waveobj.Block) string { |
| 78 | if block.Meta == nil { |
| 79 | return "" |
| 80 | } |
| 81 | |
| 82 | viewType, ok := block.Meta["view"].(string) |
| 83 | if !ok { |
| 84 | return "" |
| 85 | } |
| 86 | |
| 87 | switch viewType { |
| 88 | case "term": |
| 89 | return makeTerminalBlockDesc(block) |
| 90 | case "preview": |
| 91 | file, hasFile := block.Meta["file"].(string) |
| 92 | connection, hasConnection := block.Meta["connection"].(string) |
| 93 | |
| 94 | if hasConnection && connection != "" { |
| 95 | if hasFile && file != "" { |
| 96 | return fmt.Sprintf("preview widget viewing %q on %q", file, connection) |
| 97 | } |
| 98 | return fmt.Sprintf("preview widget viewing files on %q", connection) |
| 99 | } |
| 100 | if hasFile && file != "" { |
| 101 | return fmt.Sprintf("preview widget viewing %q", file) |
| 102 | } |
| 103 | return "file and directory preview widget" |
| 104 | case "web": |
| 105 | if url, hasUrl := block.Meta["url"].(string); hasUrl && url != "" { |
| 106 | return fmt.Sprintf("web browser widget pointing at %q", url) |
| 107 | } |
| 108 | return "web browser widget" |
| 109 | case "waveai": |
| 110 | return "AI chat widget" |
| 111 | case "cpuplot": |
| 112 | if connection, hasConnection := block.Meta["connection"].(string); hasConnection && connection != "" { |
| 113 | return fmt.Sprintf("cpu graph for %q", connection) |
| 114 | } |
| 115 | return "cpu graph" |
| 116 | case "tips": |
| 117 | return "Wave quick tips widget" |
| 118 | case "help": |
| 119 | return "Wave documentation widget" |
| 120 | case "launcher": |
| 121 | return "placeholder widget used to launch other widgets" |
| 122 | case "tsunami": |
| 123 | return handleTsunamiBlockDesc(block) |
| 124 | case "aifilediff": |
| 125 | return "" // AI doesn't need to see these |
| 126 | case "waveconfig": |
| 127 | if file, hasFile := block.Meta["file"].(string); hasFile && file != "" { |
| 128 | return fmt.Sprintf("wave config editor for %q", file) |
| 129 | } |
| 130 | return "wave config editor" |
| 131 | default: |
| 132 | return fmt.Sprintf("unknown widget with type %q", viewType) |
| 133 | } |
| 134 | } |
no test coverage detected