Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,24 @@ public List<Task> getRelatedTasks() {
return params != null ? params.tenant() : null;
}

/**
* Extracts all text content from the message and joins with the newline delimiter.
* <p>
* This is a convenience method for getting text input from messages that may contain
* multiple text parts. Non-text parts (images, etc.) are ignored.
* <p>
* <b>Examples:</b>
* <pre>{@code
* // Join with newlines (common for multi-paragraph input)
* String text = context.getUserInput();
* }</pre>
*
* @return all text parts joined with newline, or empty string if no message
*/
public String getUserInput() {
return getUserInput("\n");
}

/**
* Extracts all text content from the message and joins with the specified delimiter.
* <p>
Expand All @@ -233,7 +251,7 @@ public List<Task> getRelatedTasks() {
* <b>Examples:</b>
* <pre>{@code
* // Join with newlines (common for multi-paragraph input)
* String text = context.getUserInput("\n");
* String text = context.getUserInput();
*
* // Join with spaces (common for single-line input)
* String text = context.getUserInput(" ");
Expand All @@ -245,14 +263,11 @@ public List<Task> getRelatedTasks() {
* @param delimiter the string to insert between text parts (null defaults to "\n")
* @return all text parts joined with delimiter, or empty string if no message
*/
public String getUserInput(String delimiter) {
public String getUserInput(@Nullable String delimiter) {
if (params == null) {
return "";
}
if (delimiter == null) {
delimiter = "\n";
}
return getMessageText(params.message(), delimiter);
return getMessageText(params.message(), delimiter == null ? "\n" : delimiter);
Comment on lines +266 to +270
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The change from String delimiter to @Nullable String delimiter is good for clarity, but the null check and assignment can be made more concise using Objects.requireNonNullElse or a direct ternary operator in the getMessageText call. The current implementation is fine, but this is a minor improvement opportunity for conciseness.

Suggested change
public String getUserInput(@Nullable String delimiter) {
if (params == null) {
return "";
}
if (delimiter == null) {
delimiter = "\n";
}
return getMessageText(params.message(), delimiter);
return getMessageText(params.message(), delimiter == null ? "\n" : delimiter);
public String getUserInput(@Nullable String delimiter) {
if (params == null) {
return "";
}
return getMessageText(params.message(), Objects.requireNonNullElse(delimiter, "\n"));
}

}

/**
Expand Down