← back to kyawgyi13122-ship-it__launchpad

Function bodies 1,118 total

All specs Real LLM only Function bodies
main function · go · L21-L107 (87 LOC)
cmd/indexer-monitor/main.go
func main() {
	// Parse command-line flags
	interval := flag.Duration("interval", 30*time.Second, "How often to poll for send transactions")
	flag.Parse()

	// Load configuration
	cfg := config.LoadConfig()

	// Initialize logger
	logger := initLogger(cfg)
	defer logger.Sync()

	logger.Info("starting indexer monitor",
		zap.Duration("interval", *interval),
		zap.String("environment", cfg.Environment),
	)

	// Connect to PostgreSQL
	db, err := database.Connect(cfg.DatabaseURL)
	if err != nil {
		logger.Fatal("failed to connect to database", zap.Error(err))
	}
	defer db.Close()

	// Initialize context
	ctx := context.Background()

	// Initialize indexer repository (ClickHouse)
	indexerRepo, err := clickhouse.NewIndexerRepository(ctx, logger)
	if err != nil {
		logger.Fatal("failed to initialize indexer repository", zap.Error(err))
	}
	defer indexerRepo.Close()

	// Initialize PostgreSQL repositories
	userRepo := postgres.NewUserRepository(db)
	templateRepo := postgres.NewChainTemplateRep
initLogger function · go · L109-L124 (16 LOC)
cmd/indexer-monitor/main.go
func initLogger(cfg *config.Config) *zap.Logger {
	var logger *zap.Logger
	var err error

	if cfg.Environment == "production" {
		logger, err = zap.NewProduction()
	} else {
		logger, err = zap.NewDevelopment()
	}

	if err != nil {
		panic(fmt.Sprintf("failed to initialize logger: %v", err))
	}

	return logger
}
NewWorker function · go · L54-L73 (20 LOC)
cmd/indexer-monitor/worker.go
func NewWorker(
	logger *zap.Logger,
	indexerRepo TransactionReader,
	poolRepo DepositPoolLister,
	userRepo UserByWalletLookup,
	orderProcessor *virtualpool.OrderService,
	interval time.Duration,
) *Worker {
	return &Worker{
		logger:         logger,
		indexerRepo:    indexerRepo,
		poolRepo:       poolRepo,
		userRepo:       userRepo,
		orderProcessor: orderProcessor,
		interval:       interval,
		lastHeight:     0, // Start from beginning (will fetch current height on first run)
		stopChan:       make(chan struct{}),
		done:           make(chan struct{}),
	}
}
Start method · go · L76-L84 (9 LOC)
cmd/indexer-monitor/worker.go
func (w *Worker) Start() error {
	w.logger.Info("starting indexer monitor worker",
		zap.Duration("interval", w.interval),
		zap.Uint64("root_chain_id", rootChainID),
	)

	go w.run()
	return nil
}
Stop method · go · L87-L100 (14 LOC)
cmd/indexer-monitor/worker.go
func (w *Worker) Stop() error {
	w.logger.Info("stopping indexer monitor worker")
	close(w.stopChan)

	// Wait for worker to finish or timeout
	select {
	case <-w.done:
		w.logger.Info("worker stopped gracefully")
		return nil
	case <-time.After(10 * time.Second):
		w.logger.Warn("worker stop timeout exceeded")
		return nil
	}
}
run method · go · L103-L127 (25 LOC)
cmd/indexer-monitor/worker.go
func (w *Worker) run() {
	defer close(w.done)

	// Run immediately on startup
	w.logger.Info("running initial transaction poll")
	if err := w.pollTransactions(context.Background()); err != nil {
		w.logger.Error("initial poll failed", zap.Error(err))
	}

	ticker := time.NewTicker(w.interval)
	defer ticker.Stop()

	for {
		select {
		case <-ticker.C:
			w.logger.Debug("running scheduled transaction poll")
			if err := w.pollTransactions(context.Background()); err != nil {
				w.logger.Error("poll failed", zap.Error(err))
			}
		case <-w.stopChan:
			w.logger.Info("received stop signal, exiting")
			return
		}
	}
}
pollTransactions method · go · L130-L252 (123 LOC)
cmd/indexer-monitor/worker.go
func (w *Worker) pollTransactions(ctx context.Context) error {
	// Get active pools with deposit addresses
	depositPools, err := w.poolRepo.GetActivePoolsByDepositAddress(ctx)
	if err != nil {
		return err
	}

	if len(depositPools) == 0 {
		w.logger.Debug("no active pools with deposit addresses found")
		return nil
	}

	w.logger.Debug("loaded deposit pools",
		zap.Int("pool_count", len(depositPools)),
	)

	// Query transactions from indexer, starting from last processed height
	var cursor *uint64
	if w.lastHeight > 0 {
		cursor = &w.lastHeight
	}

	msgType := sendMessageType
	transactions, pageResp, err := w.indexerRepo.ListTransactions(
		ctx,
		rootChainID,
		cursor,
		transactionLimit,
		"asc", // Sort ascending to process in order
		&msgType,
	)
	if err != nil {
		return err
	}

	if len(transactions) == 0 {
		w.logger.Debug("no new send transactions found")
		return nil
	}

	w.logger.Info("processing send transactions",
		zap.Int("tx_count", len(transactions)),
		zap.Uint64("from_h
If a scraper extracted this row, it came from Repobility (https://repobility.com)
processDeposit method · go · L255-L270 (16 LOC)
cmd/indexer-monitor/worker.go
func (w *Worker) processDeposit(ctx context.Context, tx *indexer.Transaction, pool *models.VirtualPool, user *models.User) error {
	if tx.Amount == nil || *tx.Amount == 0 {
		return nil // Skip zero-amount transactions
	}

	// Create a buy order (same pattern as volume-gen)
	// BuyerReceiveAddress contains the user ID as bytes
	order := &lib.SellOrder{
		AmountForSale:       *tx.Amount,               // CNPY being spent
		RequestedAmount:     1,                        // Must be > 0 to indicate buy
		BuyerReceiveAddress: []byte(user.ID.String()), // User ID as bytes
	}

	// Process the order with the transaction timestamp
	return w.orderProcessor.ProcessOrder(ctx, order, pool.ChainID, &tx.Time)
}
main function · go · L14-L56 (43 LOC)
cmd/server/main.go
func main() {
	// Load configuration
	cfg, err := config.Load()
	if err != nil {
		log.Fatalf("Failed to load configuration: %v", err)
	}

	// Initialize database connection
	db, err := database.Connect(cfg.DatabaseURL)
	if err != nil {
		log.Fatalf("Failed to connect to database: %v", err)
	}
	defer db.Close()

	// Initialize repositories
	userRepo := postgres.NewUserRepository(db)
	templateRepo := postgres.NewChainTemplateRepository(db)
	chainRepo := postgres.NewChainRepository(db, userRepo, templateRepo)
	virtualPoolRepo := postgres.NewVirtualPoolRepository(db)

	// Initialize services
	chainService := chainsvc.New(chainRepo, templateRepo, virtualPoolRepo, nil, nil)

	// Create services container
	services := &server.Services{
		ChainService: chainService,
	}

	// Initialize logger
	logger, err := zap.NewDevelopment()
	if err != nil {
		log.Fatalf("Failed to initialize logger: %v", err)
	}
	defer logger.Sync()

	// Create and start server
	srv := server.NewServer(cfg, services, logg
main function · go · L12-L84 (73 LOC)
cmd/test-discord/main.go
func main() {
	// Initialize logger
	logger, err := zap.NewDevelopment()
	if err != nil {
		panic(err)
	}
	defer logger.Sync()

	// Load configuration
	cfg, err := config.Load()
	if err != nil {
		logger.Fatal("Failed to load config", zap.Error(err))
	}

	// Create Discord client
	discordClient := discord.NewClient(cfg.DiscordWebhookURL, logger)
	if discordClient == nil {
		logger.Fatal("Discord webhook URL not configured")
	}

	ctx := context.Background()

	// Test 1: Send a chain event notification
	logger.Info("Sending chain event notification...")
	discordClient.SendChainEvent(
		ctx,
		"chain-test-123",
		"Test Chain",
		"active",
		"Test chain has been activated successfully! This is a test notification from the Discord webhook package.",
		discord.ColorSuccess,
	)

	// Wait a bit between messages to avoid rate limits
	time.Sleep(2 * time.Second)

	// Test 2: Send a pool progress notification
	logger.Info("Sending pool progress notification...")
	discordClient.SendPoolProgress(
	
GetEndpointsByCategory function · go · L494-L503 (10 LOC)
cmd/tui/endpoints.go
func GetEndpointsByCategory(category EndpointCategory) []Endpoint {
	all := GetAllEndpoints()
	var filtered []Endpoint
	for _, ep := range all {
		if ep.Category == category {
			filtered = append(filtered, ep)
		}
	}
	return filtered
}
GetCategories function · go · L506-L518 (13 LOC)
cmd/tui/endpoints.go
func GetCategories() []EndpointCategory {
	return []EndpointCategory{
		CategoryHealth,
		CategoryAuth,
		CategoryTemplates,
		CategoryChains,
		CategoryVirtualPool,
		CategoryWallets,
		CategoryPortfolio,
		CategoryTransactions,
		CategoryAMM,
	}
}
ExecuteRequest function · go · L521-L636 (116 LOC)
cmd/tui/endpoints.go
func ExecuteRequest(baseURL string, endpoint Endpoint, pathParamValues map[string]string, requestBody string, queryParams map[string]string, sessionID string) RequestResult {
	startTime := time.Now()
	result := RequestResult{
		RequestTime:  startTime,
		Method:       endpoint.Method,
		EndpointName: endpoint.Name,
		RequestBody:  requestBody,
	}

	// Build URL with path parameters
	url := baseURL + endpoint.Path
	for paramName, paramValue := range pathParamValues {
		url = replacePathParam(url, paramName, paramValue)
	}

	// Add query parameters
	if len(queryParams) > 0 {
		url += "?"
		first := true
		for key, value := range queryParams {
			if value == "" {
				continue
			}
			if !first {
				url += "&"
			}
			url += key + "=" + value
			first = false
		}
	}

	result.RequestURL = url

	// Create request body reader
	var bodyReader io.Reader
	if requestBody != "" {
		bodyReader = bytes.NewBufferString(requestBody)
	}

	// Create HTTP request
	req, err := http.NewRequest(string(endp
replacePathParam function · go · L639-L642 (4 LOC)
cmd/tui/endpoints.go
func replacePathParam(path, paramName, value string) string {
	placeholder := fmt.Sprintf("{%s}", paramName)
	return strings.ReplaceAll(path, placeholder, value)
}
getFirstChainID function · go · L645-L651 (7 LOC)
cmd/tui/endpoints.go
func getFirstChainID(m *Model) string {
	// Use cached chains from background fetch
	if len(m.cachedChains) > 0 {
		return m.cachedChains[0].ID
	}
	return ""
}
Same scanner, your repo: https://repobility.com — Repobility
findEndpointByName function · go · L654-L661 (8 LOC)
cmd/tui/endpoints.go
func findEndpointByName(name string, endpoints []Endpoint) Endpoint {
	for _, ep := range endpoints {
		if ep.Name == name {
			return ep
		}
	}
	return Endpoint{}
}
main function · go · L10-L22 (13 LOC)
cmd/tui/main.go
func main() {
	// Create initial model
	m := Initialize()

	// Create program with alternate screen
	p := tea.NewProgram(m, tea.WithAltScreen())

	// Run the program
	if _, err := p.Run(); err != nil {
		fmt.Printf("Error running TUI: %v\n", err)
		os.Exit(1)
	}
}
parseMakefileCommands function · go · L170-L197 (28 LOC)
cmd/tui/model.go
func parseMakefileCommands(makefilePath string) []MakeCommand {
	data, err := os.ReadFile(makefilePath)
	if err != nil {
		return []MakeCommand{{Name: "error", Desc: "Could not read Makefile"}}
	}

	var commands []MakeCommand
	lines := strings.Split(string(data), "\n")

	for _, line := range lines {
		// Look for lines with format: target: ## description
		if strings.Contains(line, ":") && strings.Contains(line, "##") {
			parts := strings.Split(line, "##")
			if len(parts) == 2 {
				targetPart := strings.TrimSpace(strings.Split(parts[0], ":")[0])
				description := strings.TrimSpace(parts[1])
				if targetPart != "" && !strings.HasPrefix(targetPart, ".") {
					commands = append(commands, MakeCommand{
						Name: targetPart,
						Desc: description,
					})
				}
			}
		}
	}

	return commands
}
Init method · go · L280-L287 (8 LOC)
cmd/tui/model.go
func (m Model) Init() tea.Cmd {
	// Start background data fetching and prepare first endpoint
	return tea.Batch(
		m.prepareRequestBuilder(),
		m.fetchBackgroundData(), // Initial fetch
		tickCmd(),               // Start periodic updates
	)
}
tickCmd function · go · L290-L294 (5 LOC)
cmd/tui/model.go
func tickCmd() tea.Cmd {
	return tea.Tick(30*time.Second, func(t time.Time) tea.Msg {
		return tickMsg(t)
	})
}
Update method · go · L297-L589 (293 LOC)
cmd/tui/model.go
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
	var cmds []tea.Cmd

	switch msg := msg.(type) {
	case tea.KeyMsg:
		// Handle modal first - any key closes it
		if m.currentScreen == ScreenStatsModal {
			m.currentScreen = m.previousScreen
			return m, nil
		}

		switch msg.String() {
		case "ctrl+c":
			// ctrl+c always quits
			return m, tea.Quit

		case "q":
			// q quits from main screens, goes back from others
			if m.currentScreen == ScreenEndpointList || m.currentScreen == ScreenMakeCommands {
				return m, tea.Quit
			}
			// Go back to previous screen on other screens
			m = m.goBack()
			return m, nil

		case "esc":
			// If in search mode, exit search mode
			if m.currentScreen == ScreenEndpointList && m.searchMode {
				m.searchMode = false
				m.searchBuffer = ""
				return m, nil
			}
			m = m.goBack()
			return m, nil

		case "enter":
			// If in search mode, exit search mode
			if m.currentScreen == ScreenEndpointList && m.searchMode {
				m.searchMode = false
View method · go · L592-L635 (44 LOC)
cmd/tui/model.go
func (m Model) View() string {
	var content string
	switch m.currentScreen {
	case ScreenEndpointList, ScreenRequestBuilder:
		// Always show split view with endpoint list and request/response panels
		content = renderSplitView(m)
	case ScreenHistory:
		content = renderHistory(m)
	case ScreenSettings:
		content = renderSettings(m)
	case ScreenMakeCommands:
		content = renderMakeScreen(m)
	case ScreenStatsModal:
		// Render previous screen in background, then overlay modal
		var bgContent string
		switch m.previousScreen {
		case ScreenMakeCommands:
			bgContent = renderMakeScreen(m)
		default:
			bgContent = renderSplitView(m)
		}
		content = renderStatsModal(m, bgContent)
	default:
		content = renderSplitView(m)
	}

	// Global keyboard shortcuts help line at bottom
	globalHelp := renderGlobalHelp(m.width)

	// Combine content with global help line
	mainContent := content
	if m.height > 1 {
		// Reserve one line for global help
		mainContentHeight := m.height - 1
		mainContent = lipglo
handleEnter method · go · L638-L660 (23 LOC)
cmd/tui/model.go
func (m Model) handleEnter() (Model, tea.Cmd) {
	switch m.currentScreen {
	case ScreenEndpointList:
		// Sync all inputs before executing
		m.syncAllInputs()
		// Execute the request with default/current values
		return m, m.executeRequest()

	case ScreenRequestBuilder:
		// Sync all inputs before executing
		m.syncAllInputs()
		// Execute the request
		return m, m.executeRequest()

	case ScreenMakeCommands:
		// Execute the selected make command
		if m.selectedMakeCommand.Name != "" {
			return m, m.executeMakeCommand()
		}
	}

	return m, nil
}
Repobility's GitHub App fixes findings like these · https://github.com/apps/repobility-bot
executeMakeCommand method · go · L663-L687 (25 LOC)
cmd/tui/model.go
func (m Model) executeMakeCommand() tea.Cmd {
	if m.selectedMakeCommand.Name == "" {
		return nil
	}

	commandName := m.selectedMakeCommand.Name

	return func() tea.Msg {
		// Run the make command and capture output
		// Command runs from current directory (launchpad root)
		cmd := exec.Command("make", commandName)
		output, err := cmd.CombinedOutput()

		result := string(output)
		if err != nil {
			result = fmt.Sprintf("Error executing 'make %s':\n%s\n\nOutput:\n%s",
				commandName, err.Error(), string(output))
		}

		return makeCommandResult{
			command: commandName,
			output:  result,
		}
	}
}
fetchBackgroundData method · go · L703-L708 (6 LOC)
cmd/tui/model.go
func (m Model) fetchBackgroundData() tea.Cmd {
	return tea.Batch(
		m.fetchChains(),
		m.fetchTemplates(),
	)
}
fetchChains method · go · L711-L726 (16 LOC)
cmd/tui/model.go
func (m Model) fetchChains() tea.Cmd {
	return func() tea.Msg {
		chainsReq, _ := http.NewRequest("GET", m.baseURL+"/api/v1/chains", nil)
		chainsResp, err := http.DefaultClient.Do(chainsReq)
		if err == nil {
			defer chainsResp.Body.Close()
			var data struct {
				Data []CachedChain `json:"data"`
			}
			if err := json.NewDecoder(chainsResp.Body).Decode(&data); err == nil {
				return chainsUpdatedMsg{chains: data.Data}
			}
		}
		return nil
	}
}
fetchTemplates method · go · L729-L743 (15 LOC)
cmd/tui/model.go
func (m Model) fetchTemplates() tea.Cmd {
	return func() tea.Msg {
		templatesResp, err := http.Get(m.baseURL + "/api/v1/templates")
		if err == nil {
			defer templatesResp.Body.Close()
			var data struct {
				Data []CachedTemplate `json:"data"`
			}
			if err := json.NewDecoder(templatesResp.Body).Decode(&data); err == nil {
				return templatesUpdatedMsg{templates: data.Data}
			}
		}
		return nil
	}
}
fetchStats method · go · L746-L781 (36 LOC)
cmd/tui/model.go
func (m Model) fetchStats() tea.Cmd {
	return func() tea.Msg {
		var result statsResult

		// Fetch templates count
		templatesResp, err := http.Get(m.baseURL + "/api/v1/templates")
		if err == nil {
			defer templatesResp.Body.Close()
			var data struct {
				Data []interface{} `json:"data"`
			}
			if err := json.NewDecoder(templatesResp.Body).Decode(&data); err == nil {
				result.templateCount = len(data.Data)
			}
		}

		// Fetch chains count
		chainsReq, _ := http.NewRequest("GET", m.baseURL+"/api/v1/chains", nil)
		chainsResp, err := http.DefaultClient.Do(chainsReq)
		if err == nil {
			defer chainsResp.Body.Close()
			var data struct {
				Data []interface{} `json:"data"`
			}
			if err := json.NewDecoder(chainsResp.Body).Decode(&data); err == nil {
				result.chainCount = len(data.Data)
			}
		}

		if err != nil {
			result.err = err
		}

		return result
	}
}
saveCurrentEndpointState method · go · L784-L811 (28 LOC)
cmd/tui/model.go
func (m *Model) saveCurrentEndpointState() {
	if m.selectedEndpoint.Name == "" {
		return
	}

	// Deep copy the input maps to preserve state
	pathCopy := make(map[string]textinput.Model)
	for k, v := range m.pathParamInputs {
		pathCopy[k] = v
	}

	queryCopy := make(map[string]textinput.Model)
	for k, v := range m.queryParamInputs {
		queryCopy[k] = v
	}

	bodyCopy := make(map[string]textinput.Model)
	for k, v := range m.bodyFieldInputs {
		bodyCopy[k] = v
	}

	m.endpointStates[m.selectedEndpoint.Name] = &EndpointState{
		pathParamInputs:  pathCopy,
		queryParamInputs: queryCopy,
		bodyFieldInputs:  bodyCopy,
		response:         m.currentResult,
	}
}
prepareRequestBuilder method · go · L814-L936 (123 LOC)
cmd/tui/model.go
func (m *Model) prepareRequestBuilder() tea.Cmd {
	// Check if we have saved state for this endpoint
	if state, exists := m.endpointStates[m.selectedEndpoint.Name]; exists {
		// Restore saved state
		m.pathParamInputs = state.pathParamInputs
		m.queryParamInputs = state.queryParamInputs
		m.bodyFieldInputs = state.bodyFieldInputs
		m.currentResult = state.response
		if m.currentResult != nil {
			m.responseViewport.SetContent(formatResponseBody(m.currentResult))
		}

		// Override with authState values for "Verify Email Code" endpoint
		if m.selectedEndpoint.Name == "Verify Email Code" {
			if emailInput, ok := m.bodyFieldInputs["email"]; ok && m.authState.email != "" {
				emailInput.SetValue(m.authState.email)
				m.bodyFieldInputs["email"] = emailInput
			}
			if codeInput, ok := m.bodyFieldInputs["code"]; ok && m.authState.code != "" {
				codeInput.SetValue(m.authState.code)
				m.bodyFieldInputs["code"] = codeInput
			}
		}

		// Rebuild allInputs array from saved inputs
		m.all
updateInputFocus method · go · L939-L947 (9 LOC)
cmd/tui/model.go
func (m *Model) updateInputFocus() {
	for i := range m.allInputs {
		if i == m.focusedInputIndex {
			m.allInputs[i].Focus()
		} else {
			m.allInputs[i].Blur()
		}
	}
}
Repobility · code-quality intelligence · https://repobility.com
syncInputToMaps method · go · L950-L985 (36 LOC)
cmd/tui/model.go
func (m *Model) syncInputToMaps(index int) {
	if index >= len(m.allInputs) {
		return
	}

	currentIndex := 0
	// Check if it's a path param
	for _, param := range m.selectedEndpoint.PathParams {
		if currentIndex == index {
			m.pathParamInputs[param.Name] = m.allInputs[index]
			return
		}
		currentIndex++
	}

	// Check if it's a query param
	for _, param := range m.selectedEndpoint.QueryParams {
		if currentIndex == index {
			m.queryParamInputs[param.Name] = m.allInputs[index]
			return
		}
		currentIndex++
	}

	// Must be a body field - find which one by matching the input
	bodyStartIndex := len(m.selectedEndpoint.PathParams) + len(m.selectedEndpoint.QueryParams)
	if index >= bodyStartIndex {
		// Find the key by iterating through body fields in deterministic order
		bodyIndex := index - bodyStartIndex
		bodyFieldKeys := m.getBodyFieldKeysInOrder()
		if bodyIndex < len(bodyFieldKeys) {
			key := bodyFieldKeys[bodyIndex]
			m.bodyFieldInputs[key] = m.allInputs[index]
		}
	}
}
syncAllInputs method · go · L988-L993 (6 LOC)
cmd/tui/model.go
func (m *Model) syncAllInputs() {
	fmt.Fprintf(os.Stderr, "[DEBUG] Syncing all %d inputs\n", len(m.allInputs))
	for i := range m.allInputs {
		m.syncInputToMaps(i)
	}
}
executeRequest method · go · L996-L1064 (69 LOC)
cmd/tui/model.go
func (m Model) executeRequest() tea.Cmd {
	return func() tea.Msg {
		fmt.Fprintf(os.Stderr, "[DEBUG] ========== EXECUTING REQUEST ==========\n")
		fmt.Fprintf(os.Stderr, "[DEBUG] Endpoint: %s\n", m.selectedEndpoint.Name)
		fmt.Fprintf(os.Stderr, "[DEBUG] allInputs count: %d\n", len(m.allInputs))

		// Collect path param values
		pathParamValues := make(map[string]string)
		for param, input := range m.pathParamInputs {
			pathParamValues[param] = input.Value()
		}

		// Collect query param values
		queryParamValues := make(map[string]string)
		for param, input := range m.queryParamInputs {
			queryParamValues[param] = input.Value()
		}

		// Build request body from body field inputs
		var requestBody string
		if len(m.bodyFieldInputs) > 0 {
			bodyMap := make(map[string]interface{})
			fmt.Fprintf(os.Stderr, "[DEBUG] Building request body for endpoint: %s\n", m.selectedEndpoint.Name)
			fmt.Fprintf(os.Stderr, "[DEBUG] Number of body field inputs: %d\n", len(m.bodyFieldInputs))
			for ke
goBack method · go · L1067-L1078 (12 LOC)
cmd/tui/model.go
func (m Model) goBack() Model {
	switch m.currentScreen {
	case ScreenRequestBuilder:
		m.currentScreen = ScreenEndpointList
	case ScreenHistory:
		m.currentScreen = ScreenEndpointList
	case ScreenSettings:
		m.currentScreen = ScreenEndpointList
	}
	m.errorMsg = ""
	return m
}
formatResponseBody function · go · L1081-L1091 (11 LOC)
cmd/tui/model.go
func formatResponseBody(result *RequestResult) string {
	if result == nil {
		return "No response"
	}

	if result.Error != nil {
		return fmt.Sprintf("Error: %v", result.Error)
	}

	return result.Body
}
searchAndNavigate method · go · L1094-L1119 (26 LOC)
cmd/tui/model.go
func (m *Model) searchAndNavigate() {
	if m.searchBuffer == "" {
		return
	}

	searchLower := strings.ToLower(m.searchBuffer)

	// Search through all endpoints
	for i, ep := range m.endpoints {
		// Check if any part matches the search
		categoryMatch := strings.Contains(strings.ToLower(string(ep.Category)), searchLower)
		methodMatch := strings.Contains(strings.ToLower(string(ep.Method)), searchLower)
		nameMatch := strings.Contains(strings.ToLower(ep.Name), searchLower)

		if categoryMatch || methodMatch || nameMatch {
			// Save current state before switching
			m.saveCurrentEndpointState()
			// Navigate to this item
			m.endpointList.Select(i)
			// Update selected endpoint
			m.selectedEndpoint = ep
			m.prepareRequestBuilder()
			return
		}
	}
}
handleAuthState method · go · L1122-L1175 (54 LOC)
cmd/tui/model.go
func (m *Model) handleAuthState(result *RequestResult) {
	if result == nil || result.Error != nil {
		return
	}

	// Handle "Send Email Code" endpoint
	if result.EndpointName == "Send Email Code" && result.StatusCode >= 200 && result.StatusCode < 300 {
		// Parse request body to extract email
		var requestBody map[string]interface{}
		if err := json.Unmarshal([]byte(result.RequestBody), &requestBody); err == nil {
			if email, ok := requestBody["email"].(string); ok {
				m.authState.email = email
				fmt.Fprintf(os.Stderr, "[DEBUG] Captured email from request: %s\n", email)
			}
		}

		// Try to extract code from response if present
		// Response format: {"data": {"message": "...", "email": "...", "code": "..."}}
		var responseWrapper map[string]interface{}
		if err := json.Unmarshal([]byte(result.Body), &responseWrapper); err == nil {
			// Extract data object
			if data, ok := responseWrapper["data"].(map[string]interface{}); ok {
				// Try to get code from data object (server send
getMapKeys function · go · L1178-L1184 (7 LOC)
cmd/tui/model.go
func getMapKeys(m map[string]interface{}) []string {
	keys := make([]string, 0, len(m))
	for k := range m {
		keys = append(keys, k)
	}
	return keys
}
If a scraper extracted this row, it came from Repobility (https://repobility.com)
getBodyFieldKeysInOrder method · go · L1188-L1229 (42 LOC)
cmd/tui/model.go
func (m *Model) getBodyFieldKeysInOrder() []string {
	if m.selectedEndpoint.ExampleBody == "" {
		return []string{}
	}

	// Parse the example body to get keys in order
	// Using json.Decoder preserves the order from the JSON string
	var bodyMap map[string]interface{}
	if err := json.Unmarshal([]byte(m.selectedEndpoint.ExampleBody), &bodyMap); err != nil {
		return []string{}
	}

	// Extract keys by parsing the JSON string manually to preserve order
	// This ensures consistent ordering across map iterations
	keys := []string{}
	decoder := json.NewDecoder(strings.NewReader(m.selectedEndpoint.ExampleBody))

	// Read opening brace
	if _, err := decoder.Token(); err != nil {
		// Fallback: return sorted keys for consistency
		for k := range bodyMap {
			keys = append(keys, k)
		}
		return keys
	}

	// Read key-value pairs in order
	for decoder.More() {
		token, err := decoder.Token()
		if err != nil {
			break
		}
		if key, ok := token.(string); ok {
			keys = append(keys, key)
			// Skip t
Title method · go · L1238-L1240 (3 LOC)
cmd/tui/model.go
func (i endpointItem) Title() string {
	return fmt.Sprintf("[%s] %s %s", i.endpoint.Category, i.endpoint.Method, i.endpoint.Name)
}
FilterValue method · go · L1242-L1244 (3 LOC)
cmd/tui/model.go
func (i endpointItem) FilterValue() string {
	return fmt.Sprintf("%s %s %s", i.endpoint.Category, i.endpoint.Method, i.endpoint.Name)
}
getStatusStyle function · go · L115-L131 (17 LOC)
cmd/tui/styles.go
func getStatusStyle(statusCode int) lipgloss.Style {
	switch {
	case statusCode >= 200 && statusCode < 300:
		return successBadgeStyle
	case statusCode >= 300 && statusCode < 400:
		return warningBadgeStyle
	case statusCode >= 400 && statusCode < 500:
		return errorBadgeStyle
	case statusCode >= 500:
		return lipgloss.NewStyle().
			Foreground(lipgloss.Color("#FFF")).
			Background(status5xxColor).
			Bold(true)
	default:
		return baseStyle
	}
}
renderStatusBadge function · go · L134-L138 (5 LOC)
cmd/tui/styles.go
func renderStatusBadge(statusCode int, statusText string) string {
	style := getStatusStyle(statusCode)
	// Just render the status text, which already includes the code
	return style.Render(statusText)
}
renderWithBorderTitleAndHeight function · go · L11-L69 (59 LOC)
cmd/tui/views.go
func renderWithBorderTitleAndHeight(content, title string, width int, height int) string {
	// Trim any leading/trailing whitespace from content
	content = strings.TrimSpace(content)

	// Calculate content width and height (minus borders)
	contentWidth := width - 2 // subtract left and right borders
	if contentWidth < 1 {
		contentWidth = 1
	}
	contentHeight := height - 2 // subtract top and bottom borders
	if contentHeight < 1 {
		contentHeight = 1
	}

	// Apply border to content (without top border) with specified width and height
	contentStyle := lipgloss.NewStyle().
		Border(lipgloss.RoundedBorder(), false, true, true, true). // no top border
		BorderForeground(borderColor).
		Width(contentWidth).
		Height(contentHeight)

	borderedContent := contentStyle.Render(content)

	// Use the specified width for the border
	actualWidth := width

	// Border characters
	topLeft := "╭"
	topRight := "╮"
	horizontal := "─"

	// Render styled title without margins for border use
	borderTitleStyle 
renderWithBorderTitle function · go · L72-L125 (54 LOC)
cmd/tui/views.go
func renderWithBorderTitle(content, title string, width int) string {
	// Trim any leading/trailing whitespace from content
	content = strings.TrimSpace(content)

	// Calculate content width (width minus borders)
	contentWidth := width - 2 // subtract left and right borders
	if contentWidth < 1 {
		contentWidth = 1
	}

	// Apply border to content (without top border) with specified width
	contentStyle := lipgloss.NewStyle().
		Border(lipgloss.RoundedBorder(), false, true, true, true). // no top border
		BorderForeground(borderColor).
		Width(contentWidth)

	borderedContent := contentStyle.Render(content)

	// Use the specified width for the border
	actualWidth := width

	// Border characters
	topLeft := "╭"
	topRight := "╮"
	horizontal := "─"

	// Render styled title without margins for border use
	borderTitleStyle := lipgloss.NewStyle().
		Bold(true).
		Foreground(primaryColor)
	styledTitle := borderTitleStyle.Render(title)
	titleWidth := lipgloss.Width(styledTitle)

	// Calculate hor
renderSplitView function · go · L128-L147 (20 LOC)
cmd/tui/views.go
func renderSplitView(m Model) string {
	// Fixed width for left panel (endpoint list)
	leftWidth := 60
	rightWidth := m.width - leftWidth

	// Ensure minimum widths
	if leftWidth > m.width-20 {
		leftWidth = m.width / 2
		rightWidth = m.width - leftWidth
	}

	// Left panel: Endpoint list (fixed width)
	leftPanel := renderEndpointListPanel(m, leftWidth)

	// Right panel: Request builder (fills remaining width)
	rightPanel := renderRequestBuilderPanel(m, rightWidth)

	// Join horizontally
	return lipgloss.JoinHorizontal(lipgloss.Top, leftPanel, rightPanel)
}
Same scanner, your repo: https://repobility.com — Repobility
renderEndpointListPanel function · go · L150-L185 (36 LOC)
cmd/tui/views.go
func renderEndpointListPanel(m Model, width int) string {
	// Endpoint list
	listContent := m.endpointList.View()

	// Footer - show different help based on search state
	var help string
	if m.currentScreen == ScreenEndpointList {
		if m.searchMode {
			searchText := m.searchBuffer
			if searchText == "" {
				searchText = "_"
			}
			help = footerStyle.Render(fmt.Sprintf("search: %s • enter/esc: exit search", searchText))
		} else {
			help = footerStyle.Render("j/k: navigate • /: search • enter: send • tab: configure →")
		}
	} else {
		help = footerStyle.Render("j/k: navigate • enter: send • esc: back to list")
	}

	// Calculate how many lines we need to fill to push help to bottom
	listHeight := lipgloss.Height(listContent)
	helpHeight := lipgloss.Height(help) + 2                  // +2 for spacing before help
	contentHeight := m.height - 3                            // minus top and bottom borders, and global status bar
	fillLines := contentHeight - listHeight - helpHeight + 1 // 
renderRequestBuilderPanel function · go · L188-L210 (23 LOC)
cmd/tui/views.go
func renderRequestBuilderPanel(m Model, width int) string {
	if m.selectedEndpoint.Name == "" {
		// No endpoint selected
		emptyMsg := helpStyle.Render("← Select an endpoint to configure request")
		return borderStyle.Render(emptyMsg)
	}

	// Top: Request configuration (render first to get actual height)
	configPanel := renderRequestBuilderContent(m, width)

	// Get actual height of config panel
	configPanelHeight := lipgloss.Height(configPanel)

	// Bottom: Response panel fills remaining space (accounting for global status bar)
	responseHeight := m.height - configPanelHeight - 1
	if responseHeight < 10 {
		responseHeight = 10 // Minimum height for response panel
	}
	responsePanel := renderResponsePanel(m, width, responseHeight)

	// Join vertically
	return lipgloss.JoinVertical(lipgloss.Left, configPanel, responsePanel)
}
renderRequestBuilderContent function · go · L213-L352 (140 LOC)
cmd/tui/views.go
func renderRequestBuilderContent(m Model, width int) string {
	var b strings.Builder

	// Method, name and description
	methodName := titleStyle.Render(fmt.Sprintf("%s %s", m.selectedEndpoint.Method, m.selectedEndpoint.Name))
	description := subtitleStyle.Render(" - " + m.selectedEndpoint.Description)
	titleLine := lipgloss.JoinHorizontal(lipgloss.Left, methodName, description)
	b.WriteString(titleLine + "\n")

	// Build URL with current path parameter values
	url := m.baseURL + m.selectedEndpoint.Path
	for paramName, input := range m.pathParamInputs {
		placeholder := fmt.Sprintf("{%s}", paramName)
		value := input.Value()
		if value != "" {
			url = strings.ReplaceAll(url, placeholder, value)
		}
	}
	urlText := responseKeyStyle.Render("URL: ") + responseValueStyle.Render(url)
	b.WriteString(urlText + "\n")

	// Show auth state info for Verify Email Code endpoint
	if m.selectedEndpoint.Name == "Verify Email Code" {
		if m.authState != nil && m.authState.email != "" {
			authInfo := in
page 1 / 23next ›