Skip to content

Commit 954452b

Browse files
committed
fix(prompts): NPE when retrieving TaskManager
Closes: #241
1 parent d7a8b4a commit 954452b

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
### Fixed
6+
7+
- NPE when retrieving TaskManager for prompt construction.
8+
59
## [2.3.0] - 2024-09-09
610

711
### Added

src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/AICommitsUtils.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@ object AICommitsUtils {
4242
content = content.replace("{branch}", branch)
4343
content = replaceHint(content, hint)
4444

45-
val activeTask = TaskManager.getManager(project).activeTask
46-
content = content.replace("{taskId}", activeTask.id)
47-
content = content.replace("{taskSummary}", activeTask.summary)
48-
content = content.replace("{taskDescription}", activeTask.description.orEmpty())
45+
// TODO @Blarc: If TaskManager is null, the prompt might be incorrect...
46+
TaskManager.getManager(project)?.let {
47+
val activeTask = it.activeTask
48+
content = content.replace("{taskId}", activeTask.id)
49+
content = content.replace("{taskSummary}", activeTask.summary)
50+
content = content.replace("{taskDescription}", activeTask.description.orEmpty())
51+
}
4952

5053
return if (content.contains("{diff}")) {
5154
content.replace("{diff}", diff)

0 commit comments

Comments
 (0)