Skip to content

Conversation

@giordano-lucas
Copy link
Member

@giordano-lucas giordano-lucas commented Jan 29, 2026

Add NOTTE_FUNCTION_ID env var and current_function file support to functions commands, mirroring the existing session ID pattern.

Resolution priority: --id flag > NOTTE_FUNCTION_ID env > current_function file

Changes:

  • Add CurrentFunctionFile and EnvFunctionID constants to config
  • Add GetCurrentFunctionID, RequireFunctionID, setCurrentFunction, clearCurrentFunction functions
  • Update all function commands to use RequireFunctionID
  • Create command saves function ID to current_function file
  • Delete command clears current_function if matching
  • Add comprehensive unit tests for function ID resolution
  • Add integration tests for functions including ID resolution

Greptile Overview

Greptile Summary

This PR adds function ID resolution with priority: --id flag > NOTTE_FUNCTION_ID env var > current_function file. The implementation mirrors the existing session ID pattern consistently.

Key Changes

  • Added GetCurrentFunctionID(), RequireFunctionID(), setCurrentFunction(), and clearCurrentFunction() helper functions
  • Updated all function commands to use RequireFunctionID() instead of requiring --id flag
  • Create command saves function ID to current_function file
  • Delete command clears current_function file only if it matches the deleted function
  • Added comprehensive unit tests (11 new tests) covering priority resolution, file operations, and edge cases
  • Added integration tests (10 new tests) covering end-to-end workflows and ID resolution scenarios

The implementation is clean, well-tested, and follows established patterns in the codebase.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Implementation mirrors existing session ID pattern exactly, has comprehensive test coverage (unit and integration), and follows all established coding conventions
  • No files require special attention

Important Files Changed

Filename Overview
internal/cmd/functions.go Added function ID resolution pattern (flag > env > file) mirroring sessions, comprehensive and well-implemented
internal/cmd/functions_test.go Added comprehensive unit tests covering all ID resolution scenarios and edge cases
internal/config/config.go Added CurrentFunctionFile and EnvFunctionID constants following existing naming conventions
tests/integration/functions_test.go Added new integration test file with comprehensive end-to-end tests for function lifecycle and ID resolution

Add NOTTE_FUNCTION_ID env var and current_function file support to
functions commands, mirroring the existing session ID pattern.

Resolution priority: --id flag > NOTTE_FUNCTION_ID env > current_function file

Changes:
- Add CurrentFunctionFile and EnvFunctionID constants to config
- Add GetCurrentFunctionID, RequireFunctionID, setCurrentFunction,
  clearCurrentFunction functions
- Update all function commands to use RequireFunctionID
- Create command saves function ID to current_function file
- Delete command clears current_function if matching
- Add comprehensive unit tests for function ID resolution
- Add integration tests for functions including ID resolution

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

- Add notte.Session() to function content (required by API validation)
- Handle both array and paginated response formats in TestFunctionsList

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@giordano-lucas giordano-lucas merged commit 2143fdd into main Jan 29, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants