You're a helpful coding assistant and pair programmer working with a human user.

You are working in R shiny app for web scrapping EU Clinical Trials Register. 

Features:
- Select the input option [not fully implemented]
- Select sets of data to scrape [not fully implemented]
- Select the output file format [not fully implemented]

Please ask any clarifying questions before proceeding, if necessary.

This is our current code:

---

app.R:
library(shiny)

# Define UI for application that draws a histogram

ui <- shinyUI(fluidPage(
  
  # Subtitle
  h2("EUCTR Scraper 🪄", align="center"),
  
  # Instruction text with hyperlink
  div(
    style = "text-align: center; margin-top: 20px; margin-bottom: 20px;",
    HTML("This is a web scraper for the <a href='https://www.clinicaltrialsregister.eu/ctr-search/search'>EU Clinical Trial Register</a>.")
  ),
  
  # Select input option
  selectInput("input_option", "Select the input option:",
              choices = c("EUCTR search query URL", "List of EudraCT numbers"),
              selected = "EUCTR search query URL"),
  
  # Input box for the URL
  textInput("input_var", "Do a trial search on EU Clinical Trials Register website and copy the URL for the search query:", value="Paste here", width="100%"),
  
  
  # Selectize input box with list of options and suboptions
  selectizeInput("selection_box", label = "Select sets of data to scrape:",
                 choices = list(
                   "Option 1" = list(
                     "Suboption 1.1" = "suboption1.1",
                     "Suboption 1.2" = "suboption1.2",
                     "Suboption 1.3" = "suboption1.3"
                   ),
                   "Option 2" = list(
                     "Suboption 2.1" = "suboption2.1",
                     "Suboption 2.2" = "suboption2.2"
                   )
                   # Add more options and suboptions here
                 ),
                 multiple = TRUE, options = list(plugins = list('remove_button')),
                 width = "100%"),
  
  
  # Select the output file format
  selectInput("file_format", "Select the output file format:",
              choices = c("Excel file" = "xlsx", "CSV files" = "csv"),
              selected = "xlsx"),
  
  # ‘Start’ button
  actionButton("start", "Start"),
  
  
  # Output link to the generated file
  uiOutput("output_link")
))



# Define server logic 

server <- shinyServer(function(input, output) {
  
  # Create a reactive value to store the clicked button count
  click_count <- reactiveValues(count = 0)
  
  # Define a reactive expression for the selected file format
  file_format <- reactive({
    if (input$file_format == "xlsx") {
      "Excel file"
    } else if (input$file_format == "csv") {
      "CSV files"
    }
  })
  
  # Define a reactive expression for the selected data sets
  selected_data_sets <- reactive({
    input$selection_box
  })
  
  
  # Define a reactive expression for the selected input option
  selected_option <- reactive({
    
    if (input$input_option == "EUCTR search query URL") {
      "EUCTR search query URL"
      
    } else if (input$input_option == "List of EudraCT numbers") {
      "List of EudraCT numbers"
    }
  })
  
  # Define an observer for the Start button click event
  observeEvent(input$start, {
    
    # Increment the click count
    click_count$count <- click_count$count + 1
    
    # Print a message to the console to indicate that the Start button was clicked
    print(paste0("Start button clicked ", click_count$count, " time(s)."))
    
    # Source the EUCTR_shiny.R script
    source("driver.R")
    
    # Call the EUCTR_shiny.R script with the selected input values
    output_file <- isolate(EUCTR_shiny_script(selected_input = input$input_var, 
                                              selected_data_sets = selected_data_sets(),
                                              selected_option = selected_option(), 
                                              selected_format = input$file_format))

    
    # Generate a download link for the output file
    output$output_link <- renderUI({
      fluidRow(
        column(12, 
               h3("Generated file:"),
               a(href = output_file, download = "euctr_data", class = "btn btn-info",
                 icon("download"), file_format())
               
        )
      )
    })
  })
})

# Run the application 
shinyApp(ui = ui, server = server)


---

driver.R:

EUCTR_shiny_script <- function(selected_input, selected_data_sets, selected_option, 
                               selected_format) {
  
  library(rvest)
  library(tidyverse)
  library(tidyr)
  library(openxlsx)
  library(readxl)
  
  # Create a new environment to store shared variables
  my_env <- new.env()
  
  # Define variables
  EUCTR_version <- "0.2"
  process_time <- format(Sys.time(), "%Y-%m-%d %H:%M")
  
  # Assign the variables to the environment
  assign("selected_input", selected_input, envir = my_env)
  assign("selected_data_sets", selected_data_sets, envir = my_env)
  assign("selected_option", selected_option, envir = my_env)
  assign("selected_format", selected_format, envir = my_env)
  assign("EUCTR_version", EUCTR_version, envir = my_env)
  assign("process_time", process_time, envir = my_env)
  
  # Run the query crawler
  source('./crawler.R', local = my_env)
  
  # Run the protocol scraper
  source('./protocol.R', local = my_env)
  
  # Run the results scraper
  source('./results.R', local = my_env)
  
  # Save to xlsx 
  source('./savexlsx.R', local = my_env)
}

---

What are some ways to add a dynamic progress message (with messages defined throughout the scraper scripts) to the ui, which updates alongside the scraper progress?