Skip to content

Commit b39bd75

Browse files
committed
Merge branch 'main' into add-missing-controller-method
2 parents 37a28e7 + ba3a4b2 commit b39bd75

File tree

121 files changed

+16727
-25035
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+16727
-25035
lines changed

.github/workflows/pytest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ jobs:
154154

155155
playwright-examples:
156156
if: github.event_name != 'release'
157-
runs-on: ubuntu-20.04
157+
runs-on: ubuntu-latest
158158
strategy:
159159
matrix:
160160
python-version: ["3.12", "3.11", "3.10", "3.9"]

.github/workflows/verify-js-built.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
run: |
4040
if [[ `git status --porcelain` ]]; then
4141
git diff
42-
echo "Uncommitted changes found. Please commit any changes that result from 'npm run build'."
42+
echo "Uncommitted changes found. Please commit any changes that result from 'npm ci && npm run build'."
4343
exit 1
4444
else
4545
echo "No uncommitted changes found."

CHANGELOG.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,44 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### New features
1111

12-
* Added a new `.add_sass_layer_file()` method to `ui.Theme` that supports reading a Sass file with layer boundary comments, e.g. `/*-- scss:defaults --*/`. This format [is supported by Quarto](https://quarto.org/docs/output-formats/html-themes-more.html#bootstrap-bootswatch-layering) and makes it easier to store Sass rules and declarations that need to be woven into Shiny's Sass Bootstrap files. (#1790)
12+
* Added a new `ui.MarkdownStream()` component for performantly streaming in chunks of markdown/html strings into the UI. This component is primarily useful for text-based generative AI where responses are received incrementally. (#1782)
13+
14+
* The `ui.Chat()` component now supports input suggestion links. This feature is useful for providing users with clickable suggestions that can be used to quickly input text into the chat. This can be done in 2 different ways (see #1845 for more details):
15+
* By adding a `.suggestion` CSS class to an HTML element (e.g., `<span class="suggestion">A suggestion</span>`)
16+
* Add a `data-suggestion` attribute to an HTML element, and set the value to the input suggestion text (e.g., `<span data-suggestion="Suggestion value">Suggestion link</span>`)
17+
* To auto-submit the suggestion when clicked by the user, include the `.submit` class or the `data-suggestion-submit="true"` attribute on the HTML element. Alternatively, use Cmd/Ctrl + click to auto-submit any suggestion or Alt/Opt + click to apply any suggestion to the chat input without submitting.
1318

14-
* The `ui.Chat()` component's `.on_user_submit()` decorator method now passes the user input to the decorated function. This makes it a bit more obvious how to access the user input inside the decorated function. See the new templates (mentioned below) for examples. (#1801)
19+
* The `ui.Chat()` component also gains the following:
20+
* The `.on_user_submit()` decorator method now passes the user input to the decorated function. This makes it a bit easier to access the user input. See the new templates (mentioned below) for examples. (#1801)
21+
* The assistant icon is now configurable via `ui.chat_ui()` (or the `ui.Chat.ui()` method in Shiny Express) or for individual messages in the `.append_message()` and `.append_message_stream()` methods of `ui.Chat()`. (#1853)
22+
* A new `get_latest_stream_result()` method was added for an easy way to access the final result of the stream when it completes. (#1846)
23+
* The `.append_message_stream()` method now returns the `reactive.extended_task` instance that it launches. (#1846)
24+
* The `ui.Chat()` component's `.update_user_input()` method gains `submit` and `focus` options that allow you to submit the input on behalf of the user and to choose whether the input receives focus after the update. (#1851)
1525

1626
* `shiny create` includes new and improved `ui.Chat()` template options. Most of these templates leverage the new [`{chatlas}` package](https://posit-dev.github.io/chatlas/), our opinionated approach to interfacing with various LLM. (#1806)
1727

1828
* Added a new `expect_max_height()` method to the Valuebox controllers to check the maximum height of a value box (#1816)
1929

30+
* Client data values (e.g., url info, output sizes/styles, etc.) can now be accessed in the server-side Python code via `session.clientdata`. For example, `session.clientdata.url_search()` reactively reads the URL search parameters. (#1832)
31+
32+
* Available `input` ids can now be listed via `dir(input)`. This also works on the new `session.clientdata` object. (#1832)
33+
34+
* Added a new `.add_sass_layer_file()` method to `ui.Theme` that supports reading a Sass file with layer boundary comments, e.g. `/*-- scss:defaults --*/`. This format [is supported by Quarto](https://quarto.org/docs/output-formats/html-themes-more.html#bootstrap-bootswatch-layering) and makes it easier to store Sass rules and declarations that need to be woven into Shiny's Sass Bootstrap files. (#1790)
35+
36+
* `ui.input_text()`, `ui.input_text_area()`, `ui.input_numeric()` and `ui.input_password()` all gain an `update_on` option. `update_on="change"` is the default and previous behavior, where the input value updates immediately whenever the value changes. With `update_on="blur"`, the input value will update only when the text input loses focus or when the user presses Enter (or Cmd/Ctrl + Enter for `ui.input_text_area()`). (#1874)
37+
2038
### Bug fixes
2139

2240
* `ui.Chat()` now correctly handles new `ollama.chat()` return value introduced in `ollama` v0.4. (#1787)
2341

2442
* Updated `expect_height()` for Valuebox controllers to check the height property instead of max-height. (#1816)
2543

44+
### Changes
45+
46+
* The Shiny Core component `shiny.ui.Chat()` no longer has a `.ui()` method. This method
47+
was never intended to be used in Shiny Core (in that case, use `shiny.ui.chat_ui()`) to create the UI element. Note that the `shiny.express.ui.Chat()`
48+
class still has a `.ui()` method. (#1840)
49+
2650
## [1.2.1] - 2024-11-14
2751

2852
### Bug fixes

README.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ If you have questions about Shiny for Python, or want to help us decide what to
2424

2525
## Getting started
2626

27-
To get started with shiny follow the [installation instructions](https://shiny.posit.co/py/docs/install.html) or just install it from pip.
27+
To get started with shiny follow the [installation instructions](https://shiny.posit.co/py/docs/install-create-run.html) or just install it from pip.
2828

2929
```sh
3030
pip install shiny
@@ -47,10 +47,18 @@ You can create and run your first application with `shiny create`, the CLI will
4747
* https://posit-dev.github.io/py-shiny/docs/api/express/
4848
* https://posit-dev.github.io/py-shiny/docs/api/core/
4949

50-
If you want to do development on Shiny for Python:
50+
If you are working from a fork you may not have the git tags from the original repo.
51+
Git tags are required for the install to succeed. To add tags to your own fork:
5152

5253
```sh
53-
pip install -e ".[dev,test]"
54+
git remote add upstream https://github.com/posit-dev/py-shiny.git
55+
git fetch --tags upstream
56+
```
57+
58+
Then install:
59+
60+
```sh
61+
pip install -e ".[dev,test,doc]"
5462
```
5563

5664
Additionally, you can install pre-commit hooks which will automatically reformat and lint the code when you make a commit:
@@ -61,3 +69,29 @@ pre-commit install
6169
# To disable:
6270
# pre-commit uninstall
6371
```
72+
73+
Tests should now pass:
74+
75+
```sh
76+
make check
77+
# To apply formatting fixes instead of erroring:
78+
# make check-fix
79+
```
80+
81+
Or get a full list of helpers with just:
82+
83+
```sh
84+
make
85+
```
86+
87+
Typically, when developing new features for Shiny, you'll want to try them out in an application.
88+
In a **separate** application directory, use can use `-e` to reference your local checkout of `py-shiny`:
89+
90+
```sh
91+
# Rather than
92+
# pip install shiny
93+
# run:
94+
pip install -e ../py-shiny --config-settings editable_mode=compat
95+
```
96+
97+
See the [docs README](docs/README.md) for instructions on building the documentation locally.

docs/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This directory contains files to generate Shiny for Python API documentation, us
55

66
## Building the docs
77

8-
To build the docs, first install the Python dependencies and Quarto extensions:
8+
To build the docs, first [download and install Quarto](https://quarto.org/docs/get-started/), and then install the Python dependencies and Quarto extensions:
99

1010
```bash
1111
# Install build dependencies
@@ -18,14 +18,14 @@ After those dependencies are installed, build the .qmd files for Shiny, using qu
1818
make quartodoc
1919
```
2020

21-
Then build the web site using Quarto:
21+
Then you can build the docs, and serve them locally, and watch for changes to the .qmd files:
2222

2323
```bash
24-
make site
24+
make serve
2525
```
2626

27-
Alternatively, running `make serve` will build the docs, and serve them locally, and watch for changes to the .qmd files:
27+
Alternatively, build the site just once:
2828

2929
```bash
30-
make serve
30+
make site
3131
```

docs/_quartodoc-core.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ quartodoc:
102102
contents:
103103
- ui.Chat
104104
- ui.chat_ui
105+
- title: Streaming markdown
106+
desc: Stream markdown content into the UI
107+
contents:
108+
- ui.MarkdownStream
109+
- ui.output_markdown_stream
105110
- title: Custom UI
106111
desc: Lower-level UI functions for creating custom HTML/CSS/JS
107112
contents:
@@ -228,19 +233,21 @@ quartodoc:
228233
path: Session
229234
summary:
230235
name: "Session"
231-
desc: ""
236+
desc: "Tools for managing user sessions and accessing session-related information."
232237
flatten: true
233238
contents:
234239
- session.get_current_session
235240
- session.require_active_session
236241
- session.session_context
237242
- reactive.get_current_context
243+
- session.ClientData
238244
- session.Session.send_custom_message
239245
- session.Session.send_input_message
240246
- session.Session.on_flush
241247
- session.Session.on_flushed
242248
- session.Session.on_ended
243249
- session.Session.dynamic_route
250+
- session.Session.close
244251
- input_handler.input_handlers
245252
- kind: page
246253
path: Renderer
@@ -358,4 +365,3 @@ quartodoc:
358365
contents:
359366
- name: experimental.ui.card_image
360367
dynamic: false
361-

docs/_quartodoc-express.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ quartodoc:
8181
desc: Build a chatbot interface
8282
contents:
8383
- express.ui.Chat
84+
- title: Streaming markdown
85+
desc: Stream markdown content into the UI
86+
contents:
87+
- express.ui.MarkdownStream
8488
- title: Reactive programming
8589
desc: Create reactive functions and dependencies.
8690
contents:
@@ -164,6 +168,14 @@ quartodoc:
164168
- express.ui.panel_conditional
165169
- express.ui.insert_ui
166170
- express.ui.remove_ui
171+
- title: User Session
172+
desc: Tools for managing user sessions and accessing session-related information.
173+
contents:
174+
- session.Session
175+
- title: Client Data
176+
desc: Access (client-side) information about the user session (e.g., URL, output info, etc).
177+
contents:
178+
- session.ClientData
167179
- title: UI as HTML
168180
desc: Tools for creating HTML/CSS/JS
169181
contents:

docs/_quartodoc-testing.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ quartodoc:
2424
- title: UI Inputs
2525
desc: Methods for interacting with Shiny app input value controller.
2626
contents:
27+
- playwright.controller.InputActionButton
2728
- playwright.controller.InputActionLink
2829
- playwright.controller.InputCheckbox
2930
- playwright.controller.InputCheckboxGroup

js/build.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ const opts: Array<BuildOptions> = [
7474
plugins: [sassPlugin({ type: "css", sourceMap: false })],
7575
metafile: true,
7676
},
77+
{
78+
entryPoints: {
79+
"markdown-stream/markdown-stream": "markdown-stream/markdown-stream.ts",
80+
},
81+
minify: true,
82+
sourcemap: true,
83+
},
84+
{
85+
entryPoints: {
86+
"markdown-stream/markdown-stream": "markdown-stream/markdown-stream.scss",
87+
},
88+
plugins: [sassPlugin({ type: "css", sourceMap: false })],
89+
metafile: true,
90+
},
7791
{
7892
entryPoints: {
7993
"chat/chat": "chat/chat.ts",

js/chat/_utils.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)