summaryrefslogtreecommitdiffhomepage
path: root/cmd
diff options
context:
space:
mode:
authorKujtim Hoxha <[email protected]>2025-04-16 20:06:23 +0200
committerKujtim Hoxha <[email protected]>2025-04-21 13:42:00 +0200
commitbbfa60c787f2ec459f1689b9a650ddbec9693ed9 (patch)
treef7f2aa31c460c8cc22ec40cc299c386277152241 /cmd
parent76b4065f17b87a63092acfd98c997bab53700b35 (diff)
downloadopencode-bbfa60c787f2ec459f1689b9a650ddbec9693ed9.tar.gz
opencode-bbfa60c787f2ec459f1689b9a650ddbec9693ed9.zip
reimplement agent,provider and add file history
Diffstat (limited to 'cmd')
-rw-r--r--cmd/root.go24
1 files changed, 7 insertions, 17 deletions
diff --git a/cmd/root.go b/cmd/root.go
index a2e63006f..ff71747d5 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -20,7 +20,7 @@ import (
)
var rootCmd = &cobra.Command{
- Use: "termai",
+ Use: "OpenCode",
Short: "A terminal ai assistant",
Long: `A terminal ai assistant`,
RunE: func(cmd *cobra.Command, args []string) error {
@@ -89,12 +89,9 @@ var rootCmd = &cobra.Command{
// Set up message handling for the TUI
go func() {
defer tuiWg.Done()
- defer func() {
- if r := recover(); r != nil {
- logging.Error("Panic in TUI message handling: %v", r)
- attemptTUIRecovery(program)
- }
- }()
+ defer logging.RecoverPanic("TUI-message-handler", func() {
+ attemptTUIRecovery(program)
+ })
for {
select {
@@ -153,11 +150,7 @@ func attemptTUIRecovery(program *tea.Program) {
func initMCPTools(ctx context.Context, app *app.App) {
go func() {
- defer func() {
- if r := recover(); r != nil {
- logging.Error("Panic in MCP goroutine: %v", r)
- }
- }()
+ defer logging.RecoverPanic("MCP-goroutine", nil)
// Create a context with timeout for the initial MCP tools fetch
ctxWithTimeout, cancel := context.WithTimeout(ctx, 30*time.Second)
@@ -179,11 +172,7 @@ func setupSubscriber[T any](
wg.Add(1)
go func() {
defer wg.Done()
- defer func() {
- if r := recover(); r != nil {
- logging.Error("Panic in %s subscription goroutine: %v", name, r)
- }
- }()
+ defer logging.RecoverPanic(fmt.Sprintf("subscription-%s", name), nil)
for {
select {
@@ -232,6 +221,7 @@ func setupSubscriptions(app *app.App) (chan tea.Msg, func()) {
// Wait with a timeout for all goroutines to complete
waitCh := make(chan struct{})
go func() {
+ defer logging.RecoverPanic("subscription-cleanup", nil)
wg.Wait()
close(waitCh)
}()