Skip to content

Commit 1063a13

Browse files
committed
fix: address PR #156 review feedback (round 2)
- Add empty notebook guards to search notebook Conclusions and Research Questions presets (prevents modal flash on empty notebooks) - Redact api_key from verbose OpenAlex log output - Fix wizard dismissal race by requiring has_seen_wizard input before check - Fix misplaced roxygen docs on generate_preset() and document custom_prompt - Remove "Editable prompts" from README (feature not yet implemented)
1 parent bd20f54 commit 1063a13

File tree

5 files changed

+29
-9
lines changed

5 files changed

+29
-9
lines changed

R/api_openalex.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ OPENALEX_BASE_URL <- "https://api.openalex.org"
88
#' @return httr2 response
99
perform_openalex <- function(req) {
1010
if (isTRUE(getOption("serapeum.verbose_api", FALSE))) {
11-
url <- req$url
11+
url <- gsub("api_key=[^&]+", "api_key=<REDACTED>", req$url)
1212
message("[OpenAlex API] ", url)
1313
}
1414
req_perform(req)

R/mod_search_notebook.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3351,6 +3351,15 @@ mod_search_notebook_server <- function(id, con, notebook_id, config, notebook_re
33513351
}
33523352
req(!is_processing())
33533353
req(has_api_key())
3354+
3355+
# Empty notebook guard
3356+
paper_count <- tryCatch(nrow(list_abstracts(con(), notebook_id())), error = function(e) 0L)
3357+
if (paper_count == 0L) {
3358+
showNotification("This notebook has no papers yet. Run a search first, then try again.",
3359+
type = "warning", duration = 5)
3360+
return()
3361+
}
3362+
33543363
is_processing(TRUE)
33553364
show_synthesis_modal("Conclusion Synthesis")
33563365

@@ -3389,6 +3398,15 @@ mod_search_notebook_server <- function(id, con, notebook_id, config, notebook_re
33893398
}
33903399
req(!is_processing())
33913400
req(has_api_key())
3401+
3402+
# Empty notebook guard
3403+
paper_count <- tryCatch(nrow(list_abstracts(con(), notebook_id())), error = function(e) 0L)
3404+
if (paper_count == 0L) {
3405+
showNotification("This notebook has no papers yet. Run a search first, then try again.",
3406+
type = "warning", duration = 5)
3407+
return()
3408+
}
3409+
33923410
is_processing(TRUE)
33933411
show_synthesis_modal("Research Questions")
33943412

R/rag.R

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,6 @@ rag_query <- function(con, config, question, notebook_id, session_id = NULL) {
135135
response
136136
}
137137

138-
#' Generate preset content (summary, key points, etc.)
139-
#' @param con Database connection
140-
#' @param config App config
141-
#' @param notebook_id Notebook ID
142-
#' @param preset_type Type of preset ("summarize", "keypoints", "studyguide", "outline")
143-
#' @param session_id Optional Shiny session ID for cost logging (default NULL)
144-
#' @return Generated content
145138
#' Get the task instruction for a preset type
146139
#' @param preset_type Preset type string
147140
#' @return Task instruction string, or NULL if unknown
@@ -160,6 +153,15 @@ get_preset_instruction <- function(preset_type) {
160153
presets[[preset_type]]
161154
}
162155

156+
#' Generate preset content (summary, key points, etc.)
157+
#' @param con Database connection
158+
#' @param config App config
159+
#' @param notebook_id Notebook ID
160+
#' @param preset_type Type of preset ("summarize", "keypoints", "studyguide", "outline",
161+
#' "overview", "conclusions", "lit_review", "methodology_extractor", "gap_analysis")
162+
#' @param session_id Optional Shiny session ID for cost logging (default NULL)
163+
#' @param custom_prompt Optional custom prompt to override the default preset instruction
164+
#' @return Generated content
163165
generate_preset <- function(con, config, notebook_id, preset_type, session_id = NULL,
164166
custom_prompt = NULL) {
165167
prompt <- custom_prompt %||% get_preset_instruction(preset_type)

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Upload PDFs and chat with your documents using RAG (Retrieval-Augmented Generati
1717
- **Markdown rendering** - Assistant responses display with formatted headers, tables, lists, and code blocks
1818
- **One-click presets** - Summarize, Key Points, Study Guide, Outline, and more
1919
- **Synthesis progress feedback** - Status modal with rotating stage indicators for long-running presets
20-
- **Editable prompts** - Expand the prompt editor to view and customize LLM prompts before sending
2120
- **Chat export** - Download conversations as Markdown (.md) or styled HTML (.html)
2221
- **Full-text search** - Vector embeddings for semantic search across documents
2322
- **Slide generation** - Generate Quarto RevealJS presentations from your research

app.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ server <- function(input, output, session) {
668668
observe({
669669
con <- con_r()
670670
req(con)
671+
req(!is.null(input$has_seen_wizard))
671672
notebooks <- list_notebooks(con)
672673
has_seen <- isTRUE(input$has_seen_wizard)
673674
if (nrow(notebooks) == 0 && !has_seen) {

0 commit comments

Comments
 (0)