Skip to content

Commit

Permalink
Merge branch 'main' into issue-1242-url-preview
Browse files Browse the repository at this point in the history
  • Loading branch information
fflorent authored Oct 5, 2024
2 parents 99283f7 + 932a04a commit 9a72269
Show file tree
Hide file tree
Showing 128 changed files with 6,493 additions and 2,282 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ Grist can be configured in many ways. Here are the main environment variables it
| GRIST_ENABLE_REQUEST_FUNCTION | enables the REQUEST function. This function performs HTTP requests in a similar way to `requests.request`. This function presents a significant security risk, since it can let users call internal endpoints when Grist is available publicly. This function can also cause performance issues. Unset by default. |
| GRIST_HIDE_UI_ELEMENTS | comma-separated list of UI features to disable. Allowed names of parts: `helpCenter,billing,templates,createSite,multiSite,multiAccounts,sendToDrive,tutorials,supportGrist`. If a part also exists in GRIST_UI_FEATURES, it will still be disabled. |
| GRIST_HOST | hostname to use when listening on a port. |
| GRIST_HTTPS_PROXY | if set, use this proxy for webhook payload delivery. |
| GRIST_HTTPS_PROXY | if set, use this proxy for webhook payload delivery or fetching custom widgets repository from url. |
| GRIST_ID_PREFIX | for subdomains of form o-*, expect or produce o-${GRIST_ID_PREFIX}*. |
| GRIST_IGNORE_SESSION | if set, Grist will not use a session for authentication. |
| GRIST_INCLUDE_CUSTOM_SCRIPT_URL | if set, will load the referenced URL in a `<script>` tag on all app pages. |
Expand Down Expand Up @@ -332,8 +332,8 @@ ASSISTANT_MODEL | optional. If set, this string is passed along in calls to
ASSISTANT_LONGER_CONTEXT_MODEL | optional. If set, requests that fail because of a context length limitation will be retried with this model set.
OPENAI_API_KEY | optional. Synonym for ASSISTANT_API_KEY that assumes an OpenAI endpoint is being used. Sign up for an account on OpenAI and then generate a secret key [here](https://platform.openai.com/account/api-keys).

At the time of writing, the AI Assistant is known to function against OpenAI chat completion endpoints for gpt-3.5-turbo and gpt-4.
It can also function against the chat completion endpoint provided by <a href="https://github.com/abetlen/llama-cpp-python">llama-cpp-python</a>.
At the time of writing, the AI Assistant is known to function against OpenAI chat completion endpoints (those ending in `/v1/chat/completions`).
It is also known to function against the chat completion endpoint provided by <a href="https://github.com/abetlen/llama-cpp-python">llama-cpp-python</a> and by [LM Studio](https://lmstudio.ai/). For useful results, the LLM should be on par with GPT 3.5 or above.

#### Sandbox related variables:

Expand Down
7 changes: 7 additions & 0 deletions app/client/components/AceEditorCompletions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ export function setupAceEditorCompletions(editor: Ace.Editor, options: ICompleti
const {Autocomplete} = ace.require('ace/autocomplete');

const completer = new Autocomplete();
// Here is the source code:
// https://github.com/ajaxorg/ace/blob/23208f2f19020d1f69b90bc3b02460bda8422072/src/autocomplete.js#L180
// It seems that this function wasn't doing anything special, and wasn't returning anything, so
// AceEditor refused to insert new line. Option 'deleteSuffix is also not supported (line 150).
if (completer.keyboardHandler?.commands?.["Shift-Return"]) {
completer.keyboardHandler.commands["Shift-Return"].exec = () => false;
}
completer.autoSelect = false;
(editor as any).completer = completer;

Expand Down
15 changes: 14 additions & 1 deletion app/client/components/BaseView.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const {COMMENTS} = require('app/client/models/features');
const {DismissedPopup} = require('app/common/Prefs');
const {markAsSeen} = require('app/client/models/UserPrefs');
const {buildConfirmDelete, reportUndo} = require('app/client/components/modals');
const {buildReassignModal} = require('app/client/ui/buildReassignModal');
const {MutedError} = require('app/client/models/errors');


/**
* BaseView forms the basis for ViewSection classes.
Expand Down Expand Up @@ -648,7 +651,17 @@ BaseView.prototype.sendPasteActions = function(cutCallback, actions) {
// If the cut occurs on an edit restricted cell, there may be no cut action.
if (cutAction) { actions.unshift(cutAction); }
}
return this.gristDoc.docData.sendActions(actions);
return this.gristDoc.docData.sendActions(actions).catch(ex => {
if (ex.code === 'UNIQUE_REFERENCE_VIOLATION') {
buildReassignModal({
docModel: this.gristDoc.docModel,
actions,
}).catch(reportError);
throw new MutedError();
} else {
throw ex;
}
});
};

BaseView.prototype.buildDom = function() {
Expand Down
19 changes: 13 additions & 6 deletions app/client/components/Clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Base.setBaseFor(Clipboard);

Clipboard.commands = {
contextMenuCopy: function() { this._doContextMenuCopy(); },
contextMenuCopyWithHeaders: function() { this._doContextMenuCopyWithHeaders(); },
contextMenuCut: function() { this._doContextMenuCut(); },
contextMenuPaste: function() { this._doContextMenuPaste(); },
};
Expand All @@ -126,7 +127,13 @@ Clipboard.prototype._onCopy = function(elem, event) {
Clipboard.prototype._doContextMenuCopy = function() {
let pasteObj = commands.allCommands.copy.run();

this._copyToClipboard(pasteObj, 'copy');
this._copyToClipboard(pasteObj, 'copy', false);
};

Clipboard.prototype._doContextMenuCopyWithHeaders = function() {
let pasteObj = commands.allCommands.copy.run();

this._copyToClipboard(pasteObj, 'copy', true);
};

Clipboard.prototype._onCut = function(elem, event) {
Expand All @@ -146,21 +153,21 @@ Clipboard.prototype._doContextMenuCut = function() {
Clipboard.prototype._setCBdata = function(pasteObj, clipboardData) {
if (!pasteObj) { return; }

const plainText = tableUtil.makePasteText(pasteObj.data, pasteObj.selection);
const plainText = tableUtil.makePasteText(pasteObj.data, pasteObj.selection, false);
clipboardData.setData('text/plain', plainText);
const htmlText = tableUtil.makePasteHtml(pasteObj.data, pasteObj.selection);
const htmlText = tableUtil.makePasteHtml(pasteObj.data, pasteObj.selection, false);
clipboardData.setData('text/html', htmlText);

this._setCutCallback(pasteObj, plainText);
};

Clipboard.prototype._copyToClipboard = async function(pasteObj, action) {
Clipboard.prototype._copyToClipboard = async function(pasteObj, action, includeColHeaders) {
if (!pasteObj) { return; }

const plainText = tableUtil.makePasteText(pasteObj.data, pasteObj.selection);
const plainText = tableUtil.makePasteText(pasteObj.data, pasteObj.selection, includeColHeaders);
let data;
if (typeof ClipboardItem === 'function') {
const htmlText = tableUtil.makePasteHtml(pasteObj.data, pasteObj.selection);
const htmlText = tableUtil.makePasteHtml(pasteObj.data, pasteObj.selection, includeColHeaders);
// eslint-disable-next-line no-undef
data = new ClipboardItem({
// eslint-disable-next-line no-undef
Expand Down
5 changes: 1 addition & 4 deletions app/client/components/CodeEditorPanel.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
.g-code-panel {
position:absolute;
width: 100%;
height: 100%;
margin: 10px;
padding: 10px;
overflow: auto;
}

Expand Down
3 changes: 3 additions & 0 deletions app/client/components/Comm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ export class Comm extends dispose.Disposable implements GristServerAPI, DocListA
if (message.details) {
err.details = message.details;
}
if (message.error?.startsWith('[Sandbox] UniqueReferenceError')) {
err.code = 'UNIQUE_REFERENCE_VIOLATION';
}
err.shouldFork = message.shouldFork;
log.warn(`Comm response #${reqId} ${r.methodName} ERROR:${code} ${message.error}`
+ (message.shouldFork ? ` (should fork)` : ''));
Expand Down
34 changes: 12 additions & 22 deletions app/client/components/FormRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {sanitizeHTML} from 'app/client/ui/sanitizeHTML';
import {dropdownWithSearch} from 'app/client/ui/searchDropdown';
import {isXSmallScreenObs} from 'app/client/ui2018/cssVars';
import {confirmModal} from 'app/client/ui2018/modals';
import {toggleSwitch} from 'app/client/ui2018/toggleSwitch';
import {CellValue} from 'app/plugin/GristData';
import {Disposable, dom, DomContents, makeTestId, MutableObsArray, obsArray, Observable} from 'grainjs';
import {marked} from 'marked';
Expand Down Expand Up @@ -528,32 +529,21 @@ class BoolRenderer extends BaseFieldRenderer {
}

private _renderSwitchInput() {
return css.toggleSwitch(
dom('input',
dom.prop('checked', this.checked),
dom.prop('value', use => use(this.checked) ? '1' : '0'),
dom.on('change', (_e, elem) => this.checked.set(elem.checked)),
{
type: this.inputType,
name: this.name(),
required: this.field.options.formRequired,
},
return toggleSwitch(this. checked, {
label: this.field.question,
inputArgs: [
{name: this.name(), required: this.field.options.formRequired},
preventSubmitOnEnter(),
),
css.gristSwitch(
css.gristSwitchSlider(),
css.gristSwitchCircle(),
),
css.toggleLabel(
],
labelArgs: [
css.label.cls('-required', Boolean(this.field.options.formRequired)),
this.field.question,
),
);
],
});
}

private _renderCheckboxInput() {
return css.toggle(
dom('input',
css.checkboxInput(
dom.prop('checked', this.checked),
dom.prop('value', use => use(this.checked) ? '1' : '0'),
dom.on('change', (_e, elem) => this.checked.set(elem.checked)),
Expand Down Expand Up @@ -613,7 +603,7 @@ class ChoiceListRenderer extends BaseFieldRenderer {
{name: this.name(), required},
dom.forEach(this.checkboxes, (checkbox) =>
css.checkbox(
dom('input',
css.checkboxInput(
dom.prop('checked', checkbox.checked),
dom.on('change', (_e, elem) => checkbox.checked.set(elem.value)),
{
Expand Down Expand Up @@ -674,7 +664,7 @@ class RefListRenderer extends BaseFieldRenderer {
{name: this.name(), required},
dom.forEach(this.checkboxes, (checkbox) =>
css.checkbox(
dom('input',
css.checkboxInput(
dom.prop('checked', checkbox.checked),
dom.on('change', (_e, elem) => checkbox.checked.set(elem.value)),
{
Expand Down
Loading

0 comments on commit 9a72269

Please sign in to comment.