@@ -69,13 +69,13 @@ type permissionDialogCmp struct {
69func formatDiff(diffText string) string {
69func formatDiff(diffText string) string {
70 lines := strings.Split(diffText, "\n")
70 lines := strings.Split(diffText, "\n")
71 var formattedLines []string
71 var formattedLines []string
73 // Define styles for different line types
73 // Define styles for different line types
74 addStyle := lipgloss.NewStyle().Foreground(styles.Green)
74 addStyle := lipgloss.NewStyle().Foreground(styles.Green)
75 removeStyle := lipgloss.NewStyle().Foreground(styles.Red)
75 removeStyle := lipgloss.NewStyle().Foreground(styles.Red)
76 headerStyle := lipgloss.NewStyle().Bold(true).Foreground(styles.Blue)
76 headerStyle := lipgloss.NewStyle().Bold(true).Foreground(styles.Blue)
77 contextStyle := lipgloss.NewStyle().Foreground(styles.SubText0)
77 contextStyle := lipgloss.NewStyle().Foreground(styles.SubText0)
79 // Process each line
79 // Process each line
80 for _, line := range lines {
80 for _, line := range lines {
81 if strings.HasPrefix(line, "+") {
81 if strings.HasPrefix(line, "+") {
@@ -90,7 +90,7 @@ func formatDiff(diffText string) string {
90 formattedLines = append(formattedLines, line)
90 formattedLines = append(formattedLines, line)
94 // Join all formatted lines
94 // Join all formatted lines
95 return strings.Join(formattedLines, "\n")
95 return strings.Join(formattedLines, "\n")
@@ -112,13 +112,13 @@ func (p *permissionDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
112 p.selectOption.Blur()
112 p.selectOption.Blur()
113 // Add a visual indicator for focus change
113 // Add a visual indicator for focus change
114 cmds = append(cmds, tea.Batch(
114 cmds = append(cmds, tea.Batch(
115− util.CmdHandler(util.InfoMsg("Viewing content - use arrow keys to scroll")),
115+ util.ReportInfo("Viewing content - use arrow keys to scroll"),
118 p.selectOption.Focus()
118 p.selectOption.Focus()
119 // Add a visual indicator for focus change
119 // Add a visual indicator for focus change
120 cmds = append(cmds, tea.Batch(
120 cmds = append(cmds, tea.Batch(
121− util.CmdHandler(util.InfoMsg("Select an action")),
121+ util.CmdHandler(util.ReportInfo("Select an action")),
124 return p, tea.Batch(cmds...)
124 return p, tea.Batch(cmds...)
@@ -162,44 +162,44 @@ func (p *permissionDialogCmp) render() string {
162 lipgloss.JoinHorizontal(lipgloss.Left, keyStyle.Render("Path:"), " ", valueStyle.Render(p.permission.Path)),
162 lipgloss.JoinHorizontal(lipgloss.Left, keyStyle.Render("Path:"), " ", valueStyle.Render(p.permission.Path)),
166 // Create the header content first so it can be used in all cases
166 // Create the header content first so it can be used in all cases
167 headerContent := lipgloss.NewStyle().Padding(0, 1).Render(lipgloss.JoinVertical(lipgloss.Left, headerParts...))
167 headerContent := lipgloss.NewStyle().Padding(0, 1).Render(lipgloss.JoinVertical(lipgloss.Left, headerParts...))
169 r, _ := glamour.NewTermRenderer(
169 r, _ := glamour.NewTermRenderer(
170 glamour.WithStyles(styles.CatppuccinMarkdownStyle()),
170 glamour.WithStyles(styles.CatppuccinMarkdownStyle()),
171 glamour.WithWordWrap(p.width-10),
171 glamour.WithWordWrap(p.width-10),
172 glamour.WithEmoji(),
172 glamour.WithEmoji(),
175 // Handle different tool types
175 // Handle different tool types
176 switch p.permission.ToolName {
176 switch p.permission.ToolName {
177 case tools.BashToolName:
177 case tools.BashToolName:
178 pr := p.permission.Params.(tools.BashPermissionsParams)
178 pr := p.permission.Params.(tools.BashPermissionsParams)
179 headerParts = append(headerParts, keyStyle.Render("Command:"))
179 headerParts = append(headerParts, keyStyle.Render("Command:"))
180 content := fmt.Sprintf("```bash\n%s\n```", pr.Command)
180 content := fmt.Sprintf("```bash\n%s\n```", pr.Command)
182 renderedContent, _ := r.Render(content)
182 renderedContent, _ := r.Render(content)
183 p.contentViewPort.Width = p.width - 2 - 2
183 p.contentViewPort.Width = p.width - 2 - 2
185 // Calculate content height dynamically based on content
185 // Calculate content height dynamically based on content
186 contentLines := len(strings.Split(renderedContent, "\n"))
186 contentLines := len(strings.Split(renderedContent, "\n"))
187 // Set a reasonable min/max for the viewport height
187 // Set a reasonable min/max for the viewport height
188 minContentHeight := 3
188 minContentHeight := 3
189 maxContentHeight := p.height - lipgloss.Height(headerContent) - lipgloss.Height(form) - 2 - 2 - 1
189 maxContentHeight := p.height - lipgloss.Height(headerContent) - lipgloss.Height(form) - 2 - 2 - 1
191 // Add some padding to the content lines
191 // Add some padding to the content lines
192 contentHeight := contentLines + 2
192 contentHeight := contentLines + 2
193 contentHeight = max(contentHeight, minContentHeight)
193 contentHeight = max(contentHeight, minContentHeight)
194 contentHeight = min(contentHeight, maxContentHeight)
194 contentHeight = min(contentHeight, maxContentHeight)
195 p.contentViewPort.Height = contentHeight
195 p.contentViewPort.Height = contentHeight
197 p.contentViewPort.SetContent(renderedContent)
197 p.contentViewPort.SetContent(renderedContent)
199 // Style the viewport
199 // Style the viewport
200 var contentBorder lipgloss.Border
200 var contentBorder lipgloss.Border
201 var borderColor lipgloss.TerminalColor
201 var borderColor lipgloss.TerminalColor
203 if p.isViewportFocus {
203 if p.isViewportFocus {
204 contentBorder = lipgloss.DoubleBorder()
204 contentBorder = lipgloss.DoubleBorder()
205 borderColor = styles.Blue
205 borderColor = styles.Blue
@@ -207,47 +207,47 @@ func (p *permissionDialogCmp) render() string {
207 contentBorder = lipgloss.RoundedBorder()
207 contentBorder = lipgloss.RoundedBorder()
208 borderColor = styles.Flamingo
208 borderColor = styles.Flamingo
211 contentStyle := lipgloss.NewStyle().
211 contentStyle := lipgloss.NewStyle().
212 MarginTop(1).
212 MarginTop(1).
213 Padding(0, 1).
213 Padding(0, 1).
214 Border(contentBorder).
214 Border(contentBorder).
215 BorderForeground(borderColor)
215 BorderForeground(borderColor)
217 if p.isViewportFocus {
217 if p.isViewportFocus {
218 contentStyle = contentStyle.BorderBackground(styles.Surface0)
218 contentStyle = contentStyle.BorderBackground(styles.Surface0)
221 contentFinal := contentStyle.Render(p.contentViewPort.View())
221 contentFinal := contentStyle.Render(p.contentViewPort.View())
223 return lipgloss.JoinVertical(
223 return lipgloss.JoinVertical(
224 lipgloss.Top,
224 lipgloss.Top,
225 headerContent,
225 headerContent,
226 contentFinal,
226 contentFinal,
230 case tools.EditToolName:
230 case tools.EditToolName:
231 pr := p.permission.Params.(tools.EditPermissionsParams)
231 pr := p.permission.Params.(tools.EditPermissionsParams)
232 headerParts = append(headerParts, keyStyle.Render("Update"))
232 headerParts = append(headerParts, keyStyle.Render("Update"))
233 // Recreate header content with the updated headerParts
233 // Recreate header content with the updated headerParts
234 headerContent = lipgloss.NewStyle().Padding(0, 1).Render(lipgloss.JoinVertical(lipgloss.Left, headerParts...))
234 headerContent = lipgloss.NewStyle().Padding(0, 1).Render(lipgloss.JoinVertical(lipgloss.Left, headerParts...))
236 // Format the diff with colors
236 // Format the diff with colors
237 formattedDiff := formatDiff(pr.Diff)
237 formattedDiff := formatDiff(pr.Diff)
239 // Set up viewport for the diff content
239 // Set up viewport for the diff content
240 p.contentViewPort.Width = p.width - 2 - 2
240 p.contentViewPort.Width = p.width - 2 - 2
242 // Calculate content height dynamically based on window size
242 // Calculate content height dynamically based on window size
243 maxContentHeight := p.height - lipgloss.Height(headerContent) - lipgloss.Height(form) - 2 - 2 - 1
243 maxContentHeight := p.height - lipgloss.Height(headerContent) - lipgloss.Height(form) - 2 - 2 - 1
244 p.contentViewPort.Height = maxContentHeight
244 p.contentViewPort.Height = maxContentHeight
245 p.contentViewPort.SetContent(formattedDiff)
245 p.contentViewPort.SetContent(formattedDiff)
247 // Style the viewport
247 // Style the viewport
248 var contentBorder lipgloss.Border
248 var contentBorder lipgloss.Border
249 var borderColor lipgloss.TerminalColor
249 var borderColor lipgloss.TerminalColor
251 if p.isViewportFocus {
251 if p.isViewportFocus {
252 contentBorder = lipgloss.DoubleBorder()
252 contentBorder = lipgloss.DoubleBorder()
253 borderColor = styles.Blue
253 borderColor = styles.Blue
@@ -255,47 +255,47 @@ func (p *permissionDialogCmp) render() string {
255 contentBorder = lipgloss.RoundedBorder()
255 contentBorder = lipgloss.RoundedBorder()
256 borderColor = styles.Flamingo
256 borderColor = styles.Flamingo
259 contentStyle := lipgloss.NewStyle().
259 contentStyle := lipgloss.NewStyle().
260 MarginTop(1).
260 MarginTop(1).
261 Padding(0, 1).
261 Padding(0, 1).
262 Border(contentBorder).
262 Border(contentBorder).
263 BorderForeground(borderColor)
263 BorderForeground(borderColor)
265 if p.isViewportFocus {
265 if p.isViewportFocus {
266 contentStyle = contentStyle.BorderBackground(styles.Surface0)
266 contentStyle = contentStyle.BorderBackground(styles.Surface0)
269 contentFinal := contentStyle.Render(p.contentViewPort.View())
269 contentFinal := contentStyle.Render(p.contentViewPort.View())
271 return lipgloss.JoinVertical(
271 return lipgloss.JoinVertical(
272 lipgloss.Top,
272 lipgloss.Top,
273 headerContent,
273 headerContent,
274 contentFinal,
274 contentFinal,
278 case tools.WriteToolName:
278 case tools.WriteToolName:
279 pr := p.permission.Params.(tools.WritePermissionsParams)
279 pr := p.permission.Params.(tools.WritePermissionsParams)
280 headerParts = append(headerParts, keyStyle.Render("Content"))
280 headerParts = append(headerParts, keyStyle.Render("Content"))
281 // Recreate header content with the updated headerParts
281 // Recreate header content with the updated headerParts
282 headerContent = lipgloss.NewStyle().Padding(0, 1).Render(lipgloss.JoinVertical(lipgloss.Left, headerParts...))
282 headerContent = lipgloss.NewStyle().Padding(0, 1).Render(lipgloss.JoinVertical(lipgloss.Left, headerParts...))
284 // Format the diff with colors
284 // Format the diff with colors
285 formattedDiff := formatDiff(pr.Content)
285 formattedDiff := formatDiff(pr.Content)
287 // Set up viewport for the content
287 // Set up viewport for the content
288 p.contentViewPort.Width = p.width - 2 - 2
288 p.contentViewPort.Width = p.width - 2 - 2
290 // Calculate content height dynamically based on window size
290 // Calculate content height dynamically based on window size
291 maxContentHeight := p.height - lipgloss.Height(headerContent) - lipgloss.Height(form) - 2 - 2 - 1
291 maxContentHeight := p.height - lipgloss.Height(headerContent) - lipgloss.Height(form) - 2 - 2 - 1
292 p.contentViewPort.Height = maxContentHeight
292 p.contentViewPort.Height = maxContentHeight
293 p.contentViewPort.SetContent(formattedDiff)
293 p.contentViewPort.SetContent(formattedDiff)
295 // Style the viewport
295 // Style the viewport
296 var contentBorder lipgloss.Border
296 var contentBorder lipgloss.Border
297 var borderColor lipgloss.TerminalColor
297 var borderColor lipgloss.TerminalColor
299 if p.isViewportFocus {
299 if p.isViewportFocus {
300 contentBorder = lipgloss.DoubleBorder()
300 contentBorder = lipgloss.DoubleBorder()
301 borderColor = styles.Blue
301 borderColor = styles.Blue
@@ -303,75 +303,75 @@ func (p *permissionDialogCmp) render() string {
303 contentBorder = lipgloss.RoundedBorder()
303 contentBorder = lipgloss.RoundedBorder()
304 borderColor = styles.Flamingo
304 borderColor = styles.Flamingo
307 contentStyle := lipgloss.NewStyle().
307 contentStyle := lipgloss.NewStyle().
308 MarginTop(1).
308 MarginTop(1).
309 Padding(0, 1).
309 Padding(0, 1).
310 Border(contentBorder).
310 Border(contentBorder).
311 BorderForeground(borderColor)
311 BorderForeground(borderColor)
313 if p.isViewportFocus {
313 if p.isViewportFocus {
314 contentStyle = contentStyle.BorderBackground(styles.Surface0)
314 contentStyle = contentStyle.BorderBackground(styles.Surface0)
317 contentFinal := contentStyle.Render(p.contentViewPort.View())
317 contentFinal := contentStyle.Render(p.contentViewPort.View())
319 return lipgloss.JoinVertical(
319 return lipgloss.JoinVertical(
320 lipgloss.Top,
320 lipgloss.Top,
321 headerContent,
321 headerContent,
322 contentFinal,
322 contentFinal,
326 case tools.FetchToolName:
326 case tools.FetchToolName:
327 pr := p.permission.Params.(tools.FetchPermissionsParams)
327 pr := p.permission.Params.(tools.FetchPermissionsParams)
328 headerParts = append(headerParts, keyStyle.Render("URL: "+pr.URL))
328 headerParts = append(headerParts, keyStyle.Render("URL: "+pr.URL))
329 content := p.permission.Description
329 content := p.permission.Description
331 renderedContent, _ := r.Render(content)
331 renderedContent, _ := r.Render(content)
332 p.contentViewPort.Width = p.width - 2 - 2
332 p.contentViewPort.Width = p.width - 2 - 2
333 p.contentViewPort.Height = p.height - lipgloss.Height(headerContent) - lipgloss.Height(form) - 2 - 2 - 1
333 p.contentViewPort.Height = p.height - lipgloss.Height(headerContent) - lipgloss.Height(form) - 2 - 2 - 1
334 p.contentViewPort.SetContent(renderedContent)
334 p.contentViewPort.SetContent(renderedContent)
336 // Style the viewport
336 // Style the viewport
337 contentStyle := lipgloss.NewStyle().
337 contentStyle := lipgloss.NewStyle().
338 MarginTop(1).
338 MarginTop(1).
339 Padding(0, 1).
339 Padding(0, 1).
340 Border(lipgloss.RoundedBorder()).
340 Border(lipgloss.RoundedBorder()).
341 BorderForeground(styles.Flamingo)
341 BorderForeground(styles.Flamingo)
343 contentFinal := contentStyle.Render(p.contentViewPort.View())
343 contentFinal := contentStyle.Render(p.contentViewPort.View())
344 if renderedContent == "" {
344 if renderedContent == "" {
345 contentFinal = ""
345 contentFinal = ""
348 return lipgloss.JoinVertical(
348 return lipgloss.JoinVertical(
349 lipgloss.Top,
349 lipgloss.Top,
350 headerContent,
350 headerContent,
351 contentFinal,
351 contentFinal,
356 content := p.permission.Description
356 content := p.permission.Description
358 renderedContent, _ := r.Render(content)
358 renderedContent, _ := r.Render(content)
359 p.contentViewPort.Width = p.width - 2 - 2
359 p.contentViewPort.Width = p.width - 2 - 2
360 p.contentViewPort.Height = p.height - lipgloss.Height(headerContent) - lipgloss.Height(form) - 2 - 2 - 1
360 p.contentViewPort.Height = p.height - lipgloss.Height(headerContent) - lipgloss.Height(form) - 2 - 2 - 1
361 p.contentViewPort.SetContent(renderedContent)
361 p.contentViewPort.SetContent(renderedContent)
363 // Style the viewport
363 // Style the viewport
364 contentStyle := lipgloss.NewStyle().
364 contentStyle := lipgloss.NewStyle().
365 MarginTop(1).
365 MarginTop(1).
366 Padding(0, 1).
366 Padding(0, 1).
367 Border(lipgloss.RoundedBorder()).
367 Border(lipgloss.RoundedBorder()).
368 BorderForeground(styles.Flamingo)
368 BorderForeground(styles.Flamingo)
370 contentFinal := contentStyle.Render(p.contentViewPort.View())
370 contentFinal := contentStyle.Render(p.contentViewPort.View())
371 if renderedContent == "" {
371 if renderedContent == "" {
372 contentFinal = ""
372 contentFinal = ""
375 return lipgloss.JoinVertical(
375 return lipgloss.JoinVertical(
376 lipgloss.Top,
376 lipgloss.Top,
377 headerContent,
377 headerContent,